-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable/Disable Datastores [Frontend] (#693)
* Add the ability to enable/disable a connectionconfig. * Fix other location to prevent from closing modal while in progress. * Update changelog.
- Loading branch information
Showing
6 changed files
with
157 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
clients/admin-ui/src/features/datastore-connections/DisableConnectionModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import { | ||
Button, | ||
MenuItem, | ||
Modal, | ||
ModalBody, | ||
ModalCloseButton, | ||
ModalContent, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalOverlay, | ||
Stack, | ||
Text, | ||
useDisclosure, | ||
} from "@fidesui/react"; | ||
import React from "react"; | ||
|
||
import { usePatchDatastoreConnectionsMutation } from "./datastore-connection.slice"; | ||
import { AccessLevel, ConnectionType } from "./types"; | ||
|
||
type DataConnectionProps = { | ||
connection_key: string; | ||
disabled: boolean; | ||
name: string; | ||
access_type: AccessLevel; | ||
connection_type: ConnectionType; | ||
}; | ||
|
||
const DisableConnectionModal: React.FC<DataConnectionProps> = ({ | ||
connection_key, | ||
disabled, | ||
name, | ||
access_type, | ||
connection_type, | ||
}) => { | ||
const { isOpen, onOpen, onClose } = useDisclosure(); | ||
const [patchConnection, patchConnectionResult] = | ||
usePatchDatastoreConnectionsMutation(); | ||
|
||
const handleDisableConnection = async () => { | ||
const shouldDisable = !disabled; | ||
return patchConnection({ | ||
key: connection_key, | ||
name, | ||
disabled: shouldDisable, | ||
access: access_type, | ||
connection_type, | ||
}) | ||
.unwrap() | ||
.then(() => onClose()); | ||
}; | ||
|
||
const closeIfComplete = () => { | ||
if (!patchConnectionResult.isLoading) { | ||
onClose(); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<MenuItem | ||
_focus={{ color: "complimentary.500", bg: "gray.100" }} | ||
onClick={onOpen} | ||
> | ||
<Text fontSize="sm">{disabled ? "Enable" : "Disable"}</Text> | ||
</MenuItem> | ||
<Modal isCentered isOpen={isOpen} onClose={closeIfComplete}> | ||
<ModalOverlay /> | ||
<ModalContent> | ||
<ModalHeader> | ||
{disabled ? "Enable" : "Disable"} Connection | ||
</ModalHeader> | ||
<ModalCloseButton /> | ||
<ModalBody pb={6}> | ||
<Stack direction="column" spacing="15px"> | ||
<Text | ||
color="gray.600" | ||
fontSize="sm" | ||
fontWeight="sm" | ||
lineHeight="20px" | ||
> | ||
{disabled ? "Enabling" : "Disabling"} a datastore connection may | ||
impact any subject request that is currently in progress. Do you | ||
wish to proceed? | ||
</Text> | ||
</Stack> | ||
</ModalBody> | ||
|
||
<ModalFooter> | ||
<Button | ||
onClick={closeIfComplete} | ||
marginRight="10px" | ||
size="sm" | ||
variant="solid" | ||
bg="white" | ||
width="50%" | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
onClick={handleDisableConnection} | ||
isLoading={patchConnectionResult.isLoading} | ||
mr={3} | ||
size="sm" | ||
variant="solid" | ||
bg="primary.800" | ||
color="white" | ||
width="50%" | ||
> | ||
{disabled ? "Enable" : "Disable"} Connection | ||
</Button> | ||
</ModalFooter> | ||
</ModalContent> | ||
</Modal> | ||
</> | ||
); | ||
}; | ||
|
||
export default DisableConnectionModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters