Merge pull request #3648 from benjiwheeler/dont-save-someone-elses-project
when user clickes File->New, only save if user can save
This commit is contained in:
2 files changed
+8
-7
No files matched your search
@@ -150,12 +150,13 @@ class MenuBar extends React.Component {
|
||||
}
|
||||
}
|
||||
handleClickNew () {
|
||||
// if canCreateNew===true, it's safe to replace current project, since we will auto-save first.
|
||||
// else confirm first.
|
||||
const readyToReplaceProject = this.props.canCreateNew ||
|
||||
// if canSave===true and canCreateNew===true, it's safe to replace current project,
|
||||
// since we will auto-save first. Else, confirm first.
|
||||
const readyToReplaceProject = (this.props.canSave && this.props.canCreateNew) ||
|
||||
confirm('Replace contents of the current project?'); // eslint-disable-line no-alert
|
||||
this.props.onRequestCloseFile();
|
||||
if (readyToReplaceProject) {
|
||||
this.props.onClickNew(this.props.canCreateNew);
|
||||
this.props.onClickNew(this.props.canSave && this.props.canCreateNew);
|
||||
}
|
||||
}
|
||||
handleClickRemix () {
|
||||
@@ -752,7 +753,7 @@ const mapDispatchToProps = dispatch => ({
|
||||
onRequestCloseLanguage: () => dispatch(closeLanguageMenu()),
|
||||
onClickLogin: () => dispatch(openLoginMenu()),
|
||||
onRequestCloseLogin: () => dispatch(closeLoginMenu()),
|
||||
onClickNew: canCreateNew => dispatch(requestNewProject(canCreateNew)),
|
||||
onClickNew: needSave => dispatch(requestNewProject(needSave)),
|
||||
onClickRemix: () => dispatch(remixProject()),
|
||||
onClickSave: () => dispatch(updateProject()),
|
||||
onClickSaveAsCopy: () => dispatch(saveProjectAsCopy()),
|
||||
|
||||
@@ -379,8 +379,8 @@ const setProjectId = id => ({
|
||||
projectId: id
|
||||
});
|
||||
|
||||
const requestNewProject = canCreateNew => {
|
||||
if (canCreateNew) return {type: START_UPDATING_BEFORE_CREATING_NEW};
|
||||
const requestNewProject = needSave => {
|
||||
if (needSave) return {type: START_UPDATING_BEFORE_CREATING_NEW};
|
||||
return {type: START_FETCHING_NEW};
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user