-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add tour for launch #337
Conversation
adds tour close #323
@hasanagh, please rebase w.r.t |
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.
Thank you for your PR! It was more complicated than I thought. I let you some comments, and here some general comment:
- Do you think having a different components for each tour would be possible? At some point your
Tour
component will have to be expanded with a lot more tours and having different components (or something else) for each might help maintaining them. - I used the convention to name the selectors depending on the usage (id, class, name, etc). For example I would use
VISIT_SPACE_BUTTON_CLASS
instead ofVISIT_SPACE_BUTTON
(it mostly helps for tests)
public/app/config/channels.js
Outdated
@@ -71,4 +71,5 @@ module.exports = { | |||
GET_SPACE_IN_CLASSROOM_CHANNEL: 'classroom:space:get', | |||
LOAD_SPACE_IN_CLASSROOM_CHANNEL: 'classroom:space:load', | |||
GET_SPACE_TO_LOAD_IN_CLASSROOM_CHANNEL: 'classroom:space:load:get-space', | |||
TOUR_COMPLETED_CHANNEL: 'tour:complete', |
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 COMPLETE_TOUR_CHANNEL
would be better.
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.
- m
Thank you for your PR! It was more complicated than I thought. I let you some comments, and here some general comment:
- Do you think having a different components for each tour would be possible? At some point your
Tour
component will have to be expanded with a lot more tours and having different components (or something else) for each might help maintaining them.- I used the convention to name the selectors depending on the usage (id, class, name, etc). For example I would use
VISIT_SPACE_BUTTON_CLASS
instead ofVISIT_SPACE_BUTTON
(it mostly helps for tests)
Hey Kim! Thanks!
- Ok so for using a tour component for each tour: this was the approach I was using first. Then realized that it would make the process of switching between tours much more complex. Here we are managing one reducer for all the actions related to this tour and the tours expand for more than one component. (i.e if there is a tour for example only for the space screen without having to jump between screens then maybe we could consider separating tours). Also with the current structuring, any new tour (which I assume won't be many) we just need simply add a steps array and handle the callbacks. All managed in one space. of course, I plan maybe on expanding that architecture to a more refactored one especially in the callback where it looks a bit complicated maybe in future PRs and we can utilize it in other projects.
- I will fix that
src/components/common/Tour.js
Outdated
tour: tours.VISIT_SPACE_TOUR, | ||
steps: VISIT_SPACE_TOUR_STEPS, | ||
}), | ||
750 |
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.
Factor out this in constants.js
src/components/common/Tour.js
Outdated
dispatchStartTour(); | ||
break; | ||
case 2: | ||
replace('/space/owozgj'); |
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 could be worth to factor it out.
@hasanagh, don't forget to rebase. |
bfaa4fa
to
c565bf7
Compare
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.
Very nice! Some changes requested. Also, please refactor to adapt to @pyphilia's latest PRs.
src/actions/tour.js
Outdated
STOP_TOUR, | ||
} from '../types/tour'; | ||
|
||
const nextStepTour = payload => dispatch => |
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 we keep these as verbs? E.g. goToNextStep
and goToPrevStep
. Also, why is it NEXT_OR_PREV
? For clarity we might want to have two separate actions.
src/actions/tour.js
Outdated
payload, | ||
}); | ||
|
||
const navigateStopTour = payload => dispatch => |
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.
What is navigateStopTour
?
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 an action I refactored out because when we have multi-page tours we need to stop the tour and then start it again.
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.
Yes, I will go for stopTourAndNavigate
more descriptive I think.
src/components/common/Tour.js
Outdated
}, | ||
options: { | ||
primaryColor: THEME_COLORS[USER_MODES.TEACHER], | ||
zIndex: 10000, |
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 we factor this out?
src/components/common/Tour.js
Outdated
}} | ||
callback={callback} | ||
locale={{ | ||
last: 'End tour', |
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 we use t
for these?
src/config/tours.js
Outdated
}, | ||
{ | ||
target: `.${SETTINGS_ACTIONS_CLASS}`, | ||
content: 'Here you can enable tracking of actions within spaces', |
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.
Track analytics by activating this switch.
src/types/tour.js
Outdated
@@ -0,0 +1,7 @@ | |||
export const NEXT_OR_PREV_TOUR = 'NEXT_OR_PREV_TOUR'; | |||
export const NAVIGATE_STOP_TOUR = 'NAVIGATE_STOP_TOUR'; |
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.
Not sure what this means.
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.
See comment above.
src/types/tour.js
Outdated
@@ -0,0 +1,7 @@ | |||
export const NEXT_OR_PREV_TOUR = 'NEXT_OR_PREV_TOUR'; |
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.
Maybe split in two for legibility.
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.
Also, use verbs.
src/utils/elements.js
Outdated
@@ -0,0 +1,11 @@ | |||
const waitForElement = async ({ selector, time = 500 }) => { |
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 cause an infinite loop?
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.
Yes, in case the selector never showed up in the dom. I assumed in this case, anyway, there would have been a problem. But if you want maybe we could limit the number of retries?
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.
Maybe you could have a timeout or a number of retries, otherwise show a toastr error notifying that the tour couldn't be launched.
…o 323/implement-a-tour-guide
c565bf7
to
1ce1c7e
Compare
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.
Very nice! We're almost there. Just some minor changes and comments.
src/actions/tour.js
Outdated
payload, | ||
}); | ||
|
||
const navigateStopTour = payload => dispatch => |
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.
src/components/common/Tour.js
Outdated
selector: `.${VISIT_SPACE_INPUT_CLASS}`, | ||
}); | ||
document.getElementById(DRAWER_BUTTON_ID).click(); | ||
setTimeout(() => dispatchStartTour(), TOUR_DELAY_500); |
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.
Still, I would create a function in this class called handleStartTour
and put this line inside.
src/config/tours.js
Outdated
disableBeacon: true, | ||
}, | ||
{ | ||
target: `.${SPACE_SCREEN_CLASS}`, |
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 it's redundant with the previous step. Let's remove it.
src/config/tours.js
Outdated
target: `.${VISIT_SPACE_INPUT_CLASS}`, | ||
title: 'Visiting a Space', | ||
content: | ||
"You can visit a space using its URL or ID. For example, let's have a look at space https://graasp.eu/s/owozgj or simply owozgj.", |
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.
You can use the factored out value of the sample space here too.
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.
Sorry I did not understand your proposal. What do you mean?
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.
content: `You can... have a look at space https://...${TOUR_SPACE}... or ${TOUR_SPACE}`
src/types/tour.js
Outdated
@@ -0,0 +1,7 @@ | |||
export const NEXT_OR_PREV_TOUR = 'NEXT_OR_PREV_TOUR'; | |||
export const NAVIGATE_STOP_TOUR = 'NAVIGATE_STOP_TOUR'; |
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.
See comment above.
940e452
to
d089623
Compare
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 one very minor change and a question about whether you are keeping that prev condition or removing it. You discussed this with @pyphilia.
src/components/common/Tour.js
Outdated
}} | ||
callback={callback} | ||
locale={{ | ||
last: t('End tour'), |
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.
"Tour" capitalised.
For me, I think we should keep it to ensure the tour launch dispatch won't be fired twice. But I am ok with removing it as it doesn't cause any issues. |
What happened with this PR? Can we go ahead and merge it? Would be great to release it next week. |
d089623
to
1be08a1
Compare
Done with it. We can merge! |
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 added minor comments, the most important part is the tests where the syntax changed a bit.
src/components/common/Tour.js
Outdated
} | ||
break; | ||
default: | ||
dispatchCompleteTour(tours.VISIT_SPACE_TOUR); |
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.
Do we really want to dispatch VISIT_SPACE_TOUR
by default?
src/utils/elements.js
Outdated
@@ -0,0 +1,11 @@ | |||
const waitForElement = async ({ selector, time = 500 }) => { |
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.
Maybe you could have a timeout or a number of retries, otherwise show a toastr error notifying that the tour couldn't be launched.
test/utils.js
Outdated
@@ -89,6 +90,7 @@ export const menuGoToPhase = async (client, nb) => { | |||
|
|||
export const menuGoToSettings = async (client) => { | |||
await menuGoTo(client, SETTINGS_MENU_ITEM_ID, SETTINGS_MAIN_ID); | |||
await client.click(TOUR_END_SELECTOR); |
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.
You will have to change it for: (because of the dependencies update)
const tourEndButton = await client.$(TOUR_END_SELECTOR);
await tourEndButton.click()
test/utils.js
Outdated
) => { | ||
const input = await client.$(`#${LOGIN_USERNAME_INPUT_ID}`); | ||
await input.setValue(name); | ||
await client.pause(INPUT_TYPE_PAUSE); | ||
const button = await client.$(`#${LOGIN_BUTTON_ID}`); | ||
await button.click(); | ||
await client.pause(LOGIN_PAUSE); | ||
|
||
if (closeTour) { | ||
await client.click(TOUR_END_SELECTOR); |
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.
Same as above.
…o 323/implement-a-tour-guide
1be08a1
to
8a388ba
Compare
adds tour
close #323