-
-
Add File
-
-
-
- {(() => {
- if (this.props.canUploadMedia) {
- return (
-
- );
- }
- return '';
- })()}
+function NewFileModal(props) {
+ const modalClass = classNames({
+ modal: true,
+ 'modal--reduced': !props.canUploadMedia
+ });
+ return (
+
+
+
+
Add File
+
-
- );
- }
+
+ {(() => {
+ if (props.canUploadMedia) {
+ return (
+
+ );
+ }
+ return '';
+ })()}
+
+
+ );
}
NewFileModal.propTypes = {
@@ -53,10 +48,8 @@ NewFileModal.propTypes = {
canUploadMedia: PropTypes.bool.isRequired
};
-function mapStateToProps(state) {
- return {
- file: state.files
- };
+function mapStateToProps() {
+ return {};
}
function mapDispatchToProps(dispatch) {
diff --git a/client/modules/IDE/components/NewFolderForm.js b/client/modules/IDE/components/NewFolderForm.js
new file mode 100644
index 00000000..92007393
--- /dev/null
+++ b/client/modules/IDE/components/NewFolderForm.js
@@ -0,0 +1,36 @@
+import React, { PropTypes } from 'react';
+
+class NewFolderForm extends React.Component {
+ constructor(props) {
+ super(props);
+ this.createFolder = this.props.createFolder.bind(this);
+ }
+
+ render() {
+ const { fields: { name }, handleSubmit } = this.props;
+ return (
+
+ );
+ }
+}
+
+NewFolderForm.propTypes = {
+ fields: PropTypes.shape({
+ name: PropTypes.string.isRequired
+ }).isRequired,
+ handleSubmit: PropTypes.func.isRequired,
+ createFolder: PropTypes.func.isRequired
+};
+
+export default NewFolderForm;
diff --git a/client/modules/IDE/components/NewFolderModal.js b/client/modules/IDE/components/NewFolderModal.js
new file mode 100644
index 00000000..776434a7
--- /dev/null
+++ b/client/modules/IDE/components/NewFolderModal.js
@@ -0,0 +1,31 @@
+import React, { PropTypes } from 'react';
+import { reduxForm } from 'redux-form';
+import InlineSVG from 'react-inlinesvg';
+const exitUrl = require('../../../images/exit.svg');
+import NewFolderForm from './NewFolderForm';
+
+function NewFolderModal(props) {
+ return (
+
+
+
+
Add Folder
+
+
+
+
+
+ );
+}
+
+NewFolderModal.propTypes = {
+ closeModal: PropTypes.func.isRequired
+};
+
+export default reduxForm({
+ form: 'new-folder',
+ fields: ['name']
+})(NewFolderModal);
+
diff --git a/client/modules/IDE/components/Sidebar.js b/client/modules/IDE/components/Sidebar.js
index 64a2af52..fdd1fbb9 100644
--- a/client/modules/IDE/components/Sidebar.js
+++ b/client/modules/IDE/components/Sidebar.js
@@ -21,7 +21,8 @@ class Sidebar extends React.Component {
render() {
const sidebarClass = classNames({
sidebar: true,
- 'sidebar--contracted': !this.props.isExpanded
+ 'sidebar--contracted': !this.props.isExpanded,
+ 'sidebar--project-options': this.props.projectOptionsVisible
});
return (
@@ -35,12 +36,25 @@ class Sidebar extends React.Component {
+
{
+ if (this.props.ide.newFolderModalVisible) {
+ return (
+
+ );
+ }
+ return '';
+ })()}
{(() => { // eslint-disable-line
if (this.props.location.pathname.match(/sketches$/)) {
return (
@@ -304,7 +320,9 @@ IDEView.propTypes = {
modalIsVisible: PropTypes.bool.isRequired,
sidebarIsExpanded: PropTypes.bool.isRequired,
consoleIsExpanded: PropTypes.bool.isRequired,
- preferencesIsVisible: PropTypes.bool.isRequired
+ preferencesIsVisible: PropTypes.bool.isRequired,
+ projectOptionsVisible: PropTypes.bool.isRequired,
+ newFolderModalVisible: PropTypes.bool.isRequired
}).isRequired,
startSketch: PropTypes.func.isRequired,
stopSketch: PropTypes.func.isRequired,
@@ -370,7 +388,12 @@ IDEView.propTypes = {
updateFileName: PropTypes.func.isRequired,
showEditProjectName: PropTypes.func.isRequired,
hideEditProjectName: PropTypes.func.isRequired,
- logoutUser: PropTypes.func.isRequired
+ logoutUser: PropTypes.func.isRequired,
+ openProjectOptions: PropTypes.func.isRequired,
+ closeProjectOptions: PropTypes.func.isRequired,
+ newFolder: PropTypes.func.isRequired,
+ closeNewFolderModal: PropTypes.func.isRequired,
+ createFolder: PropTypes.func.isRequired
};
function mapStateToProps(state) {
diff --git a/client/modules/IDE/reducers/files.js b/client/modules/IDE/reducers/files.js
index f9445345..1bc4a369 100644
--- a/client/modules/IDE/reducers/files.js
+++ b/client/modules/IDE/reducers/files.js
@@ -43,7 +43,7 @@ function initialState() {
id: r,
_id: r,
children: [a, b, c],
- type: 'folder'
+ fileType: 'folder'
},
{
name: 'sketch.js',
@@ -51,21 +51,21 @@ function initialState() {
id: a,
_id: a,
isSelected: true,
- type: 'file'
+ fileType: 'file'
},
{
name: 'index.html',
content: defaultHTML,
id: b,
_id: b,
- type: 'file'
+ fileType: 'file'
},
{
name: 'style.css',
content: defaultCSS,
id: c,
_id: c,
- type: 'file'
+ fileType: 'file'
}];
}
@@ -105,7 +105,13 @@ const files = (state, action) => {
}
return file;
});
- return [...newState, { name: action.name, id: action.id, _id: action._id, content: action.content, url: action.url, type: 'file' }];
+ return [...newState,
+ { name: action.name,
+ id: action.id,
+ _id: action._id,
+ content: action.content,
+ url: action.url,
+ fileType: action.fileType || 'file' }];
}
case ActionTypes.SHOW_FILE_OPTIONS:
return state.map(file => {
diff --git a/client/modules/IDE/reducers/ide.js b/client/modules/IDE/reducers/ide.js
index aca1c984..786477dd 100644
--- a/client/modules/IDE/reducers/ide.js
+++ b/client/modules/IDE/reducers/ide.js
@@ -10,7 +10,9 @@ const initialState = {
modalIsVisible: false,
sidebarIsExpanded: true,
consoleIsExpanded: false,
- preferencesIsVisible: false
+ preferencesIsVisible: false,
+ projectOptionsVisible: false,
+ newFolderModalVisible: false
};
const ide = (state = initialState, action) => {
@@ -45,6 +47,14 @@ const ide = (state = initialState, action) => {
return Object.assign({}, state, { preferencesIsVisible: false });
case ActionTypes.RESET_PROJECT:
return initialState;
+ case ActionTypes.OPEN_PROJECT_OPTIONS:
+ return Object.assign({}, state, { projectOptionsVisible: true });
+ case ActionTypes.CLOSE_PROJECT_OPTIONS:
+ return Object.assign({}, state, { projectOptionsVisible: false });
+ case ActionTypes.SHOW_NEW_FOLDER_MODAL:
+ return Object.assign({}, state, { newFolderModalVisible: true });
+ case ActionTypes.CLOSE_NEW_FOLDER_MODAL:
+ return Object.assign({}, state, { newFolderModalVisible: false });
default:
return state;
}
diff --git a/client/styles/components/_modal.scss b/client/styles/components/_modal.scss
index 73faa001..ea85740a 100644
--- a/client/styles/components/_modal.scss
+++ b/client/styles/components/_modal.scss
@@ -15,6 +15,11 @@
}
}
+.modal-content-folder {
+ @extend .modal-content;
+ height: #{150 / $base-font-size}rem;
+}
+
.modal__exit-button {
@extend %icon;
}
@@ -25,11 +30,11 @@
margin-bottom: #{20 / $base-font-size}rem;
}
-.new-file-form__name-label {
- display: none;
+.new-file-form__name-label, .new-folder-form__name-label {
+ @extend %hidden-element;
}
-.new-file-form__name-input {
+.new-file-form__name-input, .new-folder-form__name-input {
margin-right: #{10 / $base-font-size}rem;
}
diff --git a/client/styles/components/_sidebar.scss b/client/styles/components/_sidebar.scss
index a7dc7d82..5c2b47ed 100644
--- a/client/styles/components/_sidebar.scss
+++ b/client/styles/components/_sidebar.scss
@@ -126,6 +126,7 @@
.sidebar__icons {
display: flex;
align-items: center;
+ position: relative;
}
.sidebar__folder-icon {
@@ -138,3 +139,15 @@
.sidebar__file-item-icon {
margin-right: #{5 / $base-font-size}rem;
}
+
+.sidebar__project-options {
+ @extend %modal;
+ display: none;
+ position: absolute;
+ .sidebar--project-options & {
+ display: block;
+ }
+ top: 100%;
+ padding: #{8 / $base-font-size}rem;
+ width: #{110 / $base-font-size}rem;
+}