1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-08 02:10:24 +00:00

Combine view mode (#2959)

This commit is contained in:
杨顺强
2019-02-20 11:54:25 +08:00
committed by Daniel Pan
parent c73bf667ed
commit a7b0fb17f4
30 changed files with 2178 additions and 1124 deletions

View File

@@ -4,6 +4,7 @@ import TreeNodeMenu from './tree-node-menu';
import { permission } from '../../utils/constants';
const propTypes = {
repoPermission: PropTypes.bool,
node: PropTypes.object.isRequired,
currentPath: PropTypes.string.isRequired,
paddingLeft: PropTypes.number.isRequired,
@@ -111,6 +112,7 @@ class TreeNodeView extends React.Component {
key={item.path}
node={item}
paddingLeft={paddingLeft}
repoPermission={this.props.repoPermission}
currentPath={this.props.currentPath}
isNodeMenuShow={this.props.isNodeMenuShow}
isItemFreezed={this.props.isItemFreezed}
@@ -150,7 +152,7 @@ class TreeNodeView extends React.Component {
</div>
{isNodeMenuShow && (
<div className="right-icon">
{(permission && this.state.isShowOperationMenu) && (
{((this.props.repoPermission || permission) && this.state.isShowOperationMenu) && (
<TreeNodeMenu
node={this.props.node}
onMenuItemClick={this.onMenuItemClick}

View File

@@ -10,17 +10,17 @@ class TreeNode {
this.parentNode = parentNode || null;
}
clone() {
clone(parentNode) {
let treeNode = new TreeNode({
path: this.path,
object: this.object.clone(),
isLoaded: this.isLoaded,
isPreload: this.isPreload,
isExpanded: this.isExpanded,
parentNode: this.parentNode,
parentNode: parentNode || null,
});
treeNode.children = this.children.map(child => {
let newChild = child.clone();
let newChild = child.clone(treeNode);
return newChild;
});
@@ -77,9 +77,24 @@ class TreeNode {
rename(newName) {
this.object.name = newName;
this.path = this.generatePath(this.parentNode);
if (this.isExpanded) {
this.updateChildrenPath(this);
}
// this.isLoaded = false;
}
updateChildrenPath(node) {
let children = node.children;
children.forEach(child => {
child.path = child.generatePath(child.parentNode);
if (child.isExpanded) {
child.updateChildrenPath(child);
} else {
child.isLoaded = false;
}
});
}
updateObjectProperties(keys, newValues) {
if (Array.isArray(keys) && Array.isArray(newValues)) {
keys.forEach((key, index) => {

View File

@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import TreeNodeView from './tree-node-view';
const propTypes = {
repoPermission: PropTypes.bool,
isNodeMenuShow: PropTypes.bool.isRequired,
treeData: PropTypes.object.isRequired,
currentPath: PropTypes.string.isRequired,
@@ -39,6 +40,7 @@ class TreeView extends React.Component {
return (
<div className="tree-view tree">
<TreeNodeView
repoPermission={this.props.repoPermission}
node={this.props.treeData.root}
currentPath={this.props.currentPath}
paddingLeft={PADDING_LEFT}