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

Add Tutorials #38

Merged
merged 6 commits into from
Oct 16, 2017
Merged

Add Tutorials #38

merged 6 commits into from
Oct 16, 2017

Conversation

wgranger
Copy link
Contributor

@wgranger wgranger commented Sep 29, 2017

This appears to be functioning well. The only issue I'm having is with the handleUnmount function on the tutorial component displaying the errors below when it hits the projectPreferences.save(); line, yet I'm not quite sure how to fix it, which is why this is RFC.

screen shot 2017-09-29 at 1 45 05 pm

Aside from that, this should contain all the styles and components necessary to display tutorials.

}
};

Tutorial.start = function (TutorialComponent, tutorial, user, preferences) {
Copy link
Contributor Author

@wgranger wgranger Oct 1, 2017

Choose a reason for hiding this comment

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

TutorialComponent is an example of where the binding seems a bit odd in this component. You can see where this is being used in PFE here. I think it's a bit odd to have static methods in the tutorial component that refer to this, but perhaps there was a reason for this?

That said, my use case isn't the same as the binding example from the classifier example above, so I'm unable to access this in such a way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Static methods should be pure functions, in my opinion, so I think you're right to explicitly pass TutorialComponent as the first argument.

The PFE code makes start look like an instance method, which can't be right because the component instance is created when start runs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's a bit odd how the Tutorial component operates in PFE.

@eatyourgreens
Copy link
Contributor

FWIW, the 422 error on save tells me that either a required parameter is missing from the POST request, or the value of one of the request parameters is in an unexpected format.

I find those 422 errors tricky to debug, because the error doesn't explicitly tell you what Panoptes was expecting (but didn't get.)

@eatyourgreens
Copy link
Contributor

Forgot to add: if you look at the network request that gives the 422 error, the response from the API might be more helpful than the error message generated by the API client.

@eatyourgreens
Copy link
Contributor

Should the generated JS files in lib be included in pull requests? It seems to generate a lot of noise in the PR changes.

if (!projectPreferences.preferences.tutorials_completed_at) {
projectPreferences.preferences.tutorials_completed_at = {};
};
projectPreferences.update(`preferences.tutorials_completed_at.${this.props.tutorial.id}`: now);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you might be missing {} around the object here, which would explain the error on save.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This appears to be the root of the problem. It's a bit strange how this is constructed with CoffeeScript vs. ES^, but I'll push up a fix.

@srallen
Copy link
Contributor

srallen commented Oct 2, 2017

Re: the generated lib files. I'd prefer they weren't because the version script removes the folder, builds the files, and then versions and pushes to github, but I haven't added the folder to the gitignore yet since we're installing via github. I think after this PR and the one I have for the header, I'll add the lib folder to the gitignore and actually publish on npm instead now that more people are contributing and using this now.

@wgranger
Copy link
Contributor Author

wgranger commented Oct 2, 2017

Ok, I'll remove the generated lib files for the new components.

@wgranger
Copy link
Contributor Author

wgranger commented Oct 2, 2017

Looks like most of the line deletions now are from the package.lock, which should've changed with a few added dependencies.

projectPreferences.update((
obj["preferences.tutorials_completed_at." + this.props.tutorial.id] = now,
obj
));
Copy link
Contributor

Choose a reason for hiding this comment

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

The convoluted syntax here makes it hard to understand what's being passed to update.

I think

projectPreferences.update({`preferences.tutorials_completed_at.${this.props.tutorial.id}`: now});

might be easier to read.

Or you could set the hash of changes separately, if line length is an issue.

const changes = {
 `preferences.tutorials_completed_at.${this.props.tutorial.id}`: now
};
projectPreferences.update(changes);

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed with @eatyourgreens on the readability here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The backend won't accept that sort of string interpolation =>
projectPreferences.update({preferences.tutorials_completed_at.${this.props.tutorial.id}: now});

but I'll try the changes variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you file that as an issue on the API client?

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you file that as an issue on the API client?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! The json client readme specifically says that the syntax for update is person.update({'links.pets': [spot.id]}) so that interpolated key should be supported.

