Skip to content

Commit 9a95049

Browse files
committed
Fix validation on metadata update
1 parent ca51be4 commit 9a95049

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const ConfigureSSOCardContent = ({ contentRef }: { contentRef: React.RefObject<H
8181
const { hasSuccessfulTestRun, isLoading: isLoadingTestRuns } = useHasSuccessfulTestRun(enterpriseConnection);
8282

8383
const isLoading = isLoadingEnterpriseConnections || isLoadingTestRuns;
84-
if (isLoading && !enterpriseConnection) {
84+
if (isLoading || !enterpriseConnection) {
8585
return <ConfigureSSOSkeleton />;
8686
}
8787

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

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { isClerkAPIResponseError } from '@clerk/shared/error';
12
import { useReverification } from '@clerk/shared/react';
23
import type { FieldId, UpdateMeEnterpriseConnectionParams } from '@clerk/shared/types';
34
import React, { type JSX } from 'react';
45

56
import {
6-
Alert,
77
Badge,
88
Box,
99
Button,
@@ -687,12 +687,21 @@ export const SubmitSamlConfigSubStep = (): JSX.Element => {
687687

688688
await updateConnection({ saml: samlPayload });
689689
}
690+
690691
void goNext();
691692
} catch (err) {
692-
if (mode === 'metadataUrl') {
693-
handleError(err as Error, [metadataUrlField], card.setError);
694-
} else {
695-
handleError(err as Error, [signOnUrlField, issuerField, certFileField], card.setError);
693+
const fields = mode === 'metadataUrl' ? [metadataUrlField] : [signOnUrlField, issuerField, certFileField];
694+
695+
handleError(err as Error, fields, card.setError);
696+
697+
if (isClerkAPIResponseError(err)) {
698+
const unscopedSamlError = err.errors.find(e => e.code?.startsWith('saml_') && !e.meta?.paramName);
699+
700+
if (unscopedSamlError) {
701+
const primaryField = mode === 'metadataUrl' ? metadataUrlField : signOnUrlField;
702+
primaryField.setError(unscopedSamlError);
703+
card.setError(undefined);
704+
}
696705
}
697706
} finally {
698707
card.setIdle();
@@ -714,7 +723,10 @@ export const SubmitSamlConfigSubStep = (): JSX.Element => {
714723
<SegmentedControl.Root
715724
aria-label={t(localizationKeys(key('modes.ariaLabel')))}
716725
value={mode}
717-
onChange={value => setMode(value as 'metadataUrl' | 'manual')}
726+
onChange={value => {
727+
card.setError(undefined);
728+
setMode(value as 'metadataUrl' | 'manual');
729+
}}
718730
fullWidth
719731
>
720732
<SegmentedControl.Button
@@ -740,14 +752,6 @@ export const SubmitSamlConfigSubStep = (): JSX.Element => {
740752
/>
741753
)}
742754
</Step.Section>
743-
744-
{card.error && (
745-
<Alert
746-
colorScheme='danger'
747-
title={card.error}
748-
sx={t => ({ margin: t.space.$3 })}
749-
/>
750-
)}
751755
</Step.Body>
752756

753757
<Step.Footer>
@@ -858,7 +862,7 @@ const ManualEntryPanel = ({
858862
/>
859863
)}
860864
<Button
861-
size='sm'
865+
size='xs'
862866
variant='outline'
863867
onClick={() => certInputRef.current?.click()}
864868
>

0 commit comments

Comments
 (0)