Skip to content

Commit

Permalink
Some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
VladLasitsa committed Apr 23, 2020
1 parent 69a01ba commit 078d346
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 39 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function IndexHeader({
<EuiButtonIcon
color="text"
onClick={setDefault}
iconType="starFilledSpace"
iconType="starFilled"
aria-label={setDefaultAriaLabel}
data-test-subj="setDefaultIndexPatternButton"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { fieldWildcardMatcher } from '../../../../../../../../../plugins/kibana_
import { IndexPatternManagementStart } from '../../../../../../../../../plugins/index_pattern_management/public';
import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public';
import { createEditIndexPatternPageStateContainer } from '../edit_index_pattern_state_container';
import { TAB_INDEXED_FIELDS } from '../constants';
import { TAB_INDEXED_FIELDS, TAB_SCRIPTED_FIELDS, TAB_SOURCE_FILTERS } from '../constants';
import { SourceFiltersTable } from '../source_filters_table';
import { IndexedFieldsTable } from '../indexed_fields_table';
import { ScriptedFieldsTable } from '../scripted_fields_table';
Expand Down Expand Up @@ -111,7 +111,7 @@ export function Tabs({ config, indexPattern, fields, services, history, location
aria-label={filterAriaLabel}
/>
</EuiFlexItem>
{type === 'indexedFields' && indexedFieldTypes.length > 0 && (
{type === TAB_INDEXED_FIELDS && indexedFieldTypes.length > 0 && (
<EuiFlexItem grow={false}>
<EuiSelect
options={indexedFieldTypes}
Expand All @@ -121,7 +121,7 @@ export function Tabs({ config, indexPattern, fields, services, history, location
/>
</EuiFlexItem>
)}
{type === 'scriptedFields' && scriptedFieldLanguages.length > 0 && (
{type === TAB_SCRIPTED_FIELDS && scriptedFieldLanguages.length > 0 && (
<EuiFlexItem grow={false}>
<EuiSelect
options={scriptedFieldLanguages}
Expand All @@ -146,7 +146,7 @@ export function Tabs({ config, indexPattern, fields, services, history, location
const getContent = useCallback(
(type: string) => {
switch (type) {
case 'indexedFields':
case TAB_INDEXED_FIELDS:
return (
<Fragment>
<EuiSpacer size="m" />
Expand All @@ -167,7 +167,7 @@ export function Tabs({ config, indexPattern, fields, services, history, location
/>
</Fragment>
);
case 'scriptedFields':
case TAB_SCRIPTED_FIELDS:
return (
<Fragment>
<EuiSpacer size="m" />
Expand All @@ -186,7 +186,7 @@ export function Tabs({ config, indexPattern, fields, services, history, location
/>
</Fragment>
);
case 'sourceFilters':
case TAB_SOURCE_FILTERS:
return (
<Fragment>
<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
*/

import { Dictionary, countBy, defaults, unique } from 'lodash';
import { parse } from 'query-string';
import { i18n } from '@kbn/i18n';
import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public';
import { IndexPatternManagementStart } from '../../../../../../../../../plugins/index_pattern_management/public';
import { TAB_INDEXED_FIELDS, TAB_SCRIPTED_FIELDS, TAB_SOURCE_FILTERS } from '../constants';

function filterByName(items: IndexPatternField[], filter: string) {
const lowercaseFilter = (filter || '').toLowerCase();
Expand Down Expand Up @@ -95,33 +95,24 @@ export function getTabs(

tabs.push({
name: getTitle('indexed', filteredCount, totalCount),
id: 'indexedFields',
id: TAB_INDEXED_FIELDS,
});

if (indexPatternListProvider.areScriptedFieldsEnabled(indexPattern)) {
tabs.push({
name: getTitle('scripted', filteredCount, totalCount),
id: 'scriptedFields',
id: TAB_SCRIPTED_FIELDS,
});
}

tabs.push({
name: getTitle('sourceFilters', filteredCount, totalCount),
id: 'sourceFilters',
id: TAB_SOURCE_FILTERS,
});

return tabs;
}

export function getTabIdFromURL(search: string) {
const params = parse(search);
let tabId = 'indexedFields';
if (params._a) {
tabId = (Array.isArray(params._a) ? params._a[0] : params._a).split(/[:)]/)[1];
}
return tabId;
}

export function getPath(field: IndexPatternField) {
return `/management/kibana/index_patterns/${field.indexPattern?.id}/field/${field.name}`;
}
Expand Down

0 comments on commit 078d346

Please sign in to comment.