2016-07-06 19:09:05 +00:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-07-08 18:57:22 +00:00
|
|
|
import classNames from 'classnames';
|
2016-07-14 16:47:54 +00:00
|
|
|
import InlineSVG from 'react-inlinesvg';
|
2016-08-24 19:29:58 +00:00
|
|
|
// import SidebarItem from './SidebarItem';
|
2016-08-25 21:32:27 +00:00
|
|
|
const folderUrl = require('../../../images/folder.svg');
|
|
|
|
const downArrowUrl = require('../../../images/down-arrow.svg');
|
2016-08-23 04:10:42 +00:00
|
|
|
import ConnectedFileNode from './FileNode';
|
2016-07-06 19:09:05 +00:00
|
|
|
|
2016-08-03 19:11:59 +00:00
|
|
|
class Sidebar extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.resetSelectedFile = this.resetSelectedFile.bind(this);
|
|
|
|
}
|
2016-07-14 16:47:54 +00:00
|
|
|
|
2016-08-03 19:11:59 +00:00
|
|
|
resetSelectedFile() {
|
2016-08-23 17:52:31 +00:00
|
|
|
this.props.setSelectedFile(this.props.files[1].id);
|
2016-08-03 19:11:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const sidebarClass = classNames({
|
|
|
|
sidebar: true,
|
2016-08-30 03:23:10 +00:00
|
|
|
'sidebar--contracted': !this.props.isExpanded,
|
|
|
|
'sidebar--project-options': this.props.projectOptionsVisible
|
2016-08-03 19:11:59 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<nav className={sidebarClass} title="file-navigation" role="navigation">
|
|
|
|
<div className="sidebar__header">
|
2016-08-25 21:32:27 +00:00
|
|
|
<h3 className="sidebar__title">
|
|
|
|
<span className="sidebar__folder-icon">
|
|
|
|
<InlineSVG src={folderUrl} />
|
|
|
|
</span>
|
|
|
|
<span>project-folder</span>
|
|
|
|
</h3>
|
2016-08-03 19:11:59 +00:00
|
|
|
<div className="sidebar__icons">
|
|
|
|
<button
|
2016-08-30 03:23:10 +00:00
|
|
|
aria-label="add file or folder"
|
2016-08-03 19:11:59 +00:00
|
|
|
className="sidebar__add"
|
2016-10-19 17:03:19 +00:00
|
|
|
tabIndex="0"
|
|
|
|
ref="sidebarOptions"
|
|
|
|
onClick={() => {
|
|
|
|
this.refs.sidebarOptions.focus();
|
2016-09-08 02:49:29 +00:00
|
|
|
this.props.openProjectOptions();
|
|
|
|
}}
|
2016-08-30 03:23:10 +00:00
|
|
|
onBlur={() => setTimeout(this.props.closeProjectOptions, 200)}
|
2016-08-03 19:11:59 +00:00
|
|
|
>
|
2016-08-25 21:32:27 +00:00
|
|
|
<InlineSVG src={downArrowUrl} />
|
2016-08-03 19:11:59 +00:00
|
|
|
</button>
|
2016-08-30 03:23:10 +00:00
|
|
|
<ul className="sidebar__project-options">
|
|
|
|
<li>
|
2016-08-30 03:43:02 +00:00
|
|
|
<a aria-label="add folder" onClick={this.props.newFolder} >
|
2016-12-20 05:21:04 +00:00
|
|
|
Add folder
|
2016-08-30 03:23:10 +00:00
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
2016-08-30 03:43:02 +00:00
|
|
|
<a aria-label="add file" onClick={this.props.newFile} >
|
2016-12-20 05:21:04 +00:00
|
|
|
Add file
|
2016-08-30 03:23:10 +00:00
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2016-08-03 19:11:59 +00:00
|
|
|
</div>
|
2016-07-14 16:47:54 +00:00
|
|
|
</div>
|
2016-08-23 17:52:31 +00:00
|
|
|
{ /* <ul className="sidebar__file-list" title="project files">
|
2016-08-03 19:11:59 +00:00
|
|
|
{this.props.files.map((file, fileIndex) =>
|
|
|
|
<SidebarItem
|
2016-07-12 19:11:45 +00:00
|
|
|
key={file.id}
|
2016-08-03 19:11:59 +00:00
|
|
|
file={file}
|
|
|
|
setSelectedFile={this.props.setSelectedFile}
|
|
|
|
fileIndex={fileIndex}
|
|
|
|
showFileOptions={this.props.showFileOptions}
|
|
|
|
hideFileOptions={this.props.hideFileOptions}
|
|
|
|
deleteFile={this.props.deleteFile}
|
|
|
|
resetSelectedFile={this.resetSelectedFile}
|
2016-08-03 21:10:03 +00:00
|
|
|
showEditFileName={this.props.showEditFileName}
|
|
|
|
hideEditFileName={this.props.hideEditFileName}
|
|
|
|
updateFileName={this.props.updateFileName}
|
2016-08-03 19:11:59 +00:00
|
|
|
/>
|
|
|
|
)}
|
2016-08-23 17:52:31 +00:00
|
|
|
</ul> */ }
|
2016-08-24 17:09:48 +00:00
|
|
|
<ConnectedFileNode id={this.props.files.filter(file => file.name === 'root')[0].id} />
|
2016-08-03 19:11:59 +00:00
|
|
|
</nav>
|
|
|
|
);
|
|
|
|
}
|
2016-07-06 19:09:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Sidebar.propTypes = {
|
2016-07-08 18:57:22 +00:00
|
|
|
files: PropTypes.array.isRequired,
|
2016-08-03 19:11:59 +00:00
|
|
|
setSelectedFile: PropTypes.func.isRequired,
|
|
|
|
isExpanded: PropTypes.bool.isRequired,
|
2016-08-30 03:23:10 +00:00
|
|
|
projectOptionsVisible: PropTypes.bool.isRequired,
|
2016-08-03 19:11:59 +00:00
|
|
|
newFile: PropTypes.func.isRequired,
|
|
|
|
showFileOptions: PropTypes.func.isRequired,
|
|
|
|
hideFileOptions: PropTypes.func.isRequired,
|
2016-08-03 21:10:03 +00:00
|
|
|
deleteFile: PropTypes.func.isRequired,
|
|
|
|
showEditFileName: PropTypes.func.isRequired,
|
|
|
|
hideEditFileName: PropTypes.func.isRequired,
|
2016-08-30 03:23:10 +00:00
|
|
|
updateFileName: PropTypes.func.isRequired,
|
|
|
|
openProjectOptions: PropTypes.func.isRequired,
|
|
|
|
closeProjectOptions: PropTypes.func.isRequired,
|
|
|
|
newFolder: PropTypes.func.isRequired
|
2016-07-06 19:09:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Sidebar;
|