- {index.children.map(child => {
- const childIndex = tree.getIndex(child);
- return (
-
- );
- })}
-
- );
- }
-
- return null;
- };
-
- isModifying = () => {
- return this.props.allowUpdates && !this.props.rootNode;
- };
-
- onClick = () => {
- const index = this.props.index;
- const node = index.node;
- if (!this.isModifying()) this.props.history.push(node.url);
- };
-
- render() {
- const index = this.props.index;
- const dragging = this.props.dragging;
- const node = index.node;
- const style = {};
-
- return (
-
-
e.stopPropagation()
- : this.handleMouseDown
- }
- >
- {!this.props.rootNode && this.renderCollapse()}
-
- {node.title}
-
-
- {this.renderChildren()}
-
- );
- }
-
- handleCollapse = e => {
- e.stopPropagation();
- const nodeId = this.props.index.id;
- if (this.props.onCollapse) this.props.onCollapse(nodeId);
- };
-
- handleMouseDown = e => {
- const nodeId = this.props.index.id;
- const dom = this.refs.inner;
-
- if (this.props.onDragStart) {
- this.props.onDragStart(nodeId, dom, e);
- }
- };
-}
-
-module.exports = Node;
diff --git a/frontend/components/Tree/Tree.js b/frontend/components/Tree/Tree.js
deleted file mode 100644
index 7296da9a9..000000000
--- a/frontend/components/Tree/Tree.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/* eslint-disable */
-const Tree = require('js-tree');
-const proto = Tree.prototype;
-
-proto.updateNodesPosition = function() {
- let top = 1;
- let left = 1;
- const root = this.getIndex(1);
- const self = this;
-
- root.top = top++;
- root.left = left++;
-
- if (root.children && root.children.length) {
- walk(root.children, root, left, root.node.collapsed);
- }
-
- function walk(children, parent, left, collapsed) {
- let height = 1;
- children.forEach(id => {
- const node = self.getIndex(id);
- if (collapsed) {
- node.top = null;
- node.left = null;
- } else {
- node.top = top++;
- node.left = left;
- }
-
- if (node.children && node.children.length) {
- height += walk(
- node.children,
- node,
- left + 1,
- collapsed || node.node.collapsed
- );
- } else {
- node.height = 1;
- height += 1;
- }
- });
-
- if (parent.node.collapsed) parent.height = 1;
- else parent.height = height;
- return parent.height;
- }
-};
-
-proto.move = function(fromId, toId, placement) {
- if (fromId === toId || toId === 1) return;
-
- const obj = this.remove(fromId);
- let index = null;
-
- if (placement === 'before') index = this.insertBefore(obj, toId);
- else if (placement === 'after') index = this.insertAfter(obj, toId);
- else if (placement === 'prepend') index = this.prepend(obj, toId);
- else if (placement === 'append') index = this.append(obj, toId);
-
- // todo: perf
- this.updateNodesPosition();
- return index;
-};
-
-proto.getNodeByTop = function(top) {
- const indexes = this.indexes;
- for (const id in indexes) {
- if (indexes.hasOwnProperty(id)) {
- if (indexes[id].top === top) return indexes[id];
- }
- }
-};
-
-module.exports = Tree;
diff --git a/frontend/components/Tree/Tree.scss b/frontend/components/Tree/Tree.scss
deleted file mode 100644
index 22c702188..000000000
--- a/frontend/components/Tree/Tree.scss
+++ /dev/null
@@ -1,87 +0,0 @@
-@mixin no-select {
- -webkit-user-select: none;
- -khtml-user-select: none;
- -moz-user-select: none;
- -ms-user-select: none;
- user-select: none;
-}
-
-.tree {
- @include no-select;
- padding: 20px 20px 20px 5px;
- overflow: scroll;
- position: absolute;
- top: 0;
- bottom: 40px;
- right: 0;
- left: 0;
-}
-
-.draggable {
- position: absolute;
- opacity: 0.8;
- @include no-select;
-}
-
-.node {
- &.placeholder > * {
- visibility: hidden;
- }
-
- &.placeholder {
- border: 1px dashed #ccc;
- }
-
- .inner {
- position: relative;
- cursor: pointer;
- padding-left: 10px;
- }
-
- .collapse {
- position: absolute;
- left: 0;
- cursor: pointer;
-
- width: 20px;
- height: 25px;
- }
-
- .caretRight {
- margin-top: 3px;
- margin-left: -3px;
- }
-
- .caretDown {
- transform: rotate(90deg);
- margin-left: -4px;
- margin-top: 2px;
- }
-}
-
-.node {
- &.placeholder {
- border: 1px dashed #1385e5;
- }
-
- .nodeLabel {
- display: inline-block;
- width: 100%;
- padding: 4px 5px 0;
- text-overflow: ellipsis;
- white-space: nowrap;
- overflow: hidden;
-
- &.isModifying {
- cursor: move;
- }
-
- &.isActive {
- background-color: #31363F;
- }
- }
-
- .rootLabel {
- color: #ccc;
- }
-}
diff --git a/frontend/components/Tree/UiTree.js b/frontend/components/Tree/UiTree.js
deleted file mode 100644
index 02d774d3b..000000000
--- a/frontend/components/Tree/UiTree.js
+++ /dev/null
@@ -1,275 +0,0 @@
-/* eslint-disable */
-const React = require('react');
-const Tree = require('./Tree');
-const Node = require('./Node');
-
-import styles from './Tree.scss';
-
-export default React.createClass({
- displayName: 'UITree',
-
- propTypes: {
- tree: React.PropTypes.object.isRequired,
- paddingLeft: React.PropTypes.number,
- onCollapse: React.PropTypes.func,
- allowUpdates: React.PropTypes.bool,
- history: React.PropTypes.object,
- },
-
- getDefaultProps() {
- return {
- paddingLeft: 20,
- };
- },
-
- getInitialState() {
- return this.init(this.props);
- },
-
- componentWillReceiveProps(nextProps) {
- if (!this._updated) this.setState(this.init(nextProps));
- else this._updated = false;
- },
-
- init(props) {
- const tree = new Tree(props.tree);
- tree.isNodeCollapsed = props.isNodeCollapsed;
- tree.changeNodeCollapsed = props.changeNodeCollapsed;
- tree.updateNodesPosition();
-
- return {
- tree,
- dragging: {
- id: null,
- x: null,
- y: null,
- w: null,
- h: null,
- },
- };
- },
-
- getDraggingDom() {
- const tree = this.state.tree;
- const dragging = this.state.dragging;
-
- if (dragging && dragging.id) {
- const draggingIndex = tree.getIndex(dragging.id);
- const draggingStyles = {
- top: dragging.y,
- left: dragging.x,
- width: dragging.w,
- };
-
- return (
-