-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f34d0b3
commit c0bd0db
Showing
12 changed files
with
211 additions
and
55 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
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
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
71 changes: 71 additions & 0 deletions
71
Src/WitsmlExplorer.Frontend/components/Modals/ConfirmDeletionModal.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,71 @@ | ||
import { ModalContentLayout } from "components/Modals/ModalDialog"; | ||
import { Checkbox } from "components/StyledComponents/Checkbox"; | ||
import OperationType from "contexts/operationType"; | ||
import { useOperationState } from "hooks/useOperationState"; | ||
import React, { ChangeEvent, useState } from "react"; | ||
import ConfirmModal from "./ConfirmModal"; | ||
import WarningBar from "components/WarningBar"; | ||
|
||
export interface ConfirmDeletionModalProps { | ||
componentType: string; | ||
objectName: string; | ||
objectUid: string; | ||
onSubmit: (cascadedDelete: boolean) => void; | ||
} | ||
|
||
const ConfirmDeletionModal = ( | ||
props: ConfirmDeletionModalProps | ||
): React.ReactElement => { | ||
const { | ||
operationState: { colors }, | ||
dispatchOperation | ||
} = useOperationState(); | ||
|
||
const [cascadedDelete, setCascadedDelete] = useState<boolean>(false); | ||
|
||
const onConfirmClick = async () => { | ||
props.onSubmit(cascadedDelete); | ||
dispatchOperation({ type: OperationType.HideModal }); | ||
}; | ||
|
||
return ( | ||
<ConfirmModal | ||
heading={"Delete " + props.componentType + "?"} | ||
content={ | ||
<> | ||
<ModalContentLayout> | ||
<span> | ||
This will permanently delete {props.componentType}{" "} | ||
<strong>{props.objectName}</strong> with uid:{" "} | ||
<strong>{props.objectUid}</strong> | ||
</span> | ||
|
||
<Checkbox | ||
label={`Delete all objects under ` + props.componentType + `?`} | ||
onChange={(e: ChangeEvent<HTMLInputElement>) => { | ||
setCascadedDelete(e.target.checked); | ||
}} | ||
colors={colors} | ||
/> | ||
|
||
{cascadedDelete && ( | ||
<WarningBar | ||
message={ | ||
`This action will permanently delete the ${props.componentType} ` + | ||
`'${props.objectName}' and all associated objects. ` + | ||
`This cannot be undone. Please ensure you want to delete the entire structure.` | ||
} | ||
/> | ||
)} | ||
</ModalContentLayout> | ||
</> | ||
} | ||
onConfirm={onConfirmClick} | ||
confirmColor={"danger"} | ||
confirmText={"Delete " + props.componentType} | ||
switchButtonPlaces={true} | ||
/> | ||
); | ||
}; | ||
|
||
export default ConfirmDeletionModal; |
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
Oops, something went wrong.