Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions apps/web/src/app/(onboarding)/setup/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {
import { useTRPC } from '@/trpc/client';
import { useUser } from '@/hooks/useUser';

import { SETUP_STEPS, getSetupPath, type SetupStep } from './types';
import {
SETUP_STEPS,
getSetupPath,
getSetupSteps,
type SetupStep,
} from './types';
import { useSetupAsyncSession } from './setup-session';
import { hasSeenSetupWelcome } from './welcome-seen';

Expand Down Expand Up @@ -66,22 +71,6 @@ const DEEP_LINK_REVISITABLE_SETUP_STEPS: readonly SetupStep[] = [
'compute-config',
];

const EMAIL_PASSWORD_SETUP_STEPS: readonly SetupStep[] = [
'welcome',
'env-vars',
'source-control-provider',
'source-control-config',
'source-control-connect',
'auth-provider',
'auth-env-vars',
'slack',
'automation-recommendations',
'compute-provider',
'compute-config',
'repo-selection',
'invoke',
];

function readUrlEntryContext(): SetupEntryContext {
if (typeof window === 'undefined') {
return {
Expand Down Expand Up @@ -295,10 +284,9 @@ export function useSetupFlow(
const setupSession = useSetupAsyncSession({
currentTaskId: status?.setupNewState.onboardingTaskId ?? null,
});
const setupSteps =
(pendingAuthProvider ?? status?.setupNewState.authProvider)
? SETUP_STEPS
: EMAIL_PASSWORD_SETUP_STEPS;
const setupSteps = getSetupSteps(
Boolean(pendingAuthProvider ?? status?.setupNewState.authProvider),
);
stepRef.current = step;

const setStepWithTransition = useCallback(
Expand Down
29 changes: 29 additions & 0 deletions apps/web/src/app/(onboarding)/setup/types.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 31 additions & 1 deletion apps/web/src/app/(onboarding)/setup/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,40 @@ type SetupStepDefinition = (typeof SETUP_STEP_DEFINITIONS)[number];

export type SetupStep = SetupStepDefinition['id'];

export const SETUP_STEPS: SetupStep[] = SETUP_STEP_DEFINITIONS.map(
export const SETUP_STEPS: readonly SetupStep[] = SETUP_STEP_DEFINITIONS.map(
(definition) => definition.id,
);

const EMAIL_PASSWORD_SETUP_ORDER_POLICY = {
move: ['auth-provider', 'auth-env-vars', 'slack'],
after: 'source-control-connect',
} as const satisfies {
move: readonly SetupStep[];
after: SetupStep;
};

const EMAIL_PASSWORD_MOVED_SETUP_STEPS = new Set<SetupStep>(
EMAIL_PASSWORD_SETUP_ORDER_POLICY.move,
);

const EMAIL_PASSWORD_SETUP_STEPS: readonly SetupStep[] = SETUP_STEPS.flatMap(
(step) => {
if (step === EMAIL_PASSWORD_SETUP_ORDER_POLICY.after) {
return [step, ...EMAIL_PASSWORD_SETUP_ORDER_POLICY.move];
}

return EMAIL_PASSWORD_MOVED_SETUP_STEPS.has(step) ? [] : [step];
},
);

export function getSetupSteps(
hasCommunicationAuthProvider: boolean,
): readonly SetupStep[] {
return hasCommunicationAuthProvider
? SETUP_STEPS
: EMAIL_PASSWORD_SETUP_STEPS;
}

const SETUP_STEP_DEFINITION_MAP = Object.fromEntries(
SETUP_STEP_DEFINITIONS.map((definition) => [definition.id, definition]),
) as {
Expand Down
Loading