mizozobu 6 лет назад
Родитель
Сommit
b7ff4eac31

+ 5 - 5
src/client/js/components/Admin/Export/ExportPage.jsx

@@ -27,15 +27,15 @@ class ExportPage extends React.Component {
   }
   }
 
 
   async componentDidMount() {
   async componentDidMount() {
-    // TODO: use apiv3.get
+    // TODO:: use apiv3.get
     // eslint-disable-next-line no-unused-vars
     // eslint-disable-next-line no-unused-vars
     const [{ collections }, { zipFileStats }] = await Promise.all([
     const [{ collections }, { zipFileStats }] = await Promise.all([
       this.props.appContainer.apiGet('/v3/mongo/collections', {}),
       this.props.appContainer.apiGet('/v3/mongo/collections', {}),
       this.props.appContainer.apiGet('/v3/export/status', {}),
       this.props.appContainer.apiGet('/v3/export/status', {}),
     ]);
     ]);
-    // TODO toastSuccess, toastError
+    // TODO: toastSuccess, toastError
 
 
-    this.setState({ collections: ['pages', 'revisions'], zipFileStats }); // FIXME
+    this.setState({ collections: ['pages', 'revisions'], zipFileStats }); // FIXME: delete this line and uncomment the line below
     // this.setState({ collections, zipFileStats });
     // this.setState({ collections, zipFileStats });
   }
   }
 
 
@@ -57,7 +57,7 @@ class ExportPage extends React.Component {
         };
         };
       });
       });
 
 
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       toastr.success(undefined, `Deleted ${fileName}`, {
       toastr.success(undefined, `Deleted ${fileName}`, {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,
@@ -69,7 +69,7 @@ class ExportPage extends React.Component {
       });
       });
     }
     }
     catch (err) {
     catch (err) {
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       toastr.error(err, 'Error', {
       toastr.error(err, 'Error', {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,

+ 4 - 4
src/client/js/components/Admin/Export/ExportZipFormModal.jsx

@@ -53,13 +53,13 @@ class ExportZipFormModal extends React.Component {
     e.preventDefault();
     e.preventDefault();
 
 
     try {
     try {
-      // TODO use appContainer.apiv3.post
+      // TODO: use appContainer.apiv3.post
       const { zipFileStat } = await this.props.appContainer.apiPost('/v3/export', { collections: Array.from(this.state.collections) });
       const { zipFileStat } = await this.props.appContainer.apiPost('/v3/export', { collections: Array.from(this.state.collections) });
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       this.props.onZipFileStatAdd(zipFileStat);
       this.props.onZipFileStatAdd(zipFileStat);
       this.props.onClose();
       this.props.onClose();
 
 
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       toastr.success(undefined, `Generated ${zipFileStat.fileName}`, {
       toastr.success(undefined, `Generated ${zipFileStat.fileName}`, {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,
@@ -71,7 +71,7 @@ class ExportZipFormModal extends React.Component {
       });
       });
     }
     }
     catch (err) {
     catch (err) {
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       toastr.error(err, 'Error', {
       toastr.error(err, 'Error', {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,

+ 3 - 3
src/client/js/components/Admin/Import/GrowiZipImportForm.jsx

@@ -48,7 +48,7 @@ class GrowiImportForm extends React.Component {
     e.preventDefault();
     e.preventDefault();
 
 
     try {
     try {
-      // TODO use appContainer.apiv3.post
+      // TODO: use appContainer.apiv3.post
       const { results } = await this.props.appContainer.apiPost('/v3/import', {
       const { results } = await this.props.appContainer.apiPost('/v3/import', {
         fileName: this.props.fileName,
         fileName: this.props.fileName,
         collections: Array.from(this.state.collections),
         collections: Array.from(this.state.collections),
@@ -58,7 +58,7 @@ class GrowiImportForm extends React.Component {
       this.setState(this.initialState);
       this.setState(this.initialState);
       this.props.onPostImport();
       this.props.onPostImport();
 
 
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       toastr.success(undefined, 'Imported documents', {
       toastr.success(undefined, 'Imported documents', {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,
@@ -81,7 +81,7 @@ class GrowiImportForm extends React.Component {
       }
       }
     }
     }
     catch (err) {
     catch (err) {
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       toastr.error(err, 'Error', {
       toastr.error(err, 'Error', {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,

+ 2 - 2
src/client/js/components/Admin/Import/GrowiZipImportSection.jsx

@@ -39,7 +39,7 @@ class GrowiZipImportSection extends React.Component {
       await this.props.appContainer.apiRequest('delete', `/v3/import/${this.state.fileName}`, {});
       await this.props.appContainer.apiRequest('delete', `/v3/import/${this.state.fileName}`, {});
       this.resetState();
       this.resetState();
 
 
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       toastr.success(undefined, `Deleted ${fileName}`, {
       toastr.success(undefined, `Deleted ${fileName}`, {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,
@@ -51,7 +51,7 @@ class GrowiZipImportSection extends React.Component {
       });
       });
     }
     }
     catch (err) {
     catch (err) {
-      // TODO toastSuccess, toastError
+      // TODO: toastSuccess, toastError
       toastr.error(err, 'Error', {
       toastr.error(err, 'Error', {
         closeButton: true,
         closeButton: true,
         progressBar: true,
         progressBar: true,

+ 2 - 2
src/client/js/components/Admin/Import/GrowiZipUploadForm.jsx

@@ -31,10 +31,10 @@ class GrowiZipUploadForm extends React.Component {
     formData.append('_csrf', this.props.appContainer.csrfToken);
     formData.append('_csrf', this.props.appContainer.csrfToken);
     formData.append('file', this.inputRef.current.files[0]);
     formData.append('file', this.inputRef.current.files[0]);
 
 
-    // TODO use appContainer.apiv3.post
+    // TODO: use appContainer.apiv3.post
     const { data } = await this.props.appContainer.apiPost('/v3/import/upload', formData);
     const { data } = await this.props.appContainer.apiPost('/v3/import/upload', formData);
     this.props.onUpload(data);
     this.props.onUpload(data);
-    // TODO toastSuccess, toastError
+    // TODO: toastSuccess, toastError
   }
   }
 
 
   validateForm() {
   validateForm() {

+ 1 - 0
src/server/service/import.js

@@ -70,6 +70,7 @@ class ImportService {
    * @return {insertedIds: Array.<string>, failedIds: Array.<string>}
    * @return {insertedIds: Array.<string>, failedIds: Array.<string>}
    */
    */
   async import(Model, jsonFile, overwriteParams = {}) {
   async import(Model, jsonFile, overwriteParams = {}) {
+    // streamToPromise(jsonStream) throws an error, use new Promise instead
     return new Promise((resolve, reject) => {
     return new Promise((resolve, reject) => {
       const { collectionName } = Model.collection;
       const { collectionName } = Model.collection;