Skip to content

Commit

Permalink
fix(rbac): conditional access form validation (janus-idp#1699)
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Cai <[email protected]>
  • Loading branch information
ciiay authored May 28, 2024
1 parent ccd80db commit d56f4af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion plugins/rbac/src/__fixtures__/mockConditionRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export const mockConditionRules = [
properties: {
kinds: {
type: 'array',
items: { type: 'string' },
items: { type: 'string' }, // TODO: should be enum?
minItems: 1,
description: 'List of kinds to match at least one of',
},
},
Expand All @@ -110,6 +111,7 @@ export const mockConditionRules = [
claims: {
type: 'array',
items: { type: 'string' },
minItems: 1,
description:
'List of claims to match at least one on within ownedBy',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ export const ConditionsFormRowFields = ({
{schema ? (
<Form
schema={paramsSchema}
formData={oldCondition?.params ?? null}
formData={oldCondition?.params || {}}
validator={validator}
uiSchema={uiSchema}
fields={customFields}
onChange={data =>
handleConditionChange({
...oldCondition,
params: data.formData ?? {},
params: data.formData || {},
})
}
transformErrors={errors => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export const CustomArrayField = (props: FieldProps) => {
label={name}
value={fieldVal}
onChange={e => {
setFieldVal(e.target.value);
onChange(e.target.value.split(',').map(val => val.trim()));
const value = e.target.value;
setFieldVal(value);
onChange(value ? value.split(',').map(val => val.trim()) : []);
}}
className={classes.bgPaper}
required={required}
Expand Down

0 comments on commit d56f4af

Please sign in to comment.