1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 08:28:11 +00:00

Adjust Draft Page (#3288)

* add start review

* adjust draft page
This commit is contained in:
Michael An
2019-04-17 10:31:17 +08:00
committed by Daniel Pan
parent 7e23be8ea7
commit c1453c6f3d
4 changed files with 41 additions and 14 deletions

View File

@@ -32,7 +32,7 @@ const MoreMenuPropTypes = {
openDialogs: PropTypes.func.isRequired, openDialogs: PropTypes.func.isRequired,
onEdit: PropTypes.func.isRequired, onEdit: PropTypes.func.isRequired,
editorMode: PropTypes.string.isRequired editorMode: PropTypes.string.isRequired
} };
class MoreMenu extends React.PureComponent { class MoreMenu extends React.PureComponent {
@@ -108,6 +108,14 @@ class MarkdownViewerToolbar extends React.Component {
<button onMouseDown={this.props.toggleNewDraft} className="btn btn-success btn-new-draft"> <button onMouseDown={this.props.toggleNewDraft} className="btn btn-success btn-new-draft">
{gettext('New Draft')}</button> {gettext('New Draft')}</button>
} }
{this.props.isDraft &&
<div>
<button type="button" className="btn btn-success seafile-btn-add-review"
onMouseDown={this.props.editorUtilities.goDraftPage}>{gettext('Start review')}</button>
<button type="button" className="btn btn-success seafile-btn-add-review"
onMouseDown={this.props.editorUtilities.publishDraftFile}>{gettext('Publish')}</button>
</div>
}
{this.props.collabUsers.length > 0 && <CollabUsersButton className={'collab-users-dropdown'} {this.props.collabUsers.length > 0 && <CollabUsersButton className={'collab-users-dropdown'}
users={this.props.collabUsers} id={'usersButton'} />} users={this.props.collabUsers} id={'usersButton'} />}
<ButtonGroup> <ButtonGroup>

View File

@@ -61,6 +61,16 @@
font-weight: normal; font-weight: normal;
} }
.file-info .file-review {
color: #999;
font-size: 1rem;
font-weight: 400;
}
.cur-file-info .last-modification {
font-size: 0.8125rem;
}
.seafile-toggle-diff { .seafile-toggle-diff {
display: flex; display: flex;
margin-right: 10px; margin-right: 10px;

View File

@@ -21,7 +21,6 @@ import classnames from 'classnames';
import HistoryList from './pages/review/history-list'; import HistoryList from './pages/review/history-list';
import { Value, Document, Block } from 'slate'; import { Value, Document, Block } from 'slate';
import ModalPortal from './components/modal-portal'; import ModalPortal from './components/modal-portal';
import { Utils } from './utils/utils';
import './assets/css/fa-solid.css'; import './assets/css/fa-solid.css';
import './assets/css/fa-regular.css'; import './assets/css/fa-regular.css';
@@ -33,6 +32,7 @@ import './css/draft.css';
require('@seafile/seafile-editor/dist/editor/code-hight-package'); require('@seafile/seafile-editor/dist/editor/code-hight-package');
const URL = require('url-parse'); const URL = require('url-parse');
var moment = require('moment');
class Draft extends React.Component { class Draft extends React.Component {
constructor(props) { constructor(props) {
@@ -40,6 +40,7 @@ class Draft extends React.Component {
this.state = { this.state = {
draftContent: '', draftContent: '',
draftOriginContent: '', draftOriginContent: '',
draftInfo: {},
isLoading: true, isLoading: true,
isShowDiff: true, isShowDiff: true,
showDiffTip: false, showDiffTip: false,
@@ -247,6 +248,12 @@ class Draft extends React.Component {
}); });
} }
getDraftInfo = () => {
seafileAPI.getFileInfo(draftRepoID, draftFilePath).then((res) => {
this.setState({ draftInfo: res.data });
});
}
getChangedNodes = () => { getChangedNodes = () => {
const nodes = this.refs.diffViewer.value.document.nodes; const nodes = this.refs.diffViewer.value.document.nodes;
let keys = []; let keys = [];
@@ -677,6 +684,7 @@ class Draft extends React.Component {
this.getCommentsNumber(); this.getCommentsNumber();
this.listReviewers(); this.listReviewers();
this.getOriginRepoInfo(); this.getOriginRepoInfo();
this.getDraftInfo();
} }
componentDidMount() { componentDidMount() {
@@ -764,6 +772,8 @@ class Draft extends React.Component {
const draftLink = siteRoot + 'lib/' + draftRepoID + '/file' + draftFilePath + '?mode=edit'; const draftLink = siteRoot + 'lib/' + draftRepoID + '/file' + draftFilePath + '?mode=edit';
const freezePublish = (this.state.freezePublish || draftStatus === 'published') ? true : false; const freezePublish = (this.state.freezePublish || draftStatus === 'published') ? true : false;
const canPublish = !this.state.freezePublish && draftFileExists; const canPublish = !this.state.freezePublish && draftFileExists;
const time = moment(this.state.draftInfo.mtime * 1000).format('YYYY-MM-DD HH:mm');
const url = `${siteRoot}profile/${encodeURIComponent(this.state.draftInfo.last_modifier_email)}/`;
return( return(
<div className="wrapper"> <div className="wrapper">
<div id="header" className="header review"> <div id="header" className="header review">
@@ -771,17 +781,21 @@ class Draft extends React.Component {
<div className="info-item file-feature"> <div className="info-item file-feature">
<span className="sf2-icon-review"></span> <span className="sf2-icon-review"></span>
</div> </div>
<div>
<div className="info-item file-info"> <div className="info-item file-info">
<React.Fragment>
<span className="file-name">{draftFileName}</span> <span className="file-name">{draftFileName}</span>
{draftFileExists && <span className="mx-2 file-review">{gettext('Review')}</span>
<a href={draftLink} className="draft-link">{gettext('Edit draft')}</a> </div>
} <div className="last-modification">
</React.Fragment> <a href={url}>{this.state.draftInfo.last_modifier_name}</a><span className="mx-1">{time}</span>
</div>
</div> </div>
</div> </div>
<div className="button-group"> <div className="button-group">
{this.renderDiffButton()} {this.renderDiffButton()}
{draftFileExists &&
<a href={draftLink} className="mx-xl-1"><Button color="secondary">{gettext('Edit Draft')}</Button></a>
}
{canPublish && {canPublish &&
<button <button
className='btn btn-success file-operation-btn' className='btn btn-success file-operation-btn'
@@ -834,10 +848,7 @@ class Draft extends React.Component {
changedNumber={this.state.changedNodes.length} changedNumber={this.state.changedNodes.length}
scrollToChangedNode={this.scrollToChangedNode}/> scrollToChangedNode={this.scrollToChangedNode}/>
} }
<SidePanelOrigin originRepoName={this.state.originRepoName}/> <SidePanelOrigin originRepoName={this.state.originRepoName} draftInfo={this.state.draftInfo}/>
{draftFileExists &&
<a href={draftLink}><Button color="secondary">{gettext('Edit Draft')}</Button></a>
}
</div> </div>
</TabPane> </TabPane>
<TabPane tabId="comments" className="comments"> <TabPane tabId="comments" className="comments">

View File

@@ -503,7 +503,6 @@ class MarkdownEditor extends React.Component {
const contentLength = res.data.length; const contentLength = res.data.length;
let isBlankFile = (contentLength === 0 || contentLength === 1); let isBlankFile = (contentLength === 0 || contentLength === 1);
let hasPermission = (this.state.fileInfo.permission === 'rw'); let hasPermission = (this.state.fileInfo.permission === 'rw');
let isEditMode = mode === 'edit' ? true : false;
let value = deserialize(res.data); let value = deserialize(res.data);
this.setState({ this.setState({
markdownContent: res.data, markdownContent: res.data,
@@ -661,7 +660,6 @@ class MarkdownEditor extends React.Component {
render() { render() {
let component; let component;
let sidePanel = this.state.isShowHistory ? true : false;
if (this.state.loading) { if (this.state.loading) {
return ( return (
<div className="empty-loading-page"> <div className="empty-loading-page">