-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add Tutorials #38
Conversation
lib/components/tutorial.js
Outdated
} | ||
}; | ||
|
||
Tutorial.start = function (TutorialComponent, tutorial, user, preferences) { |
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.
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.
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.
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.
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.
Yeah, it's a bit odd how the Tutorial component operates in PFE.
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.) |
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. |
Should the generated JS files in |
src/components/tutorial.jsx
Outdated
if (!projectPreferences.preferences.tutorials_completed_at) { | ||
projectPreferences.preferences.tutorials_completed_at = {}; | ||
}; | ||
projectPreferences.update(`preferences.tutorials_completed_at.${this.props.tutorial.id}`: now); |
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.
I think you might be missing {}
around the object here, which would explain the error on save.
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 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.
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. |
Ok, I'll remove the generated lib files for the new components. |
Looks like most of the line deletions now are from the package.lock, which should've changed with a few added dependencies. |
src/components/tutorial.jsx
Outdated
projectPreferences.update(( | ||
obj["preferences.tutorials_completed_at." + this.props.tutorial.id] = now, | ||
obj | ||
)); |
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.
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);
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.
Agreed with @eatyourgreens on the readability here.
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.
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.
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.
Could you file that as an issue on the API client?
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.
Could you file that as an issue on the API client?
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.
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.
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.
I'm still seeing the |
Oh, I see. I removed the created |
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.
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.
src/components/step-through.jsx
Outdated
<button | ||
type="button" | ||
className="step-through-direction step-through-next" | ||
aria-label="Next step" title="Next" |
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.
Can you put title
on to its own line?
src/components/step-through.jsx
Outdated
} else { | ||
const allSteps = Array.from(Array(childrenCount).keys()); | ||
return ( | ||
<div className="step-through-controls" style={{position: 'relative'}}> |
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.
Let's move this inline style into the class.
src/components/tutorial.jsx
Outdated
<MediaCard key={step._key} className="tutorial-step" src={source}> | ||
<Markdown>{step.content}</Markdown> | ||
<hr /> | ||
<p style={{ textAlign: 'center' }}> |
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.
Can this inline style be moved into a class?
src/css/common.styl
Outdated
MAIN_HIGHLIGHT = #43bbfd | ||
SECOND_HIGHLIGHT = #38b978 | ||
|
||
$reset-button |
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.
There's already a reset.styl file that includes the button reset.
src/css/common.styl
Outdated
@@ -0,0 +1,31 @@ | |||
MAIN_HIGHLIGHT = #43bbfd |
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.
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' |
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.
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.
src/css/modal.styl
Outdated
@@ -0,0 +1,59 @@ | |||
.modal-form-trigger |
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.
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.
src/components/step-through.jsx
Outdated
} | ||
|
||
handleScroll() { | ||
const reactSwipeNode = ReactDOM.findDOMNode(this.swiper); |
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.
Use this.swiper
directly. findDOMNode
is eventually going to be deprecated.
src/components/tutorial.jsx
Outdated
projectPreferences.update(( | ||
obj["preferences.tutorials_completed_at." + this.props.tutorial.id] = now, | ||
obj | ||
)); |
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.
Agreed with @eatyourgreens on the readability here.
000bdbc
to
4313888
Compare
This has been updated and rebased from the recent header merge. I think all should be set. I'm only hesitant about the |
@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? |
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.
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.
test/media-card.test.js
Outdated
import MediaCard from '../src/components/media-card'; | ||
|
||
const imageSrc = 'https://www.test.png'; | ||
const videoSrc = 'https://www.test.mp4'; |
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.
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).
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.
Makes sense.
Yes, this is a regenerated lock file. |
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.
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.
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 theprojectPreferences.save();
line, yet I'm not quite sure how to fix it, which is why this is RFC.Aside from that, this should contain all the styles and components necessary to display tutorials.