Skip to content

Commit 2911e64

Browse files
authored
Merge pull request #402 from auth0/feat/sso-hide-mappings
feat: add hideAttributeMappings prop to SsoProviderEdit
2 parents 5253ca7 + c21c4e8 commit 2911e64

9 files changed

Lines changed: 96 additions & 17 deletions

File tree

packages/react/src/components/auth0/my-organization/__tests__/sso-provider-edit.test.tsx

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,61 @@ describe('SsoProviderEdit', () => {
473473
});
474474
});
475475

476+
describe('hideAttributeMappings', () => {
477+
describe('on SSO tab', () => {
478+
describe('when is true', () => {
479+
it('should not display attribute mappings section', async () => {
480+
renderWithProviders(
481+
<SsoProviderEdit
482+
{...createMockSsoProviderEditProps({ hideAttributeMappings: true })}
483+
/>,
484+
);
485+
486+
await waitForComponentToLoad();
487+
488+
expect(screen.queryByText(/mappings.title/i)).not.toBeInTheDocument();
489+
});
490+
});
491+
492+
describe('when is false', () => {
493+
it('should display attribute mappings section', async () => {
494+
renderWithProviders(
495+
<SsoProviderEdit
496+
{...createMockSsoProviderEditProps({ hideAttributeMappings: false })}
497+
/>,
498+
);
499+
500+
await waitForComponentToLoad();
501+
502+
expect(screen.queryByText(/mappings.title/i)).toBeInTheDocument();
503+
});
504+
});
505+
});
506+
507+
describe('on Provisioning tab', () => {
508+
describe('when is true', () => {
509+
it('should not display attribute mappings section', async () => {
510+
const user = userEvent.setup();
511+
512+
renderWithProviders(
513+
<SsoProviderEdit
514+
{...createMockSsoProviderEditProps({ hideAttributeMappings: true })}
515+
/>,
516+
);
517+
518+
await waitForComponentToLoad();
519+
520+
const provisioningTab = screen.getByText(/tabs.provisioning.name/i);
521+
await user.click(provisioningTab);
522+
523+
await waitFor(() => {
524+
expect(screen.queryByText(/mappings.title/i)).not.toBeInTheDocument();
525+
});
526+
});
527+
});
528+
});
529+
});
530+
476531
describe('sso action props', () => {
477532
describe('when sso.updateAction is provided', () => {
478533
it('should call onBefore when toggling provider', async () => {

packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-edit/sso-provider-details.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import type { SsoProviderDetailsProps } from '@/types/my-organization/idp-manage
3838
export function SsoProviderDetails({
3939
provider,
4040
readOnly = false,
41+
hideAttributeMappings = false,
4142
idpConfig,
4243
formActions,
4344
customMessages = {},
@@ -134,15 +135,19 @@ export function SsoProviderDetails({
134135
/>
135136
</div>
136137

137-
<Separator />
138-
<div className="space-y-4">
139-
<SsoProviderAttributeMappings
140-
strategy={provider?.strategy || null}
141-
userAttributeMap={attributes}
142-
customMessages={customMessages.mappings}
143-
className={currentStyles.classes?.['SsoProvider-attributeMapping']}
144-
/>
145-
</div>
138+
{!hideAttributeMappings && (
139+
<>
140+
<Separator />
141+
<div className="space-y-4">
142+
<SsoProviderAttributeMappings
143+
strategy={provider?.strategy || null}
144+
userAttributeMap={attributes}
145+
customMessages={customMessages.mappings}
146+
className={currentStyles.classes?.['SsoProvider-attributeMapping']}
147+
/>
148+
</div>
149+
</>
150+
)}
146151

147152
{formActions && (
148153
<FormActions

packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-edit/sso-provider-tab.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function SsoProviderTab({
5555
shouldAllowDeletion,
5656
hideDeleteProvider = false,
5757
hideRemoveFromOrganization = false,
58+
hideAttributeMappings = false,
5859
formActions,
5960
hasSsoAttributeSyncWarning,
6061
onAttributeSync,
@@ -94,6 +95,7 @@ export function SsoProviderTab({
9495
<SsoProviderDetails
9596
provider={provider}
9697
readOnly={readOnly}
98+
hideAttributeMappings={hideAttributeMappings}
9799
formActions={formActions}
98100
customMessages={customMessages.details}
99101
styling={styling}

packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-edit/sso-provisioning/sso-provisioning-details.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export function SsoProvisioningDetails({
5959
isScimTokensLoading,
6060
isScimTokenCreating,
6161
isScimTokenDeleting,
62+
hideAttributeMappings = false,
6263
onListScimTokens,
6364
onCreateScimToken,
6465
onDeleteScimToken,
@@ -155,14 +156,18 @@ export function SsoProvisioningDetails({
155156
/>
156157
</form>
157158
</Form>
158-
<Separator />
159-
<SsoProviderAttributeMappings
160-
strategy={provisioningConfig?.strategy || null}
161-
isProvisioning
162-
userAttributeMap={provisioningConfig?.attributes || null}
163-
customMessages={customMessages.mappings}
164-
className={currentStyles.classes?.['SsoProvisioning-attributeMapping']}
165-
/>
159+
{!hideAttributeMappings && (
160+
<>
161+
<Separator />
162+
<SsoProviderAttributeMappings
163+
strategy={provisioningConfig?.strategy || null}
164+
isProvisioning
165+
userAttributeMap={provisioningConfig?.attributes || null}
166+
customMessages={customMessages.mappings}
167+
className={currentStyles.classes?.['SsoProvisioning-attributeMapping']}
168+
/>
169+
</>
170+
)}
166171
</div>
167172
);
168173
}

packages/react/src/components/auth0/my-organization/shared/idp-management/sso-provider-edit/sso-provisioning/sso-provisioning-tab.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export function SsoProvisioningTab({
4444
provider,
4545
styling = { variables: { common: {}, light: {}, dark: {} }, classes: {} },
4646
customMessages = {},
47+
hideAttributeMappings = false,
4748
hasProvisioningAttributeSyncWarning,
4849
onAttributeSync,
4950
isSyncingAttributes = false,
@@ -164,6 +165,7 @@ export function SsoProvisioningTab({
164165
isScimTokensLoading={isScimTokensLoading}
165166
isScimTokenCreating={isScimTokenCreating}
166167
isScimTokenDeleting={isScimTokenDeleting}
168+
hideAttributeMappings={hideAttributeMappings}
167169
onListScimTokens={listScimTokens}
168170
onCreateScimToken={createScimToken}
169171
onDeleteScimToken={deleteScimToken}

packages/react/src/components/auth0/my-organization/sso-provider-edit.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function SsoProviderEdit(props: SsoProviderEditProps) {
5656
hideProvisioningTab = false,
5757
hideDeleteProvider = false,
5858
hideRemoveFromOrganization = false,
59+
hideAttributeMappings = false,
5960
customMessages = {},
6061
styling = {
6162
variables: { common: {}, light: {}, dark: {} },
@@ -88,6 +89,7 @@ function SsoProviderEdit(props: SsoProviderEditProps) {
8889
hideProvisioningTab,
8990
hideDeleteProvider,
9091
hideRemoveFromOrganization,
92+
hideAttributeMappings,
9193
};
9294

9395
const ssoProviderCreateHandlerProps: SsoProviderEditHandlerProps = {
@@ -137,6 +139,7 @@ function SsoProviderEditView({ logic, handlers }: SsoProviderEditViewProps) {
137139
hideHeader,
138140
hideDeleteProvider,
139141
hideRemoveFromOrganization,
142+
hideAttributeMappings,
140143
provider,
141144
organization,
142145
isLoading,
@@ -244,6 +247,7 @@ function SsoProviderEditView({ logic, handlers }: SsoProviderEditViewProps) {
244247
shouldAllowDeletion={shouldAllowDeletion}
245248
hideDeleteProvider={hideDeleteProvider}
246249
hideRemoveFromOrganization={hideRemoveFromOrganization}
250+
hideAttributeMappings={hideAttributeMappings}
247251
hasSsoAttributeSyncWarning={hasSsoAttributeSyncWarning}
248252
onAttributeSync={syncSsoAttributes}
249253
isSyncingAttributes={isSsoAttributesSyncing}
@@ -269,6 +273,7 @@ function SsoProviderEditView({ logic, handlers }: SsoProviderEditViewProps) {
269273
isScimTokensLoading={isScimTokensLoading}
270274
isScimTokenCreating={isScimTokenCreating}
271275
isScimTokenDeleting={isScimTokenDeleting}
276+
hideAttributeMappings={hideAttributeMappings}
272277
hasProvisioningAttributeSyncWarning={hasProvisioningAttributeSyncWarning}
273278
onAttributeSync={syncProvisioningAttributes}
274279
isSyncingAttributes={isProvisioningAttributesSyncing}

packages/react/src/types/my-organization/idp-management/sso-provider/sso-provider-edit-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export interface SsoProviderEditProps
8181
hideProvisioningTab?: boolean;
8282
hideDeleteProvider?: boolean;
8383
hideRemoveFromOrganization?: boolean;
84+
hideAttributeMappings?: boolean;
8485
providerId: IdpId;
8586
sso?: SsoProviderTabEditProps;
8687
provisioning?: SsoProvisioningTabEditProps;

packages/react/src/types/my-organization/idp-management/sso-provider/sso-provider-tab-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export interface SsoProviderTabProps
6161
shouldAllowDeletion: boolean;
6262
hideDeleteProvider?: boolean;
6363
hideRemoveFromOrganization?: boolean;
64+
hideAttributeMappings?: boolean;
6465
provider: IdpKnownResponse | null;
6566
onDelete: (provider: IdpKnownResponse) => Promise<void>;
6667
onRemove: (provider: IdpKnownResponse) => Promise<void>;
@@ -97,5 +98,6 @@ export interface SsoProviderDetailsProps
9798
provider: IdpKnownResponse;
9899
idpConfig: GetIdpConfigurationResponseContent | null;
99100
readOnly?: boolean;
101+
hideAttributeMappings?: boolean;
100102
formActions?: SsoProviderDetailsFormActions;
101103
}

packages/react/src/types/my-organization/idp-management/sso-provisioning/sso-provisioning-tab-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export interface SsoProvisioningTabProps
4949
isScimTokensLoading: boolean;
5050
isScimTokenCreating: boolean;
5151
isScimTokenDeleting: boolean;
52+
hideAttributeMappings?: boolean;
5253
onCreateProvisioning: () => Promise<void>;
5354
onDeleteProvisioning: () => Promise<void>;
5455
onListScimTokens: () => Promise<ListIdpProvisioningScimTokensResponseContent | null>;
@@ -88,6 +89,7 @@ export interface SsoProvisioningDetailsProps
8889
isScimTokensLoading: boolean;
8990
isScimTokenCreating: boolean;
9091
isScimTokenDeleting: boolean;
92+
hideAttributeMappings?: boolean;
9193
onListScimTokens: () => Promise<ListIdpProvisioningScimTokensResponseContent | null>;
9294
onCreateScimToken: (
9395
data: CreateIdpProvisioningScimTokenRequestContent,

0 commit comments

Comments
 (0)