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) &&
{draftInfo.last_modifier_name}{time}
@@ -759,17 +760,17 @@ class Draft extends React.Component {
{this.renderDiffButton()} - {(draftFileExists && !freezePublish) && + {showEditButton && } - {canPublish && + {showPublishButton && } - {freezePublish && + {showPublishedButton && diff --git a/seahub/api2/endpoints/drafts.py b/seahub/api2/endpoints/drafts.py index 0e341a6505..167d9dcfb7 100644 --- a/seahub/api2/endpoints/drafts.py +++ b/seahub/api2/endpoints/drafts.py @@ -173,7 +173,10 @@ class DraftView(APIView): # 3. Send draft file publish msg. send_draft_publish_msg(draft, username, dst_file_path) - return Response({'published_file_path': dst_file_path}) + result = {} + result['published_file_path'] = dst_file_path + result['draft_status'] = draft.status + return Response(result) except Exception as e: logger.error(e) error_msg = 'Internal Server Error'