@backstage/plugin-catalog-react 0.6.11 → 0.6.12-next.0

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,18 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 0.6.12-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 2916a83b9c: Deprecated `loadIdentityOwnerRefs`, since they can now be retrieved as `ownershipEntityRefs` from `identityApi.getBackstageIdentity()` instead.
8
+ - 51fbedc445: Migrated usage of deprecated `IdentityApi` methods.
9
+ - Updated dependencies
10
+ - @backstage/core-components@0.8.5-next.0
11
+ - @backstage/core-plugin-api@0.6.0-next.0
12
+ - @backstage/catalog-model@0.9.10-next.0
13
+ - @backstage/catalog-client@0.5.5-next.0
14
+ - @backstage/integration@0.7.2-next.0
15
+
3
16
  ## 0.6.11
4
17
 
5
18
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -21,7 +21,6 @@ var isEqual = require('lodash/isEqual');
21
21
  var coreComponents = require('@backstage/core-components');
22
22
  var core = require('@material-ui/core');
23
23
  var useObservable = require('react-use/lib/useObservable');
24
- var jwtDecoder = require('jwt-decode');
25
24
  var CheckBoxIcon = require('@material-ui/icons/CheckBox');
26
25
  var CheckBoxOutlineBlankIcon = require('@material-ui/icons/CheckBoxOutlineBlank');
27
26
  var ExpandMoreIcon = require('@material-ui/icons/ExpandMore');
@@ -46,7 +45,6 @@ var useMountedState__default = /*#__PURE__*/_interopDefaultLegacy(useMountedStat
46
45
  var useAsync__default = /*#__PURE__*/_interopDefaultLegacy(useAsync);
47
46
  var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
48
47
  var useObservable__default = /*#__PURE__*/_interopDefaultLegacy(useObservable);
49
- var jwtDecoder__default = /*#__PURE__*/_interopDefaultLegacy(jwtDecoder);
50
48
  var CheckBoxIcon__default = /*#__PURE__*/_interopDefaultLegacy(CheckBoxIcon);
51
49
  var CheckBoxOutlineBlankIcon__default = /*#__PURE__*/_interopDefaultLegacy(CheckBoxOutlineBlankIcon);
52
50
  var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon);
@@ -624,11 +622,13 @@ function useEntityKinds() {
624
622
  function useOwnUser() {
625
623
  const catalogApi = corePluginApi.useApi(catalogApiRef);
626
624
  const identityApi = corePluginApi.useApi(corePluginApi.identityApiRef);
627
- return useAsync__default["default"](() => catalogApi.getEntityByName({
628
- kind: "User",
629
- namespace: "default",
630
- name: identityApi.getUserId()
631
- }), [catalogApi, identityApi]);
625
+ return useAsync__default["default"](async () => {
626
+ const identity = await identityApi.getBackstageIdentity();
627
+ return catalogApi.getEntityByName(catalogModel.parseEntityRef(identity.userEntityRef, {
628
+ defaultKind: "User",
629
+ defaultNamespace: catalogModel.ENTITY_DEFAULT_NAMESPACE
630
+ }));
631
+ }, [catalogApi, identityApi]);
632
632
  }
633
633
 
634
634
  const BATCH_SIZE = 20;
@@ -712,34 +712,9 @@ function useStarredEntity(entityOrRef) {
712
712
  };
713
713
  }
714
714
 
715
- function extendUserId(id) {
716
- try {
717
- const ref = catalogModel.parseEntityRef(id, {
718
- defaultKind: "User",
719
- defaultNamespace: "default"
720
- });
721
- return catalogModel.stringifyEntityRef(ref);
722
- } catch {
723
- return id;
724
- }
725
- }
726
715
  async function loadIdentityOwnerRefs(identityApi) {
727
- const id = identityApi.getUserId();
728
- const token = await identityApi.getIdToken();
729
- const result = [];
730
- if (id) {
731
- result.push(extendUserId(id));
732
- }
733
- if (token) {
734
- try {
735
- const decoded = jwtDecoder__default["default"](token);
736
- if (decoded == null ? void 0 : decoded.ent) {
737
- [decoded.ent].flat().filter((x) => typeof x === "string").map((x) => x.toLocaleLowerCase("en-US")).forEach((x) => result.push(x));
738
- }
739
- } catch {
740
- }
741
- }
742
- return result;
716
+ const identity = await identityApi.getBackstageIdentity();
717
+ return identity.ownershipEntityRefs;
743
718
  }
744
719
  async function loadCatalogOwnerRefs(catalogApi, identityOwnerRefs) {
745
720
  const result = new Array();
@@ -761,9 +736,9 @@ function useEntityOwnership() {
761
736
  const identityApi = corePluginApi.useApi(corePluginApi.identityApiRef);
762
737
  const catalogApi = corePluginApi.useApi(catalogApiRef);
763
738
  const { loading, value: refs } = useAsync__default["default"](async () => {
764
- const identityRefs = await loadIdentityOwnerRefs(identityApi);
765
- const catalogRefs = await loadCatalogOwnerRefs(catalogApi, identityRefs);
766
- return /* @__PURE__ */ new Set([...identityRefs, ...catalogRefs]);
739
+ const { ownershipEntityRefs } = await identityApi.getBackstageIdentity();
740
+ const catalogRefs = await loadCatalogOwnerRefs(catalogApi, ownershipEntityRefs);
741
+ return /* @__PURE__ */ new Set([...ownershipEntityRefs, ...catalogRefs]);
767
742
  }, []);
768
743
  const isOwnedEntity = React.useMemo(() => {
769
744
  const myOwnerRefs = new Set(refs != null ? refs : []);