Skip to content
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

Migrate timepicker:timeDefaults ui setting to the data plugin. #73750

Merged
merged 5 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions src/legacy/core_plugins/kibana/server/ui_setting_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,20 +258,6 @@ export function getUiSettingDefaults() {
'The maximum height that a cell in a table should occupy. Set to 0 to disable truncation',
}),
},
'timepicker:timeDefaults': {
name: i18n.translate('kbn.advancedSettings.timepicker.timeDefaultsTitle', {
defaultMessage: 'Time filter defaults',
}),
value: `{
"from": "now-15m",
"to": "now"
}`,
type: 'json',
description: i18n.translate('kbn.advancedSettings.timepicker.timeDefaultsText', {
defaultMessage: 'The timefilter selection to use when Kibana is started without one',
}),
requiresPageReload: true,
},
'theme:darkMode': {
name: i18n.translate('kbn.advancedSettings.darkModeTitle', {
defaultMessage: 'Dark mode',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ setupMock.uiSettings.get.mockImplementation((key: string) => {
return true;
case UI_SETTINGS.SEARCH_QUERY_LANGUAGE:
return 'kuery';
case 'timepicker:timeDefaults':
case UI_SETTINGS.TIMEPICKER_TIME_DEFAULTS:
return { from: 'now-15m', to: 'now' };
case UI_SETTINGS.TIMEPICKER_REFRESH_INTERVAL_DEFAULTS:
return { pause: false, value: 0 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface TimeFilterServiceDependencies {
export class TimefilterService {
public setup({ uiSettings, storage }: TimeFilterServiceDependencies): TimefilterSetup {
const timefilterConfig = {
timeDefaults: uiSettings.get('timepicker:timeDefaults'),
timeDefaults: uiSettings.get(UI_SETTINGS.TIMEPICKER_TIME_DEFAULTS),
refreshIntervalDefaults: uiSettings.get(UI_SETTINGS.TIMEPICKER_REFRESH_INTERVAL_DEFAULTS),
};
const history = new TimeHistory(storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ startMock.uiSettings.get.mockImplementation((key: string) => {
return 'MMM D, YYYY @ HH:mm:ss.SSS';
case UI_SETTINGS.HISTORY_LIMIT:
return 10;
case 'timepicker:timeDefaults':
case UI_SETTINGS.TIMEPICKER_TIME_DEFAULTS:
return {
from: 'now-15m',
to: 'now',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function QueryBarTopRow(props: Props) {
}

function getDateRange() {
const defaultTimeSetting = uiSettings!.get('timepicker:timeDefaults');
const defaultTimeSetting = uiSettings!.get(UI_SETTINGS.TIMEPICKER_TIME_DEFAULTS);
return {
from: props.dateRangeFrom || defaultTimeSetting.from,
to: props.dateRangeTo || defaultTimeSetting.to,
Expand Down
18 changes: 18 additions & 0 deletions src/plugins/data/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,24 @@ export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
value: schema.number(),
}),
},
[UI_SETTINGS.TIMEPICKER_TIME_DEFAULTS]: {
name: i18n.translate('kbn.advancedSettings.timepicker.timeDefaultsTitle', {
lukeelmers marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: 'Time filter defaults',
}),
value: `{
"from": "now-15m",
"to": "now"
}`,
type: 'json',
description: i18n.translate('kbn.advancedSettings.timepicker.timeDefaultsText', {
defaultMessage: 'The timefilter selection to use when Kibana is started without one',
}),
requiresPageReload: true,
schema: schema.object({
from: schema.string(),
to: schema.string(),
}),
},
[UI_SETTINGS.TIMEPICKER_QUICK_RANGES]: {
name: i18n.translate('data.advancedSettings.timepicker.quickRangesTitle', {
defaultMessage: 'Time filter quick ranges',
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/lens/public/app_plugin/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe('Lens App', () => {

core.uiSettings.get.mockImplementation(
jest.fn((type) => {
if (type === 'timepicker:timeDefaults') {
if (type === UI_SETTINGS.TIMEPICKER_TIME_DEFAULTS) {
return { from: 'now-7d', to: 'now' };
} else if (type === UI_SETTINGS.SEARCH_QUERY_LANGUAGE) {
return 'kuery';
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class MonitoringPlugin
UI_SETTINGS.TIMEPICKER_REFRESH_INTERVAL_DEFAULTS,
JSON.stringify(refreshInterval)
);
uiSettings.overrideLocalDefault('timepicker:timeDefaults', JSON.stringify(time));
uiSettings.overrideLocalDefault(UI_SETTINGS.TIMEPICKER_TIME_DEFAULTS, JSON.stringify(time));
}

private getExternalConfig() {
Expand Down