@eatyourgreens
Copy link
Contributor

I'm still seeing the lib files in the diff for this PR. Annoying but not a big deal, as @srallen says, because they'll be overwritten when the module is published anyway.

@wgranger
Copy link
Contributor Author

wgranger commented Oct 3, 2017

Oh, I see. I removed the created lib files for the new components, but it looks like some additions were made to lib/index.js and lib/zooniverse-react-components.css

Copy link
Contributor

@srallen srallen left a comment

Choose a reason for hiding this comment

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

There's a unique key prop warning when running the tests. I think the issue might be in the Tutorial component, but I'm not totally sure.

<button
type="button"
className="step-through-direction step-through-next"
aria-label="Next step" title="Next"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you put title on to its own line?

} else {
const allSteps = Array.from(Array(childrenCount).keys());
return (
<div className="step-through-controls" style={{position: 'relative'}}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move this inline style into the class.

<MediaCard key={step._key} className="tutorial-step" src={source}>
<Markdown>{step.content}</Markdown>
<hr />
<p style={{ textAlign: 'center' }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this inline style be moved into a class?

MAIN_HIGHLIGHT = #43bbfd
SECOND_HIGHLIGHT = #38b978

$reset-button
Copy link
Contributor

Choose a reason for hiding this comment

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

There's already a reset.styl file that includes the button reset.

@@ -0,0 +1,31 @@
MAIN_HIGHLIGHT = #43bbfd
Copy link
Contributor

Choose a reason for hiding this comment

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

I've added a colors.styl file coming in the add-header branch

@@ -6,3 +6,7 @@
@require './paginator'
@require './zoo-footer'
@require './admin-layout-indicator'
@require './tutorial'
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a heads up I also changed the import to import using a wildcard in add-header branch. Let's merge that branch first and rebase this branch off those organizational changes.

@@ -0,0 +1,59 @@
.modal-form-trigger
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this class used by the tutorial? I doubt it since the child class is something I think is used in the current PFE header... Let's not move unnecessary styles into this.

}

handleScroll() {
const reactSwipeNode = ReactDOM.findDOMNode(this.swiper);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use this.swiper directly. findDOMNode is eventually going to be deprecated.

projectPreferences.update((
obj["preferences.tutorials_completed_at." + this.props.tutorial.id] = now,
obj
));
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed with @eatyourgreens on the readability here.

@wgranger
Copy link
Contributor Author

This has been updated and rebased from the recent header merge. I think all should be set. I'm only hesitant about the package-lock.json since so many lines appear to be missing.

@wgranger wgranger changed the title [RFC] Functioning Tutorials Add Tutorials Oct 10, 2017
@srallen
Copy link
Contributor

srallen commented Oct 11, 2017

@wgranger Hm, not sure why so many lines would change with the lock file. I'm guessing there was a merge conflict because of the grommet version bump that came in with the header? Is this a regenerated lock file?

Copy link
Contributor

@srallen srallen left a comment

Choose a reason for hiding this comment

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

I have a minor comment about file mocks in the tests. This looks close to being ready for merge. Could you update the changelog.md file too? You'll see in the file what the style is for commenting on what the update is.

import MediaCard from '../src/components/media-card';

const imageSrc = 'https://www.test.png';
const videoSrc = 'https://www.test.mp4';
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make these just 'test.png' and 'test.mp4'? The mix of the url and file extension is a bit odd and potentially confusing (The file extensions are in the place of what would be the top level domain in a URL).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense.

@wgranger
Copy link
Contributor Author

Yes, this is a regenerated lock file.

Copy link
Contributor

@srallen srallen left a comment

Choose a reason for hiding this comment

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

It should be noted that the implementation of the Tutorial component here won't work in PFE. PFE is written to pass the Geordi client as a prop. Since Geordi will be deprecated, logging the tutorial click will have to be done differently.

Some modification might also need to be made to make it work with translations.

@srallen srallen merged commit 28d28ce into master Oct 16, 2017
@srallen srallen deleted the add-tutorial branch October 16, 2017 18:47
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.

3 participants