Skip to content

Commit dbcbd44

Browse files
upcoming: [DPS-41826] - add newFeature chip to render conditionally
1 parent 328ba10 commit dbcbd44

File tree

4 files changed

+108
-3
lines changed

4 files changed

+108
-3
lines changed

packages/manager/src/components/PrimaryNav/PrimaryNav.test.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,48 @@ describe('PrimaryNav', () => {
341341
expect(queryByTestId('betaChip')).toBeNull();
342342
});
343343

344+
it('should show the new chip for Alerts if the user has the account capability, aclpAlerting feature flag has beta false and new as true', async () => {
345+
const account = accountFactory.build({
346+
capabilities: ['Akamai Cloud Pulse'],
347+
});
348+
349+
queryMocks.useAccount.mockReturnValue({
350+
data: account,
351+
isLoading: false,
352+
error: null,
353+
});
354+
355+
const flags = {
356+
aclp: {
357+
beta: false,
358+
enabled: true,
359+
},
360+
aclpAlerting: {
361+
accountAlertLimit: 10,
362+
accountMetricLimit: 10,
363+
alertDefinitions: true,
364+
beta: false,
365+
new: true,
366+
notificationChannels: true,
367+
recentActivity: true,
368+
},
369+
};
370+
371+
const { findByTestId, queryByTestId, findByText } = renderWithTheme(
372+
<PrimaryNav {...props} />,
373+
{
374+
flags,
375+
}
376+
);
377+
378+
const monitorAlertsDisplayItem = await findByText('Alerts');
379+
const betaChip = queryByTestId('betaChip');
380+
const newFeatureChip = await findByTestId('newFeatureChip');
381+
382+
expect(monitorAlertsDisplayItem).toBeVisible();
383+
expect(betaChip).toBeNull();
384+
expect(newFeatureChip).toBeVisible();
385+
});
344386
it('should not show Alerts menu items if the user has the account capability, aclp feature flag is enabled, and aclpAlerting feature flag does not have any of the properties true', async () => {
345387
const account = accountFactory.build({
346388
capabilities: ['Akamai Cloud Pulse'],

packages/manager/src/components/PrimaryNav/PrimaryNav.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ export const PrimaryNav = (props: PrimaryNavProps) => {
277277
hide: !isAlertsEnabled,
278278
to: '/alerts',
279279
isBeta: flags.aclpAlerting?.beta,
280+
isNew: !flags.aclpAlerting?.beta && flags.aclpAlerting?.new,
280281
},
281282
{
282283
display: 'Logs',

packages/manager/src/features/CloudPulse/Alerts/ContextualView/AlertReusableComponent.test.tsx

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,66 @@ describe('Alert Resuable Component for contextual view', () => {
143143
).not.toBeInTheDocument();
144144
expect(screen.getByTestId('manage-alerts')).toBeVisible();
145145
});
146+
it('should show the beta chip when beta is enabled in aclpAlerting feature flag', async () => {
147+
const flags = {
148+
aclpAlerting: {
149+
accountAlertLimit: 10,
150+
accountMetricLimit: 10,
151+
alertDefinitions: true,
152+
beta: true,
153+
new: true,
154+
notificationChannels: true,
155+
recentActivity: true,
156+
},
157+
};
158+
159+
const { findByTestId, queryByTestId } = renderWithTheme(
160+
<AlertReusableComponent
161+
entityId={entityId}
162+
entityName={entityName}
163+
onToggleAlert={onToggleAlert}
164+
regionId={region}
165+
serviceType="dbaas"
166+
/>,
167+
{
168+
flags,
169+
}
170+
);
171+
172+
const betaChip = await findByTestId('betaChip');
173+
const newFeatureChip = queryByTestId('newFeatureChip');
174+
expect(betaChip).toBeVisible();
175+
expect(newFeatureChip).toBeNull();
176+
});
177+
it('should show the new chip when beta is disabled and new is enabled in aclpAlerting feature flag', async () => {
178+
const flags = {
179+
aclpAlerting: {
180+
accountAlertLimit: 10,
181+
accountMetricLimit: 10,
182+
alertDefinitions: true,
183+
beta: false,
184+
new: true,
185+
notificationChannels: true,
186+
recentActivity: true,
187+
},
188+
};
189+
190+
const { findByTestId, queryByTestId } = renderWithTheme(
191+
<AlertReusableComponent
192+
entityId={entityId}
193+
entityName={entityName}
194+
onToggleAlert={onToggleAlert}
195+
regionId={region}
196+
serviceType="dbaas"
197+
/>,
198+
{
199+
flags,
200+
}
201+
);
202+
203+
const betaChip = queryByTestId('betaChip');
204+
const newFeatureChip = await findByTestId('newFeatureChip');
205+
expect(betaChip).toBeNull();
206+
expect(newFeatureChip).toBeVisible();
207+
});
146208
});

packages/manager/src/features/CloudPulse/Alerts/ContextualView/AlertReusableComponent.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { getFeatureChip } from '@linode/shared';
12
import {
23
Autocomplete,
3-
BetaChip,
44
Box,
55
Button,
66
CircleProgress,
@@ -125,7 +125,7 @@ export const AlertReusableComponent = (props: AlertReusableComponentProps) => {
125125
[alerts, regionId, searchText, selectedType]
126126
);
127127

128-
const { aclpServices } = useFlags();
128+
const { aclpAlerting } = useFlags();
129129

130130
const navigate = useNavigate();
131131

@@ -145,7 +145,7 @@ export const AlertReusableComponent = (props: AlertReusableComponentProps) => {
145145
<Box display="flex" justifyContent="space-between">
146146
<Box alignItems="center" display="flex" gap={0.5}>
147147
<Typography variant="h2">Alerts</Typography>
148-
{aclpServices?.[serviceType]?.alerts?.beta && <BetaChip />}
148+
{aclpAlerting && getFeatureChip(aclpAlerting)}
149149
</Box>
150150
<Button
151151
buttonType="outlined"

0 commit comments

Comments
 (0)