Skip to content

Commit

Permalink
Delete confirmation (#809)
Browse files Browse the repository at this point in the history
* Fix styling

* Add DeleteConfirmation to deleting dataset fields and collections

* Update changelog

* Fix EditDatasetDrawer to take new props

* Address PR feedback
  • Loading branch information
allisonking committed Jul 28, 2022
1 parent 8775c86 commit 3b2c1fd
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 56 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The types of changes are:

## [1.7.1](https://github.com/ethyca/fides/compare/1.6.1...1.7.1) - 2022-07-28
### Added
* Add delete confirmation when deleting a field or collection from a dataset [808](https://github.com/ethyca/fides/issues/808)

### Fixed

Expand Down
Binary file not shown.
46 changes: 46 additions & 0 deletions clients/admin-ui/src/features/common/ConfirmationModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {
Button,
Modal,
ModalBody,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
SimpleGrid,
} from "@fidesui/react";
import { ReactNode } from "react";

interface Props {
isOpen: boolean;
onClose: () => void;
onDelete: () => void;
title: string;
message: ReactNode;
}
const ConfirmationModal = ({
isOpen,
onClose,
onDelete,
title,
message,
}: Props) => (
<Modal isOpen={isOpen} onClose={onClose} size="lg">
<ModalOverlay />
<ModalContent textAlign="center" p={2}>
<ModalHeader fontWeight="medium">{title}</ModalHeader>
<ModalBody>{message}</ModalBody>
<ModalFooter>
<SimpleGrid columns={2} width="100%">
<Button variant="outline" mr={3} onClick={onClose}>
Cancel
</Button>
<Button colorScheme="primary" onClick={onDelete}>
Continue
</Button>
</SimpleGrid>
</ModalFooter>
</ModalContent>
</Modal>
);

export default ConfirmationModal;
1 change: 0 additions & 1 deletion clients/admin-ui/src/features/common/form/inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export const CustomSelect = ({
isSearchable={isSearchable ?? false}
isClearable={isClearable}
/>

{tooltip ? <QuestionTooltip label={tooltip} /> : null}
</Box>
</Grid>
Expand Down
12 changes: 11 additions & 1 deletion clients/admin-ui/src/features/dataset/EditCollectionDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useToast } from "@fidesui/react";
import { Text, useToast } from "@fidesui/react";
import { useSelector } from "react-redux";

import { errorToastParams, successToastParams } from "../common/toast";
Expand Down Expand Up @@ -78,6 +78,16 @@ const EditCollectionDrawer = ({ collection, isOpen, onClose }: Props) => {
description={DESCRIPTION}
header={`Collection Name: ${collection.name}`}
onDelete={handleDelete}
deleteTitle="Delete Collection"
deleteMessage={
<Text>
You are about to permanently delete the collection named{" "}
<Text color="complimentary.500" as="span" fontWeight="bold">
{collection.name}
</Text>{" "}
from this dataset. Are you sure you would like to continue?
</Text>
}
>
<EditCollectionOrFieldForm
values={collection}
Expand Down
42 changes: 18 additions & 24 deletions clients/admin-ui/src/features/dataset/EditCollectionOrFieldForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,24 @@ const EditCollectionOrFieldForm = ({
height="80vh"
>
<Stack>
<Box>
<CustomTextInput
name="description"
label="Description"
tooltip={descriptionTooltip}
/>
</Box>
<Box>
<CustomSelect
name="data_qualifier"
label="Identifiability"
options={IDENTIFIER_OPTIONS}
tooltip={dataQualifierTooltip}
isSearchable={false}
/>
</Box>
<Box>
<DataCategoryInput
dataCategories={allDataCategories}
checked={checkedDataCategories}
onChecked={setCheckedDataCategories}
tooltip={dataCategoryTooltip}
/>
</Box>
<CustomTextInput
name="description"
label="Description"
tooltip={descriptionTooltip}
/>
<CustomSelect
name="data_qualifier"
label="Identifiability"
options={IDENTIFIER_OPTIONS}
tooltip={dataQualifierTooltip}
isSearchable={false}
/>
<DataCategoryInput
dataCategories={allDataCategories}
checked={checkedDataCategories}
onChecked={setCheckedDataCategories}
tooltip={dataCategoryTooltip}
/>
</Stack>
<Box>
<Button onClick={onClose} mr={2} size="sm" variant="outline">
Expand Down
12 changes: 11 additions & 1 deletion clients/admin-ui/src/features/dataset/EditDatasetDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useToast } from "@fidesui/react";
import { Text, useToast } from "@fidesui/react";

import { errorToastParams, successToastParams } from "../common/toast";
import { useUpdateDatasetMutation } from "./dataset.slice";
Expand Down Expand Up @@ -46,6 +46,16 @@ const EditDatasetDrawer = ({ dataset, isOpen, onClose }: Props) => {
description={DESCRIPTION}
header={`Dataset Name: ${dataset.name}`}
onDelete={() => {}} // TODO #769
deleteMessage={
<Text>
You are about to permanently delete the collection named{" "}
<Text color="complimentary.500" as="span" fontWeight="bold">
{dataset.name}
</Text>{" "}
from this dataset. Are you sure you would like to continue?
</Text>
}
deleteTitle="Delete Dataset"
>
<EditDatasetForm
values={dataset}
Expand Down
82 changes: 53 additions & 29 deletions clients/admin-ui/src/features/dataset/EditDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@ import {
DrawerOverlay,
IconButton,
Text,
useDisclosure,
} from "@fidesui/react";
import { ReactNode } from "react";

import { CloseSolidIcon, TrashCanSolidIcon } from "~/features/common/Icon";

import ConfirmationModal from "../common/ConfirmationModal";

interface Props {
header: string;
description: string;
isOpen: boolean;
onClose: () => void;
onDelete: () => void;
deleteTitle: string;
deleteMessage: ReactNode;
children: ReactNode;
}

Expand All @@ -28,35 +33,54 @@ const EditDrawer = ({
isOpen,
onClose,
onDelete,
deleteTitle,
deleteMessage,
children,
}: Props) => (
<Drawer placement="right" isOpen={isOpen} onClose={onClose} size="lg">
<DrawerOverlay />
<DrawerContent>
<Box py={2}>
<Box display="flex" justifyContent="flex-end" mr={2}>
<Button variant="ghost" onClick={onClose}>
<CloseSolidIcon />
</Button>
</Box>
<DrawerHeader py={2} display="flex" alignItems="center">
<Text mr="2">{header}</Text>
<IconButton
aria-label="delete"
icon={<TrashCanSolidIcon />}
size="xs"
onClick={onDelete}
/>
</DrawerHeader>
<DrawerBody>
<Text fontSize="sm" mb={4}>
{description}
</Text>
{children}
</DrawerBody>
</Box>
</DrawerContent>
</Drawer>
);
}: Props) => {
const {
isOpen: deleteIsOpen,
onOpen: onDeleteOpen,
onClose: onDeleteClose,
} = useDisclosure();

return (
<>
<Drawer placement="right" isOpen={isOpen} onClose={onClose} size="lg">
<DrawerOverlay />
<DrawerContent>
<Box py={2}>
<Box display="flex" justifyContent="flex-end" mr={2}>
<Button variant="ghost" onClick={onClose}>
<CloseSolidIcon />
</Button>
</Box>
<DrawerHeader py={2} display="flex" alignItems="center">
<Text mr="2">{header}</Text>
<IconButton
aria-label="delete"
icon={<TrashCanSolidIcon />}
size="xs"
onClick={onDeleteOpen}
/>
</DrawerHeader>
<DrawerBody>
<Text fontSize="sm" mb={4}>
{description}
</Text>
{children}
</DrawerBody>
</Box>
</DrawerContent>
</Drawer>
<ConfirmationModal
isOpen={deleteIsOpen}
onClose={onDeleteClose}
onDelete={onDelete}
title={deleteTitle}
message={deleteMessage}
/>
</>
);
};

export default EditDrawer;
11 changes: 11 additions & 0 deletions clients/admin-ui/src/features/dataset/EditFieldDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Text } from "@fidesui/react";
import { useSelector } from "react-redux";

import {
Expand Down Expand Up @@ -65,6 +66,16 @@ const EditFieldDrawer = ({ field, isOpen, onClose }: Props) => {
header={`Field Name: ${field.name}`}
description={DESCRIPTION}
onDelete={handleDelete}
deleteTitle="Delete Field"
deleteMessage={
<Text>
You are about to permanently delete the field named{" "}
<Text color="complimentary.500" as="span" fontWeight="bold">
{field.name}
</Text>{" "}
from this dataset. Are you sure you would like to continue?
</Text>
}
>
<EditCollectionOrFieldForm
values={field}
Expand Down

0 comments on commit 3b2c1fd

Please sign in to comment.