mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
update wiki mode
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import { gettext, siteRoot } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import ModalPortal from '../modal-portal';
|
||||
import CreateFolder from '../../components/dialog/create-folder-dialog';
|
||||
import CreateFile from '../../components/dialog/create-file-dialog';
|
||||
@@ -16,6 +17,11 @@ const propTypes = {
|
||||
onAddFolder: PropTypes.func.isRequired,
|
||||
onUploadFile: PropTypes.func.isRequired,
|
||||
onUploadFolder: PropTypes.func.isRequired,
|
||||
isDraft: PropTypes.bool,
|
||||
hasDraft: PropTypes.bool,
|
||||
reviewStatus: PropTypes.any,
|
||||
goDraftPage: PropTypes.func,
|
||||
goReviewPage: PropTypes.func,
|
||||
};
|
||||
|
||||
class DirOperationToolbar extends React.Component {
|
||||
@@ -63,6 +69,14 @@ class DirOperationToolbar extends React.Component {
|
||||
window.location.href= siteRoot + 'lib/' + repoID + '/file' + path + '?mode=edit';
|
||||
}
|
||||
|
||||
onNewDraft = (e) => {
|
||||
e.preventDefault();
|
||||
let { path, repoID } = this.props;
|
||||
seafileAPI.createDraft(repoID, path).then(res => {
|
||||
window.location.href = siteRoot + 'lib/' + res.data.origin_repo_id + '/file' + res.data.draft_file_path + '?mode=edit';
|
||||
});
|
||||
}
|
||||
|
||||
onUploadClick = (e) => {
|
||||
this.toggleOperationMenu(e);
|
||||
this.setState({
|
||||
@@ -115,14 +129,43 @@ class DirOperationToolbar extends React.Component {
|
||||
this.props.onAddFolder(dirPath);
|
||||
}
|
||||
|
||||
onViewReview = () => {
|
||||
this.props.goReviewPage();
|
||||
}
|
||||
|
||||
onViewDraft = () => {
|
||||
this.props.goDraftPage();
|
||||
}
|
||||
|
||||
render() {
|
||||
let dirName = this.props.path.replace('\/','');
|
||||
let isFile = this.props.isViewFile;
|
||||
let itemName;
|
||||
if (this.props.isViewFile) {
|
||||
itemName = Utils.getFileName(this.props.path)
|
||||
} else {
|
||||
itemName = this.props.path.replace('\/','');
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<div className="operation">
|
||||
{(this.props.isViewFile && this.props.permission === 'rw') && (
|
||||
<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) && (
|
||||
<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>
|
||||
{Utils.isSupportUploadFolder() ?
|
||||
@@ -170,8 +213,8 @@ class DirOperationToolbar extends React.Component {
|
||||
{this.state.isShareDialogShow &&
|
||||
<ModalPortal>
|
||||
<ShareDialog
|
||||
isDir={true}
|
||||
itemName={dirName}
|
||||
isDir={!isFile}
|
||||
itemName={itemName}
|
||||
itemPath={this.props.path}
|
||||
repoID={this.props.repoID}
|
||||
toggleDialog={this.onShareClick}
|
||||
|
Reference in New Issue
Block a user