start to fix editing permissions for the sidebar

This commit is contained in:
Cassie Tarakajian 2017-04-11 20:06:04 -04:00
parent 7be45ce875
commit 94694c5a72
3 changed files with 34 additions and 2 deletions

View File

@ -27,11 +27,24 @@ class Sidebar extends React.Component {
}
}
userCanEditProject() {
let canEdit;
if (!this.props.owner) {
canEdit = true;
} else if (this.props.user.authenticated && this.props.owner.id === this.props.user.id) {
canEdit = true;
} else {
canEdit = false;
}
return canEdit;
}
render() {
const sidebarClass = classNames({
'sidebar': true,
'sidebar--contracted': !this.props.isExpanded,
'sidebar--project-options': this.props.projectOptionsVisible
'sidebar--project-options': this.props.projectOptionsVisible,
'sidebar--cant-edit': !this.userCanEditProject()
});
return (
@ -85,7 +98,18 @@ Sidebar.propTypes = {
newFile: PropTypes.func.isRequired,
openProjectOptions: PropTypes.func.isRequired,
closeProjectOptions: PropTypes.func.isRequired,
newFolder: PropTypes.func.isRequired
newFolder: PropTypes.func.isRequired,
owner: PropTypes.shape({
id: PropTypes.string
}),
user: PropTypes.shape({
id: PropTypes.string,
authenticated: PropTypes.bool.isRequired
}).isRequired
};
Sidebar.defaultProps = {
owner: undefined
};
export default Sidebar;

View File

@ -265,6 +265,8 @@ class IDEView extends React.Component {
openProjectOptions={this.props.openProjectOptions}
closeProjectOptions={this.props.closeProjectOptions}
newFolder={this.props.newFolder}
user={this.props.user}
owner={this.props.project.owner}
/>
<SplitPane
split="vertical"

View File

@ -131,6 +131,9 @@
right: 0;
.sidebar__file-item--selected > .file-item__content & {
display: inline-block;
.sidebar--cant-edit & {
display: none;
}
}
& svg {
width: #{10 / $base-font-size}rem;
@ -212,6 +215,9 @@
display: flex;
align-items: center;
position: relative;
.sidebar--cant-edit & {
display: none;
}
}
.sidebar__folder-icon {