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

feat: add tour for launch #337

Merged
merged 3 commits into from
Oct 27, 2020
Merged

feat: add tour for launch #337

merged 3 commits into from
Oct 27, 2020

Conversation

hasanagh
Copy link
Contributor

@hasanagh hasanagh commented Oct 6, 2020

adds tour

close #323

@juancarlosfarah
Copy link
Member

@hasanagh, please rebase w.r.t master.

Copy link
Contributor

@pyphilia pyphilia left a 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 of VISIT_SPACE_BUTTON (it mostly helps for tests)

@@ -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',
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 COMPLETE_TOUR_CHANNEL would be better.

Copy link
Contributor Author

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 of VISIT_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

tour: tours.VISIT_SPACE_TOUR,
steps: VISIT_SPACE_TOUR_STEPS,
}),
750
Copy link
Contributor

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

dispatchStartTour();
break;
case 2:
replace('/space/owozgj');
Copy link
Contributor

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.

@juancarlosfarah
Copy link
Member

@hasanagh, don't forget to rebase.

@hasanagh hasanagh force-pushed the 323/implement-a-tour-guide branch from bfaa4fa to c565bf7 Compare October 7, 2020 22:03
Copy link
Member

@juancarlosfarah juancarlosfarah left a 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.

STOP_TOUR,
} from '../types/tour';

const nextStepTour = payload => dispatch =>
Copy link
Member

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.

payload,
});

const navigateStopTour = payload => dispatch =>
Copy link
Member

Choose a reason for hiding this comment

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

What is navigateStopTour?

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 is an action I refactored out because when we have multi-page tours we need to stop the tour and then start it again.

Copy link
Member

Choose a reason for hiding this comment

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

Let's change it then to some other more descriptive name. Like stopTourAndNavigate or goToNextTour. Any proposals, @hasanagh, @pyphilia ?

Copy link
Contributor Author

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.

},
options: {
primaryColor: THEME_COLORS[USER_MODES.TEACHER],
zIndex: 10000,
Copy link
Member

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?

}}
callback={callback}
locale={{
last: 'End tour',
Copy link
Member

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?

},
{
target: `.${SETTINGS_ACTIONS_CLASS}`,
content: 'Here you can enable tracking of actions within spaces',
Copy link
Member

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.

@@ -0,0 +1,7 @@
export const NEXT_OR_PREV_TOUR = 'NEXT_OR_PREV_TOUR';
export const NAVIGATE_STOP_TOUR = 'NAVIGATE_STOP_TOUR';
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

See comment above.

@@ -0,0 +1,7 @@
export const NEXT_OR_PREV_TOUR = 'NEXT_OR_PREV_TOUR';
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Also, use verbs.

@@ -0,0 +1,11 @@
const waitForElement = async ({ selector, time = 500 }) => {
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@hasanagh hasanagh force-pushed the 323/implement-a-tour-guide branch from c565bf7 to 1ce1c7e Compare October 15, 2020 18:27
Copy link
Member

@juancarlosfarah juancarlosfarah left a 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.

payload,
});

const navigateStopTour = payload => dispatch =>
Copy link
Member

Choose a reason for hiding this comment

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

Let's change it then to some other more descriptive name. Like stopTourAndNavigate or goToNextTour. Any proposals, @hasanagh, @pyphilia ?

selector: `.${VISIT_SPACE_INPUT_CLASS}`,
});
document.getElementById(DRAWER_BUTTON_ID).click();
setTimeout(() => dispatchStartTour(), TOUR_DELAY_500);
Copy link
Member

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.

disableBeacon: true,
},
{
target: `.${SPACE_SCREEN_CLASS}`,
Copy link
Member

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.

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.",
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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}`

@@ -0,0 +1,7 @@
export const NEXT_OR_PREV_TOUR = 'NEXT_OR_PREV_TOUR';
export const NAVIGATE_STOP_TOUR = 'NAVIGATE_STOP_TOUR';
Copy link
Member

Choose a reason for hiding this comment

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

See comment above.

@hasanagh hasanagh force-pushed the 323/implement-a-tour-guide branch from 940e452 to d089623 Compare October 18, 2020 12:15
Copy link
Member

@juancarlosfarah juancarlosfarah left a 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.

}}
callback={callback}
locale={{
last: t('End tour'),
Copy link
Member

Choose a reason for hiding this comment

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

"Tour" capitalised.

@hasanagh
Copy link
Contributor Author

Just one very minor change and a question about whether you are keeping that prev condition or removing it. You discussed this with @pyphilia.

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.

@juancarlosfarah
Copy link
Member

What happened with this PR? Can we go ahead and merge it? Would be great to release it next week.

@hasanagh hasanagh force-pushed the 323/implement-a-tour-guide branch from d089623 to 1be08a1 Compare October 24, 2020 17:02
@hasanagh
Copy link
Contributor Author

What happened with this PR? Can we go ahead and merge it? Would be great to release it next week.

Done with it. We can merge!

Copy link
Contributor

@pyphilia pyphilia left a 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.

}
break;
default:
dispatchCompleteTour(tours.VISIT_SPACE_TOUR);
Copy link
Contributor

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?

@@ -0,0 +1,11 @@
const waitForElement = async ({ selector, time = 500 }) => {
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@hasanagh hasanagh force-pushed the 323/implement-a-tour-guide branch from 1be08a1 to 8a388ba Compare October 26, 2020 18:29
@pyphilia pyphilia merged commit f188f27 into master Oct 27, 2020
@pyphilia pyphilia deleted the 323/implement-a-tour-guide branch October 27, 2020 08: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.

Implement a tour guide at desktop launch
3 participants