Skip to content

Commit

Permalink
Merge branch 'master' into task-manager/schema-config
Browse files Browse the repository at this point in the history
* master:
  Remove eslint overwrite for src/legacy/core_plugins/kibana (elastic#54222)
  • Loading branch information
gmmorris committed Jan 9, 2020
2 parents 35d55e7 + 58f792c commit 9e63e9b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 22 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ module.exports = {
'react-hooks/exhaustive-deps': 'off',
},
},
{
files: ['src/legacy/core_plugins/kibana/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/rules-of-hooks': 'off',
'react-hooks/exhaustive-deps': 'off',
},
},
{
files: ['src/legacy/core_plugins/tile_map/**/*.{js,ts,tsx}'],
rules: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export function useEsDocSearch({

useEffect(() => {
requestData();
}, []);
});

return [status, hit, indexPattern];
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ export interface Props {
* Additionally there's a button displayed that allows the user to show/hide more filter fields
*/
export function DiscoverFieldSearch({ onChange, value, types }: 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 searchPlaceholder = i18n.translate('kbn.discover.fieldChooser.searchPlaceHolder', {
defaultMessage: 'Search field names',
});
Expand Down Expand Up @@ -99,6 +94,12 @@ export function DiscoverFieldSearch({ onChange, value, types }: Props) {
missing: true,
});

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 = isPopoverOpen
? i18n.translate('kbn.discover.fieldChooser.toggleFieldFilterButtonHideAriaLabel', {
defaultMessage: 'Hide field filter settings',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ export function DiscoverIndexPattern({
selectedIndexPattern,
setIndexPattern,
}: DiscoverIndexPatternProps) {
if (!indexPatternList || indexPatternList.length === 0 || !selectedIndexPattern) {
// just in case, shouldn't happen
return null;
}
const options: IndexPatternRef[] = indexPatternList.map(entity => ({
const options: IndexPatternRef[] = (indexPatternList || []).map(entity => ({
id: entity.id,
title: entity.attributes!.title,
}));
const { id: selectedId, attributes } = selectedIndexPattern || {};

const [selected, setSelected] = useState({
id: selectedIndexPattern.id,
title: selectedIndexPattern.attributes!.title,
id: selectedId,
title: attributes?.title || '',
});
if (!selectedId) {
return null;
}

return (
<div className="indexPattern__container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import { wrapInI18nContext } from '../../../kibana_services';
import { DiscoverIndexPattern } from './discover_index_pattern';
import { DiscoverIndexPattern, DiscoverIndexPatternProps } from './discover_index_pattern';

/**
* At initial rendering the angular directive the selectedIndexPattern prop is undefined
* This wrapper catches this, had to be introduced to satisfy eslint
*/
export function DiscoverIndexPatternWrapper(props: DiscoverIndexPatternProps) {
if (!props.selectedIndexPattern || !Array.isArray(props.indexPatternList)) {
return null;
}
return <DiscoverIndexPattern {...props} />;
}

export function createIndexPatternSelectDirective(reactDirective: any) {
return reactDirective(wrapInI18nContext(DiscoverIndexPattern), [
return reactDirective(wrapInI18nContext(DiscoverIndexPatternWrapper), [
['indexPatternList', { watchDepth: 'reference' }],
['selectedIndexPattern', { watchDepth: 'reference' }],
['setIndexPattern', { watchDepth: 'reference' }],
Expand Down

0 comments on commit 9e63e9b

Please sign in to comment.