mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 02:48:51 +00:00
update draft&review dispaly (#2505)
* replace draft.id with draft_name * add updateDraftsList function * Repair operation display * update review dispaly * refactor code
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { siteRoot, gettext } from '../../utils/constants';
|
||||
import editUtilties from '../../utils/editor-utilties';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import Toast from '../../components/toast';
|
||||
import Loading from '../../components/loading';
|
||||
import DraftListView from '../../components/draft-list-view/draft-list-view';
|
||||
@@ -12,7 +13,6 @@ class DraftContent extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isLoadingDraft: true,
|
||||
isMenuShow: false,
|
||||
menuPosition: {top:'', left: ''},
|
||||
currentDraft: null,
|
||||
@@ -21,7 +21,6 @@ class DraftContent extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.initDraftList();
|
||||
document.addEventListener('click', this.onHideContextMenu);
|
||||
}
|
||||
|
||||
@@ -29,38 +28,32 @@ class DraftContent extends React.Component {
|
||||
document.removeEventListener('click', this.onHideContextMenu);
|
||||
}
|
||||
|
||||
initDraftList() {
|
||||
this.setState({isLoadingDraft: true});
|
||||
this.props.getDrafts();
|
||||
this.setState({
|
||||
isLoadingDraft: false,
|
||||
});
|
||||
}
|
||||
|
||||
onDeleteHandler = () => {
|
||||
let draft = this.state.currentDraft;
|
||||
let draft_name = Utils.getFileName(draft.draft_file_path);
|
||||
editUtilties.deleteDraft(draft.id).then(res => {
|
||||
this.initDraftList();
|
||||
this.props.updateDraftsList(draft.id);
|
||||
let msg_s = gettext('Successfully deleted draft %(draft)s.');
|
||||
msg_s = msg_s.replace('%(draft)s', draft.id);
|
||||
msg_s = msg_s.replace('%(draft)s', draft_name);
|
||||
Toast.success(msg_s);
|
||||
}).catch(() => {
|
||||
let msg_s = gettext('Failed to delete draft %(draft)s.');
|
||||
msg_s = msg_s.replace('%(draft)s', draft.id);
|
||||
msg_s = msg_s.replace('%(draft)s', draft_name);
|
||||
Toast.error(msg_s);
|
||||
});
|
||||
}
|
||||
|
||||
onPublishHandler = () => {
|
||||
let draft = this.state.currentDraft;
|
||||
let draft_name = Utils.getFileName(draft.draft_file_path);
|
||||
editUtilties.publishDraft(draft.id).then(res => {
|
||||
this.initDraftList();
|
||||
this.props.updateDraftsList(draft.id);
|
||||
let msg_s = gettext('Successfully published draft %(draft)s.');
|
||||
msg_s = msg_s.replace('%(draft)s', draft.id);
|
||||
msg_s = msg_s.replace('%(draft)s', draft_name);
|
||||
Toast.success(msg_s);
|
||||
}).catch(() => {
|
||||
let msg_s = gettext('Failed to publish draft %(draft)s.');
|
||||
msg_s = msg_s.replace('%(draft)s', draft.id);
|
||||
msg_s = msg_s.replace('%(draft)s', draft_name);
|
||||
Toast.error(msg_s);
|
||||
});
|
||||
}
|
||||
@@ -109,15 +102,15 @@ class DraftContent extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="cur-view-content">
|
||||
{this.state.isLoadingDraft && <Loading /> }
|
||||
{(!this.state.isLoadingDraft && this.props.draftList.length !==0) &&
|
||||
{this.props.isLoadingDraft && <Loading /> }
|
||||
{(!this.props.isLoadingDraft && this.props.draftList.length !==0) &&
|
||||
<DraftListView
|
||||
draftList={this.props.draftList}
|
||||
isItemFreezed={this.state.isItemFreezed}
|
||||
onMenuToggleClick={this.onMenuToggleClick}
|
||||
/>
|
||||
}
|
||||
{(!this.state.isLoadingDraft && this.props.draftList.length === 0) &&
|
||||
{(!this.props.isLoadingDraft && this.props.draftList.length === 0) &&
|
||||
<div className="message empty-tip">
|
||||
<h2>{gettext('No draft yet')}</h2>
|
||||
<p>{gettext('Draft is a way to let you collaborate with others on files. You can create a draft from a file, edit the draft and then ask for a review. The original file will be updated only after the draft be reviewed.')}</p>
|
||||
|
Reference in New Issue
Block a user