{(isAutoRefreshSelectorEnabled || isTimeRangeSelectorEnabled) && (
- {
- // This check is a workaround to catch a bug in EuiSuperDatePicker which
- // might not have disabled the refresh interval after a props change.
- if (!refreshInterval.pause) {
- mlTimefilterRefresh$.next();
- }
- }}
+ onRefresh={() => mlTimefilterRefresh$.next()}
onRefreshChange={updateInterval}
recentlyUsedRanges={recentlyUsedRanges}
dateFormat={dateFormat}
diff --git a/x-pack/legacy/plugins/ml/public/contexts/ui/__mocks__/mocks.ts b/x-pack/legacy/plugins/ml/public/contexts/ui/__mocks__/mocks.ts
index 90bc028a7cd37..e6e51f0bdecf4 100644
--- a/x-pack/legacy/plugins/ml/public/contexts/ui/__mocks__/mocks.ts
+++ b/x-pack/legacy/plugins/ml/public/contexts/ui/__mocks__/mocks.ts
@@ -11,7 +11,7 @@ export const uiChromeMock = {
get: (key: string) => {
switch (key) {
case 'dateFormat':
- return {};
+ return 'MMM D, YYYY @ HH:mm:ss.SSS';
case 'theme:darkMode':
return false;
case 'timepicker:timeDefaults':
@@ -26,12 +26,45 @@ export const uiChromeMock = {
},
};
+interface RefreshInterval {
+ value: number;
+ pause: boolean;
+}
+
+const time = {
+ from: 'Thu Aug 29 2019 02:04:19 GMT+0200',
+ to: 'Sun Sep 29 2019 01:45:36 GMT+0200',
+};
+
export const uiTimefilterMock = {
- getRefreshInterval: () => '30s',
- getTime: () => ({ from: 0, to: 0 }),
+ enableAutoRefreshSelector() {
+ this.isAutoRefreshSelectorEnabled = true;
+ },
+ enableTimeRangeSelector() {
+ this.isTimeRangeSelectorEnabled = true;
+ },
+ getEnabledUpdated$() {
+ return { subscribe: jest.fn() };
+ },
+ getRefreshInterval() {
+ return this.refreshInterval;
+ },
+ getRefreshIntervalUpdate$() {
+ return { subscribe: jest.fn() };
+ },
+ getTime: () => time,
+ getTimeUpdate$() {
+ return { subscribe: jest.fn() };
+ },
+ isAutoRefreshSelectorEnabled: false,
+ isTimeRangeSelectorEnabled: false,
+ refreshInterval: { value: 0, pause: true },
on: (event: string, reload: () => void) => {},
+ setRefreshInterval(refreshInterval: RefreshInterval) {
+ this.refreshInterval = refreshInterval;
+ },
};
export const uiTimeHistoryMock = {
- get: () => [{ from: 0, to: 0 }],
+ get: () => [time],
};
diff --git a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js
index db316f67688fe..ab29e0ba303a9 100644
--- a/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js
+++ b/x-pack/legacy/plugins/ml/public/timeseriesexplorer/timeseriesexplorer.js
@@ -467,6 +467,10 @@ export class TimeSeriesExplorer extends React.Component {
}
refresh = () => {
+ if (this.state.loading) {
+ return;
+ }
+
const { appStateHandler, timefilter } = this.props;
const {
detectorId: currentDetectorId,