Skip to content

Commit 39025ad

Browse files
upcoming: [DI-28395] - Added enabling, disabling and provisioning statuses and updated messages in CloudPulse alerts (#13127)
* upcoming: [DI-28395] - Added enabling, disabling and provisioning statuses in alerts * upcoming: [DI-28395] - Updated server handlers * upcoming: [DI-28395] - Code refactoring * upcoming: [DI-28395] - Add changeset * upcoming: [DI-28395] - Update status messages on enable, disable , create and update * upcoming: [DI-28395] - Code refactoring * upcoming: [DI-28395] - Cypress fixes * upcoming: [DI-28395] - Lint issue fix --------- Co-authored-by: nikhagra-akamai <[email protected]>
1 parent b76293d commit 39025ad

File tree

14 files changed

+106
-17
lines changed

14 files changed

+106
-17
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": Upcoming Features
3+
---
4+
5+
Add additional status types `enabling`, `disabling`, `provisioning` in CloudPulse alerts ([#13127](https://github.com/linode/manager/pull/13127))

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,15 @@ export type DimensionFilterOperatorType =
1919
| 'neq'
2020
| 'startswith';
2121
export type AlertDefinitionType = 'system' | 'user';
22-
export type AlertStatusType = 'disabled' | 'enabled' | 'failed' | 'in progress';
2322
export type AlertDefinitionScope = 'account' | 'entity' | 'region';
23+
export type AlertStatusType =
24+
| 'disabled'
25+
| 'disabling'
26+
| 'enabled'
27+
| 'enabling'
28+
| 'failed'
29+
| 'in progress'
30+
| 'provisioning';
2431
export type CriteriaConditionType = 'ALL';
2532
export type MetricUnitType =
2633
| 'bit_per_second'
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 support for additional status types and handle action menu accordingly in CloudPulse alerts ([#13127](https://github.com/linode/manager/pull/13127))

packages/manager/cypress/e2e/core/cloudpulse/alerts-listing-page.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import {
2929
import {
3030
alertStatuses,
3131
DELETE_ALERT_SUCCESS_MESSAGE,
32-
UPDATE_ALERT_SUCCESS_MESSAGE,
32+
DISABLE_ALERT_SUCCESS_MESSAGE,
33+
ENABLE_ALERT_SUCCESS_MESSAGE,
3334
} from 'src/features/CloudPulse/Alerts/constants';
3435
import { formatDate } from 'src/utilities/formatDate';
3536

@@ -426,7 +427,10 @@ describe('Integration Tests for CloudPulse Alerts Listing Page', () => {
426427
alertName,
427428
alias,
428429
confirmationText: `Are you sure you want to ${action.toLowerCase()} this alert definition?`,
429-
successMessage: UPDATE_ALERT_SUCCESS_MESSAGE,
430+
successMessage:
431+
action === 'Disable'
432+
? DISABLE_ALERT_SUCCESS_MESSAGE
433+
: ENABLE_ALERT_SUCCESS_MESSAGE,
430434
});
431435
});
432436
});

packages/manager/cypress/support/constants/alert.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,7 @@ export const statusMap: Record<AlertStatusType, string> = {
4444
enabled: 'Enabled',
4545
failed: 'Failed',
4646
'in progress': 'In Progress',
47+
disabling: 'Disabling',
48+
enabling: 'Enabling',
49+
provisioning: 'Provisioning',
4750
};

packages/manager/src/factories/featureFlags.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export const flagsFactory = Factory.Sync.makeFactory<Partial<Flags>>({
2424
alertDefinitions: true,
2525
recentActivity: false,
2626
notificationChannels: false,
27+
editDisabledStatuses: [
28+
'in progress',
29+
'failed',
30+
'provisioning',
31+
'enabling',
32+
'disabling',
33+
],
2734
},
2835
aclpServices: {
2936
linode: {

packages/manager/src/features/CloudPulse/Alerts/AlertsListing/AlertListTable.test.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import { renderWithTheme } from 'src/utilities/testHelpers';
88

99
import {
1010
DELETE_ALERT_SUCCESS_MESSAGE,
11-
UPDATE_ALERT_SUCCESS_MESSAGE,
11+
DISABLE_ALERT_SUCCESS_MESSAGE,
12+
ENABLE_ALERT_SUCCESS_MESSAGE,
1213
} from '../constants';
1314
import { AlertsListTable } from './AlertListTable';
1415

@@ -117,7 +118,7 @@ describe('Alert List Table test', () => {
117118

118119
await userEvent.click(getByRole('button', { name: 'Enable' }));
119120

120-
expect(getByText(UPDATE_ALERT_SUCCESS_MESSAGE)).toBeInTheDocument(); // validate whether snackbar is displayed properly
121+
expect(getByText(ENABLE_ALERT_SUCCESS_MESSAGE)).toBeVisible(); // validate whether snackbar is displayed properly
121122
});
122123

123124
it('should show success snackbar when disabling alert succeeds', async () => {
@@ -140,7 +141,7 @@ describe('Alert List Table test', () => {
140141

141142
await userEvent.click(getByRole('button', { name: 'Disable' }));
142143

143-
expect(getByText(UPDATE_ALERT_SUCCESS_MESSAGE)).toBeInTheDocument(); // validate whether snackbar is displayed properly
144+
expect(getByText(DISABLE_ALERT_SUCCESS_MESSAGE)).toBeVisible(); // validate whether snackbar is displayed properly
144145
});
145146

146147
it('should show error snackbar when enabling alert fails', async () => {

packages/manager/src/features/CloudPulse/Alerts/AlertsListing/AlertListTable.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ import { getAPIErrorOrDefault } from 'src/utilities/errorUtils';
2323
import { AlertConfirmationDialog } from '../AlertsLanding/AlertConfirmationDialog';
2424
import {
2525
DELETE_ALERT_SUCCESS_MESSAGE,
26-
UPDATE_ALERT_SUCCESS_MESSAGE,
26+
DISABLE_ALERT_FAILED_MESSAGE,
27+
DISABLE_ALERT_SUCCESS_MESSAGE,
28+
ENABLE_ALERT_FAILED_MESSAGE,
29+
ENABLE_ALERT_SUCCESS_MESSAGE,
2730
} from '../constants';
2831
import { AlertsTable } from './AlertsTable';
2932
import { AlertListingTableLabelMap } from './constants';
@@ -126,7 +129,6 @@ export const AlertsListTable = React.memo((props: AlertsListTableProps) => {
126129
const handleConfirm = React.useCallback(
127130
(alert: Alert, currentStatus: boolean) => {
128131
const toggleStatus = currentStatus ? 'disabled' : 'enabled';
129-
const errorStatus = currentStatus ? 'Disabling' : 'Enabling';
130132
setIsUpdating(true);
131133
editAlertDefinition({
132134
alertId: alert.id,
@@ -135,15 +137,22 @@ export const AlertsListTable = React.memo((props: AlertsListTableProps) => {
135137
})
136138
.then(() => {
137139
// Handle success
138-
enqueueSnackbar(UPDATE_ALERT_SUCCESS_MESSAGE, {
139-
variant: 'success',
140-
});
140+
enqueueSnackbar(
141+
currentStatus
142+
? DISABLE_ALERT_SUCCESS_MESSAGE
143+
: ENABLE_ALERT_SUCCESS_MESSAGE,
144+
{
145+
variant: 'success',
146+
}
147+
);
141148
})
142149
.catch((updateError: APIError[]) => {
143150
// Handle error
144151
const errorResponse = getAPIErrorOrDefault(
145152
updateError,
146-
`${errorStatus} alert failed`
153+
currentStatus
154+
? DISABLE_ALERT_FAILED_MESSAGE
155+
: ENABLE_ALERT_FAILED_MESSAGE
147156
);
148157
enqueueSnackbar(errorResponse[0].reason, {
149158
variant: 'error',

packages/manager/src/features/CloudPulse/Alerts/AlertsListing/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export const statusToActionMap: Record<AlertStatusType, AlertStatusUpdateType> =
3535
enabled: 'Disable',
3636
failed: 'Disable',
3737
'in progress': 'Disable',
38+
provisioning: 'Disable',
39+
disabling: 'Enable',
40+
enabling: 'Disable',
3841
};
3942

4043
export const AlertContextualViewTableHeaderMap: TableColumnHeader[] = [

packages/manager/src/features/CloudPulse/Alerts/Utils/AlertsActionMenu.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ export const getAlertTypeToActionsList = (
4040
title: 'Edit',
4141
},
4242
{
43-
disabled: alertStatus === 'in progress' || alertStatus === 'failed',
43+
disabled:
44+
alertStatus === 'in progress' ||
45+
alertStatus === 'failed' ||
46+
alertStatus === 'provisioning' ||
47+
alertStatus === 'enabling' ||
48+
alertStatus === 'disabling',
4449
onClick: handleStatusChange,
4550
title: getTitleForStatusChange(alertStatus),
4651
},

0 commit comments

Comments
 (0)