|
@@ -96,6 +96,10 @@ class GrowiImportForm extends React.Component {
|
|
|
this.setupWebsocketEventHandler();
|
|
this.setupWebsocketEventHandler();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ componentWillUnmount() {
|
|
|
|
|
+ this.teardownWebsocketEventHandler();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
setupWebsocketEventHandler() {
|
|
setupWebsocketEventHandler() {
|
|
|
const socket = this.props.websocketContainer.getWebSocket();
|
|
const socket = this.props.websocketContainer.getWebSocket();
|
|
|
|
|
|
|
@@ -126,6 +130,13 @@ class GrowiImportForm extends React.Component {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ teardownWebsocketEventHandler() {
|
|
|
|
|
+ const socket = this.props.websocketContainer.getWebSocket();
|
|
|
|
|
+
|
|
|
|
|
+ socket.removeAllListeners('admin:onProgressForImport');
|
|
|
|
|
+ socket.removeAllListeners('admin:onTerminateForImport');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async toggleCheckbox(collectionName, bool) {
|
|
async toggleCheckbox(collectionName, bool) {
|
|
|
const selectedCollections = new Set(this.state.selectedCollections);
|
|
const selectedCollections = new Set(this.state.selectedCollections);
|
|
|
if (bool) {
|
|
if (bool) {
|
|
@@ -264,7 +275,11 @@ class GrowiImportForm extends React.Component {
|
|
|
const { selectedCollections, optionsMap } = this.state;
|
|
const { selectedCollections, optionsMap } = this.state;
|
|
|
|
|
|
|
|
// init progress data
|
|
// init progress data
|
|
|
- this.setState({ progressMap: [], errorsMap: [] });
|
|
|
|
|
|
|
+ await this.setState({
|
|
|
|
|
+ isImporting: true,
|
|
|
|
|
+ progressMap: [],
|
|
|
|
|
+ errorsMap: [],
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
// TODO: use appContainer.apiv3.post
|
|
// TODO: use appContainer.apiv3.post
|
|
@@ -430,7 +445,10 @@ class GrowiImportForm extends React.Component {
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
const { t } = this.props;
|
|
const { t } = this.props;
|
|
|
- const { warnForPageGroups, warnForUserGroups, warnForConfigGroups } = this.state;
|
|
|
|
|
|
|
+ const {
|
|
|
|
|
+ canImport, isImporting,
|
|
|
|
|
+ warnForPageGroups, warnForUserGroups, warnForConfigGroups,
|
|
|
|
|
+ } = this.state;
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
@@ -456,7 +474,7 @@ class GrowiImportForm extends React.Component {
|
|
|
<button type="button" className="btn btn-default mx-1" onClick={this.props.onDiscard}>
|
|
<button type="button" className="btn btn-default mx-1" onClick={this.props.onDiscard}>
|
|
|
{ t('importer_management.growi_settings.discard') }
|
|
{ t('importer_management.growi_settings.discard') }
|
|
|
</button>
|
|
</button>
|
|
|
- <button type="button" className="btn btn-primary mx-1" onClick={this.import} disabled={!this.state.canImport}>
|
|
|
|
|
|
|
+ <button type="button" className="btn btn-primary mx-1" onClick={this.import} disabled={!canImport || isImporting}>
|
|
|
{ t('importer_management.import') }
|
|
{ t('importer_management.import') }
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|