-
Notifications
You must be signed in to change notification settings - Fork 479
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
Conversation
e944227
to
f68daa7
Compare
@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. |
discussed offline with @markabarrett and got approval. |
e.preventDefault(); | ||
$(this).parent().siblings('select').children('option')[flag ? 'attr' : 'removeAttr']('selected', true); | ||
}; | ||
} |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
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.
dashboard/app/models/script.rb
Outdated
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 |
There was a problem hiding this comment.
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.
👀 looking... |
@aoby thanks for the feedback - I updated based on your comments, please take a look. |
There was a problem hiding this 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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.Levelbuilder script UI (checkbox and multi-select component)
No change to UI of project widget component in the storybook
New weblab icon for start a new project
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