Skip to content

Commit dc0f93f

Browse files
upcoming: [M3-10192] - Add Beta "Alerts Assigned +n" Count to Linode Create Flow Summary (#12396)
* Add beta alerts assigned count to linode create flow summary * Added changeset: Add beta `Alerts Assigned +n` count to Linode Create flow Summary
1 parent b5b98c4 commit dc0f93f

File tree

2 files changed

+59
-2
lines changed

2 files changed

+59
-2
lines changed
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 beta `Alerts Assigned +n` count to Linode Create flow Summary ([#12396](https://github.com/linode/manager/pull/12396))

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

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
import { useImageQuery, useRegionsQuery, useTypeQuery } from '@linode/queries';
1+
import {
2+
useImageQuery,
3+
usePreferences,
4+
useRegionsQuery,
5+
useTypeQuery,
6+
} from '@linode/queries';
27
import { Divider, Paper, Stack, Typography } from '@linode/ui';
3-
import { formatStorageUnits } from '@linode/utilities';
8+
import { formatStorageUnits, isAclpSupportedRegion } from '@linode/utilities';
49
import { useTheme } from '@mui/material';
510
import useMediaQuery from '@mui/material/useMediaQuery';
611
import React from 'react';
712
import { useFormContext, useWatch } from 'react-hook-form';
813

14+
import { TextTooltip } from 'src/components/TextTooltip';
15+
import { useFlags } from 'src/hooks/useFlags';
916
import { useIsLinodeInterfacesEnabled } from 'src/utilities/linodes';
1017
import { getMonthlyBackupsPrice } from 'src/utilities/pricing/backups';
1118
import { renderMonthlyPriceToCorrectDecimalPlace } from 'src/utilities/pricing/dynamicPricing';
@@ -36,6 +43,7 @@ export const Summary = () => {
3643
clusterSize,
3744
linodeInterfaces,
3845
interfaceGeneration,
46+
alerts,
3947
] = useWatch({
4048
control,
4149
name: [
@@ -53,13 +61,26 @@ export const Summary = () => {
5361
'stackscript_data.cluster_size',
5462
'linodeInterfaces',
5563
'interface_generation',
64+
'alerts',
5665
],
5766
});
5867

5968
const { data: regions } = useRegionsQuery();
6069
const { data: type } = useTypeQuery(typeId ?? '', Boolean(typeId));
6170
const { data: image } = useImageQuery(imageId ?? '', Boolean(imageId));
6271

72+
const flags = useFlags();
73+
const { data: isAclpAlertsPreferenceBeta } = usePreferences(
74+
(preferences) => preferences?.isAclpAlertsBeta
75+
);
76+
77+
const isAclpAlertsSupportedRegionLinode = isAclpSupportedRegion({
78+
capability: 'Linodes',
79+
regionId,
80+
regions,
81+
type: 'alerts',
82+
});
83+
6384
const region = regions?.find((r) => r.id === regionId);
6485

6586
const backupsPrice = renderMonthlyPriceToCorrectDecimalPlace(
@@ -81,6 +102,30 @@ export const Summary = () => {
81102
? linodeInterfaces.some((i) => i.firewall_id)
82103
: firewallId;
83104

105+
const hasBetaAclpAlertsAssigned =
106+
flags.aclpBetaServices?.alerts &&
107+
isAclpAlertsSupportedRegionLinode &&
108+
isAclpAlertsPreferenceBeta;
109+
110+
const totalBetaAclpAlertsAssignedCount =
111+
(alerts?.system?.length ?? 0) + (alerts?.user?.length ?? 0);
112+
113+
const betaAclpAlertsAssignedList = [
114+
...(alerts?.system ?? []),
115+
...(alerts?.user ?? []),
116+
].join(', ');
117+
118+
const betaAclpAlertsAssignedDetails =
119+
totalBetaAclpAlertsAssignedCount > 0 ? (
120+
<TextTooltip
121+
displayText={`+${totalBetaAclpAlertsAssignedCount}`}
122+
minWidth={1}
123+
tooltipText={betaAclpAlertsAssignedList}
124+
/>
125+
) : (
126+
'0'
127+
);
128+
84129
const summaryItems = [
85130
{
86131
item: {
@@ -144,6 +189,13 @@ export const Summary = () => {
144189
},
145190
show: diskEncryption === 'enabled' || region?.site_type === 'distributed',
146191
},
192+
{
193+
item: {
194+
title: 'Alerts Assigned',
195+
details: betaAclpAlertsAssignedDetails,
196+
},
197+
show: hasBetaAclpAlertsAssigned,
198+
},
147199
];
148200

149201
const summaryItemsToShow = summaryItems.filter((item) => item.show);

0 commit comments

Comments
 (0)