diff --git a/packages/manager/.changeset/pr-13287-fixed-1768562046475.md b/packages/manager/.changeset/pr-13287-fixed-1768562046475.md new file mode 100644 index 00000000000..de88793d181 --- /dev/null +++ b/packages/manager/.changeset/pr-13287-fixed-1768562046475.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Fixed +--- + +Wrong time range sent in metrics payload on preference reload in `CloudPulse metrics` ([#13287](https://github.com/linode/manager/pull/13287)) diff --git a/packages/manager/src/features/CloudPulse/Dashboard/CloudPulseDashboardLanding.tsx b/packages/manager/src/features/CloudPulse/Dashboard/CloudPulseDashboardLanding.tsx index a6bb489a610..033d688a989 100644 --- a/packages/manager/src/features/CloudPulse/Dashboard/CloudPulseDashboardLanding.tsx +++ b/packages/manager/src/features/CloudPulse/Dashboard/CloudPulseDashboardLanding.tsx @@ -83,13 +83,15 @@ export const CloudPulseDashboardLanding = () => { ); const onDashboardChange = React.useCallback( - (dashboardObj: Dashboard) => { + (dashboardObj: Dashboard, skipReset: boolean = false) => { setDashboard(dashboardObj); - setFilterData({ - id: {}, - label: {}, - }); // clear the filter values on dashboard change - setTimeDuration(defaultTimeDuration(timezone)); // clear time duration on dashboard change + if (!skipReset) { + setFilterData({ + id: {}, + label: {}, + }); // clear the filter values on dashboard change + setTimeDuration(defaultTimeDuration(timezone)); // clear time duration on dashboard change + } }, [timezone] ); diff --git a/packages/manager/src/features/CloudPulse/Overview/GlobalFilters.tsx b/packages/manager/src/features/CloudPulse/Overview/GlobalFilters.tsx index fdbd89ecf4f..030aea8c122 100644 --- a/packages/manager/src/features/CloudPulse/Overview/GlobalFilters.tsx +++ b/packages/manager/src/features/CloudPulse/Overview/GlobalFilters.tsx @@ -30,7 +30,10 @@ export interface GlobalFilterProperties { filterValue: FilterValueType, labels: string[] ): void; - handleDashboardChange(dashboard: Dashboard | undefined): void; + handleDashboardChange( + dashboard: Dashboard | undefined, + skipReset?: boolean + ): void; handleGroupByChange: (selectedValues: string[]) => void; handleTimeDurationChange(timeDuration: DateTimeWithPreset): void; handleToggleAppliedFilter(isVisible: boolean): void; @@ -73,9 +76,12 @@ export const GlobalFilters = React.memo((props: GlobalFilterProperties) => { }); } setSelectedDashboard(dashboard); - handleDashboardChange(dashboard); + handleDashboardChange( + dashboard, + preferences?.[DASHBOARD_ID] === dashboard?.id + ); }, - [] + [preferences, handleDashboardChange] ); const emitFilterChange = React.useCallback( diff --git a/packages/manager/src/features/CloudPulse/shared/CloudPulseDashboardSelect.tsx b/packages/manager/src/features/CloudPulse/shared/CloudPulseDashboardSelect.tsx index 3bb9537f959..a03d9599c85 100644 --- a/packages/manager/src/features/CloudPulse/shared/CloudPulseDashboardSelect.tsx +++ b/packages/manager/src/features/CloudPulse/shared/CloudPulseDashboardSelect.tsx @@ -115,6 +115,7 @@ export const CloudPulseDashboardSelect = React.memo( // only call this code when the component is rendered initially if ( (savePreferences || !!serviceType) && + !dashboardsLoading && dashboardsList.length > 0 && selectedDashboard === undefined ) {