Skip to content

Commit 000b6e6

Browse files
committed
fix: OU-1214 [Edit Dashboard] - Time range is not persisted when saving
1 parent 6c91df7 commit 000b6e6

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

web/src/components/dashboards/perses/PersesWrapper.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,25 @@ function InnerWrapper({ children, project, dashboardName }) {
394394
const DEFAULT_DASHBOARD_DURATION = '30m';
395395
const DEFAULT_REFRESH_INTERVAL = '0s';
396396

397-
const initialTimeRange = useInitialTimeRange(DEFAULT_DASHBOARD_DURATION);
398-
const initialRefreshInterval = useInitialRefreshInterval(DEFAULT_REFRESH_INTERVAL);
397+
let clearedDashboardResource: DashboardResource | undefined;
398+
if (Array.isArray(persesDashboard)) {
399+
if (persesDashboard.length === 0) {
400+
clearedDashboardResource = undefined;
401+
} else {
402+
clearedDashboardResource = persesDashboard[0];
403+
}
404+
} else {
405+
clearedDashboardResource = persesDashboard;
406+
}
407+
408+
const dashboardDuration = clearedDashboardResource?.spec?.duration;
409+
const dashboardTimeInterval = clearedDashboardResource?.spec?.refreshInterval;
410+
411+
const effectiveDuration = dashboardDuration || DEFAULT_DASHBOARD_DURATION;
412+
const effectiveRefreshInterval = dashboardTimeInterval || DEFAULT_REFRESH_INTERVAL;
413+
414+
const initialTimeRange = useInitialTimeRange(effectiveDuration);
415+
const initialRefreshInterval = useInitialRefreshInterval(effectiveRefreshInterval);
399416

400417
const builtinVariables = useMemo(() => {
401418
const result = [
@@ -436,17 +453,6 @@ function InnerWrapper({ children, project, dashboardName }) {
436453
return <LoadingBox />;
437454
}
438455

439-
let clearedDashboardResource: DashboardResource | undefined;
440-
if (Array.isArray(persesDashboard)) {
441-
if (persesDashboard.length === 0) {
442-
clearedDashboardResource = undefined;
443-
} else {
444-
clearedDashboardResource = persesDashboard[0];
445-
}
446-
} else {
447-
clearedDashboardResource = persesDashboard;
448-
}
449-
450456
return (
451457
<TimeRangeProviderWithQueryParams
452458
initialTimeRange={initialTimeRange}

0 commit comments

Comments
 (0)