Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project Widget V2: Make project types configurable by script #16416

Merged
merged 9 commits into from
Jul 14, 2017

Conversation

caleybrock
Copy link
Contributor

@caleybrock caleybrock commented Jul 14, 2017

  • Modify ProjectWidget component to have a default set of project types, and a prop that can customize those projects. New buttons component have a new story to show how it can be configured.
  • Added weblab as a possible project type, with an asset (more project types in the future)
  • Added UI to the levelbuilder script editor to determine if a script shows the project widget, and what types of project types it will show. Save that information to the properties element of the script. Next we'll use these properties to determine what to show in stage extras.

Levelbuilder script UI (checkbox and multi-select component)
screen shot 2017-07-13 at 10 53 24 pm

No change to UI of project widget component in the storybook
screen shot 2017-06-30 at 4 18 04 pm

New weblab icon for start a new project
logo_weblab

Although this adds levelbuilder UI, it doesn't actually have any affect on public user facing UI yet. Is this still okay to merge in parts? Up until this afternoon, the CSF team was going to do the other half of this, so I haven't gotten to adding the component to pages. Either way, I'd like what I have to be reviewed.

Reviewers:
@aoby for ruby/levelbuilder files
@davidsbailey for project info and JSX
cc @joshlory - so you know what's coming for stage extras, but feel free to leave comments too
cc @breville - this shouldn't have any affect with what you're doing with the student homepage, but just as an fyi since I'm changing these files

@markabarrett
Copy link

@caleybrock, could I see an example of how this would be used in context? On the surface it feels too chaotic and busy to work as an icon.

@caleybrock
Copy link
Contributor Author

discussed offline with @markabarrett and got approval.

@caleybrock
Copy link
Contributor Author

And a square version of the gamelab logo
logo_gamelab_square

e.preventDefault();
$(this).parent().siblings('select').children('option')[flag ? 'attr' : 'removeAttr']('selected', true);
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only used once (in componentDidMount). Why make it a global function rather than inline anonymous function where it's used? Do you intend to reuse it later? Should it at least be a member of the ScriptEditor React class?

Though it may not be needed at all (see above comment).

Project widget new project types
<p>
Select up to 4 project type options to appear in the 'Start a new project' section. Select
<a className="select_none"> none </a>
Copy link
Contributor

@aoby aoby Jul 14, 2017

Choose a reason for hiding this comment

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

Instead of applying a click handler in componentDidMount, why not follow the React event pattern and add an onClick handler to this element that performs the action?

Note you can also use a ref for the select control you want to modify.

Something like:

<select
  ref={select => this.projectWidgetSelect = select;}
  // ...
>

<a onClick={handleClearProjectWidgetSelect}> none </a>

And

handleClearProjectWidgetSelect() {
  $(this.projectWidgetSelect).children('option')[flag ? 'attr' : 'removeAttr']('selected', true);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes way more sense - I ended up copying this from another place that has a multi-select and should've converted it a bit more.

student_detail_progress_view: script_data[:student_detail_progress_view] || false
student_detail_progress_view: script_data[:student_detail_progress_view] || false,
project_widget_visible: script_data[:project_widget_visible] || false,
project_widget_types: script_data[:project_widget_types] || nil
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I don't think the || nil does anything here. I expect script_data[:project_widget_types] to be an array or nil already. If it's an array, even an empty array, then || nil will preserve it. Otherwise it's already nil.

@davidsbailey
Copy link
Member

👀 looking...

@caleybrock
Copy link
Contributor Author

@aoby thanks for the feedback - I updated based on your comments, please take a look.

Copy link
Member

@davidsbailey davidsbailey left a comment

Choose a reason for hiding this comment

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

LGTM. Looks better with the ref approach!

Copy link
Contributor

@aoby aoby left a comment

Choose a reason for hiding this comment

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

LGTM

@caleybrock caleybrock merged commit e69c545 into staging Jul 14, 2017
@caleybrock caleybrock deleted the lb-project-widget-settings branch July 14, 2017 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants