Skip to content

Commit e3eb1a7

Browse files
committed
Feature flag changes
1 parent 7ff766e commit e3eb1a7

File tree

6 files changed

+72
-22
lines changed

6 files changed

+72
-22
lines changed

packages/manager/src/features/Backups/AutoEnroll.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const AutoEnroll = (props: AutoEnrollProps) => {
3535
>
3636
Backups pricing page
3737
</Link>
38+
.
3839
</Typography>
3940
</StyledDiv>
4041
}

packages/manager/src/features/Backups/BackupDrawer.tsx

+33-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { styled } from '@mui/material';
12
import Stack from '@mui/material/Stack';
23
import { useSnackbar } from 'notistack';
34
import * as React from 'react';
@@ -16,6 +17,7 @@ import { TableRow } from 'src/components/TableRow';
1617
import { TableRowError } from 'src/components/TableRowError/TableRowError';
1718
import { TableRowLoading } from 'src/components/TableRowLoading/TableRowLoading';
1819
import { Typography } from 'src/components/Typography';
20+
import { useFlags } from 'src/hooks/useFlags';
1921
import {
2022
useAccountSettings,
2123
useMutateAccountSettings,
@@ -32,7 +34,6 @@ import {
3234
getTotalBackupsPrice,
3335
useEnableBackupsOnLinodesMutation,
3436
} from './utils';
35-
import { styled } from '@mui/material';
3637

3738
interface Props {
3839
onClose: () => void;
@@ -43,6 +44,8 @@ export const BackupDrawer = (props: Props) => {
4344
const { onClose, open } = props;
4445
const { enqueueSnackbar } = useSnackbar();
4546

47+
const flags = useFlags();
48+
4649
const {
4750
data: linodes,
4851
error: linodesError,
@@ -85,6 +88,13 @@ export const BackupDrawer = (props: Props) => {
8588

8689
const linodeCount = linodesWithoutBackups.length;
8790

91+
const backupsConfirmationHelperText = (
92+
<>
93+
Confirm to add backups to{' '}
94+
<strong>{pluralize('Linode', 'Linodes', linodeCount)}</strong>.
95+
</>
96+
);
97+
8898
const renderBackupsTable = () => {
8999
if (linodesLoading || typesLoading || accountSettingsLoading) {
90100
return <TableRowLoading columns={3} />;
@@ -138,7 +148,12 @@ all new Linodes will automatically be backed up.`
138148
};
139149

140150
return (
141-
<Drawer onClose={onClose} open={open} title="Enable All Backups" wide>
151+
<Drawer
152+
onClose={onClose}
153+
open={open}
154+
title="Enable All Backups"
155+
wide={flags.dcSpecificPricing}
156+
>
142157
<Stack spacing={2}>
143158
<Typography variant="body1">
144159
Three backup slots are executed and rotated automatically: a daily
@@ -147,7 +162,8 @@ all new Linodes will automatically be backed up.`
147162
<Link to="https://www.linode.com/docs/platform/disk-images/linode-backup-service/">
148163
guide on Backups
149164
</Link>{' '}
150-
for more information on features and limitations.
165+
for more information on features and limitations.{' '}
166+
{!flags.dcSpecificPricing ? backupsConfirmationHelperText : undefined}
151167
</Typography>
152168
{failedEnableBackupsCount > 0 && (
153169
<Box>
@@ -168,9 +184,11 @@ all new Linodes will automatically be backed up.`
168184
/>
169185
)}
170186
<StyledPricingBox>
171-
<Typography variant="h2">
172-
Total for {pluralize('Linode', 'Linodes', linodeCount)}:
173-
</Typography>
187+
{flags.dcSpecificPricing ? (
188+
<StyledTypography variant="h2">
189+
Total for {pluralize('Linode', 'Linodes', linodeCount)}:
190+
</StyledTypography>
191+
) : undefined}
174192
&nbsp;
175193
<DisplayPrice
176194
interval="mo"
@@ -194,7 +212,9 @@ all new Linodes will automatically be backed up.`
194212
<TableRow>
195213
<TableCell>Label</TableCell>
196214
<TableCell>Plan</TableCell>
197-
<TableCell>Region</TableCell>
215+
{flags.dcSpecificPricing ? (
216+
<TableCell>Region</TableCell>
217+
) : undefined}
198218
<TableCell>Price</TableCell>
199219
</TableRow>
200220
</TableHead>
@@ -205,10 +225,13 @@ all new Linodes will automatically be backed up.`
205225
);
206226
};
207227

208-
const StyledPricingBox = styled(Box, { label: 'StyledPricingBox' })(
228+
const StyledPricingBox = styled(Box, { label: 'StyledPricingBox' })(({}) => ({
229+
alignItems: 'center',
230+
display: 'flex',
231+
}));
232+
233+
const StyledTypography = styled(Typography, { label: 'StyledTypography' })(
209234
({ theme }) => ({
210-
alignItems: 'center',
211235
color: theme.palette.text.primary,
212-
display: 'flex',
213236
})
214237
);

packages/manager/src/features/Backups/BackupLinodeRow.tsx

+18-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import * as React from 'react';
44
import { TableCell } from 'src/components/TableCell';
55
import { TableRow } from 'src/components/TableRow';
66
import { Typography } from 'src/components/Typography';
7+
import { useFlags } from 'src/hooks/useFlags';
8+
import { useRegionsQuery } from 'src/queries/regions';
79
import { useTypeQuery } from 'src/queries/types';
810
import { getLinodeRegionBackupPrice } from 'src/utilities/pricing/linodes';
911

@@ -15,7 +17,18 @@ interface Props {
1517
export const BackupLinodeRow = (props: Props) => {
1618
const { error, linode } = props;
1719
const { data: type } = useTypeQuery(linode.type ?? '', Boolean(linode.type));
18-
const price = type ? getLinodeRegionBackupPrice(type, linode.region) : 0;
20+
const { data: regions } = useRegionsQuery();
21+
const flags = useFlags();
22+
23+
const backupsPrice = flags.dcSpecificPricing
24+
? type
25+
? getLinodeRegionBackupPrice(type, linode.region).monthly
26+
: undefined
27+
: type?.addons.backups.price.monthly;
28+
29+
const regionLabel =
30+
regions?.find((r) => r.id === linode.region)?.label ?? linode.region;
31+
1932
return (
2033
<TableRow key={`backup-linode-${linode.id}`}>
2134
<TableCell parentColumn="Label">
@@ -35,9 +48,11 @@ export const BackupLinodeRow = (props: Props) => {
3548
<TableCell parentColumn="Plan">
3649
{type?.label ?? linode.type ?? 'Unknown'}
3750
</TableCell>
38-
<TableCell parentColumn="Region">{linode.region ?? 'Unknown'}</TableCell>
51+
{flags.dcSpecificPricing ? (
52+
<TableCell parentColumn="Region">{regionLabel ?? 'Unknown'}</TableCell>
53+
) : undefined}
3954
<TableCell parentColumn="Price">
40-
{`$${price['monthly']?.toFixed(2) ?? 'Unknown'}/mo`}
55+
{`$${backupsPrice?.toFixed(2) ?? 'Unknown'}/mo`}
4156
</TableCell>
4257
</TableRow>
4358
);

packages/manager/src/features/Linodes/LinodesDetail/LinodeBackup/BackupsPlaceholder.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as React from 'react';
21
import { styled } from '@mui/material/styles';
2+
import * as React from 'react';
33

44
import VolumeIcon from 'src/assets/icons/entityIcons/volume.svg';
55
import { Currency } from 'src/components/Currency';

packages/manager/src/features/Linodes/LinodesDetail/LinodeBackup/EnableBackupsDialog.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ConfirmationDialog } from 'src/components/ConfirmationDialog/Confirmati
66
import { Currency } from 'src/components/Currency';
77
import { Typography } from 'src/components/Typography';
88
import { resetEventsPolling } from 'src/eventsPolling';
9+
import { useFlags } from 'src/hooks/useFlags';
910
import { useLinodeBackupsEnableMutation } from 'src/queries/linodes/backups';
1011
import { useLinodeQuery } from 'src/queries/linodes/linodes';
1112
import { useTypeQuery } from 'src/queries/types';
@@ -20,6 +21,8 @@ interface Props {
2021
export const EnableBackupsDialog = (props: Props) => {
2122
const { linodeId, onClose, open } = props;
2223

24+
const flags = useFlags();
25+
2326
const {
2427
error,
2528
isLoading,
@@ -37,8 +40,11 @@ export const EnableBackupsDialog = (props: Props) => {
3740
Boolean(linode?.type)
3841
);
3942

40-
const price =
41-
type && linode ? getLinodeRegionBackupPrice(type, linode.region) : 0;
43+
const backupsPrice = flags.dcSpecificPricing
44+
? type && linode
45+
? getLinodeRegionBackupPrice(type, linode.region).monthly
46+
: undefined
47+
: type?.addons?.backups?.price?.monthly;
4248

4349
const { enqueueSnackbar } = useSnackbar();
4450

@@ -84,7 +90,7 @@ export const EnableBackupsDialog = (props: Props) => {
8490
>
8591
<Typography>
8692
Are you sure you want to enable backups on this Linode?{` `}
87-
This will add <Currency quantity={price['monthly']} />
93+
This will add <Currency quantity={backupsPrice ?? 0} />
8894
{` `}
8995
to your monthly bill.
9096
</Typography>

packages/manager/src/features/Linodes/LinodesDetail/LinodeBackup/LinodeBackups.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ import { useHistory, useParams } from 'react-router-dom';
77
import { Button } from 'src/components/Button/Button';
88
import { CircleProgress } from 'src/components/CircleProgress';
99
import { ErrorState } from 'src/components/ErrorState/ErrorState';
10+
import { Paper } from 'src/components/Paper';
1011
import { Table } from 'src/components/Table';
1112
import { TableBody } from 'src/components/TableBody';
1213
import { TableCell } from 'src/components/TableCell';
1314
import { TableHead } from 'src/components/TableHead';
1415
import { TableRow } from 'src/components/TableRow';
1516
import { TableRowEmpty } from 'src/components/TableRowEmpty/TableRowEmpty';
1617
import { Typography } from 'src/components/Typography';
17-
import { Paper } from 'src/components/Paper';
18+
import { useFlags } from 'src/hooks/useFlags';
1819
import { useLinodeBackupsQuery } from 'src/queries/linodes/backups';
1920
import { useLinodeQuery } from 'src/queries/linodes/linodes';
2021
import { useGrants, useProfile } from 'src/queries/profile';
2122
import { useTypeQuery } from 'src/queries/types';
23+
import { getLinodeRegionBackupPrice } from 'src/utilities/pricing/linodes';
2224

2325
import { LinodePermissionsError } from '../LinodePermissionsError';
2426
import { BackupTableRow } from './BackupTableRow';
@@ -27,13 +29,13 @@ import { CancelBackupsDialog } from './CancelBackupsDialog';
2729
import { CaptureSnapshot } from './CaptureSnapshot';
2830
import { RestoreToLinodeDrawer } from './RestoreToLinodeDrawer';
2931
import { ScheduleSettings } from './ScheduleSettings';
30-
import { getLinodeRegionBackupPrice } from 'src/utilities/pricing/linodes';
3132

3233
export const LinodeBackups = () => {
3334
const { linodeId } = useParams<{ linodeId: string }>();
3435
const id = Number(linodeId);
3536

3637
const history = useHistory();
38+
const flags = useFlags();
3739

3840
const { data: profile } = useProfile();
3941
const { data: grants } = useGrants();
@@ -80,8 +82,11 @@ export const LinodeBackups = () => {
8082
);
8183
}
8284

83-
const backupsPrice =
84-
type && linode ? getLinodeRegionBackupPrice(type, linode?.region) : 0;
85+
const backupsPrice = flags.dcSpecificPricing
86+
? type && linode
87+
? getLinodeRegionBackupPrice(type, linode.region).monthly
88+
: undefined
89+
: type?.addons?.backups?.price?.monthly;
8590

8691
if (isLoading) {
8792
return <CircleProgress />;
@@ -90,7 +95,7 @@ export const LinodeBackups = () => {
9095
if (!linode?.backups.enabled) {
9196
return (
9297
<BackupsPlaceholder
93-
backupsMonthlyPrice={backupsPrice['monthly']}
98+
backupsMonthlyPrice={backupsPrice ?? 0}
9499
disabled={doesNotHavePermission}
95100
linodeId={id}
96101
/>

0 commit comments

Comments
 (0)