@backstage/plugin-catalog-react 1.7.0-next.1 → 1.7.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/alpha/package.json +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.esm.js +10 -38
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
+
## 1.7.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d68692aee97e: Make `useRelatedEntities` use `getEntitiesByRefs` under the hood
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/theme@0.4.0-next.1
|
|
10
|
+
- @backstage/core-components@0.13.2-next.2
|
|
11
|
+
- @backstage/core-plugin-api@1.5.2-next.0
|
|
12
|
+
- @backstage/plugin-permission-react@0.4.13-next.0
|
|
13
|
+
|
|
3
14
|
## 1.7.0-next.1
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -569,7 +569,12 @@ declare function useEntityTypeFilter(): {
|
|
|
569
569
|
setSelectedTypes: (types: string[]) => void;
|
|
570
570
|
};
|
|
571
571
|
|
|
572
|
-
/**
|
|
572
|
+
/**
|
|
573
|
+
* Fetches all entities that appear in the entity's relations, optionally
|
|
574
|
+
* filtered by relation type and kind.
|
|
575
|
+
*
|
|
576
|
+
* @public
|
|
577
|
+
*/
|
|
573
578
|
declare function useRelatedEntities(entity: Entity, relationFilter: {
|
|
574
579
|
type?: string;
|
|
575
580
|
kind?: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Select, Link, Progress, ErrorPanel, ResponseErrorPanel, OverflowTooltip
|
|
|
8
8
|
import { ANNOTATION_SOURCE_LOCATION, parseLocationRef, stringifyEntityRef, parseEntityRef, RELATION_OWNED_BY, DEFAULT_NAMESPACE, getCompoundEntityRef, isUserEntity, isGroupEntity, RELATION_PART_OF, ANNOTATION_LOCATION, ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
|
|
9
9
|
import { g as getEntityRelations } from './esm/useEntity-de64059a.esm.js';
|
|
10
10
|
export { A as AsyncEntityProvider, E as EntityProvider, g as getEntityRelations, a as useAsyncEntity, u as useEntity } from './esm/useEntity-de64059a.esm.js';
|
|
11
|
-
import { compact, isEqual,
|
|
11
|
+
import { compact, isEqual, debounce } from 'lodash';
|
|
12
12
|
import qs from 'qs';
|
|
13
13
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
14
14
|
import useAsyncFn from 'react-use/lib/useAsyncFn';
|
|
@@ -38,7 +38,7 @@ import Star from '@material-ui/icons/Star';
|
|
|
38
38
|
import StarBorder from '@material-ui/icons/StarBorder';
|
|
39
39
|
import WorkIcon from '@material-ui/icons/Work';
|
|
40
40
|
import HelpOutlineIcon from '@material-ui/icons/HelpOutline';
|
|
41
|
-
import groupBy
|
|
41
|
+
import groupBy from 'lodash/groupBy';
|
|
42
42
|
import DialogContentText$1 from '@material-ui/core/DialogContentText';
|
|
43
43
|
import YAML from 'yaml';
|
|
44
44
|
import Alert$1 from '@material-ui/lab/Alert';
|
|
@@ -489,7 +489,6 @@ function useEntityTypeFilter() {
|
|
|
489
489
|
};
|
|
490
490
|
}
|
|
491
491
|
|
|
492
|
-
const BATCH_SIZE = 20;
|
|
493
492
|
function useRelatedEntities(entity, relationFilter) {
|
|
494
493
|
var _a, _b;
|
|
495
494
|
const filterByTypeLower = (_a = relationFilter == null ? void 0 : relationFilter.type) == null ? void 0 : _a.toLocaleLowerCase("en-US");
|
|
@@ -501,43 +500,16 @@ function useRelatedEntities(entity, relationFilter) {
|
|
|
501
500
|
error
|
|
502
501
|
} = useAsync(async () => {
|
|
503
502
|
var _a2;
|
|
504
|
-
const relations = (_a2 = entity.relations) == null ? void 0 : _a2.
|
|
505
|
-
(r) => (!filterByTypeLower || r.type.toLocaleLowerCase("en-US") === filterByTypeLower) && (!filterByKindLower || r.
|
|
503
|
+
const relations = (_a2 = entity.relations) == null ? void 0 : _a2.filter(
|
|
504
|
+
(r) => (!filterByTypeLower || r.type.toLocaleLowerCase("en-US") === filterByTypeLower) && (!filterByKindLower || parseEntityRef(r.targetRef).kind === filterByKindLower)
|
|
506
505
|
);
|
|
507
|
-
if (!relations) {
|
|
506
|
+
if (!(relations == null ? void 0 : relations.length)) {
|
|
508
507
|
return [];
|
|
509
508
|
}
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
);
|
|
515
|
-
const batchedRelationsByKindAndNamespace = [];
|
|
516
|
-
for (const rs of relationsByKindAndNamespace) {
|
|
517
|
-
batchedRelationsByKindAndNamespace.push({
|
|
518
|
-
// All relations in a group have the same kind and namespace, so its arbitrary which we pick
|
|
519
|
-
kind: rs[0].target.kind,
|
|
520
|
-
namespace: rs[0].target.namespace,
|
|
521
|
-
nameBatches: chunk(
|
|
522
|
-
rs.map((r) => r.target.name),
|
|
523
|
-
BATCH_SIZE
|
|
524
|
-
)
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
const results = await Promise.all(
|
|
528
|
-
batchedRelationsByKindAndNamespace.flatMap((rs) => {
|
|
529
|
-
return rs.nameBatches.map((names) => {
|
|
530
|
-
return catalogApi.getEntities({
|
|
531
|
-
filter: {
|
|
532
|
-
kind: rs.kind,
|
|
533
|
-
"metadata.namespace": rs.namespace,
|
|
534
|
-
"metadata.name": names
|
|
535
|
-
}
|
|
536
|
-
});
|
|
537
|
-
});
|
|
538
|
-
})
|
|
539
|
-
);
|
|
540
|
-
return results.flatMap((r) => r.items);
|
|
509
|
+
const { items } = await catalogApi.getEntitiesByRefs({
|
|
510
|
+
entityRefs: relations.map((r) => r.targetRef)
|
|
511
|
+
});
|
|
512
|
+
return items.filter((x) => Boolean(x));
|
|
541
513
|
}, [entity, filterByTypeLower, filterByKindLower]);
|
|
542
514
|
return {
|
|
543
515
|
entities,
|
|
@@ -1996,7 +1968,7 @@ function OverviewPage(props) {
|
|
|
1996
1968
|
relations = [],
|
|
1997
1969
|
status = {}
|
|
1998
1970
|
} = props.entity;
|
|
1999
|
-
const groupedRelations = groupBy
|
|
1971
|
+
const groupedRelations = groupBy(
|
|
2000
1972
|
sortBy(relations, (r) => r.targetRef),
|
|
2001
1973
|
"type"
|
|
2002
1974
|
);
|