Merge pull request #13667 from tunkl/feature/namespace_entity_picker
Update of EntityPickers to support flags which control omit of defaul…
This commit is contained in:
@@ -72,6 +72,8 @@ export interface EntityPickerUiOptions {
|
||||
allowedKinds?: string[];
|
||||
// (undocumented)
|
||||
defaultKind?: string;
|
||||
// (undocumented)
|
||||
defaultNamespace?: string | false;
|
||||
}
|
||||
|
||||
// @public
|
||||
@@ -183,6 +185,8 @@ export interface OwnedEntityPickerUiOptions {
|
||||
allowedKinds?: string[];
|
||||
// (undocumented)
|
||||
defaultKind?: string;
|
||||
// (undocumented)
|
||||
defaultNamespace?: string | false;
|
||||
}
|
||||
|
||||
// @public
|
||||
@@ -197,6 +201,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,8 @@ export const OwnerPicker = (
|
||||
...restProps
|
||||
} = props;
|
||||
|
||||
const defaultNamespace = uiSchema['ui:options']?.defaultNamespace;
|
||||
|
||||
const ownerUiSchema = {
|
||||
...uiSchema,
|
||||
'ui:options': {
|
||||
@@ -53,6 +56,7 @@ export const OwnerPicker = (
|
||||
defaultKind: 'Group',
|
||||
allowArbitraryValues:
|
||||
uiSchema['ui:options']?.allowArbitraryValues ?? true,
|
||||
...(defaultNamespace !== undefined ? { defaultNamespace } : {}),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user