Просмотр исходного кода

omit PageArchive related files

Yuki Takei 2 лет назад
Родитель
Сommit
d530854610

+ 0 - 239
apps/app/src/components/ArchiveCreateModal.jsx

@@ -1,239 +0,0 @@
-import React, { useState, useCallback } from 'react';
-
-import { useTranslation } from 'next-i18next';
-import PropTypes from 'prop-types';
-import {
-  Modal, ModalHeader, ModalBody, ModalFooter,
-} from 'reactstrap';
-
-import { apiv3Post } from '~/client/util/apiv3-client';
-import { toastSuccess, toastError } from '~/client/util/toastr';
-
-
-const ArchiveCreateModal = (props) => {
-  const { onClose } = props;
-
-  const { t } = useTranslation();
-  const [isCommentDownload, setIsCommentDownload] = useState(false);
-  const [isAttachmentFileDownload, setIsAttachmentFileDownload] = useState(false);
-  const [isSubordinatedPageDownload, setIsSubordinatedPageDownload] = useState(false);
-  const [fileType, setFileType] = useState('markdown');
-  const [hierarchyType, setHierarchyType] = useState('allSubordinatedPage');
-  const [hierarchyValue, setHierarchyValue] = useState(1);
-
-  function changeIsCommentDownloadHandler() {
-    setIsCommentDownload(!isCommentDownload);
-  }
-
-  function changeIsAttachmentFileDownloadHandler() {
-    setIsAttachmentFileDownload(!isAttachmentFileDownload);
-  }
-
-  function changeIsSubordinatedPageDownloadHandler() {
-    setIsSubordinatedPageDownload(!isSubordinatedPageDownload);
-  }
-
-  const closeModalHandler = useCallback(() => {
-    onClose?.();
-  }, [onClose]);
-
-  const handleChangeFileType = useCallback(
-    (filetype) => {
-      setFileType(filetype);
-    },
-    [],
-  );
-
-  function handleChangeSubordinatedType(hierarchyType) {
-    setHierarchyType(hierarchyType);
-  }
-
-  function handleHierarchyDepth(hierarchyValue) {
-    setHierarchyValue(hierarchyValue);
-  }
-
-
-  async function done() {
-    try {
-      await apiv3Post('/page/archive', {
-        rootPagePath: props.path,
-        isCommentDownload,
-        isAttachmentFileDownload,
-        isSubordinatedPageDownload,
-        fileType,
-        hierarchyType,
-        hierarchyValue,
-      });
-      toastSuccess(t('Submitted the request to create the archive'));
-      closeModalHandler();
-    }
-    catch (e) {
-      toastError(e);
-    }
-  }
-
-  return (
-    <Modal isOpen={props.isOpen} toggle={closeModalHandler}>
-      <ModalHeader tag="h4" toggle={closeModalHandler} className="bg-primary text-white">
-        {t('Create Archive Page')}
-      </ModalHeader>
-      <ModalBody>
-        <div className="form-group">
-          <div className="form-group">
-            <label>{t('Target page')}</label>
-            <br />
-            <code>{props.path}</code>
-          </div>
-
-          <div className="custom-control-inline">
-            <label>{t('File type')}: </label>
-          </div>
-          <div className="custom-control custom-radio custom-control-inline ">
-            <input
-              type="radio"
-              className="custom-control-input"
-              id="customRadio1"
-              name="isFileType"
-              value="customRadio1"
-              checked={fileType === 'markdown'}
-              onChange={() => {
-                handleChangeFileType('markdown');
-              }}
-            />
-            <label className="custom-control-label" htmlFor="customRadio1">
-              MarkDown(.md)
-            </label>
-          </div>
-
-          <div className="custom-control custom-radio custom-control-inline ">
-            <input
-              type="radio"
-              className="custom-control-input"
-              id="customRadio2"
-              name="isFileType"
-              value="customRadio2"
-              checked={fileType === 'pdf'}
-              onChange={() => {
-                handleChangeFileType('pdf');
-              }}
-            />
-            <label className="custom-control-label" htmlFor="customRadio2">
-              PDF(.pdf)
-            </label>
-          </div>
-        </div>
-
-        <div className="my-1 custom-control custom-checkbox custom-checkbox-info">
-          <input
-            className="custom-control-input"
-            name="comment"
-            id="commentFile"
-            type="checkbox"
-            checked={isCommentDownload}
-            onChange={changeIsCommentDownloadHandler}
-          />
-          <label className="custom-control-label" htmlFor="commentFile">
-            {t('Include Comment')}
-          </label>
-        </div>
-        <div className="my-1 custom-control custom-checkbox custom-checkbox-info">
-          <input
-            className="custom-control-input"
-            id="downloadFile"
-            type="checkbox"
-            checked={isAttachmentFileDownload}
-            onChange={changeIsAttachmentFileDownloadHandler}
-          />
-          <label className="custom-control-label" htmlFor="downloadFile">
-            {t('Include Attachment File')}
-          </label>
-        </div>
-        <div className="my-1 custom-control custom-checkbox custom-checkbox-info">
-          <input
-            className="custom-control-input"
-            id="subordinatedFile"
-            type="checkbox"
-            checked={isSubordinatedPageDownload}
-            onChange={changeIsSubordinatedPageDownloadHandler}
-          />
-          <label className="custom-control-label" htmlFor="subordinatedFile">
-            {t('Include Subordinated Page')}
-          </label>
-          {isSubordinatedPageDownload && (
-            <>
-              <div className="FormGroup">
-                <div className="my-1 custom-control custom-radio custom-control-inline ">
-                  <input
-                    type="radio"
-                    className="custom-control-input"
-                    id="customRadio3"
-                    name="isSubordinatedType"
-                    value="customRadio3"
-                    disabled={!isSubordinatedPageDownload}
-                    checked={hierarchyType === 'allSubordinatedPage'}
-                    onChange={() => {
-                      handleChangeSubordinatedType('allSubordinatedPage');
-                    }}
-                  />
-                  <label className="custom-control-label" htmlFor="customRadio3">
-                    {t('All Subordinated Page')}
-                  </label>
-                </div>
-              </div>
-              <div className="FormGroup">
-                <div className="my-1 custom-control custom-radio custom-control-inline">
-                  <input
-                    type="radio"
-                    className="custom-control-input"
-                    id="customRadio4"
-                    name="isSubordinatedType"
-                    value="customRadio4"
-                    disabled={!isSubordinatedPageDownload}
-                    checked={hierarchyType === 'decideHierarchy'}
-                    onChange={() => {
-                      handleChangeSubordinatedType('decideHierarchy');
-                    }}
-                  />
-                  <label className="my-1 custom-control-label" htmlFor="customRadio4">
-                    {t('Specify Hierarchy')}
-                  </label>
-                </div>
-              </div>
-              <div className="my-1 custom-control costom-control-inline">
-                <input
-                  type="number"
-                  min="1"
-                  max="10"
-                  disabled={hierarchyType === 'allSubordinatedPage'}
-                  value={hierarchyValue}
-                  placeholder="1"
-                  onChange={(e) => {
-                    handleHierarchyDepth(e.target.value);
-                  }}
-                />
-              </div>
-            </>
-          )}
-        </div>
-      </ModalBody>
-      <ModalFooter>
-        {/* TO DO implement correct number at GW-3053 */}
-        合計{props.totalPages}ページ取得
-        {props.errorMessage}
-        <button type="button" className="btn btn-primary" onClick={done}>
-          Done
-        </button>
-      </ModalFooter>
-    </Modal>
-  );
-};
-
-ArchiveCreateModal.propTypes = {
-  isOpen: PropTypes.bool.isRequired,
-  onClose: PropTypes.func,
-  path: PropTypes.string.isRequired,
-  totalPages: PropTypes.number,
-  errorMessage: PropTypes.string,
-};
-
-export default ArchiveCreateModal;

