|
|
@@ -1,6 +1,7 @@
|
|
|
import React, { Fragment } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
import { withTranslation } from 'react-i18next';
|
|
|
+import * as toastr from 'toastr';
|
|
|
|
|
|
import { createSubscribedElement } from '../../UnstatedUtils';
|
|
|
import AppContainer from '../../../services/AppContainer';
|
|
|
@@ -46,15 +47,39 @@ class GrowiImportForm extends React.Component {
|
|
|
async import(e) {
|
|
|
e.preventDefault();
|
|
|
|
|
|
- // TODO use appContainer.apiv3.post
|
|
|
- await this.props.appContainer.apiPost('/v3/import', {
|
|
|
- fileName: this.props.fileName,
|
|
|
- collections: Array.from(this.state.collections),
|
|
|
- schema: this.state.schema,
|
|
|
- });
|
|
|
- // TODO toastSuccess, toastError
|
|
|
- this.setState(this.initialState);
|
|
|
- this.props.onPostImport();
|
|
|
+ try {
|
|
|
+ // TODO use appContainer.apiv3.post
|
|
|
+ await this.props.appContainer.apiPost('/v3/import', {
|
|
|
+ fileName: this.props.fileName,
|
|
|
+ collections: Array.from(this.state.collections),
|
|
|
+ schema: this.state.schema,
|
|
|
+ });
|
|
|
+
|
|
|
+ this.setState(this.initialState);
|
|
|
+ this.props.onPostImport();
|
|
|
+
|
|
|
+ // TODO toastSuccess, toastError
|
|
|
+ toastr.success(undefined, 'Imported documents', {
|
|
|
+ closeButton: true,
|
|
|
+ progressBar: true,
|
|
|
+ newestOnTop: false,
|
|
|
+ showDuration: '100',
|
|
|
+ hideDuration: '100',
|
|
|
+ timeOut: '1200',
|
|
|
+ extendedTimeOut: '150',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ // TODO toastSuccess, toastError
|
|
|
+ toastr.error(err, 'Error', {
|
|
|
+ closeButton: true,
|
|
|
+ progressBar: true,
|
|
|
+ newestOnTop: false,
|
|
|
+ showDuration: '100',
|
|
|
+ hideDuration: '100',
|
|
|
+ timeOut: '3000',
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
validateForm() {
|