1- import { useImageQuery , useRegionsQuery , useTypeQuery } from '@linode/queries' ;
1+ import {
2+ useImageQuery ,
3+ usePreferences ,
4+ useRegionsQuery ,
5+ useTypeQuery ,
6+ } from '@linode/queries' ;
27import { Divider , Paper , Stack , Typography } from '@linode/ui' ;
3- import { formatStorageUnits } from '@linode/utilities' ;
8+ import { formatStorageUnits , isAclpSupportedRegion } from '@linode/utilities' ;
49import { useTheme } from '@mui/material' ;
510import useMediaQuery from '@mui/material/useMediaQuery' ;
611import React from 'react' ;
712import { useFormContext , useWatch } from 'react-hook-form' ;
813
14+ import { TextTooltip } from 'src/components/TextTooltip' ;
15+ import { useFlags } from 'src/hooks/useFlags' ;
916import { useIsLinodeInterfacesEnabled } from 'src/utilities/linodes' ;
1017import { getMonthlyBackupsPrice } from 'src/utilities/pricing/backups' ;
1118import { 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