Skip to content

Commit 1f38f18

Browse files
committed
feat(ui): create enterprise connection on Select Provider Continue
Wires Wizard.initialStepId via deriveInitialStep so the ConfigureSSO wizard re-mounts on the right step after reload. Renames the local ProviderType ids in Select Provider from 'okta' / 'custom_saml' to the backend values 'saml_okta' / 'saml_custom' so the Continue handler can forward them directly. Continue now sets the provider on the flow context, calls createConnection, and advances the wizard — wrapped in useCardState for loading and error display following the same pattern as Verify Domain.
1 parent 6f1d81e commit 1f38f18

2 files changed

Lines changed: 85 additions & 39 deletions

File tree

packages/ui/src/components/ConfigureSSO/ConfigureSSO.tsx

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import { ProfileCard } from '@/elements/ProfileCard';
1010
import { ExclamationTriangle } from '@/icons';
1111
import { Route, Switch } from '@/router';
1212

13-
import { ConfigureSSOFlowProvider } from './ConfigureSSOContext';
13+
import { ConfigureSSOFlowProvider, useConfigureSSOFlow } from './ConfigureSSOContext';
1414
import { ConfigureSSOHeader } from './ConfigureSSOHeader';
1515
import { ConfigureSSONavbar } from './ConfigureSSONavbar';
1616
import { ConfigureSSOSkeleton } from './ConfigureSSOSkeleton';
17+
import { deriveInitialStep } from './deriveInitialStep';
1718
import { ProfileCardFooter, ProfileCardHeader } from './elements/ProfileCard';
1819
import { Step } from './elements/Step';
1920
import { Wizard } from './elements/Wizard';
@@ -74,43 +75,55 @@ const ConfigureSSOCardContent = () => {
7475
}
7576

7677
return (
77-
<ConfigureSSOFlowProvider enterpriseConnection={enterpriseConnection}>
78-
<Wizard>
79-
<ConfigureSSOHeader />
78+
<ConfigureSSOFlowProvider
79+
enterpriseConnection={enterpriseConnection}
80+
isLoading={isLoading}
81+
>
82+
<ConfigureSSOSteps />
83+
</ConfigureSSOFlowProvider>
84+
);
85+
};
8086

81-
<Wizard.Step id='select-provider'>
82-
<SelectProviderStep />
83-
</Wizard.Step>
87+
const ConfigureSSOSteps = () => {
88+
const { enterpriseConnection } = useConfigureSSOFlow();
89+
const initialStepId = deriveInitialStep(enterpriseConnection);
8490

85-
<Wizard.Step
86-
id='verify-domain'
87-
label='Verify domain'
88-
>
89-
<VerifyDomainStep />
90-
</Wizard.Step>
91+
return (
92+
<Wizard initialStepId={initialStepId}>
93+
<ConfigureSSOHeader />
9194

92-
<Wizard.Step
93-
id='configure'
94-
label='Configure'
95-
>
96-
<ConfigureStep />
97-
</Wizard.Step>
95+
<Wizard.Step id='select-provider'>
96+
<SelectProviderStep />
97+
</Wizard.Step>
9898

99-
<Wizard.Step
100-
id='test'
101-
label='Test'
102-
>
103-
<TestConfigurationStep />
104-
</Wizard.Step>
99+
<Wizard.Step
100+
id='verify-domain'
101+
label='Verify domain'
102+
>
103+
<VerifyDomainStep />
104+
</Wizard.Step>
105105

106-
<Wizard.Step
107-
id='confirmation'
108-
label='Confirmation'
109-
>
110-
<ConfirmationStep />
111-
</Wizard.Step>
112-
</Wizard>
113-
</ConfigureSSOFlowProvider>
106+
<Wizard.Step
107+
id='configure'
108+
label='Configure'
109+
>
110+
<ConfigureStep />
111+
</Wizard.Step>
112+
113+
<Wizard.Step
114+
id='test'
115+
label='Test'
116+
>
117+
<TestConfigurationStep />
118+
</Wizard.Step>
119+
120+
<Wizard.Step
121+
id='confirmation'
122+
label='Confirmation'
123+
>
124+
<ConfirmationStep />
125+
</Wizard.Step>
126+
</Wizard>
114127
);
115128
};
116129

packages/ui/src/components/ConfigureSSO/steps/SelectProviderStep.tsx

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,48 @@ import {
1313
Text,
1414
useLocalizations,
1515
} from '@/customizables';
16+
import { useCardState } from '@/elements/contexts';
1617
import { Alert } from '@/ui/elements/Alert';
18+
import { handleError } from '@/utils/errorHandler';
1719

20+
import { type ProviderType, useConfigureSSOFlow } from '../ConfigureSSOContext';
1821
import { Step } from '../elements/Step';
1922
import { useWizard } from '../elements/Wizard';
2023

21-
type ProviderType = 'okta' | 'custom_saml';
22-
2324
const PROVIDER_OPTIONS: ReadonlyArray<{ id: ProviderType; label: LocalizationKey; iconId: string }> = [
24-
{ id: 'okta', label: localizationKeys('configureSSO.selectProviderStep.saml.okta'), iconId: 'okta' },
25+
{ id: 'saml_okta', label: localizationKeys('configureSSO.selectProviderStep.saml.okta'), iconId: 'okta' },
2526
{
26-
id: 'custom_saml',
27+
id: 'saml_custom',
2728
label: localizationKeys('configureSSO.selectProviderStep.saml.customSaml'),
2829
iconId: 'saml',
2930
},
3031
];
3132

3233
export const SelectProviderStep = (): JSX.Element => {
3334
const { goNext, goPrev, isFirstStep, isLastStep } = useWizard();
35+
const { setProvider, createConnection } = useConfigureSSOFlow();
36+
const card = useCardState();
3437
const [selected, setSelected] = React.useState<ProviderType | null>(null);
3538

39+
const handleContinue = async () => {
40+
if (!selected) {
41+
return;
42+
}
43+
44+
setProvider(selected);
45+
card.setError(undefined);
46+
card.setLoading();
47+
48+
try {
49+
await createConnection();
50+
void goNext();
51+
} catch (err) {
52+
handleError(err as Error, [], card.setError);
53+
} finally {
54+
card.setIdle();
55+
}
56+
};
57+
3658
return (
3759
<Flow.Part part='selectProvider'>
3860
<Step
@@ -90,6 +112,16 @@ export const SelectProviderStep = (): JSX.Element => {
90112
variant='warning'
91113
title={localizationKeys('configureSSO.selectProviderStep.warning')}
92114
/>
115+
116+
{card.error ? (
117+
<Text
118+
as='p'
119+
variant='body'
120+
sx={theme => ({ color: theme.colors.$danger500, fontSize: theme.fontSizes.$sm })}
121+
>
122+
{card.error}
123+
</Text>
124+
) : null}
93125
</Step.Section>
94126
</Step.Body>
95127

@@ -99,8 +131,9 @@ export const SelectProviderStep = (): JSX.Element => {
99131
isDisabled={isFirstStep}
100132
/>
101133
<Step.Footer.Continue
102-
onClick={() => goNext()}
103-
isDisabled={isLastStep || !selected}
134+
onClick={handleContinue}
135+
isLoading={card.isLoading}
136+
isDisabled={isLastStep || !selected || card.isLoading}
104137
/>
105138
</Step.Footer>
106139
</Step>

0 commit comments

Comments
 (0)