Skip to content

Commit

Permalink
CODE-2165: Remove Repo Selection in Onboarding Flow (#1648)
Browse files Browse the repository at this point in the history
* remove selectRepository field from useOnboardingTracking

* skip repository selection step in OrganizationSelector

* remove RepositoriesList component

* make some progress with removing repo with onboarding

* get UserOnboardingModal tests working

* fix test issue

* pass org back to extra onSuccess handler

* add hook string to remove warning

* rewrite UserOnboardingForm tests

* re-write onboarding modal to use events and not effects

* add waitFor to allow React to settle down
  • Loading branch information
nicholas-codecov authored Oct 17, 2022
1 parent 1de7f29 commit 8397b61
Show file tree
Hide file tree
Showing 11 changed files with 944 additions and 907 deletions.
45 changes: 12 additions & 33 deletions src/layouts/UserOnboarding/OrganizationSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import BaseModal from 'ui/Modal/BaseModal'
import Spinner from 'ui/Spinner'

import OrganizationsList from './OrganizationsList'
import RepositoriesList from './RepositoriesList'
import { useOnboardingTracking } from './useOnboardingTracking'

const loadingState = (
Expand All @@ -24,7 +23,7 @@ const getOrgStepProps = ({
helpFindingOrganization,
}) => ({
title: isHelpFindingOrg
? 'Dont see your organization?'
? "Don't see your organization?"
: 'Select organization',
subtitle: isHelpFindingOrg ? (
<span>
Expand All @@ -39,7 +38,7 @@ const getOrgStepProps = ({
</A>
</span>
) : (
'To set up your first repo, tell us which organization it’s in:'
'This will help improve your experience'
),
body: (
<Suspense fallback={loadingState}>
Expand All @@ -58,7 +57,7 @@ const getOrgStepProps = ({
) : (
<div className="flex flex-1 justify-between">
<span>
Dont see your org?
Don&apos;t see your org?
<button
className="text-blue-400 pl-2"
onClick={() => {
Expand All @@ -75,42 +74,22 @@ const getOrgStepProps = ({
})

function usePerStepProp({ onSelect, onOnboardingSkip, currentUser }) {
const { helpFindingOrganization, selectOrganization, selectRepository } =
const { helpFindingOrganization, selectOrganization } =
useOnboardingTracking()

const [step, setStep] = useState(0)
const [isHelpFindingOrg, setIsHelpFindingOrg] = useState(false)
const [selectedOrg, setSelectedOrg] = useState()

const handleOrgSubmit = (org) => {
selectOrganization(currentUser, org.username)
setSelectedOrg(org)
setStep(1)
onSelect({ selectedOrg: org })
}

const propsPerStep = {
0: getOrgStepProps({
isHelpFindingOrg,
handleOrgSubmit,
setIsHelpFindingOrg,
onOnboardingSkip,
helpFindingOrganization,
}),
1: {
title: 'Which repo are you working with today?',
body: selectedOrg && (
<RepositoriesList
organization={selectedOrg}
onSubmit={(selectedRepo) => {
selectRepository(currentUser, selectedRepo)
onSelect({ selectedOrg, selectedRepo })
}}
/>
),
footer: <button onClick={onOnboardingSkip}>Skip &gt;</button>,
},
}
return propsPerStep[step]
return getOrgStepProps({
isHelpFindingOrg,
handleOrgSubmit,
setIsHelpFindingOrg,
onOnboardingSkip,
helpFindingOrganization,
})
}

function OrganizationSelector({ onSelect, onOnboardingSkip, currentUser }) {
Expand Down
Loading

0 comments on commit 8397b61

Please sign in to comment.