Skip to content

Commit 0bff8eb

Browse files
upcoming: [DPS-41443] - Metrics widget dimension filter and Group By Icons disabled tool tips (#13496)
* upcoming: [DPS-41443] - Metrics widget dimension filter and Group By Icons disabled tool tips * add changesets * add changesets --------- Co-authored-by: venkatmano-akamai <vmangalr@akamai.com>
1 parent 849c34e commit 0bff8eb

10 files changed

Lines changed: 137 additions & 8 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
ACLP-Metrics updated Tooltip messages for Group-by, DimensionFilter icons when in disabled state for the Widgets ([#13496](https://github.com/linode/manager/pull/13496))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Add alternate tool tip texts for group-by, dimension filter widget icons when disabled in ACLP-Metrics ([#13496](https://github.com/linode/manager/pull/13496))

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

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,16 @@ describe('CloudPulseDashboardWithFilters component tests', () => {
139139
error: '',
140140
isLoading: false,
141141
});
142+
queryMocks.useGlobalDimensions.mockReturnValue({
143+
isLoading: false,
144+
options: mockGroupByOptions,
145+
defaultValue: [],
146+
});
142147
renderWithTheme(
143148
<CloudPulseDashboardWithFilters resource={1} serviceType="nodebalancer" />
144149
);
150+
const groupByIcon = screen.getByTestId('group-by');
151+
expect(groupByIcon).toBeEnabled();
145152
const presetButton = screen.getByTestId(PRESET_BUTTON_ID);
146153
const portsSelect = screen.getByPlaceholderText('e.g., 80,443,3000');
147154
expect(presetButton).toBeInTheDocument();
@@ -157,9 +164,18 @@ describe('CloudPulseDashboardWithFilters component tests', () => {
157164
error: '',
158165
isLoading: false,
159166
});
167+
queryMocks.useGlobalDimensions.mockReturnValue({
168+
isLoading: false,
169+
options: mockGroupByOptions,
170+
defaultValue: [],
171+
});
160172
renderWithTheme(
161173
<CloudPulseDashboardWithFilters resource={1} serviceType="firewall" />
162174
);
175+
176+
const groupByIcon = screen.getByTestId('group-by');
177+
expect(groupByIcon).toBeEnabled();
178+
163179
const presetButton = screen.getByTestId(PRESET_BUTTON_ID);
164180
expect(presetButton).toBeInTheDocument();
165181
expect(screen.getByPlaceholderText('Select a Linode Region')).toBeVisible();
@@ -173,14 +189,20 @@ describe('CloudPulseDashboardWithFilters component tests', () => {
173189
error: '',
174190
isLoading: false,
175191
});
176-
192+
queryMocks.useGlobalDimensions.mockReturnValue({
193+
isLoading: false,
194+
options: mockGroupByOptions,
195+
defaultValue: [],
196+
});
177197
renderWithTheme(
178198
<CloudPulseDashboardWithFilters
179199
region="test"
180200
resource="test"
181201
serviceType="objectstorage"
182202
/>
183203
);
204+
const groupByIcon = screen.getByTestId('group-by');
205+
expect(groupByIcon).toBeEnabled();
184206

185207
const presetButton = screen.getByTestId(PRESET_BUTTON_ID);
186208
expect(presetButton).toBeInTheDocument();
@@ -192,6 +214,11 @@ describe('CloudPulseDashboardWithFilters component tests', () => {
192214
error: '',
193215
isLoading: false,
194216
});
217+
queryMocks.useGlobalDimensions.mockReturnValue({
218+
isLoading: false,
219+
options: mockGroupByOptions,
220+
defaultValue: [],
221+
});
195222
renderWithTheme(
196223
<CloudPulseDashboardWithFilters
197224
resource={1}
@@ -208,11 +235,18 @@ describe('CloudPulseDashboardWithFilters component tests', () => {
208235
error: '',
209236
isLoading: false,
210237
});
211-
238+
queryMocks.useGlobalDimensions.mockReturnValue({
239+
isLoading: false,
240+
options: mockGroupByOptions,
241+
defaultValue: [],
242+
});
212243
renderWithTheme(
213244
<CloudPulseDashboardWithFilters resource={1} serviceType="blockstorage" />
214245
);
215246

247+
const groupByIcon = screen.getByTestId('group-by');
248+
expect(groupByIcon).toBeEnabled();
249+
216250
const presetButton = screen.getByTestId(PRESET_BUTTON_ID);
217251
expect(presetButton).toBeInTheDocument();
218252
});
@@ -237,10 +271,18 @@ describe('CloudPulseDashboardWithFilters component tests', () => {
237271
isLoading: false,
238272
});
239273

274+
queryMocks.useGlobalDimensions.mockReturnValue({
275+
isLoading: false,
276+
options: mockGroupByOptions,
277+
defaultValue: [],
278+
});
240279
renderWithTheme(
241280
<CloudPulseDashboardWithFilters resource={1} serviceType="firewall" />
242281
);
243282

283+
const groupByIcon = screen.getByTestId('group-by');
284+
expect(groupByIcon).toBeEnabled();
285+
244286
const presetButton = screen.getByTestId(PRESET_BUTTON_ID);
245287
expect(presetButton).toBeInTheDocument();
246288
await userEvent.click(screen.getByPlaceholderText('Select a Dashboard'));

packages/manager/src/features/CloudPulse/GroupBy/GlobalFilterGroupByRenderer.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,26 @@ describe('Global Group By Renderer Component', () => {
138138
expect(option).toBeInTheDocument();
139139
});
140140
});
141+
it('Should disable the group by icon and show alternate tooltip text when options are empty', async () => {
142+
const defaultValue = [mockGroupByOptions[0]];
143+
144+
mocks.useGlobalDimensions.mockReturnValue({
145+
isLoading: false,
146+
options: [],
147+
defaultValue,
148+
});
149+
renderWithTheme(
150+
<GlobalFilterGroupByRenderer
151+
handleChange={handleChange}
152+
selectedDashboard={dashboard}
153+
/>
154+
);
155+
156+
const groupByIcon = screen.getByTestId('group-by');
157+
expect(groupByIcon).toBeDisabled();
158+
159+
expect(
160+
screen.getByTestId('No dimensions available for grouping')
161+
).toBeVisible();
162+
});
141163
});

