Skip to content

handle many modes of new project creation#3391

Merged
benjiwheeler merged 3 commits intoscratchfoundation:developfrom
benjiwheeler:create-new-project
Oct 19, 2018
Merged

handle many modes of new project creation#3391
benjiwheeler merged 3 commits intoscratchfoundation:developfrom
benjiwheeler:create-new-project

Conversation

@benjiwheeler
Copy link
Contributor

@benjiwheeler benjiwheeler commented Oct 17, 2018

Needs scratchfoundation/scratch-www#2197 to work

Handles several states in which the user should be able to create a new project:

  1. standalone player/beta: file->new just replaces current project data with default data
  2. in www, logged in, viewing your project: file->new saves your project, replaces current project data with default data, then saves that data and gets a new id, then informs containing code of the change
  3. in www, logged in, viewing someone else’s project: file->new replaces current project data with default data, then saves that data and gets a new id, then informs containing code of the change
  4. in www, not logged in, viewing whatever project: file->new replaces current project data with default data, then informs containing code of the change
  5. in www, logged in, clicking “create” from front page; or, going straight to projects/editor: loads default data, then saves that data and gets a new id, then informs containing code of the change
  6. in www, not logged in, clicking “create” from front page: loads default data
  7. After Attach flyout listeners to GUI workspace #4, when you log in or register while still in the editor, saves current data and gets a new id, then informs containing code of the change

And, one state in which the project should be automatically saved:
8. User creates a project; then logs out. Later, the user opens project in editor; makes changes; realizes isn't logged in, so logs in; project should automatically save.

Copy link
Contributor

@rschamp rschamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are failing

}

SBFileUploader.propTypes = {
canSave: PropTypes.bool, // eslint-disable-line react/no-unused-prop-types

This comment was marked as abuse.

componentWillReceiveProps (nextProps) {
if (this.props.projectTitle !== nextProps.projectTitle) {
this.props.onUpdateReduxProjectTitle(nextProps.projectTitle);
setReduxTitle (newTitle) {

This comment was marked as abuse.

import storage from '../lib/storage';
import {
LoadingStates,
canNowCreateNew,

This comment was marked as abuse.

This comment was marked as abuse.

if (this.props.canSave && this.props.isShowingWithoutId &&
(!prevProps.canSave || !prevProps.isShowingWithoutId)) {
// create the project
this.props.canNowCreateNew();

This comment was marked as abuse.

}
componentDidUpdate (prevProps) {
if (this.props.projectId !== prevProps.projectId && this.props.projectId !== null) {
this.props.onUpdateProjectId(this.props.projectId);

This comment was marked as abuse.

const DONE_LOADING_VM_NEW_DEFAULT = 'scratch-gui/project-state/DONE_LOADING_VM_NEW_DEFAULT';
const DONE_LOADING_VM_NEW_DEFAULT_TO_SAVE = 'scratch-gui/project-state/DONE_LOADING_VM_NEW_DEFAULT_TO_SAVE';
const DONE_LOADING_VM_FILE_UPLOAD = 'scratch-gui/project-state/DONE_LOADING_VM_FILE_UPLOAD';
const DONE_LOADING_VM_WITHOUT_ID = 'scratch-gui/project-state/DONE_LOADING_VM_WITHOUT_ID';

This comment was marked as abuse.

ERROR: null,
FETCHING_WITH_ID: null,
FETCHING_NEW_DEFAULT: null,
FETCHING_NEW_DEFAULT_TO_SAVE: null,

This comment was marked as abuse.

}
return state;
case DONE_LOADING_VM_NEW_DEFAULT:
case DONE_LOADING_VM_TO_CREATE:

This comment was marked as abuse.

This comment was marked as abuse.

type: DONE_LOADING_VM_WITH_ID
};
case LoadingState.LOADING_VM_FILE_UPLOAD:
if (canSave) {

This comment was marked as abuse.

responding to canSave without needing canSaveNew prop
removed canSaveNew
added default for onUpdateProjectId
removed conflict files erroneously added
don't pass down onError
got tests passing
better creating and saving logic and names
@benjiwheeler
Copy link
Contributor Author

Rebased on top of develop and added the changes to project-saver-hoc that we discussed. Also removed the unused action from project-state reducer, and added tests for project-saver-hoc.

Copy link
Contributor

@rschamp rschamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are still failing.

}
return state;
case DONE_LOADING_VM_NEW_DEFAULT:
case DONE_LOADING_VM_TO_CREATE:

This comment was marked as abuse.

import storage from '../lib/storage';
import {
LoadingStates,
canNowCreateNew,

This comment was marked as abuse.

rschamp
rschamp previously approved these changes Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants