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

Tutorial explorer: select from list of unique org names #18290

Merged
merged 6 commits into from Oct 13, 2017

Conversation

breville
Copy link
Member

@breville breville commented Oct 11, 2017

This change adds a new filter group with a single dropdown (rather than a set of checkboxes) to the Tutorial Explorer. The dropdown allows the viewer to choose an organization to see all the tutorials they've contributed, or "All" to not do any filtering based on organization. The list is sorted alphabetically, and filtered appropriately for the robotics or regular (non-robotics) variant of the page. Tutorials that are tagged "do-not-show" are not included when generating the list; likewise for organization names that are themselves "do-not-show".

screenshot 2017-10-11 17 13 10

@@ -0,0 +1,44 @@
/* FilterGroupContainer: The container UI for a group of filter choices.
Copy link
Contributor

Choose a reason for hiding this comment

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

Components are usually .jsx files. Does it matter that this one is .js?

Copy link
Contributor

Choose a reason for hiding this comment

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

.js is fine, but ideally it should be FilterGroupContainer (first letter capitalized)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. tutorialExplorer doesn't use first letter capped at the moment but could change in a broader change later...

}
};

const FilterGroupContainer = React.createClass({
Copy link
Contributor

@Erin007 Erin007 Oct 11, 2017

Choose a reason for hiding this comment

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

In anticipation of upcoming changes to React ES6 that will no longer support .createClass, we want to use const class FilterGroupContainer extends Component and import Component like PropTypes at the top of the file. You can see an example here: #18194 Comment applies to all components in PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

...good point. I'd like to make this change in a separate PR for all of tutorialExplorer at once.

@Bjvanminnen
Copy link
Contributor

Would be nice to have a little more info in the description about what this PR is doing.

@@ -5,6 +5,9 @@ import * as utils from '../utils';
// Sorting for tutorials.
export const TutorialsSortBy = utils.makeEnum('default', 'popularityrank', 'displayweight');

// Orgname value.
export const TutorialsOrgName = utils.makeEnum('all');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have an enum with a single value? Presumably we're planning on adding more orgs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure yet, but I did it mainly so that it'd be consistent with how TutorialsSortBy is done, above, since it works very similarly.

getUniqueOrgNamesFromTutorials(tutorials) {
// Filter out tutorials with do-not-show tag.
const availableTutorials = tutorials.filter(t => {
return t.tags.split(',').indexOf("do-not-show") === -1 && t.orgname !== "do-not-show";
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a const somewhere for do-not-show along with a comment explaining what it is/how it's used?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea.

});

// Construct array of unique org names from the tutorials.
let uniqueOrgNames = [...new Set(availableTutorials.map(t => t.orgname))];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the goal of using Set just to get unique? If so, you could instead use _.uniq

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I thought it cool to use ES6 all the way but if we still like _ mixed in, then I can do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

We do generally like ES6 as much as possible, but afaik haven't used things like Set at all. I think that what you have is fine, but perhaps a little too clever. I think that your purpose (finding the unique entries) is somewhat more clear when using _.uniq 🤷‍♂️

Copy link
Contributor

@tanyaparker tanyaparker left a comment

Choose a reason for hiding this comment

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

Yay! I'll test on staging.

@breville
Copy link
Member Author

Description updated.

@breville breville merged commit e72142a into staging Oct 13, 2017
@breville breville deleted the tutorial-explorer-select-org-name branch October 13, 2017 00:16
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