diff --git a/client/modules/IDE/components/FileNode.jsx b/client/modules/IDE/components/FileNode.jsx index 7e5f1d70..252de291 100644 --- a/client/modules/IDE/components/FileNode.jsx +++ b/client/modules/IDE/components/FileNode.jsx @@ -65,6 +65,9 @@ export class FileNode extends React.Component { toggleFileOptions(e) { e.preventDefault(); + if (!this.props.canEdit) { + return; + } if (this.state.isOptionsOpen) { this.setState({ isOptionsOpen: false }); } else { @@ -88,7 +91,7 @@ export class FileNode extends React.Component { renderChild(childId) { return (
  • - +
  • ); } @@ -154,7 +157,6 @@ export class FileNode extends React.Component { tabIndex="0" onClick={this.toggleFileOptions} onBlur={() => setTimeout(this.hideFileOptions, 200)} - style={{ display: (this.state.isOptionsOpen) ? 'inline-block' : '' }} > @@ -251,7 +253,8 @@ FileNode.propTypes = { newFile: PropTypes.func.isRequired, newFolder: PropTypes.func.isRequired, showFolderChildren: PropTypes.func.isRequired, - hideFolderChildren: PropTypes.func.isRequired + hideFolderChildren: PropTypes.func.isRequired, + canEdit: PropTypes.bool.isRequired }; FileNode.defaultProps = { @@ -262,8 +265,7 @@ FileNode.defaultProps = { function mapStateToProps(state, ownProps) { // this is a hack, state is updated before ownProps - return state.files.find(file => file.id === ownProps.id) || { ...ownProps, name: 'test', fileType: 'file' }; - // return state.files.find(file => file.id === ownProps.id); + return state.files.find(file => file.id === ownProps.id) || { name: 'test', fileType: 'file' }; } function mapDispatchToProps(dispatch) { diff --git a/client/modules/IDE/components/Sidebar.jsx b/client/modules/IDE/components/Sidebar.jsx index 5172f27a..6419abe1 100644 --- a/client/modules/IDE/components/Sidebar.jsx +++ b/client/modules/IDE/components/Sidebar.jsx @@ -41,11 +41,12 @@ class Sidebar extends React.Component { } render() { + const canEditProject = this.userCanEditProject(); const sidebarClass = classNames({ 'sidebar': true, 'sidebar--contracted': !this.props.isExpanded, 'sidebar--project-options': this.props.projectOptionsVisible, - 'sidebar--cant-edit': !this.userCanEditProject() + 'sidebar--cant-edit': !canEditProject }); return ( @@ -82,7 +83,10 @@ class Sidebar extends React.Component { - file.name === 'root')[0].id} /> + file.name === 'root')[0].id} + canEdit={canEditProject} + /> ); } diff --git a/client/styles/components/_sidebar.scss b/client/styles/components/_sidebar.scss index bde98922..93f6967d 100644 --- a/client/styles/components/_sidebar.scss +++ b/client/styles/components/_sidebar.scss @@ -138,10 +138,16 @@ } .sidebar__file-item:hover > .file-item__content & { display: inline-block; + .sidebar--cant-edit & { + display: none; + } } & svg { width: #{10 / $base-font-size}rem; } + .sidebar__file-item--open > .file-item__content & { + display: inline-block; + } } .sidebar__file-item-options {