when clicking new project, don't save new project
This commit is contained in:
parent
91e03a6d89
commit
43c49e9617
10 changed files with 33 additions and 7 deletions
|
@ -8,7 +8,7 @@ function Nav(props) {
|
||||||
<li className="nav__item">
|
<li className="nav__item">
|
||||||
<a
|
<a
|
||||||
className="nav__new"
|
className="nav__new"
|
||||||
onClick={props.createProject}
|
onClick={props.newProject}
|
||||||
>
|
>
|
||||||
New
|
New
|
||||||
</a>
|
</a>
|
||||||
|
@ -50,7 +50,7 @@ function Nav(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Nav.propTypes = {
|
Nav.propTypes = {
|
||||||
createProject: PropTypes.func.isRequired,
|
newProject: PropTypes.func.isRequired,
|
||||||
saveProject: PropTypes.func.isRequired,
|
saveProject: PropTypes.func.isRequired,
|
||||||
exportProjectAsZip: PropTypes.func.isRequired,
|
exportProjectAsZip: PropTypes.func.isRequired,
|
||||||
cloneProject: PropTypes.func.isRequired,
|
cloneProject: PropTypes.func.isRequired,
|
||||||
|
|
|
@ -26,6 +26,7 @@ export const SET_PROJECT_NAME = 'SET_PROJECT_NAME';
|
||||||
export const PROJECT_SAVE_SUCCESS = 'PROJECT_SAVE_SUCCESS';
|
export const PROJECT_SAVE_SUCCESS = 'PROJECT_SAVE_SUCCESS';
|
||||||
export const PROJECT_SAVE_FAIL = 'PROJECT_SAVE_FAIL';
|
export const PROJECT_SAVE_FAIL = 'PROJECT_SAVE_FAIL';
|
||||||
export const NEW_PROJECT = 'NEW_PROJECT';
|
export const NEW_PROJECT = 'NEW_PROJECT';
|
||||||
|
export const RESET_PROJECT = 'RESET_PROJECT';
|
||||||
|
|
||||||
export const SET_PROJECT = 'SET_PROJECT';
|
export const SET_PROJECT = 'SET_PROJECT';
|
||||||
export const SET_PROJECTS = 'SET_PROJECTS';
|
export const SET_PROJECTS = 'SET_PROJECTS';
|
||||||
|
|
|
@ -116,7 +116,6 @@ export function createProject() {
|
||||||
|
|
||||||
export function exportProjectAsZip() {
|
export function exportProjectAsZip() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
console.log('exporting project!');
|
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const zip = new JSZip();
|
const zip = new JSZip();
|
||||||
async.each(state.files, (file, cb) => {
|
async.each(state.files, (file, cb) => {
|
||||||
|
@ -139,6 +138,13 @@ export function exportProjectAsZip() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function newProject() {
|
||||||
|
browserHistory.push('/');
|
||||||
|
return {
|
||||||
|
type: ActionTypes.RESET_PROJECT
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function cloneProject() {
|
export function cloneProject() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
|
|
@ -70,6 +70,8 @@ class Editor extends React.Component {
|
||||||
this._cm.setOption('mode', 'htmlmixed');
|
this._cm.setOption('mode', 'htmlmixed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('componentDidUpdate in editor');
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
|
|
@ -38,6 +38,7 @@ class IDEView extends React.Component {
|
||||||
|
|
||||||
this.consoleSize = this.props.ide.consoleIsExpanded ? 180 : 29;
|
this.consoleSize = this.props.ide.consoleIsExpanded ? 180 : 29;
|
||||||
this.sidebarSize = this.props.ide.sidebarIsExpanded ? 180 : 20;
|
this.sidebarSize = this.props.ide.sidebarIsExpanded ? 180 : 20;
|
||||||
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUpdate(nextProps) {
|
componentWillUpdate(nextProps) {
|
||||||
|
@ -65,11 +66,18 @@ class IDEView extends React.Component {
|
||||||
this.autosaveInterval = null;
|
this.autosaveInterval = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.autosaveInterval && !this.props.project.id) {
|
||||||
|
clearInterval(this.autosaveInterval);
|
||||||
|
this.autosaveInterval = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
clearInterval(this.autosaveInterval);
|
clearInterval(this.autosaveInterval);
|
||||||
this.autosaveInterval = null;
|
this.autosaveInterval = null;
|
||||||
|
this.consoleSize = undefined;
|
||||||
|
this.sidebarSize = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleConsolePaneOnDragFinished() {
|
_handleConsolePaneOnDragFinished() {
|
||||||
|
@ -81,6 +89,7 @@ class IDEView extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleSidebarPaneOnDragFinished() {
|
_handleSidebarPaneOnDragFinished() {
|
||||||
|
console.log('setting sidebar size');
|
||||||
this.sidebarSize = this.refs.sidebarPane.state.draggedSize;
|
this.sidebarSize = this.refs.sidebarPane.state.draggedSize;
|
||||||
this.refs.sidebarPane.setState({
|
this.refs.sidebarPane.setState({
|
||||||
resized: false,
|
resized: false,
|
||||||
|
@ -93,7 +102,7 @@ class IDEView extends React.Component {
|
||||||
<div className="ide">
|
<div className="ide">
|
||||||
<Nav
|
<Nav
|
||||||
user={this.props.user}
|
user={this.props.user}
|
||||||
createProject={this.props.createProject}
|
newProject={this.props.newProject}
|
||||||
saveProject={this.props.saveProject}
|
saveProject={this.props.saveProject}
|
||||||
exportProjectAsZip={this.props.exportProjectAsZip}
|
exportProjectAsZip={this.props.exportProjectAsZip}
|
||||||
cloneProject={this.props.cloneProject}
|
cloneProject={this.props.cloneProject}
|
||||||
|
@ -129,6 +138,7 @@ class IDEView extends React.Component {
|
||||||
ref="sidebarPane"
|
ref="sidebarPane"
|
||||||
onDragFinished={this._handleSidebarPaneOnDragFinished}
|
onDragFinished={this._handleSidebarPaneOnDragFinished}
|
||||||
allowResize={this.props.ide.sidebarIsExpanded}
|
allowResize={this.props.ide.sidebarIsExpanded}
|
||||||
|
minSize={20}
|
||||||
>
|
>
|
||||||
<Sidebar
|
<Sidebar
|
||||||
files={this.props.files}
|
files={this.props.files}
|
||||||
|
@ -220,7 +230,7 @@ IDEView.propTypes = {
|
||||||
authenticated: PropTypes.bool.isRequired,
|
authenticated: PropTypes.bool.isRequired,
|
||||||
id: PropTypes.string
|
id: PropTypes.string
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
createProject: PropTypes.func.isRequired,
|
newProject: PropTypes.func.isRequired,
|
||||||
saveProject: PropTypes.func.isRequired,
|
saveProject: PropTypes.func.isRequired,
|
||||||
ide: PropTypes.shape({
|
ide: PropTypes.shape({
|
||||||
isPlaying: PropTypes.bool.isRequired,
|
isPlaying: PropTypes.bool.isRequired,
|
||||||
|
|
|
@ -71,6 +71,8 @@ const files = (state = initialState, action) => {
|
||||||
return [...action.files];
|
return [...action.files];
|
||||||
case ActionTypes.SET_PROJECT:
|
case ActionTypes.SET_PROJECT:
|
||||||
return [...action.files];
|
return [...action.files];
|
||||||
|
case ActionTypes.RESET_PROJECT:
|
||||||
|
return initialState;
|
||||||
case ActionTypes.CREATE_FILE:
|
case ActionTypes.CREATE_FILE:
|
||||||
return [...state, { name: action.name, id: action.id, content: '', url: action.url }];
|
return [...state, { name: action.name, id: action.id, content: '', url: action.url }];
|
||||||
case ActionTypes.SHOW_FILE_OPTIONS:
|
case ActionTypes.SHOW_FILE_OPTIONS:
|
||||||
|
|
|
@ -43,6 +43,8 @@ const ide = (state = initialState, action) => {
|
||||||
return Object.assign({}, state, { preferencesIsVisible: true });
|
return Object.assign({}, state, { preferencesIsVisible: true });
|
||||||
case ActionTypes.CLOSE_PREFERENCES:
|
case ActionTypes.CLOSE_PREFERENCES:
|
||||||
return Object.assign({}, state, { preferencesIsVisible: false });
|
return Object.assign({}, state, { preferencesIsVisible: false });
|
||||||
|
case ActionTypes.RESET_PROJECT:
|
||||||
|
return initialState;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ const project = (state = initialState, action) => {
|
||||||
name: action.project.name,
|
name: action.project.name,
|
||||||
owner: action.owner
|
owner: action.owner
|
||||||
};
|
};
|
||||||
|
case ActionTypes.RESET_PROJECT:
|
||||||
|
return initialState;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ class SketchListView extends React.Component {
|
||||||
<div className="sketch-list">
|
<div className="sketch-list">
|
||||||
<Nav
|
<Nav
|
||||||
user={this.props.user}
|
user={this.props.user}
|
||||||
createProject={this.props.createProject}
|
newProject={this.props.newProject}
|
||||||
saveProject={this.props.saveProject}
|
saveProject={this.props.saveProject}
|
||||||
exportProjectAsZip={this.props.exportProjectAsZip}
|
exportProjectAsZip={this.props.exportProjectAsZip}
|
||||||
cloneProject={this.props.cloneProject}
|
cloneProject={this.props.cloneProject}
|
||||||
|
@ -47,7 +47,7 @@ class SketchListView extends React.Component {
|
||||||
|
|
||||||
SketchListView.propTypes = {
|
SketchListView.propTypes = {
|
||||||
user: PropTypes.object.isRequired,
|
user: PropTypes.object.isRequired,
|
||||||
createProject: PropTypes.func.isRequired,
|
newProject: PropTypes.func.isRequired,
|
||||||
saveProject: PropTypes.func.isRequired,
|
saveProject: PropTypes.func.isRequired,
|
||||||
getProjects: PropTypes.func.isRequired,
|
getProjects: PropTypes.func.isRequired,
|
||||||
sketches: PropTypes.array.isRequired,
|
sketches: PropTypes.array.isRequired,
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toolbar {
|
.toolbar {
|
||||||
|
|
Loading…
Reference in a new issue