Merge pull request #12284 from joanayma/OwnedEntityPicker-allowArbitraryValues

Add allowArbitraryValues in OwnedEntityPicker
This commit is contained in:
Ben Lambert
2022-06-28 15:37:18 +02:00
committed by GitHub
3 changed files with 11 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': patch
---
Add `allowArbitraryValues` to `ui:options` in `OwnedEntityPicker`, similar to `allowArbitraryValues` in `EntityPicker`
+2
View File
@@ -153,6 +153,8 @@ export const OwnedEntityPickerFieldExtension: FieldExtensionComponent<
// @public
export interface OwnedEntityPickerUiOptions {
// (undocumented)
allowArbitraryValues?: boolean;
// (undocumented)
allowedKinds?: string[];
// (undocumented)
@@ -37,6 +37,7 @@ import { FieldExtensionComponentProps } from '../../../extensions';
export interface OwnedEntityPickerUiOptions {
allowedKinds?: string[];
defaultKind?: string;
allowArbitraryValues?: boolean;
}
/**
@@ -60,6 +61,8 @@ export const OwnedEntityPicker = (
const allowedKinds = uiSchema['ui:options']?.allowedKinds;
const defaultKind = uiSchema['ui:options']?.defaultKind;
const allowArbitraryValues =
uiSchema['ui:options']?.allowArbitraryValues ?? true;
const { ownedEntities, loading } = useOwnedEntities(allowedKinds);
const entityRefs = ownedEntities?.items
@@ -83,7 +86,7 @@ export const OwnedEntityPicker = (
onChange={onSelect}
options={entityRefs || []}
autoSelect
freeSolo
freeSolo={allowArbitraryValues}
renderInput={params => (
<TextField
{...params}