+ 0 - 2
apps/app/src/server/models/index.js

@@ -2,8 +2,6 @@ import Page from '~/server/models/page';
 
 
 module.exports = {
 module.exports = {
   Page,
   Page,
-  // TODO GW-2746 bulk export pages
-  // PageArchive: require('./page-archive'),
   PageTagRelation: require('./page-tag-relation'),
   PageTagRelation: require('./page-tag-relation'),
   User: require('./user'),
   User: require('./user'),
   ExternalAccount: require('./external-account'),
   ExternalAccount: require('./external-account'),

+ 0 - 22
apps/app/src/server/models/page-archive.js

@@ -1,22 +0,0 @@
-module.exports = function(crowi) {
-  const mongoose = require('mongoose');
-  const ObjectId = mongoose.Schema.Types.ObjectId;
-
-  const pageArchiveSchema = new mongoose.Schema({
-    owner: {
-      type: ObjectId,
-      ref: 'User',
-      index: true,
-      required: true,
-    },
-    rootPagePath: { type: String, required: true },
-    fileType: { type: String, enum: ['pdf', 'markdown'], required: true },
-    numOfPages: { type: Number, required: true },
-    hasComment: { type: Boolean, required: true },
-    hasAttachment: { type: Boolean, required: true },
-  }, {
-    timestamps: true,
-  });
-
-  return mongoose.model('PageArchive', pageArchiveSchema);
-};

+ 0 - 81
apps/app/src/server/routes/apiv3/page.js

@@ -704,87 +704,6 @@ module.exports = (crowi) => {
 
 
   });
   });
 
 
