-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Aviv Turgeman <aturgema@redhat.com>
- Loading branch information
Showing
5 changed files
with
113 additions
and
122 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
3 changes: 2 additions & 1 deletion
3
...ionnaire/delete-questionnaire-message.css → ...irmDeleteCatalog/ConfirmDeleteCatalog.css
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
.confirm-deletion { | ||
margin-top: var(--pf-v5-global--spacer--md); | ||
margin-top: var(--pf-v5-global--spacer--xl); | ||
} | ||
|
||
.confirm-deletion-input { | ||
margin-top: var(--pf-v5-global--spacer--sm); | ||
margin-bottom: var(--pf-v5-global--spacer--sm); | ||
} |
100 changes: 100 additions & 0 deletions
100
client/src/app/components/ConfirmDeleteCatalog/ConfirmDeleteCatalog.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,100 @@ | ||
import React, { FC, useState } from "react"; | ||
import { useTranslation, Trans } from "react-i18next"; | ||
import { | ||
ModalProps, | ||
Button, | ||
ButtonVariant, | ||
Modal, | ||
ModalVariant, | ||
Text, | ||
TextInput, | ||
} from "@patternfly/react-core"; | ||
|
||
import "./ConfirmDeleteCatalog.css"; | ||
|
||
type ConfirmDeleteDialogProps = { | ||
cancelBtnLabel?: string; | ||
deleteBtnLabel?: string; | ||
deleteObjectMessage: string; | ||
isOpen: boolean; | ||
nameToDelete?: string; | ||
onClose: () => void; | ||
onConfirmDelete: () => void; | ||
titleWhat: string; | ||
titleIconVariant?: ModalProps["titleIconVariant"]; | ||
}; | ||
|
||
const ConfirmDeleteDialog: FC<ConfirmDeleteDialogProps> = ({ | ||
cancelBtnLabel, | ||
deleteBtnLabel, | ||
deleteObjectMessage, | ||
isOpen, | ||
nameToDelete, | ||
onClose, | ||
onConfirmDelete, | ||
titleWhat, | ||
titleIconVariant = "warning", | ||
}) => { | ||
const { t } = useTranslation(); | ||
|
||
const [nameToDeleteInput, setNameToDeleteInput] = useState<string>(""); | ||
|
||
const isDisabled = nameToDeleteInput !== nameToDelete; | ||
|
||
const confirmBtn = ( | ||
<Button | ||
id="confirm-delete-dialog-button" | ||
key="confirm" | ||
aria-label="confirm" | ||
variant={ButtonVariant.danger} | ||
isDisabled={isDisabled} | ||
onClick={isDisabled ? undefined : onConfirmDelete} | ||
> | ||
{deleteBtnLabel ?? t("actions.delete")} | ||
</Button> | ||
); | ||
|
||
const cancelBtn = ( | ||
<Button | ||
key="cancel" | ||
id="cancel-delete-button" | ||
aria-label="cancel" | ||
variant={ButtonVariant.link} | ||
onClick={onClose} | ||
> | ||
{cancelBtnLabel ?? t("actions.cancel")} | ||
</Button> | ||
); | ||
return ( | ||
<Modal | ||
id="confirm-delete-dialog" | ||
variant={ModalVariant.small} | ||
titleIconVariant={titleIconVariant} | ||
isOpen={isOpen} | ||
onClose={() => { | ||
setNameToDeleteInput(""); | ||
onClose(); | ||
}} | ||
aria-label={t("Confirm delete dialog")} | ||
actions={[confirmBtn, cancelBtn]} | ||
title={t("dialog.title.delete", { | ||
what: titleWhat, | ||
})} | ||
> | ||
<Text component="p">{deleteObjectMessage}</Text> | ||
<Text component="p">{t("dialog.message.delete")}</Text> | ||
<Text component="p" className="confirm-deletion"> | ||
<Trans i18nKey="dialog.message.confirmDeletion"> | ||
Confirm deletion by typing <strong>{{ nameToDelete }}</strong> below: | ||
</Trans> | ||
</Text> | ||
<TextInput | ||
className="confirm-deletion-input" | ||
value={nameToDeleteInput} | ||
onChange={(_, value) => setNameToDeleteInput(value)} | ||
/> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ConfirmDeleteDialog; |
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
41 changes: 0 additions & 41 deletions
41
...ment-management/assessment-settings/delete-questionnaire/delete-questionnaire-message.tsx
This file was deleted.
Oops, something went wrong.