Skip to content

Commit d9799c5

Browse files
upcoming: [M3-10326] - VM Host Maintenance - Status Icon, Copy Updates, Conditional Notice Display (linode#12512)
* upcoming: [M3-10326] - VM Host Maintenance - Status Icon, Copy Updates, Conditional Notice Display * Remove in-progress event status type - added erroneously * Add changesets * Add iconSlot to TableSortCell * Fix issue with filtering and address reason field when empty * Update test with latest utilities --------- Co-authored-by: Jaalah Ramos <[email protected]>
1 parent b9f5a74 commit d9799c5

File tree

13 files changed

+90
-23
lines changed

13 files changed

+90
-23
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Removed
3+
---
4+
5+
Remove unnecessary in-progress event.status type during earlier development ([#12512](https://github.com/linode/manager/pull/12512))

packages/api-v4/src/account/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ export type EventStatus =
510510
| 'canceled'
511511
| 'failed'
512512
| 'finished'
513-
| 'in-progress'
514513
| 'notification'
515514
| 'scheduled'
516515
| 'started';

packages/api-v4/src/cloudpulse/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,4 +392,4 @@ export interface CloudPulseAlertsPayload {
392392
* Only included in Beta mode.
393393
*/
394394
user?: number[];
395-
}
395+
}
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+
Show GPU warning notice conditionally based on policy type - display for "migrate" policy but hide for "power-off-on" policy ([#12512](https://github.com/linode/manager/pull/12512))

packages/manager/src/components/TableSortCell/TableSortCell.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface TableSortCellProps extends _TableCellProps {
1212
active: boolean;
1313
direction: 'asc' | 'desc';
1414
handleClick: (key: string, order?: 'asc' | 'desc') => void;
15+
iconSlot?: React.ReactNode;
1516
isLoading?: boolean;
1617
label: string;
1718
noWrap?: boolean;
@@ -24,6 +25,7 @@ export const TableSortCell = (props: TableSortCellProps) => {
2425
direction,
2526
// eslint-disable-next-line
2627
handleClick,
28+
iconSlot,
2729
isLoading,
2830
label,
2931
noWrap,
@@ -72,6 +74,7 @@ export const TableSortCell = (props: TableSortCellProps) => {
7274
{children}
7375
{!active && <Sort />}
7476
</TableSortLabel>
77+
{iconSlot}
7578
{isLoading && <CircleProgress size="sm" />}
7679
</TableCell>
7780
);

packages/manager/src/features/Account/Maintenance/MaintenanceTable.test.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,25 @@ describe('Maintenance Table', () => {
9595
// Check for custom empty state
9696
screen.getByText('No in progress maintenance.');
9797
});
98+
99+
it('should render tooltip icon next to status for upcoming maintenance', async () => {
100+
server.use(
101+
http.get('*/account/maintenance', () => {
102+
const accountMaintenance = accountMaintenanceFactory.buildList(1, {
103+
status: 'scheduled',
104+
});
105+
return HttpResponse.json(makeResourcePage(accountMaintenance));
106+
})
107+
);
108+
109+
await renderWithTheme(<MaintenanceTable type="upcoming" />);
110+
111+
// Wait for loading to complete
112+
await waitForElementToBeRemoved(screen.getByTestId(loadingTestId));
113+
114+
// The tooltip icon should be present with the correct data-testid
115+
expect(
116+
screen.getByTestId('maintenance-status-tooltip')
117+
).toBeInTheDocument();
118+
});
98119
});

packages/manager/src/features/Account/Maintenance/MaintenanceTable.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
useAccountMaintenanceQuery,
33
useAllAccountMaintenanceQuery,
44
} from '@linode/queries';
5-
import { Box, Paper, Typography } from '@linode/ui';
5+
import { Box, Paper, TooltipIcon, Typography } from '@linode/ui';
66
import { Hidden } from '@linode/ui';
77
import { useFormattedDate } from '@linode/utilities';
88
import * as React from 'react';
@@ -255,7 +255,7 @@ export const MaintenanceTable = ({ type }: Props) => {
255255
className={classes.cell}
256256
direction={order}
257257
handleClick={handleOrderChange}
258-
label={getMaintenanceDateLabel(type)}
258+
label={getMaintenanceDateField(type)}
259259
>
260260
{getMaintenanceDateLabel(type)}
261261
</TableSortCell>
@@ -308,6 +308,26 @@ export const MaintenanceTable = ({ type }: Props) => {
308308
className={classes.cell}
309309
direction={order}
310310
handleClick={handleOrderChange}
311+
iconSlot={
312+
type === 'upcoming' && (
313+
<TooltipIcon
314+
dataTestId="maintenance-status-tooltip"
315+
status="info"
316+
sxTooltipIcon={{
317+
margin: 0,
318+
padding: 0,
319+
}}
320+
text={
321+
<>
322+
Scheduled status refers to an event that is planned to
323+
start at a certain time. <br />
324+
<br /> Pending status refers to an event that has yet
325+
to be completed or decided.
326+
</>
327+
}
328+
/>
329+
)
330+
}
311331
label="status"
312332
>
313333
Status

packages/manager/src/features/Account/Maintenance/MaintenanceTableRow.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,18 @@ export const MaintenanceTableRow = (props: MaintenanceTableRowProps) => {
155155
)}
156156
<Hidden lgDown>
157157
<TableCell>
158-
{isTruncated ? (
159-
<Tooltip title={<Markdown textOrMarkdown={reason} />}>
160-
<div>
161-
<Markdown textOrMarkdown={truncatedReason} />
162-
</div>
163-
</Tooltip>
158+
{reason ? (
159+
isTruncated ? (
160+
<Tooltip title={<Markdown textOrMarkdown={reason} />}>
161+
<div>
162+
<Markdown textOrMarkdown={truncatedReason} />
163+
</div>
164+
</Tooltip>
165+
) : (
166+
<Markdown textOrMarkdown={truncatedReason} />
167+
)
164168
) : (
165-
<Markdown textOrMarkdown={truncatedReason} />
169+
'—'
166170
)}
167171
</TableCell>
168172
</Hidden>

packages/manager/src/features/Linodes/LinodeCreate/AdditionalOptions/MaintenancePolicy.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export const MaintenancePolicy = () => {
2121
const { control } = useFormContext<LinodeCreateFormValues>();
2222
const flags = useFlags();
2323

24-
const [selectedRegion, selectedType] = useWatch({
24+
const [selectedRegion, selectedType, maintenancePolicy] = useWatch({
2525
control,
26-
name: ['region', 'type'],
26+
name: ['region', 'type', 'maintenance_policy'],
2727
});
2828

2929
const { data: region } = useRegionQuery(selectedRegion);
@@ -52,9 +52,11 @@ export const MaintenancePolicy = () => {
5252
},
5353
}}
5454
>
55-
{regionSupportsMaintenancePolicy && isGPUPlan && (
56-
<Notice variant="warning">{GPU_PLAN_NOTICE}</Notice>
57-
)}
55+
{regionSupportsMaintenancePolicy &&
56+
isGPUPlan &&
57+
maintenancePolicy === 'linode/migrate' && (
58+
<Notice variant="warning">{GPU_PLAN_NOTICE}</Notice>
59+
)}
5860
<Controller
5961
control={control}
6062
name="maintenance_policy"
@@ -65,7 +67,7 @@ export const MaintenancePolicy = () => {
6567
onChange={(policy) => field.onChange(policy.slug)}
6668
textFieldProps={{
6769
helperText: !region
68-
? 'Select a region to see available maintenance policies.'
70+
? 'Select a region to choose a maintenance policy.'
6971
: selectedRegion && !regionSupportsMaintenancePolicy
7072
? MAINTENANCE_POLICY_NOT_AVAILABLE_IN_REGION_TEXT
7173
: undefined,

packages/manager/src/features/Linodes/LinodeCreate/Region.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,14 @@ export const Region = React.memo(() => {
122122
setValue('metadata.user_data', null);
123123
}
124124

125-
if (
126-
values.maintenance_policy &&
127-
!region.capabilities.includes('Maintenance Policy')
128-
) {
125+
// Handle maintenance policy based on region capabilities
126+
if (region.capabilities.includes('Maintenance Policy')) {
127+
// If the region supports maintenance policy, set it to the default value
128+
// or keep the current value if it's already set
129+
if (!values.maintenance_policy) {
130+
setValue('maintenance_policy', 'linode/migrate');
131+
}
132+
} else {
129133
// Clear maintenance_policy if the selected region doesn't support it
130134
setValue('maintenance_policy', undefined);
131135
}

0 commit comments

Comments
 (0)