packages/manager/src/features/CloudPulse/GroupBy/GlobalFilterGroupByRenderer.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,18 @@ export const GlobalFilterGroupByRenderer = (
7373
}, []);
7474
return (
7575
<>
76-
<CloudPulseTooltip placement="bottom-end" title="Group By">
76+
<CloudPulseTooltip
77+
placement="bottom-end"
78+
title={
79+
!options.length ? 'No dimensions available for grouping' : 'Group By'
80+
}
81+
>
7782
<IconButton
7883
aria-label="Group By Dashboard Metrics"
7984
color="inherit"
8085
data-qa-selected={isSelected}
8186
data-testid="group-by"
82-
disabled={!selectedDashboard || isLoading}
87+
disabled={!options.length || !selectedDashboard || isLoading}
8388
onClick={() => setOpen(true)}
8489
size="small"
8590
sx={(theme) => ({

packages/manager/src/features/CloudPulse/GroupBy/WidgetFilterGroupByRenderer.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ describe('Widget Group By Renderer', () => {
5656
const groupByIcon = screen.getByTestId('widget-group-by');
5757
expect(groupByIcon).toBeInTheDocument();
5858
expect(groupByIcon).toBeDisabled();
59-
59+
expect(
60+
screen.getByTestId('No dimensions available for grouping')
61+
).toBeVisible();
6062
await groupByIcon.click();
6163

6264
const drawer = screen.queryByTestId('drawer');

packages/manager/src/features/CloudPulse/GroupBy/WidgetFilterGroupByRenderer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ export const WidgetFilterGroupByRenderer = (
9696

9797
return (
9898
<>
99-
<CloudPulseTooltip placement="bottom-end" title="Group By">
99+
<CloudPulseTooltip
100+
placement="bottom-end"
101+
title={isDisabled ? 'No dimensions available for grouping' : 'Group By'}
102+
>
100103
<IconButton
101104
aria-label="Group By Dashboard Metrics"
102105
color="inherit"

packages/manager/src/features/CloudPulse/Utils/ReusableDashboardFilterUtils.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ it('test getDashboardProperties method', () => {
3030
expect(result.region).toEqual('us-east');
3131
});
3232

33+
it('test getDashboardProperties method with selected groupBy values', () => {
34+
const result = getDashboardProperties({
35+
dashboardObj: mockDashboard,
36+
filterValue: {
37+
region: 'us-east',
38+
},
39+
resource: 1,
40+
groupBy: ['entity_id', 'region'],
41+
region: 'us-east',
42+
});
43+
44+
expect(result).toBeDefined();
45+
expect(result.groupBy).toEqual(['entity_id', 'region']);
46+
});
47+
3348
it('test checkMandatoryFiltersSelected method for time duration and resource', () => {
3449
let result = checkMandatoryFiltersSelected({
3550
dashboardObj: mockDashboard,

packages/manager/src/features/CloudPulse/Widget/components/DimensionFilters/CloudPulseDimensionFiltersSelect.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,26 @@ describe('Tests for CloudPulse Dimension Filters Select', () => {
5353
const cancelButton = screen.getByText('Cancel');
5454
expect(cancelButton).toBeInTheDocument();
5555
});
56+
it('renders the CloudPulse Dimension Filter icon with disabled tool tip text when no dimension options are passed', async () => {
57+
const handleSubmit = vi.fn();
58+
renderWithTheme(
59+
<CloudPulseDimensionFiltersSelect
60+
dashboardId={1}
61+
dimensionOptions={[]}
62+
drawerLabel="Test Metric"
63+
handleSelectionChange={handleSubmit}
64+
selectedDimensions={[]}
65+
serviceType="linode"
66+
/>
67+
);
68+
69+
// Verify the tooltip text is being rendered and the icon button is disabled
70+
const tooltipElement = screen.getByTestId(
71+
'No dimensions available for filtering'
72+
);
73+
expect(tooltipElement).toBeVisible();
74+
75+
const iconButton = screen.getByTestId('dimension-filter');
76+
expect(iconButton).toBeDisabled();
77+
});
5678
});

packages/manager/src/features/CloudPulse/Widget/components/DimensionFilters/CloudPulseDimensionFiltersSelect.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,23 @@ export const CloudPulseDimensionFiltersSelect = React.memo(
7575

7676
const selectionCount = selectedDimensions?.length ?? 0;
7777

78+
const isDisabled = !dimensionOptions.length;
7879
return (
7980
<>
80-
<CloudPulseTooltip placement="bottom-end" title="Dimension Filters">
81+
<CloudPulseTooltip
82+
placement="bottom-end"
83+
title={
84+
isDisabled
85+
? 'No dimensions available for filtering'
86+
: 'Dimension Filters'
87+
}
88+
>
8189
<IconButton
8290
aria-label={`Widget Dimension Filter ${drawerLabel}`}
8391
color="inherit"
8492
data-qa-selected={selectionCount}
8593
data-testid="dimension-filter"
86-
disabled={!dimensionOptions.length}
94+
disabled={isDisabled}
8795
onClick={() => setOpen(true)}
8896
size="small"
8997
sx={(theme) => ({

0 commit comments

Comments
 (0)