Skip to content
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-13287-fixed-1768562046475.md
Original file line number Diff line number Diff line change
@@ -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))
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
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;
Expand Down Expand Up @@ -73,9 +76,12 @@
});
}
setSelectedDashboard(dashboard);
handleDashboardChange(dashboard);
handleDashboardChange(
dashboard,
preferences?.[DASHBOARD_ID] === dashboard?.id
Comment thread
venkymano-akamai marked this conversation as resolved.
);
},
[]
[preferences, handleDashboardChange]

Check warning on line 84 in packages/manager/src/features/CloudPulse/Overview/GlobalFilters.tsx

View workflow job for this annotation

GitHub Actions / ESLint Review (manager)

[eslint] reported by reviewdog 🐢 React Hook React.useCallback has a missing dependency: 'updatePreferences'. Either include it or remove the dependency array. Raw Output: {"ruleId":"react-hooks/exhaustive-deps","severity":1,"message":"React Hook React.useCallback has a missing dependency: 'updatePreferences'. Either include it or remove the dependency array.","line":84,"column":5,"nodeType":"ArrayExpression","endLine":84,"endColumn":41,"suggestions":[{"desc":"Update the dependencies array to be: [handleDashboardChange, preferences, updatePreferences]","fix":{"range":[2828,2864],"text":"[handleDashboardChange, preferences, updatePreferences]"}}]}
);

const emitFilterChange = React.useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down