diff --git a/frontend/src/draft.js b/frontend/src/draft.js index c62e17dffb..185858c5fd 100644 --- a/frontend/src/draft.js +++ b/frontend/src/draft.js @@ -56,7 +56,7 @@ class Draft extends React.Component { reviewers: [], inResizing: false, rightPartWidth: 30, - freezePublish: false + draftStatus: window.draft.config.draftStatus, }; this.quote = ''; this.newIndex = null; @@ -410,7 +410,7 @@ class Draft extends React.Component { onPublishDraft = () => { seafileAPI.publishDraft(draftID).then(res => { this.setState({ - freezePublish: !this.state.freezePublish + draftStatus: res.data.draft_status, }); }); } @@ -734,8 +734,9 @@ class Draft extends React.Component { const { draftInfo, reviewers, originRepoName } = this.state; const onResizeMove = this.state.inResizing ? this.onResizeMouseMove : null; const draftLink = siteRoot + 'lib/' + draftRepoID + '/file' + draftFilePath + '?mode=edit'; - const freezePublish = (this.state.freezePublish || draftStatus === 'published') ? true : false; - const canPublish = !this.state.freezePublish && draftFileExists && filePermission == 'rw'; + const showPublishedButton = this.state.draftStatus == 'published'; + const showPublishButton = this.state.draftStatus == 'open' && filePermission == 'rw'; + const showEditButton = this.state.draftStatus == 'open' && filePermission == 'rw'; const time = moment(draftInfo.mtime * 1000).format('YYYY-MM-DD HH:mm'); const url = `${siteRoot}profile/${encodeURIComponent(draftInfo.last_modifier_email)}/`; return( @@ -750,7 +751,7 @@ class Draft extends React.Component { {draftFileName} {gettext('Review')} - {(!freezePublish && draftInfo.mtime) && + {(!showPublishedButton && draftInfo.mtime) &&
@@ -759,17 +760,17 @@ class Draft extends React.Component {