mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 22:01:06 +00:00
optimize wiki convert ui (#7004)
This commit is contained in:
39
frontend/src/components/dialog/wiki-convert-status-dialog.js
Normal file
39
frontend/src/components/dialog/wiki-convert-status-dialog.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { Modal, ModalBody, ModalHeader } from 'reactstrap';
|
||||||
|
import { gettext } from '../../utils/constants';
|
||||||
|
import Loading from '../loading';
|
||||||
|
|
||||||
|
import '../../css/seahub-io-dialog.css';
|
||||||
|
|
||||||
|
|
||||||
|
const propTypes = {
|
||||||
|
toggle: PropTypes.func.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
class WikiConvertStatusDialog extends React.Component {
|
||||||
|
|
||||||
|
toggle = () => {
|
||||||
|
this.props.toggle();
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Modal className='seahub-io-dialog' isOpen={true} toggle={this.toggle}>
|
||||||
|
<ModalHeader toggle={this.toggle}>
|
||||||
|
{gettext('Converting')}
|
||||||
|
</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<>
|
||||||
|
<Loading/>
|
||||||
|
<div className="seahub-io-dialog-parsing-text">{gettext('Converting...')}</div>
|
||||||
|
</>
|
||||||
|
</ModalBody>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WikiConvertStatusDialog.propTypes = propTypes;
|
||||||
|
|
||||||
|
export default WikiConvertStatusDialog;
|
@@ -10,6 +10,8 @@ import AddWikiDialog from '../../components/dialog/add-wiki-dialog';
|
|||||||
import wikiAPI from '../../utils/wiki-api';
|
import wikiAPI from '../../utils/wiki-api';
|
||||||
import WikiCardView from '../../components/wiki-card-view/wiki-card-view';
|
import WikiCardView from '../../components/wiki-card-view/wiki-card-view';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
|
import { userAPI } from '../../utils/user-api';
|
||||||
|
import WikiConvertStatusDialog from '../../components/dialog/wiki-convert-status-dialog';
|
||||||
|
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
@@ -29,6 +31,7 @@ class Wikis extends Component {
|
|||||||
isShowAddWikiMenu: false,
|
isShowAddWikiMenu: false,
|
||||||
isShowAddDialog: false,
|
isShowAddDialog: false,
|
||||||
isDropdownMenuShown: false,
|
isDropdownMenuShown: false,
|
||||||
|
isShowConvertStatusDialog: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,14 +253,59 @@ class Wikis extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
convertWiki = (wiki, wikiName, departmentID) => {
|
convertWiki = (wiki, wikiName, departmentID) => {
|
||||||
|
let task_id = '';
|
||||||
|
this.setState({
|
||||||
|
isShowConvertStatusDialog: true,
|
||||||
|
});
|
||||||
wikiAPI.convertWiki(wiki.id, wikiName, departmentID).then((res) => {
|
wikiAPI.convertWiki(wiki.id, wikiName, departmentID).then((res) => {
|
||||||
this.getWikis();
|
task_id = res.data.task_id;
|
||||||
|
return userAPI.queryIOStatus(task_id);
|
||||||
|
}).then(res => {
|
||||||
|
if (res.data.is_finished === true) {
|
||||||
|
this.setState({
|
||||||
|
isShowConvertStatusDialog: false,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.queryConvertStatus(task_id);
|
||||||
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
this.setState({
|
||||||
|
isShowConvertStatusDialog: false
|
||||||
|
});
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
let errorMsg = error.response.data.error_msg;
|
let errorMsg = error.response.data.error_msg;
|
||||||
toaster.danger(errorMsg);
|
toaster.danger(errorMsg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.getWikis();
|
||||||
|
};
|
||||||
|
|
||||||
|
onConvertStatusToggle = () => {
|
||||||
|
this.setState({
|
||||||
|
isShowConvertDialog: !this.state.isShowConvertStatusDialog,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
queryConvertStatus = (task_id) => {
|
||||||
|
userAPI.queryIOStatus(task_id).then(res => {
|
||||||
|
if (res.data.is_finished === true) {
|
||||||
|
this.setState({
|
||||||
|
isShowConvertStatusDialog: false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.queryConvertStatus(task_id);
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
this.setState({
|
||||||
|
isShowConvertStatusDialog: false
|
||||||
|
});
|
||||||
|
if (err.response) {
|
||||||
|
let errorMsg = err.response.data.error_msg;
|
||||||
|
toaster.danger(errorMsg);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
toggleDropdownMenu = (e) => {
|
toggleDropdownMenu = (e) => {
|
||||||
@@ -270,6 +318,11 @@ class Wikis extends Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
{this.state.isShowConvertStatusDialog &&
|
||||||
|
<WikiConvertStatusDialog
|
||||||
|
toggle={this.onConvertStatusToggle}
|
||||||
|
/>
|
||||||
|
}
|
||||||
{this.state.isShowAddDialog &&
|
{this.state.isShowAddDialog &&
|
||||||
<ModalPortal>
|
<ModalPortal>
|
||||||
<AddWikiDialog
|
<AddWikiDialog
|
||||||
|
Reference in New Issue
Block a user