2020-11-26 09:22:30 -05:00
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
|
|
|
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
|
2024-09-25 09:46:02 -04:00
|
|
|
import OLModal, {
|
|
|
|
OLModalBody,
|
|
|
|
OLModalFooter,
|
|
|
|
OLModalHeader,
|
|
|
|
OLModalTitle,
|
|
|
|
} from '@/features/ui/components/ol/ol-modal'
|
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
|
|
import OLNotification from '@/features/ui/components/ol/ol-notification'
|
2020-11-26 09:22:30 -05:00
|
|
|
|
|
|
|
function FileTreeModalDelete() {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
const {
|
|
|
|
isDeleting,
|
|
|
|
inFlight,
|
|
|
|
finishDeleting,
|
|
|
|
actionedEntities,
|
|
|
|
cancel,
|
2021-04-27 03:52:58 -04:00
|
|
|
error,
|
2020-11-26 09:22:30 -05:00
|
|
|
} = useFileTreeActionable()
|
|
|
|
|
|
|
|
if (!isDeleting) return null // the modal will not be rendered; return early
|
|
|
|
|
|
|
|
function handleHide() {
|
|
|
|
cancel()
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleDelete() {
|
|
|
|
finishDeleting()
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2024-09-25 09:46:02 -04:00
|
|
|
<OLModal show onHide={handleHide}>
|
|
|
|
<OLModalHeader>
|
|
|
|
<OLModalTitle>{t('delete')}</OLModalTitle>
|
|
|
|
</OLModalHeader>
|
2020-11-26 09:22:30 -05:00
|
|
|
|
2024-09-25 09:46:02 -04:00
|
|
|
<OLModalBody>
|
2020-11-26 09:22:30 -05:00
|
|
|
<p>{t('sure_you_want_to_delete')}</p>
|
|
|
|
<ul>
|
|
|
|
{actionedEntities.map(entity => (
|
|
|
|
<li key={entity._id}>{entity.name}</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
{error && (
|
2024-09-25 09:46:02 -04:00
|
|
|
<OLNotification
|
|
|
|
type="error"
|
|
|
|
content={t('generic_something_went_wrong')}
|
|
|
|
/>
|
2020-11-26 09:22:30 -05:00
|
|
|
)}
|
2024-09-25 09:46:02 -04:00
|
|
|
</OLModalBody>
|
2020-11-26 09:22:30 -05:00
|
|
|
|
2024-09-25 09:46:02 -04:00
|
|
|
<OLModalFooter>
|
2020-11-26 09:22:30 -05:00
|
|
|
{inFlight ? (
|
2024-09-25 09:46:02 -04:00
|
|
|
<OLButton
|
|
|
|
variant="danger"
|
|
|
|
disabled
|
|
|
|
isLoading
|
|
|
|
bs3Props={{ loading: `${t('deleting')}…` }}
|
|
|
|
/>
|
2020-11-26 09:22:30 -05:00
|
|
|
) : (
|
|
|
|
<>
|
2024-09-25 09:46:02 -04:00
|
|
|
<OLButton className="secondary" onClick={handleHide}>
|
2022-12-07 05:51:44 -05:00
|
|
|
{t('cancel')}
|
2024-09-25 09:46:02 -04:00
|
|
|
</OLButton>
|
|
|
|
<OLButton variant="danger" onClick={handleDelete}>
|
2020-11-26 09:22:30 -05:00
|
|
|
{t('delete')}
|
2024-09-25 09:46:02 -04:00
|
|
|
</OLButton>
|
2020-11-26 09:22:30 -05:00
|
|
|
</>
|
|
|
|
)}
|
2024-09-25 09:46:02 -04:00
|
|
|
</OLModalFooter>
|
|
|
|
</OLModal>
|
2020-11-26 09:22:30 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FileTreeModalDelete
|