Skip to content

Commit

Permalink
optimize wiki convert ui (#7004)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoinTyang authored Nov 7, 2024
1 parent 57caadd commit d823a02
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
39 changes: 39 additions & 0 deletions frontend/src/components/dialog/wiki-convert-status-dialog.js
Original file line number Diff line number Diff line change
@@ -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;
55 changes: 54 additions & 1 deletion frontend/src/pages/wikis/wikis.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import AddWikiDialog from '../../components/dialog/add-wiki-dialog';
import wikiAPI from '../../utils/wiki-api';
import WikiCardView from '../../components/wiki-card-view/wiki-card-view';
import { seafileAPI } from '../../utils/seafile-api';
import { userAPI } from '../../utils/user-api';
import WikiConvertStatusDialog from '../../components/dialog/wiki-convert-status-dialog';


const propTypes = {
Expand All @@ -29,6 +31,7 @@ class Wikis extends Component {
isShowAddWikiMenu: false,
isShowAddDialog: false,
isDropdownMenuShown: false,
isShowConvertStatusDialog: false,
};
}

Expand Down Expand Up @@ -250,14 +253,59 @@ class Wikis extends Component {
};

convertWiki = (wiki, wikiName, departmentID) => {
let task_id = '';
this.setState({
isShowConvertStatusDialog: true,
});
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) => {
this.setState({
isShowConvertStatusDialog: false
});
if (error.response) {
let errorMsg = error.response.data.error_msg;
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) => {
Expand All @@ -270,6 +318,11 @@ class Wikis extends Component {
render() {
return (
<Fragment>
{this.state.isShowConvertStatusDialog &&
<WikiConvertStatusDialog
toggle={this.onConvertStatusToggle}
/>
}
{this.state.isShowAddDialog &&
<ModalPortal>
<AddWikiDialog
Expand Down

0 comments on commit d823a02

Please sign in to comment.