@grafana/scenes 5.11.1--canary.830.10631142943.0 → 5.11.2
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
# v5.11.2 (Mon Sep 02 2024)
|
2
|
+
|
3
|
+
#### 🐛 Bug Fix
|
4
|
+
|
5
|
+
- Make SceneRefreshPicker respect config.minRefreshInterval [#877](https://github.com/grafana/scenes/pull/877) ([@oscarkilhed](https://github.com/oscarkilhed))
|
6
|
+
|
7
|
+
#### Authors: 1
|
8
|
+
|
9
|
+
- Oscar Kilhed ([@oscarkilhed](https://github.com/oscarkilhed))
|
10
|
+
|
11
|
+
---
|
12
|
+
|
13
|
+
# v5.11.1 (Fri Aug 30 2024)
|
14
|
+
|
15
|
+
#### 🐛 Bug Fix
|
16
|
+
|
17
|
+
- AdHocFiltersVariable - new ad hoc filters UI [#830](https://github.com/grafana/scenes/pull/830) ([@Sergej-Vlasov](https://github.com/Sergej-Vlasov) [@bfmatei](https://github.com/bfmatei))
|
18
|
+
|
19
|
+
#### Authors: 2
|
20
|
+
|
21
|
+
- [@Sergej-Vlasov](https://github.com/Sergej-Vlasov)
|
22
|
+
- Bogdan Matei ([@bfmatei](https://github.com/bfmatei))
|
23
|
+
|
24
|
+
---
|
25
|
+
|
1
26
|
# v5.11.0 (Thu Aug 29 2024)
|
2
27
|
|
3
28
|
#### 🚀 Enhancement
|
@@ -29,13 +29,18 @@ const DEFAULT_INTERVALS = ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "
|
|
29
29
|
class SceneRefreshPicker extends SceneObjectBase {
|
30
30
|
constructor(state) {
|
31
31
|
var _a, _b, _c;
|
32
|
+
const filterDissalowedIntervals = (i) => {
|
33
|
+
var _a2;
|
34
|
+
const minInterval = (_a2 = state.minRefreshInterval) != null ? _a2 : config.minRefreshInterval;
|
35
|
+
return minInterval ? rangeUtil.intervalToMs(i) >= rangeUtil.intervalToMs(minInterval) : true;
|
36
|
+
};
|
32
37
|
super(__spreadProps(__spreadValues({
|
33
38
|
refresh: ""
|
34
39
|
}, state), {
|
35
40
|
autoValue: void 0,
|
36
41
|
autoEnabled: (_a = state.autoEnabled) != null ? _a : true,
|
37
42
|
autoMinInterval: (_b = state.autoMinInterval) != null ? _b : config.minRefreshInterval,
|
38
|
-
intervals: (_c = state.intervals) != null ? _c : DEFAULT_INTERVALS
|
43
|
+
intervals: ((_c = state.intervals) != null ? _c : DEFAULT_INTERVALS).filter(filterDissalowedIntervals)
|
39
44
|
}));
|
40
45
|
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["refresh"] });
|
41
46
|
this._autoRefreshBlocked = false;
|
@@ -127,11 +132,18 @@ class SceneRefreshPicker extends SceneObjectBase {
|
|
127
132
|
};
|
128
133
|
}
|
129
134
|
updateFromUrl(values) {
|
135
|
+
const { intervals } = this.state;
|
130
136
|
const refresh = values.refresh;
|
131
137
|
if (refresh && typeof refresh === "string") {
|
132
|
-
|
133
|
-
|
134
|
-
|
138
|
+
if (intervals == null ? void 0 : intervals.includes(refresh)) {
|
139
|
+
this.setState({
|
140
|
+
refresh
|
141
|
+
});
|
142
|
+
} else {
|
143
|
+
this.setState({
|
144
|
+
refresh: intervals ? intervals[0] : void 0
|
145
|
+
});
|
146
|
+
}
|
135
147
|
}
|
136
148
|
}
|
137
149
|
isTabVisible() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SceneRefreshPicker.js","sources":["../../../src/components/SceneRefreshPicker.tsx"],"sourcesContent":["import React from 'react';\nimport { Unsubscribable } from 'rxjs';\nimport { rangeUtil } from '@grafana/data';\nimport { config } from '@grafana/runtime';\nimport { RefreshPicker } from '@grafana/ui';\n\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { sceneGraph } from '../core/sceneGraph';\nimport { SceneComponentProps, SceneObject, SceneObjectState, SceneObjectUrlValues } from '../core/types';\nimport { SceneObjectUrlSyncConfig } from '../services/SceneObjectUrlSyncConfig';\n\nexport const DEFAULT_INTERVALS = ['5s', '10s', '30s', '1m', '5m', '15m', '30m', '1h', '2h', '1d'];\n\nexport interface SceneRefreshPickerState extends SceneObjectState {\n // Refresh interval, e.g. 5s, 1m, 2h\n refresh: string;\n autoEnabled?: boolean;\n autoMinInterval?: string;\n autoValue?: string;\n // List of allowed refresh intervals, e.g. ['5s', '1m']\n intervals?: string[];\n isOnCanvas?: boolean;\n primary?: boolean;\n withText?: boolean;\n}\n\nexport class SceneRefreshPicker extends SceneObjectBase<SceneRefreshPickerState> {\n public static Component = SceneRefreshPickerRenderer;\n protected _urlSync = new SceneObjectUrlSyncConfig(this, { keys: ['refresh'] });\n private _intervalTimer: ReturnType<typeof setInterval> | undefined;\n private _autoTimeRangeListener: Unsubscribable | undefined;\n private _autoRefreshBlocked: boolean = false;\n\n public constructor(state: Partial<SceneRefreshPickerState>) {\n super({\n refresh: '',\n ...state,\n autoValue: undefined,\n autoEnabled: state.autoEnabled ?? true,\n autoMinInterval: state.autoMinInterval ?? config.minRefreshInterval,\n intervals: state.intervals ?? DEFAULT_INTERVALS,\n });\n\n this.addActivationHandler(() => {\n this.setupIntervalTimer();\n\n const onVisibilityChange = () => {\n if (this._autoRefreshBlocked && document.visibilityState === 'visible') {\n this._autoRefreshBlocked = false;\n this.onRefresh();\n }\n }\n\n document.addEventListener('visibilitychange', onVisibilityChange);\n\n return () => {\n if (this._intervalTimer) {\n clearInterval(this._intervalTimer);\n }\n\n document.removeEventListener('visibilitychange', onVisibilityChange);\n this._autoTimeRangeListener?.unsubscribe();\n };\n });\n }\n\n public onRefresh = () => {\n const queryController = sceneGraph.getQueryController(this);\n if (queryController?.state.isRunning) {\n queryController.cancelAll();\n return;\n }\n\n const timeRange = sceneGraph.getTimeRange(this);\n\n if (this._intervalTimer) {\n clearInterval(this._intervalTimer);\n }\n\n timeRange.onRefresh();\n this.setupIntervalTimer();\n };\n\n public onIntervalChanged = (interval: string) => {\n this.setState({ refresh: interval });\n this.setupIntervalTimer();\n };\n\n public getUrlState() {\n return {\n refresh: this.state.refresh,\n };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const refresh = values.refresh;\n\n if (refresh && typeof refresh === 'string') {\n this.setState({\n refresh,\n });\n }\n }\n\n private setupAutoTimeRangeListener = () => {\n // If the time range has changed, we need to recalculate the auto interval but prevent unnecessary processing\n return sceneGraph.getTimeRange(this).subscribeToState((newState, prevState) => {\n if (newState.from !== prevState.from || newState.to !== prevState.to) {\n this.setupIntervalTimer();\n }\n });\n };\n\n private calculateAutoRefreshInterval = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n const resolution = window?.innerWidth ?? 2000;\n return rangeUtil.calculateInterval(timeRange.state.value, resolution, this.state.autoMinInterval);\n };\n\n private isTabVisible() {\n return document.visibilityState === undefined || document.visibilityState === 'visible';\n }\n\n private setupIntervalTimer = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n const { refresh, intervals } = this.state;\n\n if (this._intervalTimer || refresh === '') {\n clearInterval(this._intervalTimer);\n }\n\n if (refresh === '') {\n return;\n }\n\n // If the provided interval is not allowed\n if (refresh !== RefreshPicker.autoOption.value && intervals && !intervals.includes(refresh)) {\n return;\n }\n\n let intervalMs: number;\n\n // Unsubscribe from previous listener no matter what\n this._autoTimeRangeListener?.unsubscribe();\n\n if (refresh === RefreshPicker.autoOption.value) {\n const autoRefreshInterval = this.calculateAutoRefreshInterval();\n\n intervalMs = autoRefreshInterval.intervalMs;\n\n this._autoTimeRangeListener = this.setupAutoTimeRangeListener();\n\n if (autoRefreshInterval.interval !== this.state.autoValue) {\n this.setState({ autoValue: autoRefreshInterval.interval });\n }\n } else {\n intervalMs = rangeUtil.intervalToMs(refresh);\n }\n\n this._intervalTimer = setInterval(() => {\n if (this.isTabVisible()) {\n timeRange.onRefresh();\n } else {\n this._autoRefreshBlocked = true;\n }\n }, intervalMs);\n };\n}\n\nexport function SceneRefreshPickerRenderer({ model }: SceneComponentProps<SceneRefreshPicker>) {\n const { refresh, intervals, autoEnabled, autoValue, isOnCanvas, primary, withText } = model.useState();\n const isRunning = useQueryControllerState(model);\n\n let text = refresh === RefreshPicker.autoOption?.value ? autoValue : withText ? 'Refresh' : undefined;\n let tooltip: string | undefined;\n let width: string | undefined;\n\n if (isRunning) {\n tooltip = 'Cancel all queries';\n\n if (withText) {\n text = 'Cancel';\n }\n }\n\n if (withText) {\n width = '96px';\n }\n\n return (\n <RefreshPicker\n showAutoInterval={autoEnabled}\n value={refresh}\n intervals={intervals}\n tooltip={tooltip}\n width={width}\n text={text}\n onRefresh={model.onRefresh}\n primary={primary}\n onIntervalChanged={model.onIntervalChanged}\n isLoading={isRunning}\n isOnCanvas={isOnCanvas ?? true}\n />\n );\n}\n\nfunction useQueryControllerState(model: SceneObject): boolean {\n const queryController = sceneGraph.getQueryController(model);\n if (!queryController) {\n return false;\n }\n\n return queryController.useState().isRunning;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAWa,MAAA,iBAAA,GAAoB,CAAC,IAAA,EAAM,KAAO,EAAA,KAAA,EAAO,IAAM,EAAA,IAAA,EAAM,KAAO,EAAA,KAAA,EAAO,IAAM,EAAA,IAAA,EAAM,IAAI,EAAA;AAezF,MAAM,2BAA2B,eAAyC,CAAA;AAAA,EAOxE,YAAY,KAAyC,EAAA;AAjC9D,IAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAkCI,IAAM,KAAA,CAAA,aAAA,CAAA,cAAA,CAAA;AAAA,MACJ,OAAS,EAAA,EAAA;AAAA,KAAA,EACN,KAFC,CAAA,EAAA;AAAA,MAGJ,SAAW,EAAA,KAAA,CAAA;AAAA,MACX,WAAA,EAAA,CAAa,EAAM,GAAA,KAAA,CAAA,WAAA,KAAN,IAAqB,GAAA,EAAA,GAAA,IAAA;AAAA,MAClC,eAAiB,EAAA,CAAA,EAAA,GAAA,KAAA,CAAM,eAAN,KAAA,IAAA,GAAA,EAAA,GAAyB,MAAO,CAAA,kBAAA;AAAA,MACjD,SAAA,EA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IAAA,IAAA,GAAO,cAAY,EAAc,GAAA,aAAA,CAAA,UAAA,KAAd,mBAA0B,KAAQ,CAAA,GAAA,SAAA,GAAY,WAAW,SAAY,GAAA,KAAA,CAAA,CAAA;AAC5F,EAAI,IAAA,OAAA,CAAA;AACJ,EAAI,IAAA,KAAA,CAAA;AAEJ,EAAA,IAAI,SAAW,EAAA;AACb,IAAU,OAAA,GAAA,oBAAA,CAAA;AAEV,IAAA,IAAI,QAAU,EAAA;AACZ,MAAO,IAAA,GAAA,QAAA,CAAA;AAAA,KACT;AAAA,GACF;AAEA,EAAA,IAAI,QAAU,EAAA;AACZ,IAAQ,KAAA,GAAA,MAAA,CAAA;AAAA,GACV;AAEA,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA;AAAA,IACC,gBAAkB,EAAA,WAAA;AAAA,IAClB,KAAO,EAAA,OAAA;AAAA,IACP,SAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,IAAA;AAAA,IACA,WAAW,KAAM,CAAA,SAAA;AAAA,IACjB,OAAA;AAAA,IACA,mBAAmB,KAAM,CAAA,iBAAA;AAAA,IACzB,SAAW,EAAA,SAAA;AAAA,IACX,YAAY,UAAc,IAAA,IAAA,GAAA,UAAA,GAAA,IAAA;AAAA,GAC5B,CAAA,CAAA;AAEJ,CAAA;AAEA,SAAS,wBAAwB,KAA6B,EAAA;AAC5D,EAAM,MAAA,eAAA,GAAkB,UAAW,CAAA,kBAAA,CAAmB,KAAK,CAAA,CAAA;AAC3D,EAAA,IAAI,CAAC,eAAiB,EAAA;AACpB,IAAO,OAAA,KAAA,CAAA;AAAA,GACT;AAEA,EAAO,OAAA,eAAA,CAAgB,UAAW,CAAA,SAAA,CAAA;AACpC;;;;"}
|
1
|
+
{"version":3,"file":"SceneRefreshPicker.js","sources":["../../../src/components/SceneRefreshPicker.tsx"],"sourcesContent":["import React from 'react';\nimport { Unsubscribable } from 'rxjs';\nimport { rangeUtil } from '@grafana/data';\nimport { config } from '@grafana/runtime';\nimport { RefreshPicker } from '@grafana/ui';\n\nimport { SceneObjectBase } from '../core/SceneObjectBase';\nimport { sceneGraph } from '../core/sceneGraph';\nimport { SceneComponentProps, SceneObject, SceneObjectState, SceneObjectUrlValues } from '../core/types';\nimport { SceneObjectUrlSyncConfig } from '../services/SceneObjectUrlSyncConfig';\n\nexport const DEFAULT_INTERVALS = ['5s', '10s', '30s', '1m', '5m', '15m', '30m', '1h', '2h', '1d'];\n\nexport interface SceneRefreshPickerState extends SceneObjectState {\n /**\n * Refresh interval, e.g. 5s, 1m, 2h\n */\n refresh: string;\n autoEnabled?: boolean;\n autoMinInterval?: string;\n autoValue?: string;\n /**\n * List of allowed refresh intervals, e.g. ['5s', '1m']\n */\n intervals?: string[];\n isOnCanvas?: boolean;\n primary?: boolean;\n withText?: boolean;\n /**\n * Overrides the default minRefreshInterval from the grafana config. Can be set to \"0s\" to remove the minimum refresh interval.\n */\n minRefreshInterval?: string;\n}\n\nexport class SceneRefreshPicker extends SceneObjectBase<SceneRefreshPickerState> {\n public static Component = SceneRefreshPickerRenderer;\n protected _urlSync = new SceneObjectUrlSyncConfig(this, { keys: ['refresh'] });\n private _intervalTimer: ReturnType<typeof setInterval> | undefined;\n private _autoTimeRangeListener: Unsubscribable | undefined;\n private _autoRefreshBlocked: boolean = false;\n\n public constructor(state: Partial<SceneRefreshPickerState>) {\n const filterDissalowedIntervals = (i: string) => {\n const minInterval = state.minRefreshInterval ?? config.minRefreshInterval;\n return minInterval ? rangeUtil.intervalToMs(i) >= rangeUtil.intervalToMs(minInterval) : true;\n };\n\n super({\n refresh: '',\n ...state,\n autoValue: undefined,\n autoEnabled: state.autoEnabled ?? true,\n autoMinInterval: state.autoMinInterval ?? config.minRefreshInterval,\n intervals: (state.intervals ?? DEFAULT_INTERVALS).filter(filterDissalowedIntervals),\n });\n\n this.addActivationHandler(() => {\n this.setupIntervalTimer();\n\n const onVisibilityChange = () => {\n if (this._autoRefreshBlocked && document.visibilityState === 'visible') {\n this._autoRefreshBlocked = false;\n this.onRefresh();\n }\n }\n\n document.addEventListener('visibilitychange', onVisibilityChange);\n\n return () => {\n if (this._intervalTimer) {\n clearInterval(this._intervalTimer);\n }\n\n document.removeEventListener('visibilitychange', onVisibilityChange);\n this._autoTimeRangeListener?.unsubscribe();\n };\n });\n }\n\n public onRefresh = () => {\n const queryController = sceneGraph.getQueryController(this);\n if (queryController?.state.isRunning) {\n queryController.cancelAll();\n return;\n }\n\n const timeRange = sceneGraph.getTimeRange(this);\n\n if (this._intervalTimer) {\n clearInterval(this._intervalTimer);\n }\n\n timeRange.onRefresh();\n this.setupIntervalTimer();\n };\n\n public onIntervalChanged = (interval: string) => {\n this.setState({ refresh: interval });\n this.setupIntervalTimer();\n };\n\n public getUrlState() {\n return {\n refresh: this.state.refresh,\n };\n }\n\n public updateFromUrl(values: SceneObjectUrlValues) {\n const { intervals } = this.state;\n const refresh = values.refresh;\n\n if (refresh && typeof refresh === 'string') {\n if (intervals?.includes(refresh)) {\n this.setState({\n refresh,\n });\n } else {\n this.setState({\n // Default to the first refresh interval if the interval from the URL is not allowed, just like in the old architecture.\n refresh: intervals ? intervals[0] : undefined,\n });\n }\n }\n }\n\n private setupAutoTimeRangeListener = () => {\n // If the time range has changed, we need to recalculate the auto interval but prevent unnecessary processing\n return sceneGraph.getTimeRange(this).subscribeToState((newState, prevState) => {\n if (newState.from !== prevState.from || newState.to !== prevState.to) {\n this.setupIntervalTimer();\n }\n });\n };\n\n private calculateAutoRefreshInterval = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n const resolution = window?.innerWidth ?? 2000;\n return rangeUtil.calculateInterval(timeRange.state.value, resolution, this.state.autoMinInterval);\n };\n\n private isTabVisible() {\n return document.visibilityState === undefined || document.visibilityState === 'visible';\n }\n\n private setupIntervalTimer = () => {\n const timeRange = sceneGraph.getTimeRange(this);\n const { refresh, intervals } = this.state;\n\n if (this._intervalTimer || refresh === '') {\n clearInterval(this._intervalTimer);\n }\n\n if (refresh === '') {\n return;\n }\n\n // If the provided interval is not allowed\n if (refresh !== RefreshPicker.autoOption.value && intervals && !intervals.includes(refresh)) {\n return;\n }\n\n let intervalMs: number;\n\n // Unsubscribe from previous listener no matter what\n this._autoTimeRangeListener?.unsubscribe();\n\n if (refresh === RefreshPicker.autoOption.value) {\n const autoRefreshInterval = this.calculateAutoRefreshInterval();\n\n intervalMs = autoRefreshInterval.intervalMs;\n\n this._autoTimeRangeListener = this.setupAutoTimeRangeListener();\n\n if (autoRefreshInterval.interval !== this.state.autoValue) {\n this.setState({ autoValue: autoRefreshInterval.interval });\n }\n } else {\n intervalMs = rangeUtil.intervalToMs(refresh);\n }\n\n this._intervalTimer = setInterval(() => {\n if (this.isTabVisible()) {\n timeRange.onRefresh();\n } else {\n this._autoRefreshBlocked = true;\n }\n }, intervalMs);\n };\n}\n\nexport function SceneRefreshPickerRenderer({ model }: SceneComponentProps<SceneRefreshPicker>) {\n const { refresh, intervals, autoEnabled, autoValue, isOnCanvas, primary, withText } = model.useState();\n const isRunning = useQueryControllerState(model);\n\n let text = refresh === RefreshPicker.autoOption?.value ? autoValue : withText ? 'Refresh' : undefined;\n let tooltip: string | undefined;\n let width: string | undefined;\n\n if (isRunning) {\n tooltip = 'Cancel all queries';\n\n if (withText) {\n text = 'Cancel';\n }\n }\n\n if (withText) {\n width = '96px';\n }\n\n return (\n <RefreshPicker\n showAutoInterval={autoEnabled}\n value={refresh}\n intervals={intervals}\n tooltip={tooltip}\n width={width}\n text={text}\n onRefresh={model.onRefresh}\n primary={primary}\n onIntervalChanged={model.onIntervalChanged}\n isLoading={isRunning}\n isOnCanvas={isOnCanvas ?? true}\n />\n );\n}\n\nfunction useQueryControllerState(model: SceneObject): boolean {\n const queryController = sceneGraph.getQueryController(model);\n if (!queryController) {\n return false;\n }\n\n return queryController.useState().isRunning;\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAWa,MAAA,iBAAA,GAAoB,CAAC,IA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TimePickerState> {
|
|
1821
1821
|
declare function SceneTimePickerRenderer({ model }: SceneComponentProps<SceneTimePicker>): React__default.JSX.Element | null;
|
1822
1822
|
|
1823
1823
|
interface SceneRefreshPickerState extends SceneObjectState {
|
1824
|
+
/**
|
1825
|
+
* Refresh interval, e.g. 5s, 1m, 2h
|
1826
|
+
*/
|
1824
1827
|
refresh: string;
|
1825
1828
|
autoEnabled?: boolean;
|
1826
1829
|
autoMinInterval?: string;
|
1827
1830
|
autoValue?: string;
|
1831
|
+
/**
|
1832
|
+
* List of allowed refresh intervals, e.g. ['5s', '1m']
|
1833
|
+
*/
|
1828
1834
|
intervals?: string[];
|
1829
1835
|
isOnCanvas?: boolean;
|
1830
1836
|
primary?: boolean;
|
1831
1837
|
withText?: boolean;
|
1838
|
+
/**
|
1839
|
+
* Overrides the default minRefreshInterval from the grafana config. Can be set to "0s" to remove the minimum refresh interval.
|
1840
|
+
*/
|
1841
|
+
minRefreshInterval?: string;
|
1832
1842
|
}
|
1833
1843
|
declare class SceneRefreshPicker extends SceneObjectBase<SceneRefreshPickerState> {
|
1834
1844
|
static Component: typeof SceneRefreshPickerRenderer;
|
package/dist/index.js
CHANGED
@@ -10256,13 +10256,18 @@ const DEFAULT_INTERVALS = ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "
|
|
10256
10256
|
class SceneRefreshPicker extends SceneObjectBase {
|
10257
10257
|
constructor(state) {
|
10258
10258
|
var _a, _b, _c;
|
10259
|
+
const filterDissalowedIntervals = (i) => {
|
10260
|
+
var _a2;
|
10261
|
+
const minInterval = (_a2 = state.minRefreshInterval) != null ? _a2 : runtime.config.minRefreshInterval;
|
10262
|
+
return minInterval ? data.rangeUtil.intervalToMs(i) >= data.rangeUtil.intervalToMs(minInterval) : true;
|
10263
|
+
};
|
10259
10264
|
super(__spreadProps$3(__spreadValues$6({
|
10260
10265
|
refresh: ""
|
10261
10266
|
}, state), {
|
10262
10267
|
autoValue: void 0,
|
10263
10268
|
autoEnabled: (_a = state.autoEnabled) != null ? _a : true,
|
10264
10269
|
autoMinInterval: (_b = state.autoMinInterval) != null ? _b : runtime.config.minRefreshInterval,
|
10265
|
-
intervals: (_c = state.intervals) != null ? _c : DEFAULT_INTERVALS
|
10270
|
+
intervals: ((_c = state.intervals) != null ? _c : DEFAULT_INTERVALS).filter(filterDissalowedIntervals)
|
10266
10271
|
}));
|
10267
10272
|
this._urlSync = new SceneObjectUrlSyncConfig(this, { keys: ["refresh"] });
|
10268
10273
|
this._autoRefreshBlocked = false;
|
@@ -10354,11 +10359,18 @@ class SceneRefreshPicker extends SceneObjectBase {
|
|
10354
10359
|
};
|
10355
10360
|
}
|
10356
10361
|
updateFromUrl(values) {
|
10362
|
+
const { intervals } = this.state;
|
10357
10363
|
const refresh = values.refresh;
|
10358
10364
|
if (refresh && typeof refresh === "string") {
|
10359
|
-
|
10360
|
-
|
10361
|
-
|
10365
|
+
if (intervals == null ? void 0 : intervals.includes(refresh)) {
|
10366
|
+
this.setState({
|
10367
|
+
refresh
|
10368
|
+
});
|
10369
|
+
} else {
|
10370
|
+
this.setState({
|
10371
|
+
refresh: intervals ? intervals[0] : void 0
|
10372
|
+
});
|
10373
|
+
}
|
10362
10374
|
}
|
10363
10375
|
}
|
10364
10376
|
isTabVisible() {
|