Skip to content

Commit fcb8b3c

Browse files
fix: [DI-28200] - Fix for the volume contextual view dimension filter bug fix and group by default selection retention (#13139)
* upcoming: [DI-28222] - Dimension filter bug fix * upcoming: [DI-28222] - NB contextual view * upcoming: [DI-28200] - Group By issue fix * upcoming: [DI-28200] - Contextual view setup * upcoming: [DI-28200] - Changeset * fix: [DI-28200] - Remove contextual view changes * fix: [DI-28200] - Add info comments * fix: [DI-28200] - code refactorings * fix: [DI-28200] - code refactorings * fix: [DI-28200] - pass current dashboard * fix: [DI-28200] - UT for group by * fix: [DI-28200] - UT for group by
1 parent 855eabe commit fcb8b3c

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Fixed
3+
---
4+
5+
CloudPulse metrics volumes contextual view `not showing dimension values` and CloudPulse metrics `group by default selection retention` ([#13139](https://github.com/linode/manager/pull/13139))

packages/manager/src/features/CloudPulse/Dashboard/CloudPulseDashboardWithFilters.test.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@ import { renderWithTheme } from 'src/utilities/testHelpers';
88

99
import { CloudPulseDashboardWithFilters } from './CloudPulseDashboardWithFilters';
1010

11+
import type { GroupByOption } from '../GroupBy/CloudPulseGroupByDrawer';
12+
1113
const queryMocks = vi.hoisted(() => ({
1214
useCloudPulseDashboardsQuery: vi.fn().mockReturnValue({}),
15+
useGlobalDimensions: vi.fn().mockReturnValue({}),
1316
}));
1417

1518
const circleProgress = 'circle-progress';
1619
const mandatoryFiltersError = 'Select filters to visualize metrics.';
20+
const mockGroupByOptions: GroupByOption[] = [
21+
{ value: 'option1', label: 'Option 1' },
22+
{ value: 'option2', label: 'Option 2' },
23+
{ value: 'option3', label: 'Option 3' },
24+
];
1725

1826
vi.mock('src/queries/cloudpulse/dashboards', async () => {
1927
const actual = await vi.importActual('src/queries/cloudpulse/dashboards');
@@ -22,6 +30,14 @@ vi.mock('src/queries/cloudpulse/dashboards', async () => {
2230
useCloudPulseDashboardsQuery: queryMocks.useCloudPulseDashboardsQuery,
2331
};
2432
});
33+
vi.mock('../GroupBy/utils', async () => {
34+
const actual = await vi.importActual('../GroupBy/utils');
35+
36+
return {
37+
...actual,
38+
useGlobalDimensions: queryMocks.useGlobalDimensions,
39+
};
40+
});
2541
const mockDashboard = dashboardFactory.build();
2642

2743
describe('CloudPulseDashboardWithFilters component tests', () => {
@@ -61,10 +77,19 @@ describe('CloudPulseDashboardWithFilters component tests', () => {
6177
isLoading: false,
6278
});
6379

80+
queryMocks.useGlobalDimensions.mockReturnValue({
81+
isLoading: false,
82+
options: mockGroupByOptions,
83+
defaultValue: [],
84+
});
85+
6486
renderWithTheme(
6587
<CloudPulseDashboardWithFilters resource={1} serviceType="dbaas" />
6688
);
6789

90+
const groupByIcon = screen.getByTestId('group-by');
91+
expect(groupByIcon).toBeEnabled();
92+
6893
const startDate = screen.getByText('Start Date');
6994
const nodeTypeSelect = screen.getByTestId('node-type-select');
7095
expect(startDate).toBeInTheDocument();
@@ -217,7 +242,6 @@ describe('CloudPulseDashboardWithFilters component tests', () => {
217242

218243
const startDate = screen.getByText('Start Date');
219244
expect(startDate).toBeInTheDocument();
220-
221245
await userEvent.click(screen.getByPlaceholderText('Select a Dashboard'));
222246
await userEvent.click(screen.getByText('nodebalancer_firewall_dashbaord'));
223247
expect(

packages/manager/src/features/CloudPulse/Dashboard/CloudPulseDashboardWithFilters.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const CloudPulseDashboardWithFilters = React.memo(
202202
/>
203203
<GlobalFilterGroupByRenderer
204204
handleChange={handleGroupByChange}
205-
selectedDashboard={dashboard}
205+
selectedDashboard={currentDashboard}
206206
/>
207207
</Box>
208208
</Box>

packages/manager/src/features/CloudPulse/Overview/GlobalFilters.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ export const GlobalFilters = React.memo((props: GlobalFilterProperties) => {
165165
handleChange={onGroupByChange}
166166
preferenceGroupBy={preferences?.[GROUP_BY]}
167167
savePreferences
168-
selectedDashboard={selectedDashboard}
168+
selectedDashboard={
169+
preferences?.[DASHBOARD_ID] === selectedDashboard?.id // wait for dashboard id in preference to match selected dashboard id
170+
? selectedDashboard
171+
: undefined
172+
}
169173
/>
170174
</Box>
171175
</Box>

packages/manager/src/features/CloudPulse/Widget/CloudPulseWidget.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ export const CloudPulseWidget = (props: CloudPulseWidgetProperties) => {
209209
dimensionLabel: 'linode_id',
210210
type: 'metrics',
211211
entities: entityIds,
212-
regions: regions?.filter((region) => region.id === linodeRegion) ?? [],
212+
regions: linodeRegion // if linode region is selected, filter regions to only that region else pass all regions
213+
? (regions?.filter(({ id }) => id === linodeRegion) ?? [])
214+
: regions,
213215
scope: 'entity',
214216
serviceType,
215217
associatedEntityType: FILTER_CONFIG.get(dashboardId)?.associatedEntityType,
@@ -218,15 +220,19 @@ export const CloudPulseWidget = (props: CloudPulseWidgetProperties) => {
218220
dimensionLabel: 'vpc_subnet_id',
219221
type: 'metrics',
220222
entities: entityIds,
221-
regions: regions?.filter((region) => region.id === linodeRegion) ?? [],
223+
regions: linodeRegion // if linode region is selected, filter regions to only that region else pass all regions
224+
? (regions?.filter(({ id }) => id === linodeRegion) ?? [])
225+
: regions,
222226
scope: 'entity',
223227
serviceType,
224228
associatedEntityType: FILTER_CONFIG.get(dashboardId)?.associatedEntityType,
225229
});
226230
const linodeFromVolumes = useBlockStorageFetchOptions({
227231
entities: entityIds,
228232
dimensionLabel: 'linode_id',
229-
regions: regions?.filter(({ id }) => id === region) ?? [],
233+
regions: region // if region is selected, filter regions to only that region else pass all regions
234+
? (regions?.filter(({ id }) => id === region) ?? [])
235+
: regions,
230236
type: 'metrics',
231237
scope: 'entity',
232238
serviceType,

0 commit comments

Comments
 (0)