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) => {
form.setValue("autoProvision", checked);
}}
orgId={orgId as string}
roleMappingMode={roleMappingMode}
onRoleMappingModeChange={(data) => {
setRoleMappingMode(data);

View File

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

View File

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

View File

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

View File

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