Fix org selectors

This commit is contained in:
Owen
2026-05-06 13:57:17 -07:00
parent 5426031cd4
commit dd18375f23
5 changed files with 529 additions and 484 deletions

View File

@@ -500,6 +500,7 @@ export default function GeneralPage() {
onAutoProvisionChange={(checked) => { onAutoProvisionChange={(checked) => {
form.setValue("autoProvision", checked); form.setValue("autoProvision", checked);
}} }}
orgId={orgId as string}
roleMappingMode={roleMappingMode} roleMappingMode={roleMappingMode}
onRoleMappingModeChange={(data) => { onRoleMappingModeChange={(data) => {
setRoleMappingMode(data); setRoleMappingMode(data);

View File

@@ -246,7 +246,10 @@ export default function Page() {
<PaidFeaturesAlert tiers={tierMatrix.orgOidc} /> <PaidFeaturesAlert tiers={tierMatrix.orgOidc} />
<fieldset disabled={disabled} className={disabled ? "opacity-50 pointer-events-none" : ""}> <fieldset
disabled={disabled}
className={disabled ? "opacity-50 pointer-events-none" : ""}
>
<SettingsContainer> <SettingsContainer>
<SettingsSection> <SettingsSection>
<SettingsSectionHeader> <SettingsSectionHeader>
@@ -261,7 +264,10 @@ export default function Page() {
<OidcIdpProviderTypeSelect <OidcIdpProviderTypeSelect
value={form.watch("type")} value={form.watch("type")}
onTypeChange={(next) => { onTypeChange={(next) => {
applyOidcIdpProviderType(form.setValue, next); applyOidcIdpProviderType(
form.setValue,
next
);
}} }}
/> />
@@ -318,30 +324,42 @@ export default function Page() {
> >
<AutoProvisionConfigWidget <AutoProvisionConfigWidget
autoProvision={ autoProvision={
form.watch("autoProvision") as boolean form.watch(
"autoProvision"
) as boolean
} // is this right? } // is this right?
onAutoProvisionChange={(checked) => { onAutoProvisionChange={(checked) => {
form.setValue("autoProvision", checked); form.setValue(
"autoProvision",
checked
);
}} }}
orgId={params.orgId as string}
roleMappingMode={roleMappingMode} roleMappingMode={roleMappingMode}
onRoleMappingModeChange={(data) => { onRoleMappingModeChange={(data) => {
setRoleMappingMode(data); setRoleMappingMode(data);
}} }}
roles={roles} roles={roles}
fixedRoleNames={fixedRoleNames} fixedRoleNames={fixedRoleNames}
onFixedRoleNamesChange={setFixedRoleNames} onFixedRoleNamesChange={
setFixedRoleNames
}
mappingBuilderClaimPath={ mappingBuilderClaimPath={
mappingBuilderClaimPath mappingBuilderClaimPath
} }
onMappingBuilderClaimPathChange={ onMappingBuilderClaimPathChange={
setMappingBuilderClaimPath setMappingBuilderClaimPath
} }
mappingBuilderRules={mappingBuilderRules} mappingBuilderRules={
mappingBuilderRules
}
onMappingBuilderRulesChange={ onMappingBuilderRulesChange={
setMappingBuilderRules setMappingBuilderRules
} }
rawExpression={rawRoleExpression} rawExpression={rawRoleExpression}
onRawExpressionChange={setRawRoleExpression} onRawExpressionChange={
setRawRoleExpression
}
orgMappingField={{ orgMappingField={{
control: form.control, control: form.control,
name: "orgMapping" name: "orgMapping"
@@ -368,7 +386,9 @@ export default function Page() {
<form <form
className="space-y-4" className="space-y-4"
id="create-idp-form" id="create-idp-form"
onSubmit={form.handleSubmit(onSubmit)} onSubmit={form.handleSubmit(
onSubmit
)}
> >
<FormField <FormField
control={form.control} control={form.control}
@@ -397,7 +417,9 @@ export default function Page() {
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel> <FormLabel>
{t("idpClientSecret")} {t(
"idpClientSecret"
)}
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input <Input
@@ -437,7 +459,9 @@ export default function Page() {
<form <form
className="space-y-4" className="space-y-4"
id="create-idp-form" id="create-idp-form"
onSubmit={form.handleSubmit(onSubmit)} onSubmit={form.handleSubmit(
onSubmit
)}
> >
<FormField <FormField
control={form.control} control={form.control}
@@ -445,7 +469,9 @@ export default function Page() {
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel> <FormLabel>
{t("idpTenantIdLabel")} {t(
"idpTenantIdLabel"
)}
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input {...field} /> <Input {...field} />
@@ -487,7 +513,9 @@ export default function Page() {
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel> <FormLabel>
{t("idpClientSecret")} {t(
"idpClientSecret"
)}
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input <Input
@@ -527,7 +555,9 @@ export default function Page() {
<form <form
className="space-y-4" className="space-y-4"
id="create-idp-form" id="create-idp-form"
onSubmit={form.handleSubmit(onSubmit)} onSubmit={form.handleSubmit(
onSubmit
)}
> >
<FormField <FormField
control={form.control} control={form.control}
@@ -556,7 +586,9 @@ export default function Page() {
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel> <FormLabel>
{t("idpClientSecret")} {t(
"idpClientSecret"
)}
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input <Input
@@ -640,7 +672,9 @@ export default function Page() {
<form <form
className="space-y-4" className="space-y-4"
id="create-idp-form" id="create-idp-form"
onSubmit={form.handleSubmit(onSubmit)} onSubmit={form.handleSubmit(
onSubmit
)}
> >
<FormField <FormField
control={form.control} control={form.control}
@@ -648,7 +682,9 @@ export default function Page() {
render={({ field }) => ( render={({ field }) => (
<FormItem> <FormItem>
<FormLabel> <FormLabel>
{t("idpJmespathLabel")} {t(
"idpJmespathLabel"
)}
</FormLabel> </FormLabel>
<FormControl> <FormControl>
<Input {...field} /> <Input {...field} />

View File

@@ -681,6 +681,9 @@ export default function PoliciesPage() {
control: form.control, control: form.control,
name: "orgMapping" name: "orgMapping"
}} }}
orgId={
editingPolicy?.orgId || policyFormOrgId
}
roleMappingFieldIdPrefix="admin-idp-policy-role" roleMappingFieldIdPrefix="admin-idp-policy-role"
roleMappingMode={policyRoleMappingMode} roleMappingMode={policyRoleMappingMode}
onRoleMappingModeChange={ onRoleMappingModeChange={

View File

@@ -47,6 +47,7 @@ type AutoProvisionConfigWidgetProps = {
roleMappingFieldIdPrefix?: string; roleMappingFieldIdPrefix?: string;
showFreeformRoleNamesHint?: boolean; showFreeformRoleNamesHint?: boolean;
autoProvisionSwitchId?: string; autoProvisionSwitchId?: string;
orgId?: string;
}; };
export default function AutoProvisionConfigWidget({ export default function AutoProvisionConfigWidget({
@@ -67,7 +68,8 @@ export default function AutoProvisionConfigWidget({
showAutoProvisionSwitch = true, showAutoProvisionSwitch = true,
roleMappingFieldIdPrefix = "org-idp-auto-provision", roleMappingFieldIdPrefix = "org-idp-auto-provision",
showFreeformRoleNamesHint = false, showFreeformRoleNamesHint = false,
autoProvisionSwitchId = "auto-provision-toggle" autoProvisionSwitchId = "auto-provision-toggle",
orgId
}: AutoProvisionConfigWidgetProps) { }: AutoProvisionConfigWidgetProps) {
const t = useTranslations(); const t = useTranslations();
const { isPaidUser } = usePaidStatus(); const { isPaidUser } = usePaidStatus();
@@ -106,6 +108,7 @@ export default function AutoProvisionConfigWidget({
showFreeformRoleNamesHint={ showFreeformRoleNamesHint={
showFreeformRoleNamesHint showFreeformRoleNamesHint
} }
orgId={orgId}
roleMappingMode={roleMappingMode} roleMappingMode={roleMappingMode}
onRoleMappingModeChange={onRoleMappingModeChange} onRoleMappingModeChange={onRoleMappingModeChange}
roles={roles} roles={roles}

View File

@@ -17,7 +17,6 @@ import { useEnvContext } from "@app/hooks/useEnvContext";
import { tierMatrix } from "@server/lib/billing/tierMatrix"; import { tierMatrix } from "@server/lib/billing/tierMatrix";
import { build } from "@server/build"; import { build } from "@server/build";
import { RolesSelector } from "./roles-selector"; import { RolesSelector } from "./roles-selector";
import { useParams } from "next/navigation";
export type RoleMappingRoleOption = { export type RoleMappingRoleOption = {
roleId: number; roleId: number;
@@ -40,6 +39,8 @@ export type RoleMappingConfigFieldsProps = {
fieldIdPrefix?: string; fieldIdPrefix?: string;
/** When true, show extra hint for global default policies (no org role list). */ /** When true, show extra hint for global default policies (no org role list). */
showFreeformRoleNamesHint?: boolean; showFreeformRoleNamesHint?: boolean;
/** Org ID to use for role lookup. Falls back to URL params when not provided. */
orgId?: string;
}; };
export default function RoleMappingConfigFields({ export default function RoleMappingConfigFields({
@@ -55,14 +56,13 @@ export default function RoleMappingConfigFields({
rawExpression, rawExpression,
onRawExpressionChange, onRawExpressionChange,
fieldIdPrefix = "role-mapping", fieldIdPrefix = "role-mapping",
showFreeformRoleNamesHint = false showFreeformRoleNamesHint = false,
orgId
}: RoleMappingConfigFieldsProps) { }: RoleMappingConfigFieldsProps) {
const t = useTranslations(); const t = useTranslations();
const { env } = useEnvContext(); const { env } = useEnvContext();
const { isPaidUser } = usePaidStatus(); const { isPaidUser } = usePaidStatus();
const { orgId } = useParams();
const supportsMultipleRolesPerUser = isPaidUser(tierMatrix.fullRbac); const supportsMultipleRolesPerUser = isPaidUser(tierMatrix.fullRbac);
const showSingleRoleDisclaimer = const showSingleRoleDisclaimer =
!env.flags.disableEnterpriseFeatures && !env.flags.disableEnterpriseFeatures &&
@@ -242,6 +242,7 @@ export default function RoleMappingConfigFields({
showFreeformRoleNamesHint={ showFreeformRoleNamesHint={
showFreeformRoleNamesHint showFreeformRoleNamesHint
} }
orgId={orgId}
supportsMultipleRolesPerUser={ supportsMultipleRolesPerUser={
supportsMultipleRolesPerUser supportsMultipleRolesPerUser
} }
@@ -318,7 +319,8 @@ function BuilderRuleRow({
supportsMultipleRolesPerUser, supportsMultipleRolesPerUser,
showRemoveButton, showRemoveButton,
onChange, onChange,
onRemove onRemove,
orgId
}: { }: {
rule: MappingBuilderRule; rule: MappingBuilderRule;
roleOptions: Tag[]; roleOptions: Tag[];
@@ -330,10 +332,10 @@ function BuilderRuleRow({
showRemoveButton: boolean; showRemoveButton: boolean;
onChange: (rule: MappingBuilderRule) => void; onChange: (rule: MappingBuilderRule) => void;
onRemove: () => void; onRemove: () => void;
orgId?: string;
}) { }) {
const t = useTranslations(); const t = useTranslations();
const [activeTagIndex, setActiveTagIndex] = useState<number | null>(null); const [activeTagIndex, setActiveTagIndex] = useState<number | null>(null);
const { orgId } = useParams();
return ( return (
<div <div