Skip to content

Commit 8af48ab

Browse files
authored
fix: [M3-9034] - Use empty string instead of unknown for delete dialog titles (linode#12701)
## Description 📝 Use empty string instead of unknown for delete dialog titles ## How to test 🧪 ### Reproduction steps (How to reproduce the issue, if applicable) - [ ] On another branch, go to the Domains landing page - [ ] Open the network tab, disable cache, and throttle to the slowest speed you can - [ ] Open the delete dialog for a domain and while it is still fetching, hover over the close icon - [ ] The text tooltip displays unknown ### Verification steps (How to verify changes) - [ ] Checkout this PR and go to the Domains landing page - [ ] Open the network tab, disable cache, and throttle to the slowest speed you can - [ ] Open the delete dialog for a domain and while it is still fetching, hover over the close icon - [ ] The text tooltip should not display unknown
1 parent 9e46eb4 commit 8af48ab

File tree

17 files changed

+127
-189
lines changed

17 files changed

+127
-189
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Fixed
3+
---
4+
5+
Use empty string instead of unknown for delete dialog titles ([#12701](https://github.com/linode/manager/pull/12701))

packages/manager/cypress/e2e/core/placementGroups/delete-placement-groups.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('Placement Group deletion', () => {
8484
).as('deletePlacementGroupError');
8585

8686
ui.dialog
87-
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`)
87+
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}?`)
8888
.should('be.visible')
8989
.within(() => {
9090
cy.findByLabelText('Placement Group').type(mockPlacementGroup.label);
@@ -106,7 +106,7 @@ describe('Placement Group deletion', () => {
106106

107107
// Confirm deletion warning appears, complete Type-to-Confirm, and submit confirmation.
108108
ui.dialog
109-
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`)
109+
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}?`)
110110
.should('be.visible')
111111
.within(() => {
112112
cy.findByText(deletionWarning).should('be.visible');
@@ -197,7 +197,7 @@ describe('Placement Group deletion', () => {
197197
).as('UnassignPlacementGroupError');
198198

199199
ui.dialog
200-
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`)
200+
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}?`)
201201
.should('be.visible')
202202
.within(() => {
203203
cy.get('[data-qa-selection-list]').within(() => {
@@ -223,7 +223,7 @@ describe('Placement Group deletion', () => {
223223
// Confirm deletion warning appears and that form cannot be submitted
224224
// while Linodes are assigned.
225225
ui.dialog
226-
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`)
226+
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}?`)
227227
.should('be.visible')
228228
.within(() => {
229229
cy.findByText(deletionWarning).should('be.visible');
@@ -346,7 +346,7 @@ describe('Placement Group deletion', () => {
346346

347347
// The dialog can be closed after an unexpect error show up
348348
ui.dialog
349-
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`)
349+
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}?`)
350350
.should('be.visible')
351351
.within(() => {
352352
cy.findByLabelText('Placement Group').type(mockPlacementGroup.label);
@@ -366,9 +366,9 @@ describe('Placement Group deletion', () => {
366366
.should('be.enabled')
367367
.click();
368368
});
369-
cy.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`).should(
370-
'not.exist'
371-
);
369+
cy.findByTitle(
370+
`Delete Placement Group ${mockPlacementGroup.label}?`
371+
).should('not.exist');
372372

373373
// Click "Delete" button next to the mock Placement Group,
374374
// mock a successful response and confirm that Cloud
@@ -389,7 +389,7 @@ describe('Placement Group deletion', () => {
389389

390390
// Confirm deletion warning appears, complete Type-to-Confirm, and submit confirmation.
391391
ui.dialog
392-
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`)
392+
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}?`)
393393
.should('be.visible')
394394
.within(() => {
395395
// ensure error message not exist when reopening the dialog
@@ -472,7 +472,7 @@ describe('Placement Group deletion', () => {
472472
).as('UnassignPlacementGroupError');
473473

474474
ui.dialog
475-
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`)
475+
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}?`)
476476
.should('be.visible')
477477
.within(() => {
478478
cy.get('[data-qa-selection-list]').within(() => {
@@ -501,9 +501,9 @@ describe('Placement Group deletion', () => {
501501
.click();
502502
});
503503

504-
cy.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`).should(
505-
'not.exist'
506-
);
504+
cy.findByTitle(
505+
`Delete Placement Group ${mockPlacementGroup.label}?`
506+
).should('not.exist');
507507

508508
// Click "Delete" button next to the mock Placement Group to reopen the dialog.
509509
cy.findByText(mockPlacementGroup.label)
@@ -519,7 +519,7 @@ describe('Placement Group deletion', () => {
519519

520520
// Confirm that the error message from the previous attempt is no longer present.
521521
ui.dialog
522-
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}`)
522+
.findByTitle(`Delete Placement Group ${mockPlacementGroup.label}?`)
523523
.should('be.visible')
524524
.within(() => {
525525
cy.findByText(PlacementGroupErrorMessage).should('not.exist');

packages/manager/src/features/Domains/DeleteDomain.test.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

packages/manager/src/features/Domains/DeleteDomain.tsx

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { useDeleteDomainMutation } from '@linode/queries';
2+
import { Notice, Typography } from '@linode/ui';
3+
import { useSnackbar } from 'notistack';
4+
import * as React from 'react';
5+
6+
import { TypeToConfirmDialog } from 'src/components/TypeToConfirmDialog/TypeToConfirmDialog';
7+
8+
import type { APIError } from '@linode/api-v4';
9+
export interface DeleteDomainProps {
10+
domainError: APIError[] | null;
11+
domainId?: number;
12+
domainLabel?: string;
13+
isFetching: boolean;
14+
onClose?: () => void;
15+
// Function that is invoked after Domain has been successfully deleted.
16+
onSuccess?: () => void;
17+
open: boolean;
18+
}
19+
20+
export const DeleteDomainDialog = (props: DeleteDomainProps) => {
21+
const { domainError, domainId, domainLabel, open, onClose, isFetching } =
22+
props;
23+
const { enqueueSnackbar } = useSnackbar();
24+
25+
const {
26+
error,
27+
isPending,
28+
mutateAsync: deleteDomain,
29+
} = useDeleteDomainMutation(domainId ?? 0);
30+
31+
const onDelete = () => {
32+
deleteDomain().then(() => {
33+
enqueueSnackbar('Domain deleted successfully.', {
34+
variant: 'success',
35+
});
36+
if (props.onSuccess) {
37+
props.onSuccess();
38+
}
39+
});
40+
};
41+
42+
return (
43+
<TypeToConfirmDialog
44+
entity={{
45+
action: 'deletion',
46+
error: domainError,
47+
name: domainLabel,
48+
primaryBtnText: 'Delete Domain',
49+
type: 'Domain',
50+
}}
51+
errors={error}
52+
isFetching={isFetching}
53+
label="Domain Name"
54+
loading={isPending}
55+
onClick={onDelete}
56+
onClose={onClose}
57+
open={open}
58+
title={`Delete Domain${domainLabel ? ` ${domainLabel}` : ''}?`}
59+
>
60+
<Notice variant="warning">
61+
<Typography>
62+
<strong>Warning:</strong> Deleting this domain is permanent and can’t
63+
be undone.
64+
</Typography>
65+
</Notice>
66+
</TypeToConfirmDialog>
67+
);
68+
};

packages/manager/src/features/Domains/DisableDomainDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const DisableDomainDialog = React.memo(
6262
isFetching={isFetching}
6363
onClose={onClose}
6464
open={open}
65-
title={`Disable Domain ${domain?.domain ?? 'Unknown'}?`}
65+
title={`Disable Domain${domain ? ` ${domain.domain}` : ''}?`}
6666
>
6767
Are you sure you want to disable this DNS zone?
6868
</ConfirmationDialog>

packages/manager/src/features/Domains/DomainDetail/DomainDetail.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
useUpdateDomainMutation,
55
} from '@linode/queries';
66
import {
7+
Button,
78
CircleProgress,
89
ErrorState,
910
Notice,
@@ -20,7 +21,7 @@ import { LandingHeader } from 'src/components/LandingHeader';
2021
import { TagCell } from 'src/components/TagCell/TagCell';
2122
import { useIsResourceRestricted } from 'src/hooks/useIsResourceRestricted';
2223

23-
import { DeleteDomain } from '../DeleteDomain';
24+
import { DeleteDomainDialog } from '../DeleteDomainDialog';
2425
import { DownloadDNSZoneFileButton } from '../DownloadDNSZoneFileButton';
2526
import { DomainRecords } from './DomainRecords/DomainRecords';
2627

@@ -35,6 +36,7 @@ export const DomainDetail = () => {
3536
const {
3637
data: domain,
3738
error,
39+
isFetching: isFetchingDomain,
3840
isLoading,
3941
} = useDomainQuery(domainId, !!domainId);
4042
const { mutateAsync: updateDomain } = useUpdateDomainMutation();
@@ -52,6 +54,8 @@ export const DomainDetail = () => {
5254
});
5355

5456
const [updateError, setUpdateError] = React.useState<string | undefined>();
57+
const [isDeleteDomainDialogOpen, setDeleteDomainDialogOpen] =
58+
React.useState(false);
5559

5660
const handleLabelChange = (label: string) => {
5761
setUpdateError(undefined);
@@ -146,11 +150,20 @@ export const DomainDetail = () => {
146150
/>
147151
</StyledPaper>
148152
<StyledDiv>
149-
<DeleteDomain
153+
<StyledButton
154+
buttonType="outlined"
155+
onClick={() => setDeleteDomainDialogOpen(true)}
156+
>
157+
Delete Domain
158+
</StyledButton>
159+
<DeleteDomainDialog
150160
domainError={error}
151161
domainId={domain.id}
152162
domainLabel={domain.domain}
163+
isFetching={isFetchingDomain}
164+
onClose={() => setDeleteDomainDialogOpen(false)}
153165
onSuccess={() => navigate({ to: '/domains' })}
166+
open={isDeleteDomainDialogOpen}
154167
/>
155168
</StyledDiv>
156169
</StyledTagSectionGrid>
@@ -209,3 +222,9 @@ const StyledDiv = styled('div', { label: 'StyledDiv' })(({ theme }) => ({
209222
marginLeft: theme.spacing(),
210223
},
211224
}));
225+
226+
const StyledButton = styled(Button, { label: 'StyledButton' })(({ theme }) => ({
227+
[theme.breakpoints.down('lg')]: {
228+
marginRight: theme.spacing(),
229+
},
230+
}));

0 commit comments

Comments
 (0)