Skip to content

Commit

Permalink
Migrate timepicker:timeDefaults ui setting to the data plugin. (#73750)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeelmers committed Aug 3, 2020
1 parent 6049425 commit 06412ae
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 25 deletions.
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('data.advancedSettings.timepicker.timeDefaultsTitle', {
defaultMessage: 'Time filter defaults',
}),
value: `{
"from": "now-15m",
"to": "now"
}`,
type: 'json',
description: i18n.translate('data.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
6 changes: 3 additions & 3 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@
"data.advancedSettings.timepicker.refreshIntervalDefaultsText": "時間フィルターのデフォルト更新間隔「値」はミリ秒で指定する必要があります。",
"data.advancedSettings.timepicker.refreshIntervalDefaultsTitle": "タイムピッカーの更新間隔",
"data.advancedSettings.timepicker.thisWeek": "今週",
"data.advancedSettings.timepicker.timeDefaultsText": "時間フィルターが選択されずに Kibana が起動した際に使用される時間フィルターです",
"data.advancedSettings.timepicker.timeDefaultsTitle": "デフォルトのタイムピッカー",
"data.advancedSettings.timepicker.today": "今日",
"data.aggTypes.buckets.ranges.rangesFormatMessage": "{gte} {from} と {lt} {to}",
"data.common.kql.errors.endOfInputText": "インプットの終わり",
Expand Down Expand Up @@ -2791,8 +2793,6 @@
"kbn.advancedSettings.storeUrlTitle": "セッションストレージに URL を格納",
"kbn.advancedSettings.themeVersionText": "現在のバージョンと次のバージョンのKibanaで使用されるテーマを切り替えます。この設定を適用するにはページの更新が必要です。",
"kbn.advancedSettings.themeVersionTitle": "テーマバージョン",
"kbn.advancedSettings.timepicker.timeDefaultsText": "時間フィルターが選択されずに Kibana が起動した際に使用される時間フィルターです",
"kbn.advancedSettings.timepicker.timeDefaultsTitle": "デフォルトのタイムピッカー",
"kbn.advancedSettings.visualization.showRegionMapWarningsText": "用語がマップの形に合わない場合に地域マップに警告を表示するかどうかです。",
"kbn.advancedSettings.visualization.showRegionMapWarningsTitle": "地域マップに警告を表示",
"kbn.advancedSettings.visualization.tileMap.maxPrecision.cellDimensionsLinkText": "ディメンションの説明",
Expand Down Expand Up @@ -19304,7 +19304,7 @@
"xpack.watcher.models.baseAction.simulateMessage": "アクション {id} のシミュレーションが完了しました",
"xpack.watcher.models.baseAction.typeName": "アクション",
"xpack.watcher.models.baseWatch.createUnknownActionTypeErrorMessage": "不明なアクションタイプ {type} を作成しようとしました。",
"xpack.watcher.models.baseWatch.idPropertyMissingBadRequestMessage": "json 引数には {id} プロパティが含まれている必要があります",
"xpack.watcher.models.baseWatch.idPropertyMissingBadRequestMessage": "json 引数には {id} プロパティが含まれている必要があります",
"xpack.watcher.models.baseWatch.selectMessageText": "新規ウォッチをセットアップします。",
"xpack.watcher.models.baseWatch.typeName": "ウォッチ",
"xpack.watcher.models.baseWatch.watchJsonPropertyMissingBadRequestMessage": "json 引数には {watchJson} プロパティが含まれている必要があります",
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@
"data.advancedSettings.timepicker.refreshIntervalDefaultsText": "时间筛选的默认刷新时间间隔。需要使用毫秒单位指定“值”。",
"data.advancedSettings.timepicker.refreshIntervalDefaultsTitle": "时间筛选刷新时间间隔",
"data.advancedSettings.timepicker.thisWeek": "本周",
"data.advancedSettings.timepicker.timeDefaultsText": "未使用时间筛选启动 Kibana 时要使用的时间筛选选择",
"data.advancedSettings.timepicker.timeDefaultsTitle": "时间筛选默认值",
"data.advancedSettings.timepicker.today": "今日",
"data.aggTypes.buckets.ranges.rangesFormatMessage": "{gte} {from} 和 {lt} {to}",
"data.common.kql.errors.endOfInputText": "输入结束",
Expand Down Expand Up @@ -2792,8 +2794,6 @@
"kbn.advancedSettings.storeUrlTitle": "将 URL 存储在会话存储中",
"kbn.advancedSettings.themeVersionText": "在用于 Kibana 当前和下一版本的主题间切换。需要刷新页面,才能应用设置。",
"kbn.advancedSettings.themeVersionTitle": "主题版本",
"kbn.advancedSettings.timepicker.timeDefaultsText": "未使用时间筛选启动 Kibana 时要使用的时间筛选选择",
"kbn.advancedSettings.timepicker.timeDefaultsTitle": "时间筛选默认值",
"kbn.advancedSettings.visualization.showRegionMapWarningsText": "词无法联接到地图上的形状时,区域地图是否显示警告。",
"kbn.advancedSettings.visualization.showRegionMapWarningsTitle": "显示区域地图警告",
"kbn.advancedSettings.visualization.tileMap.maxPrecision.cellDimensionsLinkText": "单元格维度的解释",
Expand Down

0 comments on commit 06412ae

Please sign in to comment.