-  // TODO GW-2746 bulk export pages
-  // /**
-  //  * @swagger
-  //  *
-  //  *    /page/archive:
-  //  *      post:
-  //  *        tags: [Page]
-  //  *        summary: /page/archive
-  //  *        description: create page archive
-  //  *        requestBody:
-  //  *          content:
-  //  *            application/json:
-  //  *              schema:
-  //  *                properties:
-  //  *                  rootPagePath:
-  //  *                    type: string
-  //  *                    description: path of the root page
-  //  *                  isCommentDownload:
-  //  *                    type: boolean
-  //  *                    description: whether archive data contains comments
-  //  *                  isAttachmentFileDownload:
-  //  *                    type: boolean
-  //  *                    description: whether archive data contains attachments
-  //  *                  isSubordinatedPageDownload:
-  //  *                    type: boolean
-  //  *                    description: whether archive data children pages
-  //  *                  fileType:
-  //  *                    type: string
-  //  *                    description: file type of archive data(.md, .pdf)
-  //  *                  hierarchyType:
-  //  *                    type: string
-  //  *                    description: method of select children pages archive data contains('allSubordinatedPage', 'decideHierarchy')
-  //  *                  hierarchyValue:
-  //  *                    type: number
-  //  *                    description: depth of hierarchy(use when hierarchyType is 'decideHierarchy')
-  //  *        responses:
-  //  *          200:
-  //  *            description: create page archive
-  //  *            content:
-  //  *              application/json:
-  //  *                schema:
-  //  *                  $ref: '#/components/schemas/Page'
-  //  */
-  // router.post('/archive', accessTokenParser, loginRequired, validator.archive, apiV3FormValidator, async(req, res) => {
-  //   const PageArchive = crowi.model('PageArchive');
-
-  //   const {
-  //     rootPagePath,
-  //     isCommentDownload,
-  //     isAttachmentFileDownload,
-  //     fileType,
-  //   } = req.body;
-  //   const owner = req.user._id;
-
-  //   const numOfPages = 1; // TODO 最終的にzipファイルに取り込むページ数を入れる
-
-  //   const createdPageArchive = PageArchive.create({
-  //     owner,
-  //     fileType,
-  //     rootPagePath,
-  //     numOfPages,
-  //     hasComment: isCommentDownload,
-  //     hasAttachment: isAttachmentFileDownload,
-  //   });
-
-  //   console.log(createdPageArchive);
-  //   return res.apiv3({ });
-
-  // });
-
-  // router.get('/count-children-pages', accessTokenParser, loginRequired, async(req, res) => {
-
-  //   // TO DO implement correct number at another task
-
-  //   const { pageId } = req.query;
-  //   console.log(pageId);
-
-  //   const dummy = 6;
-  //   return res.apiv3({ dummy });
-  // });
-
   /**
   /**
    * @swagger
    * @swagger
    *
    *