mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 02:42:47 +00:00
fix code format (#6365)
This commit is contained in:
@@ -5,7 +5,7 @@ import Dirent from '../../models/dirent';
|
||||
|
||||
class TreeHelper {
|
||||
|
||||
expandNode(tree, node) { // This tree has been cloned
|
||||
expandNode(tree, node) { // This tree has been cloned
|
||||
tree.expandNode(node);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class TreeHelper {
|
||||
let treeCopy = tree.clone();
|
||||
let node = treeCopy.getNodeByPath(nodePath);
|
||||
let destNode = treeCopy.getNodeByPath(destPath);
|
||||
if (destNode && node) { // node has loaded
|
||||
if (destNode && node) { // node has loaded
|
||||
node.object.name = nodeName; // need not update path
|
||||
treeCopy.moveNode(node, destNode);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class TreeHelper {
|
||||
treeCopy.moveNode(node, destNode);
|
||||
});
|
||||
} else {
|
||||
nodePaths.forEach(nodePath=> {
|
||||
nodePaths.forEach(nodePath => {
|
||||
let node = treeCopy.getNodeByPath(nodePath);
|
||||
treeCopy.delete(node);
|
||||
});
|
||||
@@ -111,8 +111,8 @@ class TreeHelper {
|
||||
let destNode = treeCopy.getNodeByPath(destPath);
|
||||
let treeNode = treeCopy.getNodeByPath(nodePath);
|
||||
if (destNode) {
|
||||
let node = treeNode.clone(); // need a dup
|
||||
node.object.name = nodeName; // need not update path
|
||||
let node = treeNode.clone(); // need a dup
|
||||
node.object.name = nodeName; // need not update path
|
||||
treeCopy.copyNode(node, destNode);
|
||||
}
|
||||
return treeCopy;
|
||||
@@ -132,8 +132,8 @@ class TreeHelper {
|
||||
|
||||
buildTree() {
|
||||
let tree = new Tree();
|
||||
let object = new Dirent({name: '/'});
|
||||
let root = new TreeNode({object, isLoaded: false, isExpanded: true});
|
||||
let object = new Dirent({ name: '/' });
|
||||
let root = new TreeNode({ object, isLoaded: false, isExpanded: true });
|
||||
tree.setRoot(root);
|
||||
return tree;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ const propTypes = {
|
||||
onNodeDrop: PropTypes.func,
|
||||
handleContextClick: PropTypes.func.isRequired,
|
||||
onNodeDragEnter: PropTypes.func.isRequired,
|
||||
onNodeDragLeave:PropTypes.func.isRequired,
|
||||
onNodeDragLeave: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
class TreeNodeView extends React.Component {
|
||||
@@ -119,7 +119,7 @@ class TreeNodeView extends React.Component {
|
||||
return false;
|
||||
}
|
||||
if (this.props.node.object.type === 'dir') {
|
||||
this.setState({isNodeDropShow: true});
|
||||
this.setState({ isNodeDropShow: true });
|
||||
}
|
||||
this.props.onNodeDragEnter(e, this.props.node);
|
||||
};
|
||||
@@ -135,7 +135,7 @@ class TreeNodeView extends React.Component {
|
||||
if (Utils.isIEBrower() || !this.canDrag) {
|
||||
return false;
|
||||
}
|
||||
this.setState({isNodeDropShow: false});
|
||||
this.setState({ isNodeDropShow: false });
|
||||
this.props.onNodeDragLeave(e, this.props.node);
|
||||
};
|
||||
|
||||
@@ -144,12 +144,12 @@ class TreeNodeView extends React.Component {
|
||||
return false;
|
||||
}
|
||||
e.stopPropagation();
|
||||
this.setState({isNodeDropShow: false});
|
||||
this.setState({ isNodeDropShow: false });
|
||||
this.props.onNodeDrop(e, this.props.node);
|
||||
};
|
||||
|
||||
unfreezeItem = () => {
|
||||
this.setState({isShowOperationMenu: false});
|
||||
this.setState({ isShowOperationMenu: false });
|
||||
this.props.unfreezeItem();
|
||||
};
|
||||
|
||||
@@ -170,7 +170,7 @@ class TreeNodeView extends React.Component {
|
||||
|
||||
handleContextClick = (event) => {
|
||||
this.props.handleContextClick(event, this.props.node);
|
||||
this.setState({isShowOperationMenu: false});
|
||||
this.setState({ isShowOperationMenu: false });
|
||||
};
|
||||
|
||||
getNodeTypeAndIcon = () => {
|
||||
@@ -201,11 +201,11 @@ class TreeNodeView extends React.Component {
|
||||
}
|
||||
}
|
||||
}
|
||||
return {icon, type};
|
||||
return { icon, type };
|
||||
};
|
||||
|
||||
calculateMenuList = (node) => {
|
||||
let { NEW_FOLDER, NEW_FILE, COPY, MOVE, RENAME, DELETE, OPEN_VIA_CLIENT} = TextTranslation;
|
||||
let { NEW_FOLDER, NEW_FILE, COPY, MOVE, RENAME, DELETE, OPEN_VIA_CLIENT } = TextTranslation;
|
||||
|
||||
let menuList = [RENAME, DELETE, COPY, MOVE, OPEN_VIA_CLIENT];
|
||||
if (node.object.type === 'dir') {
|
||||
@@ -284,7 +284,7 @@ class TreeNodeView extends React.Component {
|
||||
<div className="tree-node">
|
||||
<div
|
||||
type={type}
|
||||
className={`tree-node-inner text-nowrap ${hlClass} ${node.path === '/'? 'hide': ''} ${this.state.isNodeDropShow ? 'tree-node-drop' : ''}`}
|
||||
className={`tree-node-inner text-nowrap ${hlClass} ${node.path === '/' ? 'hide' : ''} ${this.state.isNodeDropShow ? 'tree-node-drop' : ''}`}
|
||||
title={node.object.name}
|
||||
onMouseEnter={this.onMouseEnter}
|
||||
onMouseOver={this.onMouseOver}
|
||||
@@ -301,15 +301,17 @@ class TreeNodeView extends React.Component {
|
||||
onDragLeave={this.onNodeDragLeave}
|
||||
onDragOver={this.onNodeDragMove}
|
||||
onDrop={this.onNodeDrop}
|
||||
style={{paddingLeft: leftIndent + 5}}
|
||||
>{node.object.name}</div>
|
||||
<div className="left-icon" style={{left: leftIndent - 40}}>
|
||||
style={{ paddingLeft: leftIndent + 5 }}
|
||||
>{node.object.name}
|
||||
</div>
|
||||
<div className="left-icon" style={{ left: leftIndent - 40 }}>
|
||||
{type === 'dir' && (!node.isLoaded || (node.isLoaded && node.hasChildren())) && (
|
||||
<i
|
||||
className={`folder-toggle-icon sf3-font sf3-font-down ${node.isExpanded ? '' : 'rotate-270'}`}
|
||||
onMouseDown={e => e.stopPropagation()}
|
||||
onClick={this.onLoadToggle}
|
||||
></i>
|
||||
>
|
||||
</i>
|
||||
)}
|
||||
<i className="tree-node-icon">{icon}</i>
|
||||
</div>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
class TreeNode {
|
||||
|
||||
constructor({ path, object, isLoaded, isPreload, isExpanded, parentNode }) {
|
||||
this.path = path || object.name; // The default setting is the object name, which is set to a relative path when the father is set.
|
||||
this.path = path || object.name; // The default setting is the object name, which is set to a relative path when the father is set.
|
||||
this.object = object;
|
||||
this.isLoaded = isLoaded || false;
|
||||
this.isPreload = isPreload || false;
|
||||
@@ -30,7 +30,7 @@ class TreeNode {
|
||||
setParent(parentNode) {
|
||||
this.path = this.generatePath(parentNode);
|
||||
this.parentNode = parentNode;
|
||||
this.isLoaded = false; // update parentNode need loaded data again;
|
||||
this.isLoaded = false; // update parentNode need loaded data again;
|
||||
}
|
||||
|
||||
hasChildren() {
|
||||
|
@@ -52,7 +52,7 @@ class TreeView extends React.Component {
|
||||
if (Utils.isIEBrower()) {
|
||||
return false;
|
||||
}
|
||||
let dragStartNodeData = {nodeDirent: node.object, nodeParentPath: node.parentNode.path, nodeRootPath: node.path};
|
||||
let dragStartNodeData = { nodeDirent: node.object, nodeParentPath: node.parentNode.path, nodeRootPath: node.path };
|
||||
dragStartNodeData = JSON.stringify(dragStartNodeData);
|
||||
|
||||
e.dataTransfer.effectAllowed = 'move';
|
||||
@@ -109,17 +109,17 @@ class TreeView extends React.Component {
|
||||
let dragStartNodeData = e.dataTransfer.getData('applicaiton/drag-item-info');
|
||||
dragStartNodeData = JSON.parse(dragStartNodeData);
|
||||
|
||||
let {nodeDirent, nodeParentPath, nodeRootPath} = dragStartNodeData;
|
||||
let { nodeDirent, nodeParentPath, nodeRootPath } = dragStartNodeData;
|
||||
let dropNodeData = node;
|
||||
|
||||
if (Array.isArray(dragStartNodeData)) { //move items
|
||||
if (!dropNodeData) { //move items to root
|
||||
if (Array.isArray(dragStartNodeData)) { // move items
|
||||
if (!dropNodeData) { // move items to root
|
||||
if (dragStartNodeData[0].nodeParentPath === '/') {
|
||||
this.setState({isTreeViewDropTipShow: false});
|
||||
this.setState({ isTreeViewDropTipShow: false });
|
||||
return;
|
||||
}
|
||||
this.props.onItemsMove(this.props.currentRepoInfo, '/');
|
||||
this.setState({isTreeViewDropTipShow: false});
|
||||
this.setState({ isTreeViewDropTipShow: false });
|
||||
return;
|
||||
}
|
||||
this.onMoveItems(dragStartNodeData, dropNodeData, this.props.currentRepoInfo, dropNodeData.path);
|
||||
@@ -128,11 +128,11 @@ class TreeView extends React.Component {
|
||||
|
||||
if (!dropNodeData) {
|
||||
if (nodeParentPath === '/') {
|
||||
this.setState({isTreeViewDropTipShow: false});
|
||||
this.setState({ isTreeViewDropTipShow: false });
|
||||
return;
|
||||
}
|
||||
this.onItemMove(this.props.currentRepoInfo, nodeDirent, '/', nodeParentPath);
|
||||
this.setState({isTreeViewDropTipShow: false});
|
||||
this.setState({ isTreeViewDropTipShow: false });
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -198,11 +198,11 @@ class TreeView extends React.Component {
|
||||
};
|
||||
|
||||
freezeItem = () => {
|
||||
this.setState({isItemFreezed: true});
|
||||
this.setState({ isItemFreezed: true });
|
||||
};
|
||||
|
||||
unfreezeItem = () => {
|
||||
this.setState({isItemFreezed: false});
|
||||
this.setState({ isItemFreezed: false });
|
||||
};
|
||||
|
||||
onMenuItemClick = (operation, node) => {
|
||||
|
Reference in New Issue
Block a user