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