1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 17:02:47 +00:00

New file/folder menu on toolbar (#2452)

This commit is contained in:
山水人家
2018-10-16 14:27:21 +08:00
committed by Daniel Pan
parent 2a6548b1de
commit d49e2f38f7
19 changed files with 339 additions and 148 deletions

View File

@@ -87,7 +87,7 @@
"dependencies": { "dependencies": {
"reactstrap": { "reactstrap": {
"version": "5.0.0", "version": "5.0.0",
"resolved": "http://registry.npmjs.org/reactstrap/-/reactstrap-5.0.0.tgz", "resolved": "https://registry.npmjs.org/reactstrap/-/reactstrap-5.0.0.tgz",
"integrity": "sha512-y0eju/LAK7gbEaTFfq2iW92MF7/5Qh0tc1LgYr2mg92IX8NodGc03a+I+cp7bJ0VXHAiLy0bFL9UP89oSm4cBg==", "integrity": "sha512-y0eju/LAK7gbEaTFfq2iW92MF7/5Qh0tc1LgYr2mg92IX8NodGc03a+I+cp7bJ0VXHAiLy0bFL9UP89oSm4cBg==",
"requires": { "requires": {
"classnames": "^2.2.3", "classnames": "^2.2.3",
@@ -10175,9 +10175,9 @@
} }
}, },
"seafile-js": { "seafile-js": {
"version": "0.2.25", "version": "0.2.26",
"resolved": "https://registry.npmjs.org/seafile-js/-/seafile-js-0.2.25.tgz", "resolved": "https://registry.npmjs.org/seafile-js/-/seafile-js-0.2.26.tgz",
"integrity": "sha512-XVJ6qvFeSv6tfihBvNscBS+rmnb+TkhyXvEYKBa13PipZbJdxbzVeWRhCXiR82fQwWLzYdAAv2rclSeURyCe5Q==", "integrity": "sha512-iKP2nLBCDE2G4MoiVdtQ4JlKY3vUByb7dwbwOV/pC8OdSxYcpu1zmCFl45TLnhz8B6wOlc7EC00ByZAvyTaZOQ==",
"requires": { "requires": {
"axios": "^0.18.0", "axios": "^0.18.0",
"form-data": "^2.3.2" "form-data": "^2.3.2"

View File

@@ -25,7 +25,7 @@
"react-dom": "^16.5.2", "react-dom": "^16.5.2",
"react-moment": "^0.7.9", "react-moment": "^0.7.9",
"reactstrap": "^6.4.0", "reactstrap": "^6.4.0",
"seafile-js": "^0.2.25", "seafile-js": "^0.2.26",
"seafile-ui": "^0.1.10", "seafile-ui": "^0.1.10",
"sw-precache-webpack-plugin": "0.11.4", "sw-precache-webpack-plugin": "0.11.4",
"url-loader": "0.6.2", "url-loader": "0.6.2",

View File

@@ -0,0 +1,73 @@
import React from 'react';
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Col, FormText } from 'reactstrap';
import { gettext } from '../../utils/constants';
class CreateFile extends React.Component {
constructor(props) {
super(props);
this.state = {
parentPath: '',
childName: props.fileType,
};
this.newInput = React.createRef()
}
handleChange = (e) => {
this.setState({
childName: e.target.value,
})
}
handleSubmit = () => {
let path = this.state.parentPath + this.state.childName
this.props.onAddFile(path);
}
handleKeyPress = (e) => {
if (e.key === 'Enter') {
this.handleSubmit();
}
}
toggle = () => {
this.props.addFileCancel();
}
componentDidMount() {
if (this.props.parentPath === "/") {
this.setState({parentPath: this.props.parentPath});
} else {
this.setState({parentPath: this.props.parentPath + "/"});
}
this.newInput.focus();
this.newInput.setSelectionRange(0,0);
}
render() {
return (
<Modal isOpen={true} toggle={this.toggle}>
<ModalHeader toggle={this.toggle}>{gettext("New File")}</ModalHeader>
<ModalBody>
<Form>
<FormGroup row>
<Label sm={3}>Parent path: </Label>
<Col sm={9} className="parent-path"><FormText>{this.state.parentPath}</FormText></Col>
</FormGroup>
<FormGroup row>
<Label for="fileName" sm={3}>{gettext("Name")}: </Label>
<Col sm={9}>
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input}} id="fileName" placeholder={gettext("newName")} value={this.state.childName} onChange={this.handleChange}/>
</Col>
</FormGroup>
</Form>
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={this.handleSubmit}>{gettext("Submit")}</Button>
<Button color="secondary" onClick={this.toggle}>{gettext("Cancel")}</Button>
</ModalFooter>
</Modal>
)
}
}
export default CreateFile;

View File

@@ -1,8 +1,8 @@
import React from 'react'; import React from 'react';
import { gettext } from '../../../utils/constants';
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Col, FormText } from 'reactstrap'; import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Col, FormText } from 'reactstrap';
import { gettext } from '../../utils/constants';
class CreateFileForder extends React.Component { class CreateForder extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@@ -20,11 +20,7 @@ class CreateFileForder extends React.Component {
handleSubmit = () => { handleSubmit = () => {
let path = this.state.parentPath + this.state.childName let path = this.state.parentPath + this.state.childName
if (this.props.isFile) { this.props.onAddFolder(path);
this.props.onAddFile(path);
} else {
this.props.onAddFolder(path);
}
} }
handleKeyPress = (e) => { handleKeyPress = (e) => {
@@ -34,44 +30,23 @@ class CreateFileForder extends React.Component {
} }
toggle = () => { toggle = () => {
if (this.props.isFile) { this.props.addFolderCancel();
this.props.addFileCancel();
} else {
this.props.addFolderCancel();
}
}
componentWillMount() {
this.changeState(this.props.isFile);
} }
componentDidMount() { componentDidMount() {
if (this.props.currentNode.path === "/") { if (this.props.parentPath === "/") {
this.setState({parentPath: this.props.currentNode.path}); this.setState({parentPath: this.props.parentPath});
} else { } else {
this.setState({parentPath: this.props.currentNode.path + "/"}); this.setState({parentPath: this.props.parentPath + "/"});
} }
this.newInput.focus(); this.newInput.focus();
this.newInput.setSelectionRange(0,0); this.newInput.setSelectionRange(0,0);
} }
componentWillReceiveProps(nextProps) {
this.changeState(nextProps.isFile);
}
changeState(isFile) {
if (isFile) {
this.setState({childName: '.md'});
} else{
this.setState({childName: ""});
}
}
render() { render() {
return ( return (
<Modal isOpen={true} toggle={this.toggle}> <Modal isOpen={true} toggle={this.toggle}>
<ModalHeader toggle={this.toggle}>{this.props.isFile ? gettext("New File") : gettext("New Folder")}</ModalHeader> <ModalHeader toggle={this.toggle}>{gettext("New Folder")}</ModalHeader>
<ModalBody> <ModalBody>
<Form> <Form>
<FormGroup row> <FormGroup row>
@@ -95,4 +70,4 @@ class CreateFileForder extends React.Component {
} }
} }
export default CreateFileForder; export default CreateForder;

View File

@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { gettext } from '../../../utils/constants'; import { gettext } from '../../utils/constants';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
const propTypes = { const propTypes = {

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { gettext } from '../../../utils/constants'; import { gettext } from '../../utils/constants';
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter } from 'reactstrap'; import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter } from 'reactstrap';
class Rename extends React.Component { class Rename extends React.Component {

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { siteRoot, lang } from '../../utils/constants'; import { siteRoot, lang } from '../../utils/constants';
import NodeMenuControl from '../menu-component/node-menu-control'; import MenuControl from '../menu-control';
import moment from 'moment'; import moment from 'moment';
moment.locale(lang); moment.locale(lang);
@@ -87,7 +87,7 @@ class DraftListItem extends React.Component {
<td className="menu-toggle"> <td className="menu-toggle">
{ {
this.props.draft.review_status !== 'open' && this.props.draft.review_status !== 'open' &&
<NodeMenuControl <MenuControl
isShow={this.state.isMenuControlShow} isShow={this.state.isMenuControlShow}
onClick={this.onMenuToggleClick} onClick={this.onMenuToggleClick}
/> />

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import moment from 'moment'; import moment from 'moment';
import NodeMenuControl from '../menu-component/node-menu-control'; import MenuControl from '../menu-control';
moment.locale(window.app.config.lang); moment.locale(window.app.config.lang);
const propTypes = { const propTypes = {
@@ -70,7 +70,7 @@ class HistoryListItem extends React.Component {
</div> </div>
</div> </div>
<div className="history-operation"> <div className="history-operation">
<NodeMenuControl <MenuControl
isShow={this.state.isShowOperationIcon || isHigtlightItem} isShow={this.state.isShowOperationIcon || isHigtlightItem}
onClick={this.onMenuControlClick} onClick={this.onMenuControlClick}
/> />

View File

@@ -1,30 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
isShow: PropTypes.bool.isRequired,
currentNode: PropTypes.object,
onClick: PropTypes.func.isRequired,
};
class NodeMenuControl extends React.Component {
onClick = (e) => {
let node = this.props.currentNode;
this.props.onClick(e, node);
}
render() {
return (
<i
className={`fas fa-ellipsis-v ${this.props.isShow ? '' : 'hide'}`}
onClick={this.onClick}
>
</i>
);
}
}
NodeMenuControl.propTypes = propTypes;
export default NodeMenuControl;

View File

@@ -0,0 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {
isShow: PropTypes.bool.isRequired,
};
class MenuControl extends React.Component {
render() {
return (
<i className={`fas fa-ellipsis-v ${this.props.isShow ? '' : 'hide'}`} onClick={this.props.onClick}></i>
);
}
}
MenuControl.propTypes = propTypes;
export default MenuControl;

View File

@@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { siteRoot, lang } from '../../utils/constants';
import moment from 'moment'; import moment from 'moment';
import { siteRoot, lang } from '../../utils/constants';
moment.locale(lang); moment.locale(lang);
const propTypes = { const propTypes = {

View File

@@ -2,11 +2,15 @@ import React from 'react';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
class NodeMenu extends React.Component { class NodeMenu extends React.Component {
toggleAddFileFolder = (ev, flag) => { toggleAddFile = () => {
this.props.toggleAddFileFolder(flag); this.props.toggleAddFile();
} }
toggleAddFolder = () => {
this.props.toggleAddFolder();
}
toggleRename = () => { toggleRename = () => {
this.props.toggleRename(); this.props.toggleRename();
} }
@@ -23,16 +27,16 @@ class NodeMenu extends React.Component {
if (this.props.currentNode.name === '/') { if (this.props.currentNode.name === '/') {
return ( return (
<ul className="dropdown-menu" style={style}> <ul className="dropdown-menu" style={style}>
<li className="dropdown-item" onClick={this.toggleAddFileFolder}>{gettext('New Folder')}</li> <li className="dropdown-item" onClick={this.toggleAddFolder}>{gettext('New Folder')}</li>
<li className="dropdown-item" onClick={(ev,flag) => this.toggleAddFileFolder(ev,true)}>{gettext('New File')}</li> <li className="dropdown-item" onClick={this.toggleAddFile}>{gettext('New File')}</li>
</ul> </ul>
); );
} }
return ( return (
<ul className="dropdown-menu" style={style}> <ul className="dropdown-menu" style={style}>
<li className="dropdown-item" onClick={this.toggleAddFileFolder}>{gettext('New Folder')}</li> <li className="dropdown-item" onClick={this.toggleAddFolder}>{gettext('New Folder')}</li>
<li className="dropdown-item" onClick={(ev,flag) => this.toggleAddFileFolder(ev,true)}>{gettext('New File')}</li> <li className="dropdown-item" onClick={this.toggleAddFile}>{gettext('New File')}</li>
<li className="dropdown-item" onClick={this.toggleRename}>{gettext('Rename')}</li> <li className="dropdown-item" onClick={this.toggleRename}>{gettext('Rename')}</li>
<li className="dropdown-item" onClick={this.toggleDelete}>{gettext('Delete')}</li> <li className="dropdown-item" onClick={this.toggleDelete}>{gettext('Delete')}</li>
</ul> </ul>

View File

@@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import MenuControl from '../menu-component/node-menu-control'; import MenuControl from '../menu-control';
import { permission } from '../../utils/constants'; import { permission } from '../../utils/constants';
function sortByType(a, b) { function sortByType(a, b) {

View File

@@ -1,5 +1,5 @@
/* begin current-module-toobar */ /* begin toobar-container */
.cur-view-toolbar { .cur-view-toolbar {
position: relative; position: relative;
display: flex; display: flex;
@@ -15,7 +15,10 @@
content: ''; content: '';
} }
.top-toolbar-btn { /* end toolbar-container */
/* file-operation toolbar eg: edit, upload, new, share*/
.operation-item {
padding: 0 0.25rem; padding: 0 0.25rem;
margin-right: 0.25rem; margin-right: 0.25rem;
height: 30px; height: 30px;
@@ -29,7 +32,10 @@
border-radius: 2px; border-radius: 2px;
} }
.sf-view-mode-change-btn { /* end file-operation toolbar */
/* begin view-mode toolbar */
.sf-view-mode-btn {
padding: 0; padding: 0;
height: 30px; height: 30px;
min-width: 2rem; min-width: 2rem;
@@ -41,12 +47,11 @@
border-radius: 0 !important; border-radius: 0 !important;
} }
.sf-view-mode-change-btn.current-mode { .sf-view-mode-btn.current-mode {
background-color: #ccc !important; background-color: #ccc !important;
color: #fff !important; color: #fff !important;
} }
/* end view-mode toolbar */
/* end current-module-toobar */
/* begin common-toolbar */ /* begin common-toolbar */
.common-toolbar { .common-toolbar {
@@ -81,3 +86,4 @@
text-decoration:none; text-decoration:none;
} }
/* end path toolbar */ /* end path toolbar */

View File

@@ -2,11 +2,13 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { gettext, repoID, serviceUrl, slug, siteRoot } from '../../utils/constants'; import { gettext, repoID, serviceUrl, slug, siteRoot } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api'; import { seafileAPI } from '../../utils/seafile-api';
import Dirent from '../../models/dirent';
import CommonToolbar from '../../components/toolbar/common-toolbar'; import CommonToolbar from '../../components/toolbar/common-toolbar';
import PathToolbar from '../../components/toolbar/path-toolbar'; import PathToolbar from '../../components/toolbar/path-toolbar';
import MarkdownViewer from '../../components/markdown-viewer'; import MarkdownViewer from '../../components/markdown-viewer';
import DirentListView from '../../components/dirent-list-view/dirent-list-view'; import DirentListView from '../../components/dirent-list-view/dirent-list-view';
import Dirent from '../../models/dirent'; import CreateFolder from '../../components/dialog/create-folder-dialog';
import CreateFile from '../../components/dialog/create-file-dialog';
const propTypes = { const propTypes = {
content: PropTypes.string, content: PropTypes.string,
@@ -29,10 +31,19 @@ class MainPanel extends Component {
super(props); super(props);
this.state = { this.state = {
isWikiMode: true, isWikiMode: true,
direntList: [] direntList: [],
newMenuShow: false,
uploadMenuShow: false,
showFileDialog: false,
showFolderDialog: false,
createFileType: '',
}; };
} }
componentDidMount() {
document.addEventListener('click', this.hideOperationMenu);
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
let node = nextProps.changedNode; let node = nextProps.changedNode;
if (node && node.isDir()) { if (node && node.isDir()) {
@@ -41,6 +52,10 @@ class MainPanel extends Component {
} }
} }
componentWillUnmount() {
document.removeEventListener('click', this.hideOperationMenu);
}
updateViewList = (filePath) => { updateViewList = (filePath) => {
seafileAPI.listDir(repoID, filePath, 48).then(res => { seafileAPI.listDir(repoID, filePath, 48).then(res => {
let direntList = []; let direntList = [];
@@ -76,6 +91,78 @@ class MainPanel extends Component {
window.location.href= serviceUrl + '/lib/' + repoID + '/file' + this.props.filePath + '?mode=edit'; window.location.href= serviceUrl + '/lib/' + repoID + '/file' + this.props.filePath + '?mode=edit';
} }
onUploadClick = (e) => {
this.toggleOperationMenu(e);
this.setState({
newMenuShow: false,
uploadMenuShow: !this.state.uploadMenuShow,
});
}
onNewClick = (e) => {
this.toggleOperationMenu(e);
this.setState({
newMenuShow: !this.state.newMenuShow,
uploadMenuShow: false,
});
}
onShareClick = () => {
alert('share btn clicked');
}
toggleOperationMenu = (e) => {
e.nativeEvent.stopImmediatePropagation();
let targetRect = e.target.getClientRects()[0];
let left = targetRect.x;
let top = targetRect.y + targetRect.height;
let style = {position: 'fixed', display: 'block', left: left, top: top};
this.setState({operationMenuStyle: style});
}
hideOperationMenu = () => {
this.setState({
uploadMenuShow: false,
newMenuShow: false,
});
}
addFolder = () => {
this.setState({showFolderDialog: !this.showFolderDialog});
}
addFile = () => {
this.setState({
showFileDialog: !this.showFileDialog,
createFileType: '',
});
}
addMarkdownFile = () => {
this.setState({
showFileDialog: !this.showFileDialog,
createFileType: '.md',
});
}
addFolderCancel = () => {
this.setState({showFolderDialog: !this.state.showFolderDialog});
}
addFileCancel = () => {
this.setState({showFileDialog: !this.state.showFileDialog});
}
onMainAddFile = (filePath) => {
this.setState({showFileDialog: !this.state.showFileDialog});
this.props.onMainAddFile(filePath);
}
onMainAddFolder = (dirPath) => {
this.setState({showFolderDialog: !this.state.showFolderDialog});
this.props.onMainAddFolder(dirPath);
}
render() { render() {
let filePathList = this.props.filePath.split('/'); let filePathList = this.props.filePath.split('/');
let nodePath = ''; let nodePath = '';
@@ -108,14 +195,37 @@ class MainPanel extends Component {
<div className="main-panel-top panel-top"> <div className="main-panel-top panel-top">
<div className="cur-view-toolbar border-left-show"> <div className="cur-view-toolbar border-left-show">
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title={gettext('Side Nav Menu')} onClick={this.onMenuClick}></span> <span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title={gettext('Side Nav Menu')} onClick={this.onMenuClick}></span>
{ <div className="file-operation">
this.props.permission === 'rw' && <div className="operation">
<button className="btn btn-secondary top-toolbar-btn" title={gettext('Edit File')} onClick={this.onEditClick}>{gettext('Edit')}</button> {
} this.props.permission === 'rw' &&
<div className="btn-group"> <button className="btn btn-secondary operation-item" title={gettext('Edit File')} onClick={this.onEditClick}>{gettext('Edit')}</button>
<button className="btn btn-secondary btn-icon sf-view-mode-change-btn sf2-icon-list-view" id='list' title={gettext('List')} onClick={this.switchViewMode}></button> }
<button className="btn btn-secondary btn-icon sf-view-mode-change-btn sf2-icon-grid-view" id='grid' title={gettext('Grid')} onClick={this.switchViewMode}></button> <button className="btn btn-secondary operation-item" title={gettext('Edit File')} onClick={this.onUploadClick}>{gettext('Upload')}</button>
<button className={`btn btn-secondary btn-icon sf-view-mode-change-btn sf2-icon-two-columns ${this.state.isWikiMode ? 'current-mode' : ''}`} id='wiki' title={gettext('wiki')} onClick={this.switchViewMode}></button> <button className="btn btn-secondary operation-item" title={gettext('Edit File')} onClick={this.onNewClick}>{gettext('New')}</button>
<button className="btn btn-secondary operation-item" title={gettext('Edit File')} onClick={this.onShareClick}>{gettext('Share')}</button>
</div>
{
this.state.uploadMenuShow &&
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
<li className="dropdown-item">{gettext('Upload Files')}</li>
<li className="dropdown-item">{gettext('Upload Folder')}</li>
</ul>
}
{
this.state.newMenuShow &&
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
<li className="dropdown-item" onClick={this.addFolder}>{gettext('New Folder')}</li>
<li className="dropdown-item" onClick={this.addFile}>{gettext('New File')}</li>
<li className="dropdown-item menu-inner-divider"></li>
<li className="dropdown-item" onClick={this.addMarkdownFile}>{gettext('New Markdown File')}</li>
</ul>
}
</div>
<div className="view-mode btn-group">
<button className="btn btn-secondary btn-icon sf-view-mode-btn sf2-icon-list-view" id='list' title={gettext('List')} onClick={this.switchViewMode}></button>
<button className="btn btn-secondary btn-icon sf-view-mode-btn sf2-icon-grid-view" id='grid' title={gettext('Grid')} onClick={this.switchViewMode}></button>
<button className={`btn btn-secondary btn-icon sf-view-mode-btn sf2-icon-two-columns ${this.state.isWikiMode ? 'current-mode' : ''}`} id='wiki' title={gettext('wiki')} onClick={this.switchViewMode}></button>
</div> </div>
</div> </div>
<CommonToolbar onSearchedClick={this.props.onSearchedClick} searchPlaceholder={'Search files in this library'}/> <CommonToolbar onSearchedClick={this.props.onSearchedClick} searchPlaceholder={'Search files in this library'}/>
@@ -153,6 +263,21 @@ class MainPanel extends Component {
} }
</div> </div>
</div> </div>
{this.state.showFileDialog &&
<CreateFile
fileType={this.state.createFileType}
parentPath={this.props.filePath}
addFileCancel={this.addFileCancel}
onAddFile={this.onMainAddFile}
/>
}
{this.state.showFolderDialog &&
<CreateFolder
parentPath={this.props.filePath}
addFolderCancel={this.addFolderCancel}
onAddFolder={this.onMainAddFolder}
/>
}
</div> </div>
); );
} }

View File

@@ -1,11 +1,12 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { gettext, siteRoot, logoPath, mediaUrl, siteTitle, logoWidth, logoHeight } from '../../utils/constants'; import { gettext, siteRoot, logoPath, mediaUrl, siteTitle, logoWidth, logoHeight } from '../../utils/constants';
import TreeView from '../../components/tree-view/tree-view'; import TreeView from '../../components/tree-view/tree-view';
import NodeMenu from '../../components/menu-component/node-menu'; import NodeMenu from '../../components/tree-view/node-menu';
import MenuControl from '../../components/menu-component/node-menu-control'; import MenuControl from '../../components/menu-control';
import Delete from '../../components/menu-component/menu-dialog/delete-dialog'; import Delete from '../../components/dialog/delete-dialog';
import Rename from '../../components/menu-component/menu-dialog/rename-dialog'; import Rename from '../../components/dialog/rename-dialog';
import CreateFlieFolder from '../../components/menu-component/menu-dialog/create-fileforder-dialog'; import CreateFolder from '../../components/dialog/create-folder-dialog';
import CreateFile from '../../components/dialog/create-file-dialog';
class SidePanel extends Component { class SidePanel extends Component {
@@ -22,7 +23,8 @@ class SidePanel extends Component {
isLoadFailed: false, isLoadFailed: false,
isMenuIconShow: false, isMenuIconShow: false,
showDelete: false, showDelete: false,
showAddFileFolder: false, showFile: false,
showFolder: false,
showRename: false, showRename: false,
isFile: false isFile: false
}; };
@@ -85,12 +87,13 @@ class SidePanel extends Component {
}); });
} }
toggleAddFileFolder = (flag) => { toggleAddFile = () => {
let isFile = flag === true ? true : false; this.setState({showFile: !this.state.showFile});
this.setState({ this.onHideContextMenu();
showAddFileFolder: !this.state.showAddFileFolder, }
isFile: isFile
}); toggleAddFolder = () => {
this.setState({showFolder: !this.state.showFolder});
this.onHideContextMenu(); this.onHideContextMenu();
} }
@@ -105,12 +108,12 @@ class SidePanel extends Component {
} }
onAddFolderNode = (dirPath) => { onAddFolderNode = (dirPath) => {
this.setState({showAddFileFolder: !this.state.showAddFileFolder}); this.setState({showFolder: !this.state.showFolder});
this.props.onAddFolderNode(dirPath); this.props.onAddFolderNode(dirPath);
} }
onAddFileNode = (filePath) => { onAddFileNode = (filePath) => {
this.setState({showAddFileFolder: !this.state.showAddFileFolder}); this.setState({showFile: !this.state.showFile});
this.props.onAddFileNode(filePath); this.props.onAddFileNode(filePath);
} }
@@ -141,11 +144,11 @@ class SidePanel extends Component {
} }
addFolderCancel = () => { addFolderCancel = () => {
this.setState({showAddFileFolder: !this.state.showAddFileFolder}); this.setState({showFolder: !this.state.showFolder});
} }
addFileCancel = () => { addFileCancel = () => {
this.setState({showAddFileFolder: !this.state.showAddFileFolder}); this.setState({showFile: !this.state.showFile});
} }
deleteCancel = () => { deleteCancel = () => {
@@ -195,7 +198,8 @@ class SidePanel extends Component {
<NodeMenu <NodeMenu
menuPosition={this.state.menuPosition} menuPosition={this.state.menuPosition}
currentNode={this.state.currentNode} currentNode={this.state.currentNode}
toggleAddFileFolder={this.toggleAddFileFolder} toggleAddFile={this.toggleAddFile}
toggleAddFolder={this.toggleAddFolder}
toggleRename={this.toggleRename} toggleRename={this.toggleRename}
toggleDelete={this.toggleDelete} toggleDelete={this.toggleDelete}
/> />
@@ -207,16 +211,21 @@ class SidePanel extends Component {
toggleCancel={this.deleteCancel} toggleCancel={this.deleteCancel}
/> />
} }
{this.state.showAddFileFolder && {this.state.showFile &&
<CreateFlieFolder <CreateFile
isFile={this.state.isFile} fileType={'.md'}
currentNode={this.state.currentNode} parentPath={this.state.currentNode.path}
onAddFolder={this.onAddFolderNode}
addFolderCancel={this.addFolderCancel}
onAddFile={this.onAddFileNode} onAddFile={this.onAddFileNode}
addFileCancel={this.addFileCancel} addFileCancel={this.addFileCancel}
/> />
} }
{this.state.showFolder &&
<CreateFolder
parentPath={this.state.currentNode.path}
onAddFolder={this.onAddFolderNode}
addFolderCancel={this.addFolderCancel}
/>
}
{this.state.showRename && {this.state.showRename &&
<Rename <Rename
currentNode={this.state.currentNode} currentNode={this.state.currentNode}

View File

@@ -62,7 +62,7 @@ class MainPanel extends Component {
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title="Side Nav Menu" onClick={this.onMenuClick}></span> <span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title="Side Nav Menu" onClick={this.onMenuClick}></span>
{ {
this.props.permission === 'rw' && this.props.permission === 'rw' &&
<button className="btn btn-secondary top-toolbar-btn" title="Edit File" onClick={this.onEditClick}>{gettext('Edit Page')}</button> <button className="btn btn-secondary operation-item" title="Edit File" onClick={this.onEditClick}>{gettext('Edit Page')}</button>
} }
</div> </div>
<CommonToolbar onSearchedClick={this.props.onSearchedClick} searchPlaceholder={'Search files in this library'}/> <CommonToolbar onSearchedClick={this.props.onSearchedClick} searchPlaceholder={'Search files in this library'}/>

View File

@@ -1,11 +1,12 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { gettext, siteRoot, logoPath, mediaUrl, siteTitle, logoWidth, logoHeight } from '../../utils/constants'; import { gettext, siteRoot, logoPath, mediaUrl, siteTitle, logoWidth, logoHeight } from '../../utils/constants';
import TreeView from '../../components/tree-view/tree-view'; import TreeView from '../../components/tree-view/tree-view';
import NodeMenu from '../../components/menu-component/node-menu'; import NodeMenu from '../../components/tree-view/node-menu';
import MenuControl from '../../components/menu-component/node-menu-control'; import MenuControl from '../../components/menu-control';
import Delete from '../../components/menu-component/menu-dialog/delete-dialog'; import Delete from '../../components/dialog/delete-dialog';
import Rename from '../../components/menu-component/menu-dialog/rename-dialog'; import Rename from '../../components/dialog/rename-dialog';
import CreateFlieFolder from '../../components/menu-component/menu-dialog/create-fileforder-dialog'; import CreateFolder from '../../components/dialog/create-folder-dialog';
import CreateFile from '../../components/dialog/create-file-dialog';
class SidePanel extends Component { class SidePanel extends Component {
@@ -22,9 +23,9 @@ class SidePanel extends Component {
isLoadFailed: false, isLoadFailed: false,
isMenuIconShow: false, isMenuIconShow: false,
showDelete: false, showDelete: false,
showAddFileFolder: false, showFile: false,
showFolder: false,
showRename: false, showRename: false,
isFile: false
}; };
this.searchedPath = null; this.searchedPath = null;
} }
@@ -85,12 +86,13 @@ class SidePanel extends Component {
}); });
} }
toggleAddFileFolder = (flag) => { toggleAddFile = () => {
let isFile = flag === true ? true : false; this.setState({showFile: !this.state.showFile});
this.setState({ this.onHideContextMenu();
showAddFileFolder: !this.state.showAddFileFolder, }
isFile: isFile
}); toggleAddFolder = () => {
this.setState({showFolder: !this.state.showFolder});
this.onHideContextMenu(); this.onHideContextMenu();
} }
@@ -105,12 +107,12 @@ class SidePanel extends Component {
} }
onAddFolderNode = (dirPath) => { onAddFolderNode = (dirPath) => {
this.setState({showAddFileFolder: !this.state.showAddFileFolder}); this.setState({showFolder: !this.state.showFolder});
this.props.onAddFolderNode(dirPath); this.props.onAddFolderNode(dirPath);
} }
onAddFileNode = (filePath) => { onAddFileNode = (filePath) => {
this.setState({showAddFileFolder: !this.state.showAddFileFolder}); this.setState({showFile: !this.state.showFile});
this.props.onAddFileNode(filePath); this.props.onAddFileNode(filePath);
} }
@@ -141,11 +143,11 @@ class SidePanel extends Component {
} }
addFolderCancel = () => { addFolderCancel = () => {
this.setState({showAddFileFolder: !this.state.showAddFileFolder}); this.setState({showFolder: !this.state.showFolder});
} }
addFileCancel = () => { addFileCancel = () => {
this.setState({showAddFileFolder: !this.state.showAddFileFolder}); this.setState({showFile: !this.state.showFile});
} }
deleteCancel = () => { deleteCancel = () => {
@@ -195,7 +197,8 @@ class SidePanel extends Component {
<NodeMenu <NodeMenu
menuPosition={this.state.menuPosition} menuPosition={this.state.menuPosition}
currentNode={this.state.currentNode} currentNode={this.state.currentNode}
toggleAddFileFolder={this.toggleAddFileFolder} toggleAddFile={this.toggleAddFile}
toggleAddFolder={this.toggleAddFolder}
toggleRename={this.toggleRename} toggleRename={this.toggleRename}
toggleDelete={this.toggleDelete} toggleDelete={this.toggleDelete}
/> />
@@ -207,16 +210,21 @@ class SidePanel extends Component {
toggleCancel={this.deleteCancel} toggleCancel={this.deleteCancel}
/> />
} }
{this.state.showAddFileFolder && {this.state.showFile &&
<CreateFlieFolder <CreateFile
isFile={this.state.isFile} fileType={'.md'}
currentNode={this.state.currentNode} parentPath={this.state.currentNode.path}
onAddFolder={this.onAddFolderNode}
addFolderCancel={this.addFolderCancel}
onAddFile={this.onAddFileNode} onAddFile={this.onAddFileNode}
addFileCancel={this.addFileCancel} addFileCancel={this.addFileCancel}
/> />
} }
{this.state.showFolder &&
<CreateFolder
parentPath={this.state.currentNode.path}
onAddFolder={this.onAddFolderNode}
addFolderCancel={this.addFolderCancel}
/>
}
{this.state.showRename && {this.state.showRename &&
<Rename <Rename
currentNode={this.state.currentNode} currentNode={this.state.currentNode}

View File

@@ -537,6 +537,8 @@ class Wiki extends Component {
onMainNavBarClick={this.onMainNavBarClick} onMainNavBarClick={this.onMainNavBarClick}
onMainItemClick={this.onMainItemClick} onMainItemClick={this.onMainItemClick}
onMainItemDelete={this.onMainItemDelete} onMainItemDelete={this.onMainItemDelete}
onMainAddFile={this.onAddFileNode}
onMainAddFolder={this.onAddFolderNode}
/> />
</div> </div>
); );