From 690788899ee231417fed79d4e94527948ae15f46 Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Wed, 24 Oct 2018 13:57:57 -0400 Subject: [PATCH] Refactor the toggle to show it on the file tree --- embark-ui/src/components/FileExplorer.js | 15 +++-- embark-ui/src/components/TextEditorToolbar.js | 59 ++++++++----------- embark-ui/src/containers/EditorContainer.js | 5 +- .../src/containers/FileExplorerContainer.js | 7 ++- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/embark-ui/src/components/FileExplorer.js b/embark-ui/src/components/FileExplorer.js index 9eeab1762..491b92472 100644 --- a/embark-ui/src/components/FileExplorer.js +++ b/embark-ui/src/components/FileExplorer.js @@ -1,3 +1,5 @@ +import {AppSwitch} from '@coreui/react'; +import {Label} from 'reactstrap'; import React from 'react'; import PropTypes from 'prop-types'; import {Treebeard, decorators} from 'react-treebeard'; @@ -138,7 +140,7 @@ class FileExplorer extends React.Component { const cursor = this.state.cursor; const showHidden = this.props.showHiddenFiles; // we need a foreach to build an array instead of a - // filter to prevent mutating the original object (in props) + // filter to prevent mutating the original object (in props) nodes.forEach(node => { if (!showHidden && node.isHidden) return; let updatedNode = {...node}; @@ -150,11 +152,11 @@ class FileExplorer extends React.Component { updatedNode.children = children; } } - + // if this is the selected node, set it as active if (this.nodeEquals(node, cursor)) { updatedNode.active = cursor.active; - // if this node is the selected node and is a folder, set + // if this node is the selected node and is a folder, set // it as toggled (expanded) according to the selected node if (node.children) updatedNode.toggled = cursor.toggled; } @@ -178,7 +180,12 @@ class FileExplorer extends React.Component { onToggle={this.onToggle.bind(this)} style={style} /> - + + + ); } } diff --git a/embark-ui/src/components/TextEditorToolbar.js b/embark-ui/src/components/TextEditorToolbar.js index d33caed19..01a73440c 100644 --- a/embark-ui/src/components/TextEditorToolbar.js +++ b/embark-ui/src/components/TextEditorToolbar.js @@ -5,47 +5,40 @@ import FontAwesomeIcon from 'react-fontawesome'; import { AppSwitch } from '@coreui/react' const TextEditorToolbar = (props) => ( - - - - - - {props.currentFile.name} - | +
    + + +
  1. + + +
  2. +
); TextEditorToolbar.propTypes = { diff --git a/embark-ui/src/containers/EditorContainer.js b/embark-ui/src/containers/EditorContainer.js index 3a0b6486c..881d67360 100644 --- a/embark-ui/src/containers/EditorContainer.js +++ b/embark-ui/src/containers/EditorContainer.js @@ -64,13 +64,12 @@ class EditorContainer extends React.Component { return ( - this.toggleShowHiddenFiles()} - openAsideTab={(newTab) => this.openAsideTab(newTab)} + this.openAsideTab(newTab)} isContract={this.isContract()} currentFile={this.props.currentFile} /> - + this.toggleShowHiddenFiles()} /> this.onFileContentChange(newContent)} /> diff --git a/embark-ui/src/containers/FileExplorerContainer.js b/embark-ui/src/containers/FileExplorerContainer.js index 4a7729a53..367e33d23 100644 --- a/embark-ui/src/containers/FileExplorerContainer.js +++ b/embark-ui/src/containers/FileExplorerContainer.js @@ -14,9 +14,9 @@ class FileExplorerContainer extends Component { render() { return ( - 0} {...this.props} render={({files, fetchFile, showHiddenFiles}) => ( - - )} /> + 0} {...this.props} render={({files, fetchFile, showHiddenFiles, toggleShowHiddenFiles}) => ( + + )} /> ); } } @@ -30,6 +30,7 @@ FileExplorerContainer.propTypes = { fetchFiles: PropTypes.func, fetchFile: PropTypes.func, showHiddenFiles: PropTypes.bool, + toggleShowHiddenFiles: PropTypes.func, }; export default connect(