From 3bce493156798c7bb6eb3ca58eac7f7bef04b7be Mon Sep 17 00:00:00 2001 From: kjuulh Date: Thu, 14 Jul 2022 12:36:20 +0200 Subject: [PATCH 1/4] Add allowArbitraryValues to This change makes the OwnerPicker able to validate that the selected option is one of the provided values. This should provide a smoother experience for users, as they now can only enter valid values on the client side None of the tests are changed, as this value is passed to MUI, which is the library containing the validation. Signed-off-by: kjuulh --- .../src/components/fields/OwnerPicker/OwnerPicker.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/scaffolder/src/components/fields/OwnerPicker/OwnerPicker.tsx b/plugins/scaffolder/src/components/fields/OwnerPicker/OwnerPicker.tsx index a0c22b7fef..4d9db1f5e5 100644 --- a/plugins/scaffolder/src/components/fields/OwnerPicker/OwnerPicker.tsx +++ b/plugins/scaffolder/src/components/fields/OwnerPicker/OwnerPicker.tsx @@ -25,6 +25,7 @@ import { FieldExtensionComponentProps } from '../../../extensions'; */ export interface OwnerPickerUiOptions { allowedKinds?: string[]; + allowArbitraryValues?: boolean; } /** @@ -50,6 +51,8 @@ export const OwnerPicker = ( 'User', ]) as string[], defaultKind: 'Group', + allowArbitraryValues: + uiSchema['ui:options']?.allowArbitraryValues || true, }, }; From 11a5ca35f3397bcf0179f5e6d8278c21a4395768 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Thu, 14 Jul 2022 12:49:16 +0200 Subject: [PATCH 2/4] Add changeset Signed-off-by: kjuulh --- .changeset/famous-forks-carry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/famous-forks-carry.md diff --git a/.changeset/famous-forks-carry.md b/.changeset/famous-forks-carry.md new file mode 100644 index 0000000000..0c165a37ca --- /dev/null +++ b/.changeset/famous-forks-carry.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder': patch +--- + +Add allowArbitraryValues for to provide input validation From 180c06d6239efad491f23ce61a9d5edd39ff345c Mon Sep 17 00:00:00 2001 From: kjuulh Date: Thu, 14 Jul 2022 13:00:12 +0200 Subject: [PATCH 3/4] Change boolean pipe to a Optional chaining pipe Change boolean pipe to a Optional chaining pipe Signed-off-by: kjuulh --- .changeset/famous-forks-carry.md | 2 +- .../src/components/fields/OwnerPicker/OwnerPicker.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/famous-forks-carry.md b/.changeset/famous-forks-carry.md index 0c165a37ca..0362d463cd 100644 --- a/.changeset/famous-forks-carry.md +++ b/.changeset/famous-forks-carry.md @@ -2,4 +2,4 @@ '@backstage/plugin-scaffolder': patch --- -Add allowArbitraryValues for to provide input validation +Add allowArbitraryValues for to provide input validation. This makes it a better experience of users, as they can now expect the values they enter to correspond to a valid owner. This is set to the default behavior by default. diff --git a/plugins/scaffolder/src/components/fields/OwnerPicker/OwnerPicker.tsx b/plugins/scaffolder/src/components/fields/OwnerPicker/OwnerPicker.tsx index 4d9db1f5e5..10425c17ff 100644 --- a/plugins/scaffolder/src/components/fields/OwnerPicker/OwnerPicker.tsx +++ b/plugins/scaffolder/src/components/fields/OwnerPicker/OwnerPicker.tsx @@ -52,7 +52,7 @@ export const OwnerPicker = ( ]) as string[], defaultKind: 'Group', allowArbitraryValues: - uiSchema['ui:options']?.allowArbitraryValues || true, + uiSchema['ui:options']?.allowArbitraryValues ?? true, }, }; From 3c13f3dc79cc66098bbb65b42dd15f4c6f635b26 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Thu, 14 Jul 2022 13:34:01 +0200 Subject: [PATCH 4/4] Add api refs Signed-off-by: kjuulh --- plugins/scaffolder/api-report.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index 3fa623b5b9..8485198724 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -169,6 +169,8 @@ export const OwnerPickerFieldExtension: FieldExtensionComponent< // @public export interface OwnerPickerUiOptions { + // (undocumented) + allowArbitraryValues?: boolean; // (undocumented) allowedKinds?: string[]; }