@backstage/plugin-catalog-react 0.6.14 → 0.6.15

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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 0.6.15
4
+
5
+ ### Patch Changes
6
+
7
+ - 1ed305728b: Bump `node-fetch` to version 2.6.7 and `cross-fetch` to version 3.1.5
8
+ - c77c5c7eb6: Added `backstage.role` to `package.json`
9
+ - 538ca90790: Use updated type names from `@backstage/catalog-client`
10
+ - edbc03814a: Replace usage of `serializeEntityRef` with `stringifyEntityRef`
11
+ - 244d24ebc4: Import `Location` from the `@backstage/catalog-client` package.
12
+ - deaf6065db: Adapt to the new `CatalogApi.getLocationByRef`
13
+ - 216725b434: Updated to use new names for `parseLocationRef` and `stringifyLocationRef`
14
+ - e72d371296: Use `TemplateEntityV1beta2` from `@backstage/plugin-scaffolder-common` instead
15
+ of `@backstage/catalog-model`.
16
+ - 98d1aa1ea1: Fix CatalogPage showing all components when owned filter was pre-selected
17
+ - 27eccab216: Replaces use of deprecated catalog-model constants.
18
+ - 7aeb491394: Replace use of deprecated `ENTITY_DEFAULT_NAMESPACE` constant with `DEFAULT_NAMESPACE`.
19
+ - Updated dependencies
20
+ - @backstage/catalog-client@0.7.0
21
+ - @backstage/core-components@0.8.9
22
+ - @backstage/core-plugin-api@0.6.1
23
+ - @backstage/errors@0.2.1
24
+ - @backstage/integration@0.7.3
25
+ - @backstage/plugin-permission-common@0.5.0
26
+ - @backstage/plugin-permission-react@0.3.1
27
+ - @backstage/catalog-model@0.10.0
28
+ - @backstage/types@0.1.2
29
+ - @backstage/version-bridge@0.1.2
30
+
3
31
  ## 0.6.14
4
32
 
5
33
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { CatalogApi, CatalogListResponse } from '@backstage/catalog-client';
2
+ import { CatalogApi, GetEntitiesResponse } from '@backstage/catalog-client';
3
3
  export { CATALOG_FILTER_EXISTS, CatalogApi } from '@backstage/catalog-client';
4
4
  import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
5
5
  import { ApiRef, StorageApi, IdentityApi } from '@backstage/core-plugin-api';
