2020-11-26 09:22:30 -05:00
|
|
|
import React from 'react'
|
|
|
|
import { Button, Modal } from 'react-bootstrap'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
2021-01-05 05:57:45 -05:00
|
|
|
import AccessibleModal from '../../../../shared/components/accessible-modal'
|
|
|
|
|
2020-11-26 09:22:30 -05:00
|
|
|
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
|
|
|
|
|
|
|
|
function FileTreeModalDelete() {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
|
|
|
|
const {
|
|
|
|
isDeleting,
|
|
|
|
inFlight,
|
|
|
|
finishDeleting,
|
|
|
|
actionedEntities,
|
|
|
|
cancel,
|
|
|
|
error
|
|
|
|
} = useFileTreeActionable()
|
|
|
|
|
|
|
|
if (!isDeleting) return null // the modal will not be rendered; return early
|
|
|
|
|
|
|
|
function handleHide() {
|
|
|
|
cancel()
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleDelete() {
|
|
|
|
finishDeleting()
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-01-05 05:57:45 -05:00
|
|
|
<AccessibleModal show={isDeleting} onHide={handleHide}>
|
2020-11-26 09:22:30 -05:00
|
|
|
<Modal.Header>
|
|
|
|
<Modal.Title>{t('delete')}</Modal.Title>
|
|
|
|
</Modal.Header>
|
|
|
|
|
|
|
|
<Modal.Body>
|
|
|
|
<p>{t('sure_you_want_to_delete')}</p>
|
|
|
|
<ul>
|
|
|
|
{actionedEntities.map(entity => (
|
|
|
|
<li key={entity._id}>{entity.name}</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
{error && (
|
|
|
|
<div className="alert alert-danger file-tree-modal-alert">
|
|
|
|
{t('generic_something_went_wrong')}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</Modal.Body>
|
|
|
|
|
|
|
|
<Modal.Footer>
|
|
|
|
{inFlight ? (
|
|
|
|
<Button bsStyle="danger" disabled>
|
|
|
|
{t('deleting')}…
|
|
|
|
</Button>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<Button onClick={handleHide}>{t('cancel')}</Button>
|
|
|
|
<Button bsStyle="danger" onClick={handleDelete}>
|
|
|
|
{t('delete')}
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</Modal.Footer>
|
2021-01-05 05:57:45 -05:00
|
|
|
</AccessibleModal>
|
2020-11-26 09:22:30 -05:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FileTreeModalDelete
|