adding team mappings UI

This commit is contained in:
yuneng-jiang 2026-02-02 13:12:20 -08:00
parent f1bca73431
commit 899bafb290
4 changed files with 28 additions and 6 deletions

View file

@ -41,7 +41,7 @@ export interface RoleMappings {
}
export interface TeamMappings {
team_id_jwt_field: string;
team_ids_jwt_field: string;
}
export interface SSOSettingsResponse {

View file

@ -33,6 +33,7 @@ const DeleteSSOSettingsModal: React.FC<DeleteSSOSettingsModalProps> = ({ isVisib
user_email: null,
sso_provider: null,
role_mappings: null,
team_mappings: null,
};
await editSSOSettings(clearSettings, {

View file

@ -1,7 +1,7 @@
"use client";
import { useSSOSettings, type SSOSettingsValues } from "@/app/(dashboard)/hooks/sso/useSSOSettings";
import { Button, Card, Descriptions, Space, Typography } from "antd";
import { Button, Card, Descriptions, Space, Tag, Typography } from "antd";
import { Edit, Shield, Trash2 } from "lucide-react";
import { useState } from "react";
import { ssoProviderDisplayNames, ssoProviderLogoMap } from "./constants";
@ -28,6 +28,7 @@ export default function SSOSettings() {
const selectedProvider = ssoSettings?.values ? detectSSOProvider(ssoSettings.values) : null;
const isRoleMappingsEnabled = Boolean(ssoSettings?.values.role_mappings);
const isTeamMappingsEnabled = Boolean(ssoSettings?.values.team_mappings);
const renderEndpointValue = (value?: string | null) => (
<Text className="font-mono text-gray-600 text-sm" copyable={!!value}>
@ -38,6 +39,15 @@ export default function SSOSettings() {
const renderSimpleValue = (value?: string | null) =>
value ? value : <span className="text-gray-400 italic">Not configured</span>;
const renderTeamMappingsField = (values: SSOSettingsValues) => {
if (!values.team_mappings?.team_ids_jwt_field) {
return <span className="text-gray-400 italic">Not configured</span>;
}
return (
<Tag>{values.team_mappings.team_ids_jwt_field}</Tag>
);
};
const descriptionsConfig = {
column: {
xxl: 1,
@ -103,6 +113,10 @@ export default function SSOSettings() {
render: (values: SSOSettingsValues) => renderEndpointValue(values.generic_userinfo_endpoint),
},
{ label: "Proxy Base URL", render: (values: SSOSettingsValues) => renderSimpleValue(values.proxy_base_url) },
isTeamMappingsEnabled ? {
label: "Team IDs JWT Field",
render: (values: SSOSettingsValues) => renderTeamMappingsField(values),
} : null,
],
},
generic: {
@ -129,6 +143,10 @@ export default function SSOSettings() {
render: (values: SSOSettingsValues) => renderEndpointValue(values.generic_userinfo_endpoint),
},
{ label: "Proxy Base URL", render: (values: SSOSettingsValues) => renderSimpleValue(values.proxy_base_url) },
isTeamMappingsEnabled ? {
label: "Team IDs JWT Field",
render: (values: SSOSettingsValues) => renderTeamMappingsField(values),
} : null,
],
},
};
@ -155,7 +173,7 @@ export default function SSOSettings() {
<span>{config.providerText}</span>
</div>
</Descriptions.Item>
{config.fields.map((field, index) => (
{config.fields.map((field, index) => field && (
<Descriptions.Item key={index} label={field.label}>
{field.render(values)}
</Descriptions.Item>

View file

@ -23,7 +23,9 @@ export const processSSOSettingsPayload = (formValues: Record<string, any>): Reco
};
// Add role mappings only if use_role_mappings is checked AND provider supports role mappings
if (use_role_mappings) {
const provider = rest.sso_provider;
const supportsRoleMappings = provider === "okta" || provider === "generic";
if (use_role_mappings && supportsRoleMappings) {
// Helper function to split comma-separated string into array
const splitTeams = (teams: string | undefined): string[] => {
if (!teams || teams.trim() === "") return [];
@ -54,8 +56,9 @@ export const processSSOSettingsPayload = (formValues: Record<string, any>): Reco
};
}
// Add team mappings only if use_team_mappings is checked
if (use_team_mappings) {
// Add team mappings only if use_team_mappings is checked AND provider supports team mappings
const supportsTeamMappings = provider === "okta" || provider === "generic";
if (use_team_mappings && supportsTeamMappings) {
payload.team_mappings = {
team_ids_jwt_field: team_ids_jwt_field,
};