-
Notifications
You must be signed in to change notification settings - Fork 38
fix: clean up to get passing test #1550
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
Draft
adamstankiewicz
wants to merge
8
commits into
master
Choose a base branch
from
ags/fix-onboarding-tour-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
83e1d1f
fix: adding onboardingflow
kiram15 016f873
fix: fixes next step progression
b5ade56
fix: some lint stuff
kiram15 add3da5
fix: continuing work
kiram15 4b37d43
chore: merge master
kiram15 3f36dc9
fix: lint fixes
kiram15 9a76dd0
Merge branch 'master' into kiram15/ENT-10219
kiram15 623f786
fix: clean up to get passing test
adamstankiewicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18,776 changes: 9,491 additions & 9,285 deletions
18,776
src/components/Admin/__snapshots__/Admin.test.jsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import React, { FC } from 'react'; | ||
| import React, { FC, useState, useEffect } from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { connect } from 'react-redux'; | ||
| import { ProductTour } from '@openedx/paragon'; | ||
| import { FormattedMessage } from '@edx/frontend-platform/i18n'; | ||
|
|
@@ -9,29 +10,44 @@ import '../_ProductTours.scss'; | |
| interface AdminOnboardingToursProps { | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| enterpriseSlug: string; | ||
| targetSelector: string; | ||
| adminUuid: string, | ||
| setTarget: Function, | ||
| enterpriseSlug: string; | ||
| } | ||
|
|
||
| interface RootState { | ||
| portalConfiguration: { | ||
| enterpriseSlug: string; | ||
| }; | ||
| enterpriseCustomerAdmin: { | ||
| uuid: string; | ||
| } | ||
| } | ||
|
|
||
| const AdminOnboardingTours: FC<AdminOnboardingToursProps> = ({ | ||
| isOpen, | ||
| onClose, | ||
| enterpriseSlug, | ||
| targetSelector, | ||
| adminUuid, | ||
| setTarget, | ||
| enterpriseSlug, | ||
| }) => { | ||
| const learnerProgressStep = useLearnerProgressTour({ enterpriseSlug }); | ||
| const [currentStep, setCurrentStep] = useState(0); | ||
| const learnerProgressSteps = useLearnerProgressTour({ enterpriseSlug, adminUuid }); | ||
|
|
||
| useEffect(() => { | ||
| if (learnerProgressSteps[currentStep]) { | ||
| const nextTarget = learnerProgressSteps[currentStep].target.replace('#', ''); | ||
| setTarget(nextTarget); | ||
| } | ||
| }, [currentStep, learnerProgressSteps, setTarget]); | ||
|
|
||
| const tours = [ | ||
| { | ||
| tourId: 'admin-onboarding-tour', | ||
| enabled: isOpen, | ||
| startingIndex: 0, | ||
| startingIndex: currentStep, | ||
| advanceButtonText: ( | ||
| <FormattedMessage | ||
| id="adminPortal.productTours.adminOnboarding.next" | ||
|
|
@@ -49,32 +65,44 @@ const AdminOnboardingTours: FC<AdminOnboardingToursProps> = ({ | |
| endButtonText: ( | ||
| <FormattedMessage | ||
| id="adminPortal.productTours.adminOnboarding.end" | ||
| defaultMessage="Complete" | ||
| defaultMessage="Keep going" | ||
| description="Text for the end button" | ||
| /> | ||
| ), | ||
| onDismiss: onClose, | ||
| onEnd: onClose, | ||
| onEscape: onClose, | ||
| checkpoints: [learnerProgressStep], | ||
| checkpoints: learnerProgressSteps.map((step, index) => ({ | ||
| ...step, | ||
| onAdvance: () => { | ||
| setCurrentStep(index + 1); | ||
| step.onAdvance(); | ||
| }, | ||
| })), | ||
| }, | ||
| ]; | ||
|
|
||
| if (!isOpen) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <CheckpointOverlay target={`#${targetSelector}`} /> | ||
| <CheckpointOverlay target={targetSelector} /> | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [inform] Ensuring we always include |
||
| <ProductTour | ||
| tours={tours} | ||
| /> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| AdminOnboardingTours.propTypes = { | ||
| isOpen: PropTypes.bool.isRequired, | ||
| onClose: PropTypes.func.isRequired, | ||
| targetSelector: PropTypes.string.isRequired, | ||
| setTarget: PropTypes.func.isRequired, | ||
| adminUuid: PropTypes.string.isRequired, | ||
| enterpriseSlug: PropTypes.string.isRequired, | ||
| }; | ||
|
|
||
| const mapStateToProps = (state: RootState) => ({ | ||
| adminUuid: state.enterpriseCustomerAdmin.uuid, | ||
| enterpriseSlug: state.portalConfiguration.enterpriseSlug, | ||
| }); | ||
|
|
||
|
|
||
20 changes: 18 additions & 2 deletions
20
src/components/ProductTours/AdminOnboardingTours/constants.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[inform] It's OK to render the
ProductTourcomponent itself because each tour itself has theenabled: booleanflag, which is also set toisOpen. Then,CheckpointOverlayappears toreturn nullas well if there's norect, so rendering bothCheckpointOverlayandProductTourhere irrespective ofisOpenshould be a no-op.