@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-react': patch
|
||||
---
|
||||
|
||||
Small internal fix to better work with recent `lodash` versions
|
||||
@@ -71,6 +71,9 @@ export function defaultEntityPresentation(
|
||||
};
|
||||
}
|
||||
|
||||
const isString = (value: unknown): value is string =>
|
||||
Boolean(value) && typeof value === 'string';
|
||||
|
||||
// Try to extract display-worthy parts of an entity or ref as best we can, without throwing
|
||||
function getParts(entityOrRef: Entity | CompoundEntityRef | string): {
|
||||
kind?: string;
|
||||
@@ -99,35 +102,29 @@ function getParts(entityOrRef: Entity | CompoundEntityRef | string): {
|
||||
}
|
||||
|
||||
if (typeof entityOrRef === 'object' && entityOrRef !== null) {
|
||||
const kind = [get(entityOrRef, 'kind')].find(
|
||||
candidate => candidate && typeof candidate === 'string',
|
||||
);
|
||||
const kind = [get(entityOrRef, 'kind')].find(isString);
|
||||
|
||||
const namespace = [
|
||||
get(entityOrRef, 'metadata.namespace'),
|
||||
get(entityOrRef, 'namespace'),
|
||||
].find(candidate => candidate && typeof candidate === 'string');
|
||||
].find(isString);
|
||||
|
||||
const name = [
|
||||
get(entityOrRef, 'metadata.name'),
|
||||
get(entityOrRef, 'name'),
|
||||
].find(candidate => candidate && typeof candidate === 'string');
|
||||
].find(isString);
|
||||
|
||||
const title = [get(entityOrRef, 'metadata.title')].find(
|
||||
candidate => candidate && typeof candidate === 'string',
|
||||
);
|
||||
const title = [get(entityOrRef, 'metadata.title')].find(isString);
|
||||
|
||||
const description = [get(entityOrRef, 'metadata.description')].find(
|
||||
candidate => candidate && typeof candidate === 'string',
|
||||
isString,
|
||||
);
|
||||
|
||||
const displayName = [get(entityOrRef, 'spec.profile.displayName')].find(
|
||||
candidate => candidate && typeof candidate === 'string',
|
||||
isString,
|
||||
);
|
||||
|
||||
const type = [get(entityOrRef, 'spec.type')].find(
|
||||
candidate => candidate && typeof candidate === 'string',
|
||||
);
|
||||
const type = [get(entityOrRef, 'spec.type')].find(isString);
|
||||
|
||||
return { kind, namespace, name, title, description, displayName, type };
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ type FacetsInitialRequest = {
|
||||
text: string;
|
||||
};
|
||||
|
||||
const maybeString = (value: unknown): string | undefined =>
|
||||
typeof value === 'string' ? value : undefined;
|
||||
|
||||
/**
|
||||
* This hook asynchronously loads the entity owners using the facets endpoint.
|
||||
* EntityOwnerPicker uses this hook when mode="owners-only" is passed as prop.
|
||||
@@ -67,11 +70,11 @@ export function useFacetsEntities({ enabled }: { enabled: boolean }) {
|
||||
'en-US',
|
||||
) ||
|
||||
(
|
||||
get(a, 'spec.profile.displayName') ||
|
||||
maybeString(get(a, 'spec.profile.displayName')) ||
|
||||
a.metadata.title ||
|
||||
a.metadata.name
|
||||
).localeCompare(
|
||||
get(b, 'spec.profile.displayName') ||
|
||||
maybeString(get(b, 'spec.profile.displayName')) ||
|
||||
b.metadata.title ||
|
||||
b.metadata.name,
|
||||
'en-US',
|
||||
|
||||
Reference in New Issue
Block a user