diff --git a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/ConfirmationModal/ConfirmationModal.jsx b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/ConfirmationModal/ConfirmationModal.jsx new file mode 100644 index 00000000..d215a5a3 --- /dev/null +++ b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/ConfirmationModal/ConfirmationModal.jsx @@ -0,0 +1,38 @@ +import React from "react"; +import { Modal, Icon, Message } from "semantic-ui-react"; + +export function ConfirmationModal({ + header, + content, + trigger, + actions, + isOpen, + close, +}) { + return ( + <> + {trigger} + + {header} + {content && ( + + +

+ {content} +

+
+
+ )} + {actions} +
+ + ); +} + +export default ConfirmationModal; diff --git a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/ConfirmationModal/index.js b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/ConfirmationModal/index.js new file mode 100644 index 00000000..ccb94b1e --- /dev/null +++ b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/ConfirmationModal/index.js @@ -0,0 +1,2 @@ +export * from './ConfirmationModal'; +export { default } from './ConfirmationModal'; diff --git a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/DeleteButton/DeleteButton.jsx b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/DeleteButton/DeleteButton.jsx index d87d33ac..09d01b14 100644 --- a/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/DeleteButton/DeleteButton.jsx +++ b/oarepo_ui/theme/assets/semantic-ui/js/oarepo_ui/forms/components/DeleteButton/DeleteButton.jsx @@ -1,76 +1,72 @@ import React from "react"; -import { Button, Modal, Icon, Message } from "semantic-ui-react"; +import { Button, Icon } from "semantic-ui-react"; import { i18next } from "@translations/i18next"; import { useConfirmationModal, useFormConfig, useDepositApiClient, + ConfirmationModal, } from "@js/oarepo_ui"; import PropTypes from "prop-types"; export const DeleteButton = React.memo( ({ modalMessage, modalHeader, redirectUrl }) => { - const { isModalOpen, handleCloseModal, handleOpenModal } = - useConfirmationModal(); + const { + isOpen: isModalOpen, + close: closeModal, + open: openModal, + } = useConfirmationModal(); const { formConfig: { permissions }, } = useFormConfig(); const { values, isSubmitting, _delete, isDeleting } = useDepositApiClient(); return ( - + <> {values.id && permissions?.can_delete_draft && ( - + -