Update of EntityPickers to support flags which control omit of default namespace in result.

Signed-off-by: Tomáš Tunkl <tomas.tunkl@avast.com>
This commit is contained in:
Tomáš Tunkl
2022-09-13 13:46:32 +02:00
parent e29c23a5eb
commit 05f22193c5
5 changed files with 19 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder': minor
---
EntityPickers now support flags to control ommit of default namespace
+6
View File
@@ -66,6 +66,8 @@ export interface EntityPickerUiOptions {
allowedKinds?: string[];
// (undocumented)
defaultKind?: string;
// (undocumented)
defaultNamespace?: string | false;
}
// @public
@@ -163,6 +165,8 @@ export interface OwnedEntityPickerUiOptions {
allowedKinds?: string[];
// (undocumented)
defaultKind?: string;
// (undocumented)
defaultNamespace?: string | false;
}
// @public
@@ -177,6 +181,8 @@ export interface OwnerPickerUiOptions {
allowArbitraryValues?: boolean;
// (undocumented)
allowedKinds?: string[];
// (undocumented)
defaultNamespace?: string | false;
}
// @public
@@ -35,6 +35,7 @@ export interface EntityPickerUiOptions {
allowedKinds?: string[];
defaultKind?: string;
allowArbitraryValues?: boolean;
defaultNamespace?: string | false;
}
/**
@@ -57,6 +58,7 @@ export const EntityPicker = (
} = props;
const allowedKinds = uiSchema['ui:options']?.allowedKinds;
const defaultKind = uiSchema['ui:options']?.defaultKind;
const defaultNamespace = uiSchema['ui:options']?.defaultNamespace;
const catalogApi = useApi(catalogApiRef);
@@ -67,7 +69,7 @@ export const EntityPicker = (
);
const entityRefs = entities?.items.map(e =>
humanizeEntityRef(e, { defaultKind }),
humanizeEntityRef(e, { defaultKind, defaultNamespace }),
);
const onSelect = useCallback(
@@ -38,6 +38,7 @@ export interface OwnedEntityPickerUiOptions {
allowedKinds?: string[];
defaultKind?: string;
allowArbitraryValues?: boolean;
defaultNamespace?: string | false;
}
/**
@@ -61,12 +62,13 @@ export const OwnedEntityPicker = (
const allowedKinds = uiSchema['ui:options']?.allowedKinds;
const defaultKind = uiSchema['ui:options']?.defaultKind;
const defaultNamespace = uiSchema['ui:options']?.defaultNamespace;
const allowArbitraryValues =
uiSchema['ui:options']?.allowArbitraryValues ?? true;
const { ownedEntities, loading } = useOwnedEntities(allowedKinds);
const entityRefs = ownedEntities?.items
.map(e => humanizeEntityRef(e, { defaultKind }))
.map(e => humanizeEntityRef(e, { defaultKind, defaultNamespace }))
.filter(n => n);
const onSelect = (_: any, value: string | null) => {
@@ -26,6 +26,7 @@ import { FieldExtensionComponentProps } from '../../../extensions';
export interface OwnerPickerUiOptions {
allowedKinds?: string[];
allowArbitraryValues?: boolean;
defaultNamespace?: string | false;
}
/**
@@ -53,6 +54,7 @@ export const OwnerPicker = (
defaultKind: 'Group',
allowArbitraryValues:
uiSchema['ui:options']?.allowArbitraryValues ?? true,
defaultNamespace: uiSchema['ui:options']?.defaultNamespace ?? '',
},
};