-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Discover] De-angularize side bar search field #46679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kertal
merged 19 commits into
elastic:master
from
kertal:kertal-pr-2019-09-23-discover-field-filter
Oct 2, 2019
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6dc76b0
Add DiscoverFieldSearch react component
kertal 268929f
Adapt field_chooser.js
kertal dee9147
Add DiscoverFieldSearch react component
kertal 00fe05f
Adapt component and usage
kertal 492b7a3
Add jest test
kertal e3b7807
Adapt scss
kertal b10bf05
Migrate from EuiButtonToggle to EuiButtonIcon
kertal f60176b
Remove unused translations
kertal 6bd3bf5
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-09…
kertal 9c3baad
Change filter icon + height for alignment
kertal aac51b1
Use CSS BEM naming scheme for toggleFieldFilterButton
kertal 836aa3d
Adapt reactDirective
kertal 9825fde
merge upstream/master
kertal 50826c7
Merge branch 'master' into kertal-pr-2019-09-23-discover-field-filter
elasticmachine a45ac05
Various adaptions
kertal 478daee
Merge branch 'kertal-pr-2019-09-23-discover-field-filter' of github.c…
kertal 890d107
Fix CSS issue when sidebar is collapsed
kertal 8113c83
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-09…
kertal aa8e021
Change position of the tooltip showing when hovering the toggle field…
kertal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...re_plugins/kibana/public/discover/components/field_chooser/discover_field_search.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import React from 'react'; | ||
| import { mountWithIntl } from 'test_utils/enzyme_helpers'; | ||
| // @ts-ignore | ||
| import { findTestSubject } from '@elastic/eui/lib/test'; | ||
| import { DiscoverFieldSearch } from './discover_field_search'; | ||
|
|
||
| describe('DiscoverFieldSearch', () => { | ||
| function mountComponent() { | ||
| const props = { | ||
| onChange: jest.fn(), | ||
| onShowFilter: jest.fn(), | ||
| showFilter: false, | ||
| value: 'test', | ||
| }; | ||
| const comp = mountWithIntl(<DiscoverFieldSearch {...props} />); | ||
| const input = findTestSubject(comp, 'fieldFilterSearchInput'); | ||
| const btn = findTestSubject(comp, 'toggleFieldFilterButton'); | ||
| return { comp, input, btn, props }; | ||
| } | ||
|
|
||
| test('enter value', () => { | ||
| const { input, props } = mountComponent(); | ||
| input.simulate('change', { target: { value: 'new filter' } }); | ||
| expect(props.onChange).toBeCalledTimes(1); | ||
| }); | ||
|
|
||
| // this should work, but doesn't, have to do some research | ||
| test('click toggle filter button', () => { | ||
| const { btn, props } = mountComponent(); | ||
| btn.simulate('click'); | ||
| expect(props.onShowFilter).toBeCalledTimes(1); | ||
| }); | ||
|
|
||
| test('change showFilter value should change button label', () => { | ||
| const { btn, comp } = mountComponent(); | ||
| const prevFilterBtnHTML = btn.html(); | ||
| comp.setProps({ showFilter: true }); | ||
| expect(btn.html()).not.toBe(prevFilterBtnHTML); | ||
| }); | ||
| }); |
91 changes: 91 additions & 0 deletions
91
...cy/core_plugins/kibana/public/discover/components/field_chooser/discover_field_search.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| import React from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { EuiButtonIcon, EuiFieldSearch, EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui'; | ||
|
|
||
| export interface Props { | ||
| /** | ||
| * triggered on input of user into search field | ||
| */ | ||
| onChange: (field: string, value: string) => void; | ||
| /** | ||
| * triggered when the "additional filter btn" is clicked | ||
| */ | ||
| onShowFilter: () => void; | ||
| /** | ||
| * determines whether additional filter fields are displayed | ||
| */ | ||
| showFilter: boolean; | ||
| /** | ||
| * the input value of the user | ||
| */ | ||
| value?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Component is Discover's side bar to search of available fields | ||
| * Additionally there's a button displayed that allows the user to show/hide more filter fields | ||
| */ | ||
| export function DiscoverFieldSearch({ showFilter, onChange, onShowFilter, value }: Props) { | ||
| if (typeof value !== 'string') { | ||
| // at initial rendering value is undefined (angular related), this catches the warning | ||
| // should be removed once all is react | ||
| return null; | ||
| } | ||
| const filterBtnAriaLabel = showFilter | ||
| ? i18n.translate('kbn.discover.fieldChooser.toggleFieldFilterButtonHideAriaLabel', { | ||
| defaultMessage: 'Hide field filter settings', | ||
| }) | ||
| : i18n.translate('kbn.discover.fieldChooser.toggleFieldFilterButtonShowAriaLabel', { | ||
| defaultMessage: 'Show field filter settings', | ||
| }); | ||
| const searchPlaceholder = i18n.translate('kbn.discover.fieldChooser.searchPlaceHolder', { | ||
| defaultMessage: 'Search fields', | ||
| }); | ||
|
|
||
| return ( | ||
| <EuiFlexGroup responsive={false} gutterSize={'s'}> | ||
| <EuiFlexItem> | ||
| <EuiFieldSearch | ||
| aria-label={searchPlaceholder} | ||
| data-test-subj="fieldFilterSearchInput" | ||
| compressed | ||
| fullWidth | ||
| onChange={event => onChange('name', event.currentTarget.value)} | ||
| placeholder={searchPlaceholder} | ||
| value={value} | ||
| /> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem grow={false}> | ||
| <EuiToolTip content={filterBtnAriaLabel} position="right"> | ||
| <EuiButtonIcon | ||
| aria-expanded={showFilter} | ||
| aria-label={filterBtnAriaLabel} | ||
| className="dscToggleFieldFilterButton" | ||
| data-test-subj="toggleFieldFilterButton" | ||
| iconType="filter" | ||
| onClick={() => onShowFilter()} | ||
| size="m" | ||
| /> | ||
| </EuiToolTip> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| ); | ||
| } | ||
33 changes: 33 additions & 0 deletions
33
...lugins/kibana/public/discover/components/field_chooser/discover_field_search_directive.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Licensed to Elasticsearch B.V. under one or more contributor | ||
| * license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright | ||
| * ownership. Elasticsearch B.V. licenses this file to you under | ||
| * the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| // @ts-ignore | ||
| import { uiModules } from 'ui/modules'; | ||
| import { wrapInI18nContext } from 'ui/i18n'; | ||
| import { DiscoverFieldSearch } from './discover_field_search'; | ||
|
|
||
| const app = uiModules.get('apps/discover'); | ||
|
|
||
| app.directive('discoverFieldSearch', function(reactDirective: any) { | ||
| return reactDirective(wrapInI18nContext(DiscoverFieldSearch), [ | ||
| ['onChange', { watchDepth: 'reference' }], | ||
| ['onShowFilter', { watchDepth: 'reference' }], | ||
| ['showFilter', { watchDepth: 'value' }], | ||
| ['value', { watchDepth: 'value' }], | ||
| ]); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.