Inline timezoneProvider function, remove ui/vis/lib/timezone (#60475)
* Inline getTimezone in discover, vis_type_timeseries, timelion app & vis_type_timelion
This commit is contained in:
parent
10afcf4be8
commit
c537d453e6
|
@ -52,9 +52,6 @@ export { angular };
|
|||
export { wrapInI18nContext } from 'ui/i18n';
|
||||
import { search } from '../../../../../plugins/data/public';
|
||||
export const { getRequestInspectorStats, getResponseInspectorStats, tabifyAggResponse } = search;
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
export { timezoneProvider } from 'ui/vis/lib/timezone';
|
||||
export {
|
||||
unhashUrl,
|
||||
redirectWhenMissing,
|
||||
|
|
|
@ -42,9 +42,10 @@ import {
|
|||
} from '@elastic/charts';
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { IUiSettingsClient } from 'kibana/public';
|
||||
import { EuiChartThemeType } from '@elastic/eui/dist/eui_charts_theme';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { getServices, timezoneProvider } from '../../../kibana_services';
|
||||
import { getServices } from '../../../kibana_services';
|
||||
|
||||
export interface DiscoverHistogramProps {
|
||||
chartData: any;
|
||||
|
@ -86,6 +87,16 @@ function getIntervalInMs(
|
|||
}
|
||||
}
|
||||
|
||||
function getTimezone(uiSettings: IUiSettingsClient) {
|
||||
if (uiSettings.isDefault('dateFormat:tz')) {
|
||||
const detectedTimezone = moment.tz.guess();
|
||||
if (detectedTimezone) return detectedTimezone;
|
||||
else return moment().format('Z');
|
||||
} else {
|
||||
return uiSettings.get('dateFormat:tz', 'Browser');
|
||||
}
|
||||
}
|
||||
|
||||
export function findMinInterval(
|
||||
xValues: number[],
|
||||
esValue: number,
|
||||
|
@ -193,7 +204,7 @@ export class DiscoverHistogram extends Component<DiscoverHistogramProps, Discove
|
|||
|
||||
public render() {
|
||||
const uiSettings = getServices().uiSettings;
|
||||
const timeZone = timezoneProvider(uiSettings)();
|
||||
const timeZone = getTimezone(uiSettings);
|
||||
const { chartData } = this.props;
|
||||
const { chartsTheme } = this.state;
|
||||
|
||||
|
|
|
@ -24,10 +24,10 @@ import { i18n } from '@kbn/i18n';
|
|||
import { capabilities } from 'ui/capabilities';
|
||||
import { docTitle } from 'ui/doc_title';
|
||||
import { fatalError, toastNotifications } from 'ui/notify';
|
||||
import { timezoneProvider } from 'ui/vis/lib/timezone';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { getSavedSheetBreadcrumbs, getCreateBreadcrumbs } from './breadcrumbs';
|
||||
import { getTimezone } from '../../vis_type_timelion/public';
|
||||
|
||||
import 'uiExports/savedObjectTypes';
|
||||
|
||||
|
@ -115,8 +115,7 @@ app.controller('timelion', function(
|
|||
$timeout,
|
||||
AppState,
|
||||
config,
|
||||
kbnUrl,
|
||||
Private
|
||||
kbnUrl
|
||||
) {
|
||||
// Keeping this at app scope allows us to keep the current page when the user
|
||||
// switches to say, the timepicker.
|
||||
|
@ -127,7 +126,7 @@ app.controller('timelion', function(
|
|||
timefilter.enableTimeRangeSelector();
|
||||
|
||||
const savedVisualizations = visualizations.savedVisualizationsLoader;
|
||||
const timezone = Private(timezoneProvider)();
|
||||
const timezone = getTimezone(config);
|
||||
|
||||
const defaultExpression = '.es(*)';
|
||||
const savedSheet = $route.current.locals.savedSheet;
|
||||
|
|
|
@ -18,15 +18,14 @@
|
|||
*/
|
||||
|
||||
import moment from 'moment-timezone';
|
||||
import { IUiSettingsClient } from 'kibana/public';
|
||||
|
||||
export function timezoneProvider(config) {
|
||||
return function() {
|
||||
if (config.isDefault('dateFormat:tz')) {
|
||||
const detectedTimezone = moment.tz.guess();
|
||||
if (detectedTimezone) return detectedTimezone;
|
||||
else return moment().format('Z');
|
||||
} else {
|
||||
return config.get('dateFormat:tz', 'Browser');
|
||||
}
|
||||
};
|
||||
export function getTimezone(config: IUiSettingsClient) {
|
||||
if (config.isDefault('dateFormat:tz')) {
|
||||
const detectedTimezone = moment.tz.guess();
|
||||
if (detectedTimezone) return detectedTimezone;
|
||||
else return moment().format('Z');
|
||||
} else {
|
||||
return config.get('dateFormat:tz', 'Browser');
|
||||
}
|
||||
}
|
|
@ -21,8 +21,8 @@ import { i18n } from '@kbn/i18n';
|
|||
import { KIBANA_CONTEXT_NAME } from 'src/plugins/expressions/public';
|
||||
import { VisParams } from 'src/legacy/core_plugins/visualizations/public';
|
||||
import { TimeRange, Filter, esQuery, Query } from '../../../../../plugins/data/public';
|
||||
import { timezoneProvider } from '../legacy_imports';
|
||||
import { TimelionVisDependencies } from '../plugin';
|
||||
import { getTimezone } from './get_timezone';
|
||||
|
||||
interface Stats {
|
||||
cacheCount: number;
|
||||
|
@ -66,7 +66,7 @@ export function getTimelionRequestHandler({
|
|||
http,
|
||||
timefilter,
|
||||
}: TimelionVisDependencies) {
|
||||
const timezone = timezoneProvider(uiSettings)();
|
||||
const timezone = getTimezone(uiSettings);
|
||||
|
||||
return async function({
|
||||
timeRange,
|
||||
|
|
|
@ -23,3 +23,5 @@ import { TimelionVisPlugin as Plugin } from './plugin';
|
|||
export function plugin(initializerContext: PluginInitializerContext) {
|
||||
return new Plugin(initializerContext);
|
||||
}
|
||||
|
||||
export { getTimezone } from './helpers/get_timezone';
|
||||
|
|
|
@ -19,6 +19,3 @@
|
|||
|
||||
export { npSetup, npStart } from 'ui/new_platform';
|
||||
export { PluginsStart } from 'ui/new_platform/new_platform';
|
||||
|
||||
// @ts-ignore
|
||||
export { timezoneProvider } from 'ui/vis/lib/timezone';
|
||||
|
|
|
@ -17,5 +17,15 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
// @ts-ignore
|
||||
export { timezoneProvider } from 'ui/vis/lib/timezone';
|
||||
import moment from 'moment-timezone';
|
||||
import { IUiSettingsClient } from 'kibana/public';
|
||||
|
||||
export function getTimezone(config: IUiSettingsClient) {
|
||||
if (config.isDefault('dateFormat:tz')) {
|
||||
const detectedTimezone = moment.tz.guess();
|
||||
if (detectedTimezone) return detectedTimezone;
|
||||
else return moment().format('Z');
|
||||
} else {
|
||||
return config.get('dateFormat:tz', 'Browser');
|
||||
}
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import { validateInterval } from './lib/validate_interval';
|
||||
import { timezoneProvider } from './legacy_imports';
|
||||
import { getTimezone } from './lib/get_timezone';
|
||||
import { getUISettings, getDataStart, getCoreStart } from './services';
|
||||
|
||||
export const metricsRequestHandler = async ({
|
||||
|
@ -30,7 +30,7 @@ export const metricsRequestHandler = async ({
|
|||
savedObjectId,
|
||||
}) => {
|
||||
const config = getUISettings();
|
||||
const timezone = timezoneProvider(config)();
|
||||
const timezone = getTimezone(config);
|
||||
const uiStateObj = uiState.get(visParams.type, {});
|
||||
const parsedTimeRange = getDataStart().query.timefilter.timefilter.calculateBounds(timeRange);
|
||||
const scaledDataFormat = config.get('dateFormat:scaled');
|
||||
|
|
|
@ -31,8 +31,7 @@ import {
|
|||
TooltipType,
|
||||
} from '@elastic/charts';
|
||||
import { EuiIcon } from '@elastic/eui';
|
||||
|
||||
import { timezoneProvider } from '../../../legacy_imports';
|
||||
import { getTimezone } from '../../../lib/get_timezone';
|
||||
import { eventBus, ACTIVE_CURSOR } from '../../lib/active_cursor';
|
||||
import { getUISettings } from '../../../services';
|
||||
import { GRID_LINE_CONFIG, ICON_TYPES_MAP, STACKED_OPTIONS } from '../../constants';
|
||||
|
@ -87,7 +86,7 @@ export const TimeSeries = ({
|
|||
|
||||
const tooltipFormatter = decorateFormatter(xAxisFormatter);
|
||||
const uiSettings = getUISettings();
|
||||
const timeZone = timezoneProvider(uiSettings)();
|
||||
const timeZone = getTimezone(uiSettings);
|
||||
const hasBarChart = series.some(({ bars }) => bars.show);
|
||||
|
||||
// compute the theme based on the bg color
|
||||
|
|
Loading…
Reference in a new issue