|
|
@@ -4,12 +4,15 @@ import { withTranslation } from 'react-i18next';
|
|
|
import {
|
|
|
Modal, ModalHeader, ModalBody, ModalFooter,
|
|
|
} from 'reactstrap';
|
|
|
+import AppContainer from '../services/AppContainer';
|
|
|
+import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
+import { toastSuccess, toastError } from '../util/apiNotification';
|
|
|
|
|
|
|
|
|
const ArchiveCreateModal = (props) => {
|
|
|
- const { t } = props;
|
|
|
+ const { t, appContainer } = props;
|
|
|
const [isCommentDownload, setIsCommentDownload] = useState(false);
|
|
|
- const [isFileDownload, setIsFileDownload] = useState(false);
|
|
|
+ const [isAttachmentFileDownload, setIsAttachmentFileDownload] = useState(false);
|
|
|
const [isSubordinatedPageDownload, setIsSubordinatedPageDownload] = useState(false);
|
|
|
const [fileType, setFileType] = useState('markDown');
|
|
|
const [hierarchyType, setHierarchyType] = useState('allSubordinatedPage');
|
|
|
@@ -19,8 +22,8 @@ const ArchiveCreateModal = (props) => {
|
|
|
setIsCommentDownload(!isCommentDownload);
|
|
|
}
|
|
|
|
|
|
- function changeIsFileDownloadHandler() {
|
|
|
- setIsFileDownload(!isFileDownload);
|
|
|
+ function changeIsAttachmentFileDownloadHandler() {
|
|
|
+ setIsAttachmentFileDownload(!isAttachmentFileDownload);
|
|
|
}
|
|
|
|
|
|
function changeIsSubordinatedPageDownloadHandler() {
|
|
|
@@ -50,6 +53,23 @@ const ArchiveCreateModal = (props) => {
|
|
|
setHierarchyValue(hierarchyValue);
|
|
|
}
|
|
|
|
|
|
+ async function done() {
|
|
|
+
|
|
|
+ try {
|
|
|
+ await appContainer.apiv3Post('/page/archive', {
|
|
|
+ isCommentDownload,
|
|
|
+ isAttachmentFileDownload,
|
|
|
+ isSubordinatedPageDownload,
|
|
|
+ fileType,
|
|
|
+ hierarchyType,
|
|
|
+ hierarchyValue,
|
|
|
+ });
|
|
|
+ toastSuccess(t('Submitted the request to create the archive'));
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ toastError(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
|
<Modal isOpen={props.isOpen} toggle={closeModalHandler}>
|
|
|
@@ -120,8 +140,8 @@ const ArchiveCreateModal = (props) => {
|
|
|
className="custom-control-input"
|
|
|
id="downloadFile"
|
|
|
type="checkbox"
|
|
|
- checked={isFileDownload}
|
|
|
- onChange={changeIsFileDownloadHandler}
|
|
|
+ checked={isAttachmentFileDownload}
|
|
|
+ onChange={changeIsAttachmentFileDownloadHandler}
|
|
|
/>
|
|
|
<label className="custom-control-label" htmlFor="downloadFile">
|
|
|
{t('Include Attachment File')}
|
|
|
@@ -196,7 +216,7 @@ const ArchiveCreateModal = (props) => {
|
|
|
</div>
|
|
|
</ModalBody>
|
|
|
<ModalFooter>
|
|
|
- <button type="button" className="btn btn-primary">
|
|
|
+ <button type="button" className="btn btn-primary" onClick={done}>
|
|
|
Done
|
|
|
</button>
|
|
|
</ModalFooter>
|
|
|
@@ -204,13 +224,15 @@ const ArchiveCreateModal = (props) => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+const ArchiveCreateModalWrapper = withUnstatedContainers(ArchiveCreateModal, [AppContainer]);
|
|
|
|
|
|
ArchiveCreateModal.propTypes = {
|
|
|
t: PropTypes.func.isRequired, // i18next
|
|
|
+ appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
isOpen: PropTypes.bool.isRequired,
|
|
|
onClose: PropTypes.func,
|
|
|
path: PropTypes.string.isRequired,
|
|
|
};
|
|
|
|
|
|
|
|
|
-export default withTranslation()(ArchiveCreateModal);
|
|
|
+export default withTranslation()(ArchiveCreateModalWrapper);
|