@@ -516,11 +516,10 @@ declare function useEntityOwnership(): {
516
516
  * @public
517
517
  *
518
518
  * @param allowedKinds - Array of allowed kinds to filter the entities
519
- * @returns CatalogListResponse<Entity>
520
519
  */
521
520
  declare function useOwnedEntities(allowedKinds?: string[]): {
522
521
  loading: boolean;
523
- ownedEntities: CatalogListResponse<Entity> | undefined;
522
+ ownedEntities: GetEntitiesResponse | undefined;
524
523
  };
525
524
 
526
525
  /**
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { CATALOG_FILTER_EXISTS } from '@backstage/catalog-client';
2
2
  import { createApiRef, createRouteRef, useRouteRefParams, useApi, errorApiRef, useRouteRef, identityApiRef, alertApiRef, useApp, configApiRef } from '@backstage/core-plugin-api';
3
3
  import ObservableImpl from 'zen-observable';
4
- import { stringifyEntityRef, ENTITY_DEFAULT_NAMESPACE, VIEW_URL_ANNOTATION, EDIT_URL_ANNOTATION, SOURCE_LOCATION_ANNOTATION, parseLocationReference, RELATION_MEMBER_OF, getEntityName, RELATION_OWNED_BY, serializeEntityRef, parseEntityRef, RELATION_PART_OF, LOCATION_ANNOTATION, ORIGIN_LOCATION_ANNOTATION } from '@backstage/catalog-model';
4
+ import { stringifyEntityRef, DEFAULT_NAMESPACE, ANNOTATION_VIEW_URL, ANNOTATION_EDIT_URL, ANNOTATION_SOURCE_LOCATION, parseLocationRef, RELATION_MEMBER_OF, getEntityName, RELATION_OWNED_BY, parseEntityRef, RELATION_PART_OF, ANNOTATION_LOCATION, ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
5
5
  import { isArray, isString, compact, isEqual, groupBy, chunk } from 'lodash';
6
6
  import React, { createContext, useEffect, useState, useMemo, useCallback, useContext, forwardRef, useRef, useLayoutEffect, Fragment } from 'react';
7
7
  import { Alert, Autocomplete } from '@material-ui/lab';
@@ -117,7 +117,7 @@ function entityRouteParams(entity) {
117
117
  var _a, _b;
118
118
  return {
119
119
  kind: entity.kind.toLocaleLowerCase("en-US"),
120
- namespace: (_b = (_a = entity.metadata.namespace) == null ? void 0 : _a.toLocaleLowerCase("en-US")) != null ? _b : ENTITY_DEFAULT_NAMESPACE,
120
+ namespace: (_b = (_a = entity.metadata.namespace) == null ? void 0 : _a.toLocaleLowerCase("en-US")) != null ? _b : DEFAULT_NAMESPACE,
121
121
  name: entity.metadata.name
122
122
  };
123
123
  }
@@ -219,11 +219,11 @@ function reduceEntityFilters(filters) {
219
219
 
220
220
  function getEntityMetadataViewUrl(entity) {
221
221
  var _a;
222
- return (_a = entity.metadata.annotations) == null ? void 0 : _a[VIEW_URL_ANNOTATION];
222
+ return (_a = entity.metadata.annotations) == null ? void 0 : _a[ANNOTATION_VIEW_URL];
223
223
  }
224
224
  function getEntityMetadataEditUrl(entity) {
225
225
  var _a;
226
- return (_a = entity.metadata.annotations) == null ? void 0 : _a[EDIT_URL_ANNOTATION];
226
+ return (_a = entity.metadata.annotations) == null ? void 0 : _a[ANNOTATION_EDIT_URL];
227
227
  }
228
228
 
229
229
  function getEntityRelations(entity, relationType, filter) {
@@ -237,12 +237,12 @@ function getEntityRelations(entity, relationType, filter) {
237
237
 
238
238
  function getEntitySourceLocation(entity, scmIntegrationsApi) {
239
239
  var _a;
240
- const sourceLocation = (_a = entity.metadata.annotations) == null ? void 0 : _a[SOURCE_LOCATION_ANNOTATION];
240
+ const sourceLocation = (_a = entity.metadata.annotations) == null ? void 0 : _a[ANNOTATION_SOURCE_LOCATION];
241
241
  if (!sourceLocation) {
242
242
  return void 0;
243
243
  }
244
244
  try {
245
- const sourceLocationRef = parseLocationReference(sourceLocation);
245
+ const sourceLocationRef = parseLocationRef(sourceLocation);
246
246
  const integration = scmIntegrationsApi.byUrl(sourceLocationRef.target);
247
247
  return {
248
248
  locationTargetUrl: sourceLocationRef.target,
@@ -367,15 +367,12 @@ function formatEntityRefTitle(entityRef, opts) {
367
367
  namespace = entityRef.namespace;
368
368
  name = entityRef.name;
369
369
  }
370
- if (namespace === ENTITY_DEFAULT_NAMESPACE) {
370
+ if (namespace === DEFAULT_NAMESPACE) {
371
371
  namespace = void 0;
372
372
  }
373
373
  kind = kind.toLocaleLowerCase("en-US");
374
- return `${serializeEntityRef({
375
- kind: defaultKind && defaultKind.toLocaleLowerCase("en-US") === kind ? void 0 : kind,
376
- name,
377
- namespace
378
- })}`;
374
+ kind = defaultKind && defaultKind.toLocaleLowerCase("en-US") === kind ? void 0 : kind;
375
+ return `${kind ? `${kind}:` : ""}${namespace ? `${namespace}/` : ""}${name}`;
379
376
  }
380
377
 
381
378
  const EntityRefLink = forwardRef((props, ref) => {
@@ -397,7 +394,7 @@ const EntityRefLink = forwardRef((props, ref) => {
397
394
  kind = kind.toLocaleLowerCase("en-US");
398
395
  const routeParams = {
399
396
  kind,
400
- namespace: (_a = namespace == null ? void 0 : namespace.toLocaleLowerCase("en-US")) != null ? _a : ENTITY_DEFAULT_NAMESPACE,
397
+ namespace: (_a = namespace == null ? void 0 : namespace.toLocaleLowerCase("en-US")) != null ? _a : DEFAULT_NAMESPACE,
401
398
  name
402
399
  };
403
400
  const formattedEntityRefTitle = formatEntityRefTitle(entityRef, {
@@ -612,7 +609,7 @@ function useOwnUser() {
612
609
  const identity = await identityApi.getBackstageIdentity();
613
610
  return catalogApi.getEntityByName(parseEntityRef(identity.userEntityRef, {
614
611
  defaultKind: "User",
615
- defaultNamespace: ENTITY_DEFAULT_NAMESPACE
612
+ defaultNamespace: DEFAULT_NAMESPACE
616
613
  }));
617
614
  }, [catalogApi, identityApi]);
618
615
  }
@@ -1357,7 +1354,7 @@ function CustomNode({ node }) {
1357
1354
  const onClick = () => {
1358
1355
  navigate(entityRoute({
1359
1356
  kind: node.kind,
1360
- namespace: node.metadata.namespace || ENTITY_DEFAULT_NAMESPACE,
1357
+ namespace: node.metadata.namespace || DEFAULT_NAMESPACE,
1361
1358
  name: node.metadata.name
1362
1359
  }));
1363
1360
  };
@@ -1482,16 +1479,16 @@ function useColocated(entity) {
1482
1479
  var _a, _b;
1483
1480
  const catalogApi = useApi(catalogApiRef);
1484
1481
  const currentEntityRef = stringifyEntityRef(entity);
1485
- const location = (_a = entity.metadata.annotations) == null ? void 0 : _a[LOCATION_ANNOTATION];
1486
- const origin = (_b = entity.metadata.annotations) == null ? void 0 : _b[ORIGIN_LOCATION_ANNOTATION];
1482
+ const location = (_a = entity.metadata.annotations) == null ? void 0 : _a[ANNOTATION_LOCATION];
1483
+ const origin = (_b = entity.metadata.annotations) == null ? void 0 : _b[ANNOTATION_ORIGIN_LOCATION];
1487
1484
  const { loading, error, value } = useAsync(async () => {
1488
1485
  if (!location && !origin) {
1489
1486
  return [];
1490
1487
  }
1491
1488
  const response = await catalogApi.getEntities({
1492
1489
  filter: [
1493
- ...location ? [{ [`metadata.annotations.${LOCATION_ANNOTATION}`]: location }] : [],
1494
- ...origin ? [{ [`metadata.annotations.${ORIGIN_LOCATION_ANNOTATION}`]: origin }] : []
1490
+ ...location ? [{ [`metadata.annotations.${ANNOTATION_LOCATION}`]: location }] : [],
1491
+ ...origin ? [{ [`metadata.annotations.${ANNOTATION_ORIGIN_LOCATION}`]: origin }] : []
1495
1492
  ]
1496
1493
  });
1497
1494
  return response.items;
@@ -1546,11 +1543,11 @@ function Contents$1(props) {
1546
1543
  }
1547
1544
  const atLocation = colocatedEntities.filter((e) => {
1548
1545
  var _a;
1549
- return ((_a = e.metadata.annotations) == null ? void 0 : _a[LOCATION_ANNOTATION]) === location;
1546
+ return ((_a = e.metadata.annotations) == null ? void 0 : _a[ANNOTATION_LOCATION]) === location;
1550
1547
  });
1551
1548
  const atOrigin = colocatedEntities.filter((e) => {
1552
1549
  var _a;
1553
- return ((_a = e.metadata.annotations) == null ? void 0 : _a[ORIGIN_LOCATION_ANNOTATION]) === originLocation;
1550
+ return ((_a = e.metadata.annotations) == null ? void 0 : _a[ANNOTATION_ORIGIN_LOCATION]) === originLocation;
1554
1551
  });
1555
1552
  return /* @__PURE__ */ React.createElement(React.Fragment, null, atLocation.length > 0 && /* @__PURE__ */ React.createElement(EntityList, {
1556
1553
  entities: atLocation,
@@ -1813,16 +1810,16 @@ function InspectEntityDialog(props) {
1813
1810
  function useUnregisterEntityDialogState(entity) {
1814
1811
  var _a;
1815
1812
  const catalogApi = useApi(catalogApiRef);
1816
- const locationRef = (_a = entity.metadata.annotations) == null ? void 0 : _a[ORIGIN_LOCATION_ANNOTATION];
1813
+ const locationRef = (_a = entity.metadata.annotations) == null ? void 0 : _a[ANNOTATION_ORIGIN_LOCATION];
1817
1814
  const uid = entity.metadata.uid;
1818
1815
  const isBootstrap = locationRef === "bootstrap:bootstrap";
1819
1816
  const prerequisites = useAsync(async () => {
1820
- const locationPromise = catalogApi.getOriginLocationByEntity(entity);
1817
+ const locationPromise = catalogApi.getLocationByRef(locationRef);
1821
1818
  let colocatedEntitiesPromise;
1822
1819
  if (!locationRef) {
1823
1820
  colocatedEntitiesPromise = Promise.resolve([]);
1824
1821
  } else {
1825
- const locationAnnotationFilter = `metadata.annotations.${ORIGIN_LOCATION_ANNOTATION}`;
1822
+ const locationAnnotationFilter = `metadata.annotations.${ANNOTATION_ORIGIN_LOCATION}`;
1826
1823
  colocatedEntitiesPromise = catalogApi.getEntities({
1827
1824
  filter: { [locationAnnotationFilter]: locationRef },
1828
1825
  fields: [
@@ -2065,14 +2062,21 @@ const UserListPicker = ({
2065
2062
  const classes = useStyles();
2066
2063
  const configApi = useApi(configApiRef);
2067
2064
  const orgName = (_a = configApi.getOptionalString("organization.name")) != null ? _a : "Company";
2068
- const { filters, updateFilters, backendEntities, queryParameters, loading } = useEntityListProvider();
2065
+ const {
2066
+ filters,
2067
+ updateFilters,
2068
+ backendEntities,
2069
+ queryParameters,
2070
+ loading: loadingBackendEntities
2071
+ } = useEntityListProvider();
2069
2072
  const userAndGroupFilterIds = ["starred", "all"];
2070
2073
  const filterGroups = getFilterGroups(orgName).map((filterGroup) => ({
2071
2074
  ...filterGroup,
2072
2075
  items: filterGroup.items.filter(({ id }) => ["group", "user"].some((kind) => kind === queryParameters.kind) ? userAndGroupFilterIds.includes(id) : !availableFilters || availableFilters.includes(id))
2073
2076
  })).filter(({ items }) => !!items.length);
2074
2077
  const { isStarredEntity } = useStarredEntities();
2075
- const { isOwnedEntity } = useEntityOwnership();
2078
+ const { isOwnedEntity, loading: loadingEntityOwnership } = useEntityOwnership();
2079
+ const loading = loadingBackendEntities || loadingEntityOwnership;
2076
2080
  const ownedFilter = useMemo(() => new UserListFilter("owned", isOwnedEntity, isStarredEntity), [isOwnedEntity, isStarredEntity]);
2077
2081
  const starredFilter = useMemo(() => new UserListFilter("starred", isOwnedEntity, isStarredEntity), [isOwnedEntity, isStarredEntity]);
2078
2082
  const queryParamUserFilter = useMemo(() => [queryParameters.user].flat()[0], [queryParameters]);