Skip to content

Commit

Permalink
[NP] Migrate uiSettings owned by Kibana app (elastic#64321)
Browse files Browse the repository at this point in the history
* Move META_FIELDS_SETTING, DOC_HIGHLIGHT_SETTING to data plugin.ts

* Refactor table_list_view.tsx to no longer get PER_PAGE_SETTING by uiSettings

* Migrate graph, visualize, dashboard usage of saved_objects module constants to accessor functions

* Remove redundant logging in plugins start and setup methods

Co-authored-by: Matthias Wilhelm <matthias.wilhelm@elastic.co>

# Conflicts:
#	src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts
  • Loading branch information
maryia-lapata authored and kertal committed May 15, 2020
1 parent 3a4c86b commit b599cbd
Show file tree
Hide file tree
Showing 67 changed files with 874 additions and 408 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { i18n } from '@kbn/i18n';
import { fieldWildcardMatcher } from '../../../../../../../../../plugins/kibana_utils/public';
import { IndexPatternManagementStart } from '../../../../../../../../../plugins/index_pattern_management/public';
import { IndexPattern, IndexPatternField } from '../../../../../../../../../plugins/data/public';
import { META_FIELDS_SETTING } from '../../../../../../../../../plugins/data/common';
import { createEditIndexPatternPageStateContainer } from '../edit_index_pattern_state_container';
import { TAB_INDEXED_FIELDS, TAB_SCRIPTED_FIELDS, TAB_SOURCE_FILTERS } from '../constants';
import { SourceFiltersTable } from '../source_filters_table';
Expand Down Expand Up @@ -98,7 +99,7 @@ export function Tabs({ config, indexPattern, fields, services, history, location
}, [indexPattern, indexPattern.fields, refreshFilters]);

const fieldWildcardMatcherDecorated = useCallback(
(filters: string[]) => fieldWildcardMatcher(filters, config.get('metaFields')),
(filters: string[]) => fieldWildcardMatcher(filters, config.get(META_FIELDS_SETTING)),
[config]
);

Expand Down
220 changes: 0 additions & 220 deletions src/legacy/core_plugins/kibana/server/ui_setting_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,106 +271,6 @@ export function getUiSettingDefaults() {
defaultMessage: 'The index to access if no index is set',
}),
},
defaultColumns: {
name: i18n.translate('kbn.advancedSettings.defaultColumnsTitle', {
defaultMessage: 'Default columns',
}),
value: ['_source'],
description: i18n.translate('kbn.advancedSettings.defaultColumnsText', {
defaultMessage: 'Columns displayed by default in the Discovery tab',
}),
category: ['discover'],
},
metaFields: {
name: i18n.translate('kbn.advancedSettings.metaFieldsTitle', {
defaultMessage: 'Meta fields',
}),
value: ['_source', '_id', '_type', '_index', '_score'],
description: i18n.translate('kbn.advancedSettings.metaFieldsText', {
defaultMessage:
'Fields that exist outside of _source to merge into our document when displaying it',
}),
},
'discover:sampleSize': {
name: i18n.translate('kbn.advancedSettings.discover.sampleSizeTitle', {
defaultMessage: 'Number of rows',
}),
value: 500,
description: i18n.translate('kbn.advancedSettings.discover.sampleSizeText', {
defaultMessage: 'The number of rows to show in the table',
}),
category: ['discover'],
},
'discover:aggs:terms:size': {
name: i18n.translate('kbn.advancedSettings.discover.aggsTermsSizeTitle', {
defaultMessage: 'Number of terms',
}),
value: 20,
type: 'number',
description: i18n.translate('kbn.advancedSettings.discover.aggsTermsSizeText', {
defaultMessage:
'Determines how many terms will be visualized when clicking the "visualize" ' +
'button, in the field drop downs, in the discover sidebar.',
}),
category: ['discover'],
},
'discover:sort:defaultOrder': {
name: i18n.translate('kbn.advancedSettings.discover.sortDefaultOrderTitle', {
defaultMessage: 'Default sort direction',
}),
value: 'desc',
options: ['desc', 'asc'],
optionLabels: {
desc: i18n.translate('kbn.advancedSettings.discover.sortOrderDesc', {
defaultMessage: 'Descending',
}),
asc: i18n.translate('kbn.advancedSettings.discover.sortOrderAsc', {
defaultMessage: 'Ascending',
}),
},
type: 'select',
description: i18n.translate('kbn.advancedSettings.discover.sortDefaultOrderText', {
defaultMessage:
'Controls the default sort direction for time based index patterns in the Discover app.',
}),
category: ['discover'],
},
'discover:searchOnPageLoad': {
name: i18n.translate('kbn.advancedSettings.discover.searchOnPageLoadTitle', {
defaultMessage: 'Search on page load',
}),
value: true,
type: 'boolean',
description: i18n.translate('kbn.advancedSettings.discover.searchOnPageLoadText', {
defaultMessage:
'Controls whether a search is executed when Discover first loads. This setting does not ' +
'have an effect when loading a saved search.',
}),
category: ['discover'],
},
'doc_table:highlight': {
name: i18n.translate('kbn.advancedSettings.docTableHighlightTitle', {
defaultMessage: 'Highlight results',
}),
value: true,
description: i18n.translate('kbn.advancedSettings.docTableHighlightText', {
defaultMessage:
'Highlight results in Discover and Saved Searches Dashboard. ' +
'Highlighting makes requests slow when working on big documents.',
}),
category: ['discover'],
},
'doc_table:hideTimeColumn': {
name: i18n.translate('kbn.advancedSettings.docTableHideTimeColumnTitle', {
defaultMessage: "Hide 'Time' column",
}),
value: false,
description: i18n.translate('kbn.advancedSettings.docTableHideTimeColumnText', {
defaultMessage:
"Hide the 'Time' column in Discover and in all Saved Searches on Dashboards.",
}),
category: ['discover'],
},
'courier:ignoreFilterIfFieldNotInIndex': {
name: i18n.translate('kbn.advancedSettings.courier.ignoreFilterTitle', {
defaultMessage: 'Ignore filter(s)',
Expand Down Expand Up @@ -484,15 +384,6 @@ export function getUiSettingDefaults() {
value: false,
category: ['search'],
},
'fields:popularLimit': {
name: i18n.translate('kbn.advancedSettings.fieldsPopularLimitTitle', {
defaultMessage: 'Popular fields limit',
}),
value: 10,
description: i18n.translate('kbn.advancedSettings.fieldsPopularLimitText', {
defaultMessage: 'The top N most popular fields to show',
}),
},
'histogram:barTarget': {
name: i18n.translate('kbn.advancedSettings.histogram.barTargetTitle', {
defaultMessage: 'Target bars',
Expand Down Expand Up @@ -602,56 +493,6 @@ export function getUiSettingDefaults() {
}),
category: ['visualization'],
},
'visualization:colorMapping': {
name: i18n.translate('kbn.advancedSettings.visualization.colorMappingTitle', {
defaultMessage: 'Color mapping',
}),
value: JSON.stringify({
Count: '#00A69B',
}),
type: 'json',
description: i18n.translate('kbn.advancedSettings.visualization.colorMappingText', {
defaultMessage: 'Maps values to specified colors within visualizations',
}),
category: ['visualization'],
},
'visualization:loadingDelay': {
name: i18n.translate('kbn.advancedSettings.visualization.loadingDelayTitle', {
defaultMessage: 'Loading delay',
}),
value: '2s',
description: i18n.translate('kbn.advancedSettings.visualization.loadingDelayText', {
defaultMessage: 'Time to wait before dimming visualizations during query',
}),
category: ['visualization'],
},
'visualization:dimmingOpacity': {
name: i18n.translate('kbn.advancedSettings.visualization.dimmingOpacityTitle', {
defaultMessage: 'Dimming opacity',
}),
value: 0.5,
type: 'number',
description: i18n.translate('kbn.advancedSettings.visualization.dimmingOpacityText', {
defaultMessage:
'The opacity of the chart items that are dimmed when highlighting another element of the chart. ' +
'The lower this number, the more the highlighted element will stand out. ' +
'This must be a number between 0 and 1.',
}),
category: ['visualization'],
},
'visualization:heatmap:maxBuckets': {
name: i18n.translate('kbn.advancedSettings.visualization.heatmap.maxBucketsTitle', {
defaultMessage: 'Heatmap maximum buckets',
}),
value: 50,
type: 'number',
description: i18n.translate('kbn.advancedSettings.visualization.heatmap.maxBucketsText', {
defaultMessage:
'The maximum number of buckets a single datasource can return. ' +
'A higher number might have negative impact on browser rendering performance',
}),
category: ['visualization'],
},
'csv:separator': {
name: i18n.translate('kbn.advancedSettings.csv.separatorTitle', {
defaultMessage: 'CSV separator',
Expand Down Expand Up @@ -831,26 +672,6 @@ export function getUiSettingDefaults() {
},
}),
},
'savedObjects:perPage': {
name: i18n.translate('kbn.advancedSettings.savedObjects.perPageTitle', {
defaultMessage: 'Objects per page',
}),
value: 20,
type: 'number',
description: i18n.translate('kbn.advancedSettings.savedObjects.perPageText', {
defaultMessage: 'Number of objects to show per page in the load dialog',
}),
},
'savedObjects:listingLimit': {
name: i18n.translate('kbn.advancedSettings.savedObjects.listingLimitTitle', {
defaultMessage: 'Objects listing limit',
}),
type: 'number',
value: 1000,
description: i18n.translate('kbn.advancedSettings.savedObjects.listingLimitText', {
defaultMessage: 'Number of objects to fetch for the listing pages',
}),
},
'timepicker:timeDefaults': {
name: i18n.translate('kbn.advancedSettings.timepicker.timeDefaultsTitle', {
defaultMessage: 'Time filter defaults',
Expand Down Expand Up @@ -1097,15 +918,6 @@ export function getUiSettingDefaults() {
type: 'number',
category: ['notifications'],
},
'metrics:max_buckets': {
name: i18n.translate('kbn.advancedSettings.maxBucketsTitle', {
defaultMessage: 'Maximum buckets',
}),
value: 2000,
description: i18n.translate('kbn.advancedSettings.maxBucketsText', {
defaultMessage: 'The maximum number of buckets a single datasource can return',
}),
},
'state:storeInSessionStorage': {
name: i18n.translate('kbn.advancedSettings.storeUrlTitle', {
defaultMessage: 'Store URLs in session storage',
Expand All @@ -1128,38 +940,6 @@ export function getUiSettingDefaults() {
'The placeholder for the "Index pattern name" field in "Management > Index Patterns > Create Index Pattern".',
}),
},
'context:defaultSize': {
name: i18n.translate('kbn.advancedSettings.context.defaultSizeTitle', {
defaultMessage: 'Context size',
}),
value: 5,
description: i18n.translate('kbn.advancedSettings.context.defaultSizeText', {
defaultMessage: 'The number of surrounding entries to show in the context view',
}),
category: ['discover'],
},
'context:step': {
name: i18n.translate('kbn.advancedSettings.context.sizeStepTitle', {
defaultMessage: 'Context size step',
}),
value: 5,
description: i18n.translate('kbn.advancedSettings.context.sizeStepText', {
defaultMessage: 'The step size to increment or decrement the context size by',
}),
category: ['discover'],
},
'context:tieBreakerFields': {
name: i18n.translate('kbn.advancedSettings.context.tieBreakerFieldsTitle', {
defaultMessage: 'Tie breaker fields',
}),
value: ['_doc'],
description: i18n.translate('kbn.advancedSettings.context.tieBreakerFieldsText', {
defaultMessage:
'A comma-separated list of fields to use for tie-breaking between documents that have the same timestamp value. ' +
'From this list the first field that is present and sortable in the current index pattern is used.',
}),
category: ['discover'],
},
'accessibility:disableAnimations': {
name: i18n.translate('kbn.advancedSettings.disableAnimationsTitle', {
defaultMessage: 'Disable Animations',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
PaginateControlsDirectiveProvider,
PaginateDirectiveProvider,
} from '../../../../../plugins/kibana_legacy/public';
import { PER_PAGE_SETTING } from '../../../../../plugins/saved_objects/common';

const module = uiModules.get('kibana');

Expand Down Expand Up @@ -65,7 +66,7 @@ module
const $input = $element.find('input[ng-model=filter]');

// The number of items to show in the list
$scope.perPage = config.get('savedObjects:perPage');
$scope.perPage = config.get(PER_PAGE_SETTING);

// the list that will hold the suggestions
const $list = $element.find('ul');
Expand Down
20 changes: 20 additions & 0 deletions src/plugins/charts/common/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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.
*/

export const COLOR_MAPPING_SETTING = 'visualization:colorMapping';
2 changes: 1 addition & 1 deletion src/plugins/charts/kibana.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "charts",
"version": "kibana",
"server": false,
"server": true,
"ui": true
}
7 changes: 4 additions & 3 deletions src/plugins/charts/public/services/colors/colors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { coreMock } from '../../../../../core/public/mocks';
import { COLOR_MAPPING_SETTING } from '../../../common';
import { seedColors } from './seed_colors';
import { ColorsService } from './colors';

Expand All @@ -44,13 +45,13 @@ describe('Vislib Color Service', () => {
const nullValue = null;

beforeEach(() => {
previousConfig = config.get('visualization:colorMapping');
config.set('visualization:colorMapping', {});
previousConfig = config.get(COLOR_MAPPING_SETTING);
config.set(COLOR_MAPPING_SETTING, {});
color = colors.createColorLookupFunction(arr, {});
});

afterEach(() => {
config.set('visualization:colorMapping', previousConfig);
config.set(COLOR_MAPPING_SETTING, previousConfig);
});

it('should throw error if not initialized', () => {
Expand Down
Loading

0 comments on commit b599cbd

Please sign in to comment.