diff --git a/frontend/src/components/dir-view-mode/dir-column-view.js b/frontend/src/components/dir-view-mode/dir-column-view.js
index 0baa062abd..9a5e19e540 100644
--- a/frontend/src/components/dir-view-mode/dir-column-view.js
+++ b/frontend/src/components/dir-view-mode/dir-column-view.js
@@ -3,8 +3,10 @@ import PropTypes from 'prop-types';
import DirColumnNav from './dir-column-nav';
import DirColumnFile from './dir-column-file';
import DirListView from './dir-list-view';
+import DirGridView from './dir-grid-view';
const propTypes = {
+ currentMode: PropTypes.string.isRequired,
path: PropTypes.string.isRequired,
repoID: PropTypes.string.isRequired,
// repoinfo
@@ -64,7 +66,8 @@ const propTypes = {
onFileTagChanged: PropTypes.func,
showDirentDetail: PropTypes.func.isRequired,
fullDirentList: PropTypes.array,
- onItemsScroll: PropTypes.func.isRequired
+ onItemsScroll: PropTypes.func.isRequired,
+ isDirentDetailShow: PropTypes.bool.isRequired
};
class DirColumnView extends React.Component {
@@ -143,6 +146,7 @@ class DirColumnView extends React.Component {
}
render() {
+ const { currentMode } = this.props;
const onResizeMove = this.state.inResizing ? this.onResizeMouseMove : null;
const select = this.state.inResizing ? 'none' : '';
const mainFlex = '1 0 ' + (1 - this.state.navRate - 0.05) * 100 + '%';
@@ -185,7 +189,7 @@ class DirColumnView extends React.Component {
latestContributor={this.props.latestContributor}
onLinkClick={this.props.onLinkClick}
/>
- ) : (
+ ) : (currentMode == 'list' ?
:
+
)}
diff --git a/frontend/src/components/toolbar/view-mode-toolbar.js b/frontend/src/components/toolbar/view-mode-toolbar.js
index da7c2df3a8..ab7ce7a3e2 100644
--- a/frontend/src/components/toolbar/view-mode-toolbar.js
+++ b/frontend/src/components/toolbar/view-mode-toolbar.js
@@ -30,7 +30,6 @@ class ViewModeToolbar extends React.Component {
-
{!this.props.isCustomPermission && (
diff --git a/frontend/src/pages/lib-content-view/lib-content-container.js b/frontend/src/pages/lib-content-view/lib-content-container.js
index e23f7bd8ae..e033470983 100644
--- a/frontend/src/pages/lib-content-view/lib-content-container.js
+++ b/frontend/src/pages/lib-content-view/lib-content-container.js
@@ -4,14 +4,13 @@ import { gettext } from '../../utils/constants';
import CurDirPath from '../../components/cur-dir-path';
import DirentDetail from '../../components/dirent-detail/dirent-details';
import LibDetail from '../../components/dirent-detail/lib-details';
-import DirListView from '../../components/dir-view-mode/dir-list-view';
-import DirGridView from '../../components/dir-view-mode/dir-grid-view';
import DirColumnView from '../../components/dir-view-mode/dir-column-view';
import '../../css/lib-content-view.css';
const propTypes = {
pathPrefix: PropTypes.array.isRequired,
+ isTreePanelShown: PropTypes.bool.isRequired,
currentMode: PropTypes.string.isRequired,
path: PropTypes.string.isRequired,
pathExist: PropTypes.bool.isRequired,
@@ -114,12 +113,6 @@ class LibContentContainer extends React.Component {
this.props.closeDirentDetail();
};
- onGridItemClick = (dirent) => {
- this.setState({currentDirent: dirent});
- this.props.onDirentClick(dirent);
- };
-
- // on '
'
onDirentClick = (dirent) => {
this.setState({currentDirent: dirent});
this.props.onDirentClick(dirent);
@@ -195,141 +188,68 @@ class LibContentContainer extends React.Component {
sortItems={this.props.sortItems}
/>
-
+
{!this.props.pathExist && this.errMessage}
{this.props.pathExist && (
-
- {this.props.currentMode === 'list' && (
-
- )}
- {this.props.currentMode === 'grid' && (
-
- )}
- {this.props.currentMode === 'column' && (
-
- )}
-
+
)}
diff --git a/frontend/src/pages/lib-content-view/lib-content-view.js b/frontend/src/pages/lib-content-view/lib-content-view.js
index ae209671c4..22fffe0168 100644
--- a/frontend/src/pages/lib-content-view/lib-content-view.js
+++ b/frontend/src/pages/lib-content-view/lib-content-view.js
@@ -35,6 +35,7 @@ class LibContentView extends React.Component {
super(props);
this.state = {
currentMode: cookie.load('seafile_view_mode') || 'list',
+ isTreePanelShown: true, // display the 'dirent tree' side panel
path: '',
pathExist: true,
isViewFile: false,
@@ -213,7 +214,7 @@ class LibContentView extends React.Component {
}
} else if (event.state && event.state.path) { // file path
let path = event.state.path;
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
if (Utils.isMarkdownFile(path)) { // Judging not strict
this.showFile(path);
return;
@@ -235,7 +236,7 @@ class LibContentView extends React.Component {
let repoID = this.props.repoID;
let { path, dirID } = this.state;
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
if (this.state.isViewFile) {
this.updateColumnMarkdownData(path);
} else {
@@ -328,14 +329,16 @@ class LibContentView extends React.Component {
if (Utils.isMarkdownFile(path)) {
seafileAPI.getFileInfo(this.props.repoID, path).then(() => {
+ /*
if (this.state.currentMode !== 'column') {
cookie.save('seafile_view_mode', 'column');
this.setState({currentMode: 'column'});
}
+ */
this.loadSidePanel(path);
this.showFile(path);
}).catch(() => {
- if (this.state.currentMode === 'column') { // After an error occurs, follow dir
+ if (this.state.isTreePanelShown) { // After an error occurs, follow dir
this.loadSidePanel(path);
this.showDir(path);
} else {
@@ -343,7 +346,7 @@ class LibContentView extends React.Component {
}
});
} else {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.loadSidePanel(path);
this.showDir(path);
} else {
@@ -401,7 +404,7 @@ class LibContentView extends React.Component {
showFile = (filePath) => {
let repoID = this.props.repoID;
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
seafileAPI.listFileTags(repoID, filePath).then(res => {
let fileTags = res.data.file_tags.map(item => {
return new FileTag(item);
@@ -607,14 +610,14 @@ class LibContentView extends React.Component {
if (data.successful) {
if (asyncOperationType === 'move') {
if (this.currentMoveItemName && this.currentMoveItemPath) {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.deleteTreeNode(this.currentMoveItemPath);
}
this.moveDirent(this.currentMoveItemName);
this.currentMoveItemName = '';
this.currentMoveItemPath = '';
} else {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
let direntPaths = this.getSelectedDirentPaths();
this.deleteTreeNodes(direntPaths);
}
@@ -688,14 +691,14 @@ class LibContentView extends React.Component {
}
if (repoID === destRepo.repo_id) {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.deleteTreeNodes(direntPaths);
}
this.moveDirents(dirNames);
// 2. tow columns mode need update left tree
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.updateMoveCopyTreeNode(destDirentPath);
}
@@ -740,7 +743,7 @@ class LibContentView extends React.Component {
}
if (repoID === destRepo.repo_id) {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.updateMoveCopyTreeNode(destDirentPath);
}
@@ -779,14 +782,14 @@ class LibContentView extends React.Component {
let name = Utils.getFileName(dirent.path);
let parentPath = Utils.getDirName(dirent.path);
if (!dirent.is_dir) {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.addNodeToTree(name, parentPath, 'file');
}
if (parentPath === this.state.path && !this.state.isViewFile) {
this.addDirent(name, 'file');
}
} else {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.addNodeToTree(name, parentPath, 'dir');
}
if (parentPath === this.state.path && !this.state.isViewFile) {
@@ -823,7 +826,7 @@ class LibContentView extends React.Component {
this.setState({updateDetail: !this.state.updateDetail});
seafileAPI.deleteMutipleDirents(repoID, this.state.path, dirNames).then(res => {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.deleteTreeNodes(direntPaths);
}
@@ -862,7 +865,7 @@ class LibContentView extends React.Component {
let name = Utils.getFileName(dirPath);
let parentPath = Utils.getDirName(dirPath);
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.addNodeToTree(name, parentPath, 'dir');
}
@@ -880,7 +883,7 @@ class LibContentView extends React.Component {
seafileAPI.createFile(repoID, filePath).then(res => {
let name = Utils.getFileName(filePath);
let parentPath = Utils.getDirName(filePath);
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.addNodeToTree(name, parentPath, 'file');
}
if (parentPath === this.state.path && !this.state.isViewFile) {
@@ -902,7 +905,7 @@ class LibContentView extends React.Component {
}
cookie.save('seafile_view_mode', mode);
let path = this.state.path;
- if (this.state.currentMode === 'column' && this.state.isViewFile) {
+ if (this.state.isTreePanelShown && this.state.isViewFile) {
path = Utils.getDirName(path);
this.setState({
path: path,
@@ -914,7 +917,7 @@ class LibContentView extends React.Component {
window.history.pushState({url: url, path: path}, path, url);
}
- if (mode === 'column') {
+ if (this.state.isTreePanelShown) {
this.loadSidePanel(this.state.path);
}
this.isNeedUpdateHistoryState = false;
@@ -927,7 +930,7 @@ class LibContentView extends React.Component {
if (this.state.currentPath === path) {
return;
}
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
// load sidePanel
let index = -1;
let paths = Utils.getPaths(path);
@@ -982,7 +985,7 @@ class LibContentView extends React.Component {
onMainNavBarClick = (nodePath) => {
//just for dir
this.resetSelected();
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
let tree = this.state.treeData.clone();
let node = tree.getNodeByPath(nodePath);
tree.expandNode(node);
@@ -1058,7 +1061,7 @@ class LibContentView extends React.Component {
};
renameItemAjaxCallback(path, newName) {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.renameTreeNode(path, newName);
}
this.renameDirent(path, newName);
@@ -1122,7 +1125,7 @@ class LibContentView extends React.Component {
}
deleteItemAjaxCallback(path) {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.deleteTreeNode(path);
}
this.deleteDirent(path);
@@ -1153,13 +1156,14 @@ class LibContentView extends React.Component {
});
}
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.deleteTreeNode(direntPath);
}
// 1. move to current repo
// 2. tow columns mode need update left tree
- if (repoID === destRepo.repo_id && this.state.currentMode === 'column') {
+ if (repoID === destRepo.repo_id &&
+ this.state.isTreePanelShown) {
this.updateMoveCopyTreeNode(moveToDirentPath);
}
@@ -1215,7 +1219,7 @@ class LibContentView extends React.Component {
}
if (repoID === destRepo.repo_id) {
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.updateMoveCopyTreeNode(copyToDirentPath);
}
@@ -1258,7 +1262,7 @@ class LibContentView extends React.Component {
let new_path = parentDir + '/' + newFileName;
let parentPath = Utils.getDirName(new_path);
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.addNodeToTree(newFileName, parentPath, 'file');
}
@@ -1303,12 +1307,12 @@ class LibContentView extends React.Component {
let repoID = this.props.repoID;
let direntPath = Utils.joinPath(this.state.path, dirent.name);
if (dirent.isDir()) { // is dir
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.loadTreeNodeByPath(direntPath);
}
this.showDir(direntPath);
} else { // is file
- if (this.state.currentMode === 'column' && Utils.isMarkdownFile(direntPath)) {
+ if (this.state.isTreePanelShown && Utils.isMarkdownFile(direntPath)) {
this.showColumnMarkdownFile(direntPath);
} else {
let url = siteRoot + 'lib/' + repoID + '/file' + Utils.encodePath(direntPath);
@@ -1426,7 +1430,7 @@ class LibContentView extends React.Component {
// use current dirent parent's permission as it's permission
direntObject.permission = this.state.userPerm;
let dirent = new Dirent(direntObject);
- if (this.state.currentMode === 'column') {
+ if (this.state.isTreePanelShown) {
this.addNodeToTree(dirent.name, this.state.path, dirent.type);
}
if (direntObject.type === 'dir') {
@@ -2041,6 +2045,7 @@ class LibContentView extends React.Component {