Facebook
From Tinct Tortoise, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 123
  1. diff --git a/examples/search_examples/public/components/app.tsx b/examples/search_examples/public/components/app.tsx
  2. index 33ad8bbfe3d..1e83fb34f9e 100644
  3. --- a/examples/search_examples/public/components/app.tsx
  4. +++ b/examples/search_examples/public/components/app.tsx
  5. @@ -40,6 +40,7 @@ import {
  6.    EuiCode,
  7.    EuiComboBox,
  8.    EuiFormLabel,
  9. +  EuiButton,
  10.  } from '@elastic/eui';
  11.  
  12.  import { CoreStart } from '../../../../src/core/public';
  13. @@ -60,6 +61,7 @@ import {
  14.    isCompleteResponse,
  15.    isErrorResponse,
  16.  } from '../../../../src/plugins/data/public';
  17. +import { buildFilter, FILTERS, FilterStateStore } from '../../../../src/plugins/data/common';
  18.  
  19.  interface SearchExamplesAppDeps {
  20.    basename: string;
  21. @@ -271,6 +273,7 @@ export const SearchExamplesApp = ({
  22.              showSearchBar={true}
  23.              useDefaultBehaviors={true}
  24.              indexPatterns={indexPattern ? [indexPattern] : undefined}
  25. +            onFiltersUpdated={() => {}}
  26.            />
  27.            <EuiPage>
  28.              <EuiPageBody>
  29. @@ -345,6 +348,25 @@ export const SearchExamplesApp = ({
  30.                          </EuiFlexGroup>
  31.                        </EuiText>
  32.                        <EuiSpacer />
  33. +                      <EuiTitle size="s">
  34. +                        <h3>
  35. +                          Add or remove filter from application
  36. +                        </h3>
  37. +                      </EuiTitle>
  38. +                      <EuiText>
  39. +                        <EuiButton onClick={() => {
  40. +                          if (!indexPattern) return;
  41. +                          const filterType = FILTERS.PHRASE;
  42. +                          const newFilter = buildFilter(indexPattern, indexPattern.getFieldByName('extension')!, filterType, true, false, 'jpg', null, FilterStateStore.APP_STATE);
  43. +                          data.query.filterManager.addFilters(newFilter)
  44. +                        }}>Add FILTER</EuiButton>
  45. +
  46. +                        <EuiButton onClick={() => {
  47. +                          const filters = data.query.filterManager.getAppFilters();
  48. +                          if (filters.length) data.query.filterManager.removeFilter(filters[0])
  49. +                        }}>Remove FILTER</EuiButton>
  50. +                      </EuiText>
  51. +                      <EuiSpacer />
  52.                        <EuiTitle size="s">
  53.                          <h3>
  54.                            Searching Elasticsearch using <EuiCode>data.search</EuiCode>
  55.