2018-10-25 05:36:06 +00:00
|
|
|
import React, { Component, Fragment } from 'react';
|
2018-10-13 09:07:54 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-10-09 02:56:59 +00:00
|
|
|
import { gettext, repoID, serviceUrl, slug, siteRoot } from '../../utils/constants';
|
2018-10-13 09:07:54 +00:00
|
|
|
import { seafileAPI } from '../../utils/seafile-api';
|
2018-11-14 02:55:11 +00:00
|
|
|
import { Utils } from '../../utils/utils';
|
2018-11-23 12:19:42 +00:00
|
|
|
import URLDecorator from '../../utils/url-decorator';
|
2018-11-01 10:40:18 +00:00
|
|
|
import Repo from '../../models/repo';
|
2018-09-20 02:19:11 +00:00
|
|
|
import CommonToolbar from '../../components/toolbar/common-toolbar';
|
2018-09-19 01:57:17 +00:00
|
|
|
import PathToolbar from '../../components/toolbar/path-toolbar';
|
2018-09-12 02:32:31 +00:00
|
|
|
import MarkdownViewer from '../../components/markdown-viewer';
|
2018-10-13 09:07:54 +00:00
|
|
|
import DirentListView from '../../components/dirent-list-view/dirent-list-view';
|
2018-10-25 05:36:06 +00:00
|
|
|
import DirentDetail from '../../components/dirent-detail/dirent-details';
|
2018-10-16 06:27:21 +00:00
|
|
|
import CreateFolder from '../../components/dialog/create-folder-dialog';
|
|
|
|
import CreateFile from '../../components/dialog/create-file-dialog';
|
2018-11-23 12:19:42 +00:00
|
|
|
import ZipDownloadDialog from '../../components/dialog/zip-download-dialog';
|
|
|
|
import MoveDirentDialog from '../../components/dialog/move-dirent-dialog';
|
|
|
|
import CopyDirentDialog from '../../components/dialog/copy-dirent-dialog';
|
2018-11-14 02:55:11 +00:00
|
|
|
import FileUploader from '../../components/file-uploader/file-uploader';
|
2018-10-13 09:07:54 +00:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
content: PropTypes.string,
|
|
|
|
lastModified: PropTypes.string,
|
|
|
|
latestContributor: PropTypes.string,
|
|
|
|
permission: PropTypes.string,
|
2018-11-22 03:26:00 +00:00
|
|
|
path: PropTypes.string.isRequired,
|
|
|
|
// whether the file or dir corresponding to the path exist
|
|
|
|
pathExist: PropTypes.bool.isRequired,
|
2018-10-13 09:07:54 +00:00
|
|
|
isFileLoading: PropTypes.bool.isRequired,
|
2018-11-22 03:26:00 +00:00
|
|
|
isViewFile: PropTypes.bool.isRequired,
|
|
|
|
isDirentListLoading: PropTypes.bool.isRequired,
|
2018-11-23 12:19:42 +00:00
|
|
|
isDirentSelected: PropTypes.bool.isRequired,
|
|
|
|
isAllDirentSelected: PropTypes.bool.isRequired,
|
2018-11-22 03:26:00 +00:00
|
|
|
direntList: PropTypes.array.isRequired,
|
2018-11-23 12:19:42 +00:00
|
|
|
selectedDirentList: PropTypes.array.isRequired,
|
2018-11-22 03:26:00 +00:00
|
|
|
updateDirent: PropTypes.func.isRequired,
|
|
|
|
onSideNavMenuClick: PropTypes.func.isRequired,
|
2018-10-13 09:07:54 +00:00
|
|
|
onSearchedClick: PropTypes.func.isRequired,
|
|
|
|
onMainNavBarClick: PropTypes.func.isRequired,
|
2018-10-16 10:19:51 +00:00
|
|
|
onLinkClick: PropTypes.func.isRequired,
|
2018-11-22 03:26:00 +00:00
|
|
|
onItemClick: PropTypes.func.isRequired,
|
2018-11-23 12:19:42 +00:00
|
|
|
onAllDirentSelected: PropTypes.func.isRequired,
|
|
|
|
onItemSelected: PropTypes.func.isRequired,
|
2018-11-22 03:26:00 +00:00
|
|
|
onItemDelete: PropTypes.func.isRequired,
|
|
|
|
onItemRename: PropTypes.func.isRequired,
|
|
|
|
onItemMove: PropTypes.func.isRequired,
|
|
|
|
onItemCopy: PropTypes.func.isRequired,
|
|
|
|
onAddFile: PropTypes.func.isRequired,
|
|
|
|
onAddFolder: PropTypes.func.isRequired,
|
2018-10-16 10:19:51 +00:00
|
|
|
switchViewMode: PropTypes.func.isRequired,
|
2018-11-22 03:26:00 +00:00
|
|
|
onFileTagChanged: PropTypes.func.isRequired,
|
2018-11-23 12:19:42 +00:00
|
|
|
onItemsMove: PropTypes.func.isRequired,
|
|
|
|
onItemsCopy: PropTypes.func.isRequired,
|
|
|
|
onItemsDelete: PropTypes.func.isRequired,
|
2018-10-16 10:19:51 +00:00
|
|
|
};
|
2018-09-12 02:32:31 +00:00
|
|
|
|
|
|
|
class MainPanel extends Component {
|
|
|
|
|
2018-09-19 01:57:17 +00:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
2018-09-29 07:47:53 +00:00
|
|
|
isWikiMode: true,
|
2018-10-16 06:27:21 +00:00
|
|
|
newMenuShow: false,
|
|
|
|
uploadMenuShow: false,
|
|
|
|
showFileDialog: false,
|
|
|
|
showFolderDialog: false,
|
|
|
|
createFileType: '',
|
2018-10-25 05:36:06 +00:00
|
|
|
isDirentDetailShow: false,
|
|
|
|
currentDirent: null,
|
2018-11-23 12:19:42 +00:00
|
|
|
direntPath: '',
|
2018-11-01 10:40:18 +00:00
|
|
|
currentRepo: null,
|
|
|
|
isRepoOwner: false,
|
2018-11-23 12:19:42 +00:00
|
|
|
progress: 0,
|
|
|
|
isProgressDialogShow: false,
|
|
|
|
isMoveDialogShow: false,
|
|
|
|
isCopyDialogShow: false,
|
|
|
|
isMutipleOperation: false,
|
2018-09-29 07:47:53 +00:00
|
|
|
};
|
2018-11-23 12:19:42 +00:00
|
|
|
this.zip_token = null;
|
2018-09-19 01:57:17 +00:00
|
|
|
}
|
|
|
|
|
2018-10-16 06:27:21 +00:00
|
|
|
componentDidMount() {
|
2018-11-01 10:40:18 +00:00
|
|
|
seafileAPI.getRepoInfo(repoID).then(res => {
|
|
|
|
let repo = new Repo(res.data);
|
|
|
|
seafileAPI.getAccountInfo().then(res => {
|
|
|
|
let user_email = res.data.email;
|
|
|
|
let isRepoOwner = repo.owner_email === user_email;
|
|
|
|
this.setState({
|
|
|
|
currentRepo: repo,
|
|
|
|
isRepoOwner: isRepoOwner,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-10-16 06:27:21 +00:00
|
|
|
document.addEventListener('click', this.hideOperationMenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
document.removeEventListener('click', this.hideOperationMenu);
|
|
|
|
}
|
|
|
|
|
2018-09-12 02:32:31 +00:00
|
|
|
switchViewMode = (e) => {
|
2018-09-29 10:32:53 +00:00
|
|
|
e.preventDefault();
|
2018-09-19 01:57:17 +00:00
|
|
|
if (e.target.id === 'wiki') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.setState({isWikiMode: false});
|
2018-09-12 02:32:31 +00:00
|
|
|
this.props.switchViewMode(e.target.id);
|
|
|
|
}
|
|
|
|
|
2018-11-22 03:26:00 +00:00
|
|
|
onSideNavMenuClick = () => {
|
|
|
|
this.props.onSideNavMenuClick();
|
|
|
|
}
|
|
|
|
|
|
|
|
onMainNavBarClick = (e) => {
|
|
|
|
this.props.onMainNavBarClick(e.target.dataset.path);
|
|
|
|
}
|
|
|
|
|
2018-10-13 09:07:54 +00:00
|
|
|
onEditClick = (e) => {
|
|
|
|
e.preventDefault();
|
2018-11-22 03:26:00 +00:00
|
|
|
window.location.href= serviceUrl + '/lib/' + repoID + '/file' + this.props.path + '?mode=edit';
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
2018-09-12 02:32:31 +00:00
|
|
|
|
2018-10-16 06:27:21 +00:00
|
|
|
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});
|
|
|
|
}
|
|
|
|
|
2018-11-22 03:26:00 +00:00
|
|
|
onAddFile = (filePath, isDraft) => {
|
2018-10-16 06:27:21 +00:00
|
|
|
this.setState({showFileDialog: !this.state.showFileDialog});
|
2018-11-22 03:26:00 +00:00
|
|
|
this.props.onAddFile(filePath, isDraft);
|
2018-10-16 06:27:21 +00:00
|
|
|
}
|
|
|
|
|
2018-11-22 03:26:00 +00:00
|
|
|
onAddFolder = (dirPath) => {
|
2018-10-16 06:27:21 +00:00
|
|
|
this.setState({showFolderDialog: !this.state.showFolderDialog});
|
2018-11-22 03:26:00 +00:00
|
|
|
this.props.onAddFolder(dirPath);
|
2018-10-16 06:27:21 +00:00
|
|
|
}
|
|
|
|
|
2018-10-25 05:36:06 +00:00
|
|
|
onItemDetails = (dirent, direntPath) => {
|
|
|
|
this.setState({
|
|
|
|
currentDirent: dirent,
|
2018-11-23 12:19:42 +00:00
|
|
|
direntPath: direntPath,
|
2018-10-25 05:36:06 +00:00
|
|
|
isDirentDetailShow: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onItemDetailsClose = () => {
|
|
|
|
this.setState({isDirentDetailShow: false});
|
|
|
|
}
|
|
|
|
|
2018-11-22 03:26:00 +00:00
|
|
|
onFileTagChanged = (dirent, direntPath) => {
|
|
|
|
//todos;
|
|
|
|
this.props.onFileTagChanged(dirent, direntPath);
|
2018-11-13 08:39:13 +00:00
|
|
|
}
|
|
|
|
|
2018-11-14 02:55:11 +00:00
|
|
|
uploadFile = (e) => {
|
|
|
|
e.nativeEvent.stopImmediatePropagation();
|
|
|
|
this.uploader.onFileUpload();
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadFolder = (e) => {
|
|
|
|
e.nativeEvent.stopImmediatePropagation();
|
|
|
|
this.uploader.onFolderUpload();
|
|
|
|
}
|
|
|
|
|
|
|
|
onFileSuccess = (file) => {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-23 12:19:42 +00:00
|
|
|
onSelectedMoveToggle = () => {
|
|
|
|
this.setState({
|
|
|
|
isMutipleOperation: true,
|
|
|
|
isMoveDialogShow: true,
|
|
|
|
currentDirent: null,
|
|
|
|
direntPath: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onSelectedCopyToggle = () => {
|
|
|
|
this.setState({
|
|
|
|
isMutipleOperation: true,
|
|
|
|
isCopyDialogShow: true,
|
|
|
|
currentDirent: null,
|
|
|
|
direntPath: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onItemMoveToggle = (dirent, direntPath) => {
|
|
|
|
this.setState({
|
|
|
|
isMutipleOperation: false,
|
|
|
|
isMoveDialogShow: true,
|
|
|
|
currentDirent: dirent,
|
|
|
|
direntPath: direntPath,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onItemCopyToggle = (dirent, direntPath) => {
|
|
|
|
this.setState({
|
|
|
|
isMutipleOperation: false,
|
|
|
|
isCopyDialogShow: true,
|
|
|
|
currentDirent: dirent,
|
|
|
|
direntPath: direntPath
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onCancelMove = () => {
|
|
|
|
this.setState({isMoveDialogShow: false});
|
|
|
|
}
|
|
|
|
|
|
|
|
onCancelCopy = () => {
|
|
|
|
this.setState({isCopyDialogShow: false});
|
|
|
|
}
|
|
|
|
|
|
|
|
onItemsDownload = () => {
|
|
|
|
let selectedDirentList = this.props.selectedDirentList;
|
|
|
|
if (selectedDirentList.length) {
|
|
|
|
if (selectedDirentList.length === 1 && !selectedDirentList[0].isDir()) {
|
|
|
|
let direntPath = Utils.joinPath(this.props.path, selectedDirentList[0].name);
|
|
|
|
let url = URLDecorator.getUrl({type: 'download_file_url', repoID: repoID, filePath: direntPath});
|
|
|
|
location.href= url;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let selectedDirentNames = selectedDirentList.map(dirent => {
|
|
|
|
return dirent.name;
|
|
|
|
});
|
|
|
|
this.setState({isProgressDialogShow: true, progress: 0});
|
|
|
|
seafileAPI.zipDownload(repoID, this.props.path, selectedDirentNames).then(res => {
|
|
|
|
this.zip_token = res.data['zip_token'];
|
|
|
|
this.addDownloadAnimation();
|
|
|
|
this.interval = setInterval(this.addDownloadAnimation, 1000);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onItemDownload = (dirent, direntPath) => {
|
|
|
|
if (dirent.type === 'dir') {
|
|
|
|
this.setState({isProgressDialogShow: true, progress: 0});
|
|
|
|
seafileAPI.zipDownload(repoID, this.props.path, dirent.name).then(res => {
|
|
|
|
this.zip_token = res.data['zip_token'];
|
|
|
|
this.addDownloadAnimation();
|
|
|
|
this.interval = setInterval(this.addDownloadAnimation, 1000);
|
|
|
|
}).catch(() => {
|
|
|
|
clearInterval(this.interval);
|
|
|
|
// Toast.error(gettext(''));
|
|
|
|
//todo;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
let url = URLDecorator.getUrl({type: 'download_file_url', repoID: repoID, filePath: direntPath});
|
|
|
|
location.href = url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addDownloadAnimation = () => {
|
|
|
|
let _this = this;
|
|
|
|
let token = this.zip_token;
|
|
|
|
seafileAPI.queryZipProgress(token).then(res => {
|
|
|
|
let data = res.data;
|
|
|
|
let progress = data.total === 0 ? 100 : (data.zipped / data.total * 100).toFixed(0);
|
|
|
|
this.setState({progress: parseInt(progress)});
|
|
|
|
|
|
|
|
if (data['total'] === data['zipped']) {
|
|
|
|
this.setState({
|
|
|
|
progress: 100
|
|
|
|
});
|
|
|
|
clearInterval(this.interval);
|
|
|
|
location.href = URLDecorator.getUrl({type: 'download_dir_zip_url', token: token});
|
|
|
|
setTimeout(function() {
|
|
|
|
_this.setState({isProgressDialogShow: false});
|
|
|
|
}, 500);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
onCancelDownload = () => {
|
|
|
|
let zip_token = this.zip_token;
|
|
|
|
seafileAPI.cancelZipTask(zip_token).then(res => {
|
|
|
|
this.setState({
|
|
|
|
isProgressDialogShow: false,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-10-13 09:07:54 +00:00
|
|
|
render() {
|
2018-11-22 03:26:00 +00:00
|
|
|
let path = this.props.path;
|
|
|
|
path = path[path.length - 1] === '/' ? path.slice(0, path.length - 1) : path;
|
|
|
|
let pathList = path.split('/');
|
2018-09-29 10:32:53 +00:00
|
|
|
let nodePath = '';
|
2018-11-22 03:26:00 +00:00
|
|
|
let pathElem = pathList.map((item, index) => {
|
2018-09-29 10:32:53 +00:00
|
|
|
if (item === '') {
|
2018-09-12 02:32:31 +00:00
|
|
|
return;
|
2018-11-22 03:26:00 +00:00
|
|
|
}
|
|
|
|
if (index === (pathList.length - 1)) {
|
2018-09-12 02:32:31 +00:00
|
|
|
return (
|
|
|
|
<span key={index}><span className="path-split">/</span>{item}</span>
|
2018-09-29 10:32:53 +00:00
|
|
|
);
|
2018-09-12 02:32:31 +00:00
|
|
|
} else {
|
2018-09-29 10:32:53 +00:00
|
|
|
nodePath += '/' + item;
|
2018-09-12 02:32:31 +00:00
|
|
|
return (
|
2018-09-19 01:57:17 +00:00
|
|
|
<span key={index} >
|
|
|
|
<span className="path-split">/</span>
|
2018-11-22 03:26:00 +00:00
|
|
|
<a
|
|
|
|
className="path-link"
|
|
|
|
data-path={nodePath}
|
2018-09-19 01:57:17 +00:00
|
|
|
onClick={this.onMainNavBarClick}>
|
|
|
|
{item}
|
|
|
|
</a>
|
|
|
|
</span>
|
2018-09-29 10:32:53 +00:00
|
|
|
);
|
2018-09-12 02:32:31 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2018-09-25 01:13:06 +00:00
|
|
|
<div className="main-panel wiki-main-panel o-hidden">
|
2018-09-12 02:32:31 +00:00
|
|
|
<div className="main-panel-top panel-top">
|
2018-09-20 02:19:11 +00:00
|
|
|
<div className="cur-view-toolbar border-left-show">
|
2018-11-22 03:26:00 +00:00
|
|
|
<span className="sf2-icon-menu hidden-md-up d-md-none side-nav-toggle" title={gettext('Side Nav Menu')} onClick={this.onSideNavMenuClick}></span>
|
2018-11-23 12:19:42 +00:00
|
|
|
<div className="dir-operation">
|
|
|
|
{this.props.isDirentSelected &&
|
|
|
|
<div className="operation mutiple-dirents-operation">
|
|
|
|
<button className="btn btn-secondary operation-item op-icon sf2-icon-move" title={gettext('Move')} onClick={this.onSelectedMoveToggle}></button>
|
|
|
|
<button className="btn btn-secondary operation-item op-icon sf2-icon-copy" title={gettext('Copy')} onClick={this.onSelectedCopyToggle}></button>
|
|
|
|
<button className="btn btn-secondary operation-item op-icon sf2-icon-delete" title={gettext('Delete')} onClick={this.props.onItemsDelete}></button>
|
|
|
|
<button className="btn btn-secondary operation-item op-icon sf2-icon-download" title={gettext('Download')} onClick={this.onItemsDownload}></button>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
{!this.props.isDirentSelected &&
|
|
|
|
<div className="operation">
|
|
|
|
{
|
|
|
|
this.props.permission === 'rw' &&
|
|
|
|
<button className="btn btn-secondary operation-item" title={gettext('Edit File')} onClick={this.onEditClick}>{gettext('Edit')}</button>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
!this.props.isViewFile &&
|
|
|
|
<Fragment>
|
|
|
|
{
|
|
|
|
Utils.isSupportUploadFolder() ?
|
|
|
|
<button className="btn btn-secondary operation-item" title={gettext('Upload')} onClick={this.onUploadClick}>{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.onNewClick}>{gettext('New')}</button>
|
|
|
|
<button className="btn btn-secondary operation-item" title={gettext('Share')} onClick={this.onShareClick}>{gettext('Share')}</button>
|
|
|
|
</Fragment>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
}
|
2018-11-22 03:26:00 +00:00
|
|
|
{
|
|
|
|
this.state.uploadMenuShow &&
|
2018-10-16 06:27:21 +00:00
|
|
|
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
|
2018-11-14 02:55:11 +00:00
|
|
|
<li className="dropdown-item" onClick={this.uploadFile}>{gettext('File Upload')}</li>
|
|
|
|
<li className="dropdown-item" onClick={this.uploadFolder}>{gettext('Folder Upload')}</li>
|
2018-10-16 06:27:21 +00:00
|
|
|
</ul>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
this.state.newMenuShow &&
|
|
|
|
<ul className="menu dropdown-menu" style={this.state.operationMenuStyle}>
|
2018-10-16 10:19:51 +00:00
|
|
|
<li className="dropdown-item" onClick={this.addFolder}>{gettext('New Folder')}</li>
|
|
|
|
<li className="dropdown-item" onClick={this.addFile}>{gettext('New File')}</li>
|
2018-10-25 05:36:06 +00:00
|
|
|
<li className="dropdown-divider"></li>
|
2018-10-16 10:19:51 +00:00
|
|
|
<li className="dropdown-item" onClick={this.addMarkdownFile}>{gettext('New Markdown File')}</li>
|
2018-10-16 06:27:21 +00:00
|
|
|
</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>
|
2018-09-19 01:57:17 +00:00
|
|
|
</div>
|
2018-09-12 02:32:31 +00:00
|
|
|
</div>
|
2018-09-25 01:13:06 +00:00
|
|
|
<CommonToolbar onSearchedClick={this.props.onSearchedClick} searchPlaceholder={'Search files in this library'}/>
|
2018-09-12 02:32:31 +00:00
|
|
|
</div>
|
2018-10-25 05:36:06 +00:00
|
|
|
<div className="main-panel-center flex-direction-row">
|
|
|
|
<div className="cur-view-container">
|
|
|
|
<div className="cur-view-path">
|
|
|
|
<div className="path-containter">
|
|
|
|
<a href={siteRoot + '#common/'} className="normal">{gettext('Libraries')}</a>
|
|
|
|
<span className="path-split">/</span>
|
2018-11-22 03:26:00 +00:00
|
|
|
{this.props.path === '/' ?
|
2018-10-25 05:36:06 +00:00
|
|
|
<span>{slug}</span> :
|
|
|
|
<a className="path-link" data-path="/" onClick={this.onMainNavBarClick}>{slug}</a>
|
|
|
|
}
|
|
|
|
{pathElem}
|
|
|
|
</div>
|
2018-11-22 03:26:00 +00:00
|
|
|
<PathToolbar path={this.props.path}/>
|
2018-10-25 05:36:06 +00:00
|
|
|
</div>
|
|
|
|
<div className="cur-view-content">
|
2018-11-22 03:26:00 +00:00
|
|
|
{ !this.props.pathExist ?
|
|
|
|
<div className="message empty-tip err-message"><h2>{gettext('Folder does not exist.')}</h2></div> :
|
2018-11-14 02:55:11 +00:00
|
|
|
<Fragment>
|
2018-11-22 03:26:00 +00:00
|
|
|
{ this.props.isViewFile ?
|
|
|
|
<MarkdownViewer
|
|
|
|
markdownContent={this.props.content}
|
|
|
|
latestContributor={this.props.latestContributor}
|
|
|
|
lastModified = {this.props.lastModified}
|
|
|
|
onLinkClick={this.props.onLinkClick}
|
|
|
|
isFileLoading={this.props.isFileLoading}
|
|
|
|
/> :
|
|
|
|
<Fragment>
|
|
|
|
<DirentListView
|
|
|
|
direntList={this.props.direntList}
|
|
|
|
path={this.props.path}
|
|
|
|
onItemClick={this.props.onItemClick}
|
|
|
|
onItemDelete={this.props.onItemDelete}
|
|
|
|
onItemRename={this.props.onItemRename}
|
2018-11-23 12:19:42 +00:00
|
|
|
onItemDownload={this.onItemDownload}
|
|
|
|
onItemMoveToggle={this.onItemMoveToggle}
|
|
|
|
onItemCopyToggle={this.onItemCopyToggle}
|
2018-11-22 03:26:00 +00:00
|
|
|
onItemDetails={this.onItemDetails}
|
|
|
|
isDirentListLoading={this.props.isDirentListLoading}
|
|
|
|
updateDirent={this.props.updateDirent}
|
|
|
|
currentRepo={this.state.currentRepo}
|
|
|
|
isRepoOwner={this.state.isRepoOwner}
|
2018-11-23 12:19:42 +00:00
|
|
|
isAllItemSelected={this.props.isAllDirentSelected}
|
|
|
|
onAllItemSelected={this.props.onAllDirentSelected}
|
|
|
|
onItemSelected={this.props.onItemSelected}
|
2018-11-22 03:26:00 +00:00
|
|
|
/>
|
|
|
|
<FileUploader
|
|
|
|
ref={uploader => this.uploader = uploader}
|
|
|
|
dragAndDrop={true}
|
|
|
|
path={this.props.path}
|
|
|
|
onFileSuccess={this.onFileSuccess}
|
|
|
|
direntList={this.props.direntList}
|
|
|
|
/>
|
|
|
|
</Fragment>
|
|
|
|
}
|
2018-11-14 02:55:11 +00:00
|
|
|
</Fragment>
|
2018-10-13 09:07:54 +00:00
|
|
|
}
|
2018-09-12 02:32:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-10-25 05:36:06 +00:00
|
|
|
{ this.state.isDirentDetailShow &&
|
|
|
|
<div className="cur-view-detail">
|
2018-11-22 03:26:00 +00:00
|
|
|
<DirentDetail
|
2018-10-25 05:36:06 +00:00
|
|
|
dirent={this.state.currentDirent}
|
2018-11-23 12:19:42 +00:00
|
|
|
direntPath={this.state.direntPath}
|
2018-10-25 05:36:06 +00:00
|
|
|
onItemDetailsClose={this.onItemDetailsClose}
|
2018-11-13 08:39:13 +00:00
|
|
|
onFileTagChanged={this.onFileTagChanged}
|
2018-09-21 06:16:15 +00:00
|
|
|
/>
|
2018-10-25 05:36:06 +00:00
|
|
|
</div>
|
|
|
|
}
|
2018-09-12 02:32:31 +00:00
|
|
|
</div>
|
2018-11-22 03:26:00 +00:00
|
|
|
{this.state.showFileDialog &&
|
2018-10-16 06:27:21 +00:00
|
|
|
<CreateFile
|
|
|
|
fileType={this.state.createFileType}
|
2018-11-22 03:26:00 +00:00
|
|
|
parentPath={this.props.path}
|
2018-10-16 06:27:21 +00:00
|
|
|
addFileCancel={this.addFileCancel}
|
2018-11-22 03:26:00 +00:00
|
|
|
onAddFile={this.onAddFile}
|
2018-10-16 06:27:21 +00:00
|
|
|
/>
|
|
|
|
}
|
|
|
|
{this.state.showFolderDialog &&
|
2018-11-22 03:26:00 +00:00
|
|
|
<CreateFolder
|
|
|
|
parentPath={this.props.path}
|
2018-10-16 06:27:21 +00:00
|
|
|
addFolderCancel={this.addFolderCancel}
|
2018-11-22 03:26:00 +00:00
|
|
|
onAddFolder={this.onAddFolder}
|
2018-10-16 06:27:21 +00:00
|
|
|
/>
|
|
|
|
}
|
2018-11-23 12:19:42 +00:00
|
|
|
{this.state.isMoveDialogShow &&
|
|
|
|
<MoveDirentDialog
|
|
|
|
path={this.props.path}
|
|
|
|
isMutipleOperation={this.state.isMutipleOperation}
|
|
|
|
selectedDirentList={this.props.selectedDirentList}
|
|
|
|
dirent={this.state.currentDirent}
|
|
|
|
direntPath={this.state.direntPath}
|
|
|
|
onItemMove={this.props.onItemMove}
|
|
|
|
onItemsMove={this.props.onItemsMove}
|
|
|
|
onCancelMove={this.onCancelMove}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{this.state.isCopyDialogShow &&
|
|
|
|
<CopyDirentDialog
|
|
|
|
path={this.props.path}
|
|
|
|
isMutipleOperation={this.state.isMutipleOperation}
|
|
|
|
selectedDirentList={this.props.selectedDirentList}
|
|
|
|
dirent={this.state.currentDirent}
|
|
|
|
direntPath={this.state.direntPath}
|
|
|
|
onItemCopy={this.props.onItemCopy}
|
|
|
|
onItemsCopy={this.props.onItemsCopy}
|
|
|
|
onCancelCopy={this.onCancelCopy}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{this.state.isProgressDialogShow &&
|
|
|
|
<ZipDownloadDialog progress={this.state.progress} onCancelDownload={this.onCancelDownload}
|
|
|
|
/>
|
|
|
|
}
|
2018-09-29 10:32:53 +00:00
|
|
|
</div>
|
|
|
|
);
|
2018-09-12 02:32:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-13 09:07:54 +00:00
|
|
|
MainPanel.propTypes = propTypes;
|
|
|
|
|
2018-09-12 02:32:31 +00:00
|
|
|
export default MainPanel;
|