mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 01:12:03 +00:00
add review && draft
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import MarkdownViewer from '@seafile/seafile-editor/dist/viewer/markdown-viewer';
|
||||
import { Tooltip } from 'reactstrap';
|
||||
|
||||
const gettext = window.gettext;
|
||||
|
||||
@@ -16,6 +17,15 @@ const viewerPropTypes = {
|
||||
const contentClass = 'markdown-content';
|
||||
|
||||
class MarkdownContentViewer extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
showReviewTip: false,
|
||||
showDraftTip: false,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidUpdate () {
|
||||
var links = document.querySelectorAll(`.${contentClass} a`);
|
||||
links.forEach((li) => {li.addEventListener('click', this.onLinkClick); });
|
||||
@@ -34,6 +44,24 @@ class MarkdownContentViewer extends React.Component {
|
||||
}
|
||||
return (
|
||||
<div className="markdown-content">
|
||||
{this.props.reviewStatus === 'open' &&
|
||||
<div className='seafile-btn-view-review text-center'>
|
||||
<div className='tag tag-green'>
|
||||
{gettext('This file is in review stage')}
|
||||
<a className="ml-2" onMouseDown={this.props.goReviewPage}>{gettext('View Review')}</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
{(!this.props.isDraft && this.props.hasDraft && this.props.reviewStatus !== 'open') &&
|
||||
<div className='seafile-btn-view-review text-center'>
|
||||
<div className='tag tag-green'>
|
||||
{gettext('This file is in draft stage.')}
|
||||
<a className="ml-2" onMouseDown={this.props.goDraftPage}>{gettext('Edit Draft')}</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<MarkdownViewer markdownContent={this.props.markdownContent} showTOC={true}
|
||||
activeTitleIndex={this.props.activeTitleIndex}
|
||||
onContentRendered={this.props.onContentRendered}
|
||||
|
@@ -19,9 +19,6 @@ const propTypes = {
|
||||
onUploadFolder: PropTypes.func.isRequired,
|
||||
isDraft: PropTypes.bool,
|
||||
hasDraft: PropTypes.bool,
|
||||
reviewStatus: PropTypes.any,
|
||||
goDraftPage: PropTypes.func,
|
||||
goReviewPage: PropTypes.func,
|
||||
};
|
||||
|
||||
class DirOperationToolbar extends React.Component {
|
||||
@@ -149,22 +146,15 @@ class DirOperationToolbar extends React.Component {
|
||||
return (
|
||||
<Fragment>
|
||||
<div className="operation">
|
||||
{(this.props.isViewFile && this.props.permission === 'rw') && (
|
||||
{(this.props.isViewFile && this.props.permission === 'rw' && !this.props.hasDraft ) && (
|
||||
<Fragment>
|
||||
<button className="btn btn-secondary operation-item" title={gettext('Edit File')} onClick={this.onEditClick}>{gettext('Edit')}</button>
|
||||
<button className="btn btn-secondary operation-item" title={gettext('Share')} onClick={this.onShareClick}>{gettext('Share')}</button>
|
||||
</Fragment>
|
||||
)}
|
||||
|
||||
{(this.props.isViewFile && this.props.permission !== 'None' && !this.props.isDraft && !this.props.hasDraft) && (
|
||||
{(this.props.isViewFile && !this.props.isDraft && !this.props.hasDraft) && (
|
||||
<button className="btn btn-secondary operation-item" title={gettext('New Draft')} onClick={this.onNewDraft}>{gettext('New Draft')}</button>
|
||||
)}
|
||||
{(this.props.reviewStatus === 'open') &&
|
||||
<button className="btn btn-secondary operation-item" title={gettext('View Review')} onClick={this.onViewReview}>{gettext('View Review')}</button>
|
||||
}
|
||||
{(!this.props.isDraft && this.props.hasDraft) &&
|
||||
<button className="btn btn-secondary operation-item" title={gettext('View Draft')} onClick={this.onViewDraft}>{gettext('View Draft')}</button>
|
||||
}
|
||||
|
||||
{!this.props.isViewFile && (
|
||||
<Fragment>
|
||||
@@ -173,9 +163,9 @@ class DirOperationToolbar extends React.Component {
|
||||
<button className="btn btn-secondary operation-item" title={gettext('Upload')} onClick={this.uploadFile}>{gettext('Upload')}</button>
|
||||
}
|
||||
<button className="btn btn-secondary operation-item" title={gettext('New')} onClick={this.onCreateClick}>{gettext('New')}</button>
|
||||
<button className="btn btn-secondary operation-item" title={gettext('Share')} onClick={this.onShareClick}>{gettext('Share')}</button>
|
||||
</Fragment>
|
||||
)}
|
||||
<button className="btn btn-secondary operation-item" title={gettext('Share')} onClick={this.onShareClick}>{gettext('Share')}</button>
|
||||
</div>
|
||||
{this.state.isUploadMenuShow && (
|
||||
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
|
||||
|
@@ -54,6 +54,7 @@ const propTypes = {
|
||||
reviewStatus: PropTypes.any,
|
||||
goReviewPage: PropTypes.func,
|
||||
goDraftPage: PropTypes.func,
|
||||
reviewID: PropTypes.any,
|
||||
};
|
||||
|
||||
class MainPanel extends Component {
|
||||
@@ -193,9 +194,6 @@ class MainPanel extends Component {
|
||||
repoID={repoID}
|
||||
isDraft={this.props.isDraft}
|
||||
hasDraft={this.props.hasDraft}
|
||||
reviewStatus={this.props.reviewStatus}
|
||||
goDraftPage={this.props.goDraftPage}
|
||||
goReviewPage={this.props.goReviewPage}
|
||||
permission={this.props.permission}
|
||||
isViewFile={this.props.isViewFile}
|
||||
onAddFile={this.props.onAddFile}
|
||||
@@ -236,6 +234,12 @@ class MainPanel extends Component {
|
||||
activeTitleIndex={this.state.activeTitleIndex}
|
||||
onContentRendered={this.onContentRendered}
|
||||
onLinkClick={this.props.onLinkClick}
|
||||
isDraft={this.props.isDraft}
|
||||
hasDraft={this.props.hasDraft}
|
||||
reviewID={this.props.reviewID}
|
||||
reviewStatus={this.props.reviewStatus}
|
||||
goDraftPage={this.props.goDraftPage}
|
||||
goReviewPage={this.props.goReviewPage}
|
||||
/> :
|
||||
<Fragment>
|
||||
<DirentListView
|
||||
|
@@ -870,6 +870,7 @@ class Wiki extends Component {
|
||||
isDraft={this.state.isDraft}
|
||||
hasDraft={this.state.hasDraft}
|
||||
reviewStatus={this.state.reviewStatus}
|
||||
reviewID={this.state.reviewID}
|
||||
goDraftPage={this.goDraftPage}
|
||||
goReviewPage={this.goReviewPage}
|
||||
/>
|
||||
|
@@ -92,10 +92,10 @@ def get_file_review(repo_id, file_path, is_draft=False, has_draft=False):
|
||||
|
||||
if file_uuid:
|
||||
try:
|
||||
DraftReview.objects.get(origin_file_uuid=file_uuid)
|
||||
d_r = DraftReview.objects.get(origin_file_uuid=file_uuid)
|
||||
review['review_id'] = d_r.id
|
||||
review['review_status'] = d_r.status
|
||||
review['draft_id'] = d_r.draft_id.id
|
||||
review['draft_id'] = d_r.draft_id_id
|
||||
review['draft_file_path'] = d_r.draft_file_path
|
||||
except DraftReview.DoesNotExist:
|
||||
pass
|
||||
|
Reference in New Issue
Block a user