Skip to content

TagSpaces is an offline, open source, document manager with tagging support

cleaning old treenav implementation

Ilian Sapundshiev14b26e4eb3d4
diff --git a/app/components/LocationManager.js b/app/components/LocationManager.js
index 4456a3faa..a2e41e97a 100644
--- a/app/components/LocationManager.js
+++ b/app/components/LocationManager.js
@@ -19,7 +19,6 @@
import React from 'react';
import Table from 'rc-table';
-// import 'rc-table/assets/index.css';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { withStyles } from '@material-ui/core/styles';
@@ -45,10 +44,8 @@ import CloseIcon from '@material-ui/icons/Close';
import DefaultLocationIcon from '@material-ui/icons/Highlight';
import ArrowDownwardIcon from '@material-ui/icons/ArrowDownward';
import ArrowUpwardIcon from '@material-ui/icons/ArrowUpward';
-// import Button from '@material-ui/Button';
import styles from './SidePanels.css';
import DirectoryMenu from './menus/DirectoryMenu';
-// import TreeNav from './TreeNav/TreeNav';
import EditLocationDialog from './dialogs/EditLocationDialog';
import CreateLocationDialog from './dialogs/CreateLocationDialog';
import ConfirmDialog from './dialogs/ConfirmDialog';
@@ -581,7 +578,6 @@ class LocationManager extends React.Component<Props, State> {
<DefaultLocationIcon
title={i18n.t('core: thisIsStartupLocation')}
data-tid="startupIndication"
- className={this.props.classes.icon}
/>
)}
<IconButton
diff --git a/app/components/TreeNav/TreeNav.js b/app/components/TreeNav/TreeNav.js
deleted file mode 100644
index aec225ce3..000000000
--- a/app/components/TreeNav/TreeNav.js
+++ /dev/null
@@ -1,176 +0,0 @@
-/**
- * TagSpaces - universal file and folder organizer
- * Copyright (C) 2017-present TagSpaces UG (haftungsbeschraenkt)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License (version 3) as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * @flow
- */
-
-import React from 'react';
-import Tree, { TreeNode } from 'rc-tree';
-import './index.less';
-import { loadSubFolders } from '../../services/utils-io';
-
-class TreeNav extends React.Component {
- constructor() {
- super();
-
- this.state = {
- selectedKeys: '',
- treeData: [],
- checkedKeys: []
- };
-
- this.onSelect = this.onSelect.bind(this);
- // this.onCheck = this.onCheck.bind(this);
- this.onLoadData = this.onLoadData.bind(this);
- }
-
- componentDidMount() {
- loadSubFolders(this.props.locationRootPath).then((rootDirContent) => {
- this.setState({
- treeData: rootDirContent
- });
- return true;
- }).catch((error) => {
- console.log('Error listing directory ' + error);
- });
- }
-
- componentWillReceiveProps(nextProps) {
- loadSubFolders(nextProps.locationRootPath).then((rootDirContent) => {
- this.setState({
- treeData: rootDirContent
- });
- return true;
- }).catch((error) => {
- console.log('Error listing directory ' + error);
- });
- }
-
- onSelect = (info, event) => {
- this.props.loadDirectoryContent(event.node.props.path);
- this.setState({ selectedKeys: info });
- // console.log('selected tree path', e.node.props.path );
- };
-
- onRightClick = (info) => {
- // console.log('right click', info, event);
- this.setState({ selectedKeys: [info.node.props.eventKey] });
- const selectedPath = info.node.props.path;
- this.props.handleDirectoryContextMenu(info.event, selectedPath);
- };
-
- /* onCheck = (checkedKeys) => {
- console.log(checkedKeys);
- this.setState({
- checkedKeys
- });
- }; */
-
- onLoadData = (treeNode) => new Promise((resolve) => {
- const level = treeNode.props.eventKey.split('-').length + 1;
- // console.log('Level ' + level);
- loadSubFolders(treeNode.props.path).then((dirContent) => {
- const treeData = [...this.state.treeData];
- for (let i = 0; i < dirContent.length; i++) {
- dirContent[i].key = treeNode.props.eventKey + '-' + i;
- }
- getNewTreeData(treeData, treeNode.props.eventKey, dirContent, level);
- this.setState({ treeData }, resolve());
- return true;
- }).catch((error) => {
- console.log('Error listing directory ' + error);
- });
- });
-
- render() {
- const loop = (data) => data.map((item) => {
- if (item.children) {
- return (
- <TreeNode
- title={item.name}
- path={item.path}
- key={item.key}
- isLeaf={false}
- >
- {loop(item.children)}
- </TreeNode>
- );
- }
- return (
- <TreeNode
- title={item.name}
- path={item.path}
- key={item.key}
- isLeaf={false}
- />
- );
- });
- const treeNodes = loop(this.state.treeData);
- return (
- <div>
- <Tree
- onRightClick={this.onRightClick}
- disableCheckbox={true}
- showIcon={false}
- checkable={false}
- onSelect={this.onSelect}
- checkedKeys={this.state.checkedKeys}
- loadData={this.onLoadData}
- >
- {treeNodes}
- </Tree>
- </div>
- );
- }
-}
-
-/*
-function setLeaf(treeData, curKey, level) {
- const loopLeaf = (data, lev) => {
- const l = lev - 1;
- data.forEach((item) => {
- if ((item.key.length > curKey.length) ? item.key.indexOf(curKey) !== 0 :
- curKey.indexOf(item.key) !== 0) {
- return;
- }
- if (item.children) {
- loopLeaf(item.children, l);
- } else if (l < 1) {
- item.isLeaf = true;
- }
- });
- };
- loopLeaf(treeData, level + 1);
-} */
-
-function getNewTreeData(treeData, curKey, children, level) {
- const loop = (tData) => {
- // if (level < 1 || curKey.length - 3 > level * 2) return;
- tData.forEach((item) => {
- if (curKey.indexOf(item.key) === 0) {
- if (item.children) {
- loop(item.children);
- } else {
- item.children = children;
- }
- }
- });
- };
- loop(treeData);
- // setLeaf(treeData, curKey, level);
-}
-
-export default TreeNav;
diff --git a/app/components/TreeNav/icons.png b/app/components/TreeNav/icons.png
deleted file mode 100644
index ffda01ef1..000000000
Binary files a/app/components/TreeNav/icons.png and /dev/null differ
diff --git a/app/components/TreeNav/index.less b/app/components/TreeNav/index.less
deleted file mode 100644
index 1426110ae..000000000
--- a/app/components/TreeNav/index.less
+++ /dev/null
@@ -1,184 +0,0 @@
-@treePrefixCls: rc-tree;
-.@{treePrefixCls} {
- margin: 0;
- padding: 5px;
- li {
- padding: 0;
- margin: 0;
- list-style: none;
- white-space: nowrap;
- outline: 0;
- .draggable {
- color: #333;
- -moz-user-select: none;
- -khtml-user-select: none;
- -webkit-user-select: none;
- user-select: none;
- /* Required to make elements draggable in old WebKit */
- -khtml-user-drag: element;
- -webkit-user-drag: element;
- }
- &.drag-over {
- > .draggable {
- background-color: #316ac5;
- color: white;
- border: 1px #316ac5 solid;
- opacity: 0.8;
- }
- }
- &.drag-over-gap-top {
- > .draggable {
- border-top: 2px blue solid;
- }
- }
- &.drag-over-gap-bottom {
- > .draggable {
- border-bottom: 2px blue solid;
- }
- }
- &.filter-node {
- > .@{treePrefixCls}-node-content-wrapper {
- color: #a60000!important;
- font-weight: bold!important;
- }
- }
- ul {
- margin: 0;
- padding: 0 0 0 18px;
- }
- .@{treePrefixCls}-node-content-wrapper {
- display: inline-block;
- padding: 1px 3px 0 0;
- margin: 0;
- cursor: pointer;
- height: 17px;
- text-decoration: none;
- vertical-align: top;
- }
- span {
- &.@{treePrefixCls}-switcher,
- &.@{treePrefixCls}-checkbox,
- &.@{treePrefixCls}-iconEle {
- line-height: 16px;
- margin-right: 2px;
- width: 16px;
- height: 16px;
- display: inline-block;
- vertical-align: middle;
- border: 0 none;
- cursor: pointer;
- outline: none;
- background-color: transparent;
- background-repeat: no-repeat;
- background-attachment: scroll;
- background-image: url('./icons.png');
- }
- &.@{treePrefixCls}-icon_loading {
- margin-right: 2px;
- vertical-align: top;
- background: url('./loading.gif') no-repeat scroll 0 0 transparent;
- }
- &.@{treePrefixCls}-switcher {
- &.@{treePrefixCls}-switcher-noop {
- cursor: auto;
- }
- &.@{treePrefixCls}-switcher_open {
- background-position: -93px -56px;
- }
- &.@{treePrefixCls}-switcher_close {
- background-position: -75px -56px;
- }
- }
- &.@{treePrefixCls}-checkbox {
- width: 13px;
- height: 13px;
- margin: 0 3px;
- background-position: 0 0;
- &-checked {
- background-position: -14px 0;
- }
- &-indeterminate {
- background-position: -14px -28px;
- }
- &-disabled {
- background-position: 0 -56px;
- }
- &.@{treePrefixCls}-checkbox-checked.@{treePrefixCls}-checkbox-disabled {
- background-position: -14px -56px;
- }
- &.@{treePrefixCls}-checkbox-indeterminate.@{treePrefixCls}-checkbox-disabled {
- position: relative;
- background: #ccc;
- border-radius: 3px;
- &::after {
- content: ' ';
- -webkit-transform: scale(1);
- transform: scale(1);
- position: absolute;
- left: 3px;
- top: 5px;
- width: 5px;
- height: 0;
- border: 2px solid #fff;
- border-top: 0;
- border-left: 0;
- }
- }
- }
- }
- }
- &:not(.@{treePrefixCls}-show-line) {
- .@{treePrefixCls}-switcher-noop {
- background: none;
- }
- }
- &.@{treePrefixCls}-show-line {
- li:not(:last-child) {
- > ul {
- background: url('data:image/gif;base64,R0lGODlhCQACAIAAAMzMzP///yH5BAEAAAEALAAAAAAJAAIAAAIEjI9pUAA7') 0 0 repeat-y;
- }
- > .@{treePrefixCls}-switcher-noop {
- background-position: -56px -18px;
- }
- }
- li:last-child {
- > .@{treePrefixCls}-switcher-noop {
- background-position: -56px -36px;
- }
- }
- }
- &-child-tree {
- display: none;
- &-open {
- display: block;
- }
- }
- &-treenode-disabled {
- >span,
- >a,
- >a span {
- color: #ccc;
- cursor: not-allowed;
- }
- }
- &-node-selected {
- background-color: #ffe6b0;
- border: 1px #ffb951 solid;
- opacity: 0.8;
- }
- &-icon__open {
- margin-right: 2px;
- background-position: -110px -16px;
- vertical-align: top;
- }
- &-icon__close {
- margin-right: 2px;
- background-position: -110px 0;
- vertical-align: top;
- }
- &-icon__docu {
- margin-right: 2px;
- background-position: -110px -32px;
- vertical-align: top;
- }
-}
diff --git a/app/components/TreeNav/line.gif b/app/components/TreeNav/line.gif
deleted file mode 100644
index d561d36a9..000000000
Binary files a/app/components/TreeNav/line.gif and /dev/null differ
diff --git a/app/components/TreeNav/loading.gif b/app/components/TreeNav/loading.gif
deleted file mode 100644
index e8c289293..000000000
Binary files a/app/components/TreeNav/loading.gif and /dev/null differ