@backstage/plugin-catalog-react 0.6.7 → 0.6.8

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,15 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 0.6.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 3491a36ab9: added useOwnedEntities hook to get the list of entities of the logged-in user
8
+ - Updated dependencies
9
+ - @backstage/core-plugin-api@0.4.0
10
+ - @backstage/core-components@0.8.2
11
+ - @backstage/catalog-client@0.5.3
12
+
3
13
  ## 0.6.7
4
14
 
5
15
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -769,6 +769,30 @@ function useEntityOwnership() {
769
769
  return React.useMemo(() => ({ loading, isOwnedEntity }), [loading, isOwnedEntity]);
770
770
  }
771
771
 
772
+ function useOwnedEntities(allowedKinds) {
773
+ const identityApi = corePluginApi.useApi(corePluginApi.identityApiRef);
774
+ const catalogApi = corePluginApi.useApi(catalogApiRef);
775
+ const { loading, value: refs } = reactUse.useAsync(async () => {
776
+ const identityRefs = await loadIdentityOwnerRefs(identityApi);
777
+ const catalogRefs = await loadCatalogOwnerRefs(catalogApi, identityRefs);
778
+ const catalogs = await catalogApi.getEntities(allowedKinds ? {
779
+ filter: {
780
+ kind: allowedKinds,
781
+ [`relations.${catalogModel.RELATION_OWNED_BY}`]: [...identityRefs, ...catalogRefs]
782
+ }
783
+ } : {
784
+ filter: {
785
+ [`relations.${catalogModel.RELATION_OWNED_BY}`]: [...identityRefs, ...catalogRefs]
786
+ }
787
+ });
788
+ return catalogs;
789
+ }, []);
790
+ const ownedEntities = React.useMemo(() => {
791
+ return refs;
792
+ }, [refs]);
793
+ return React.useMemo(() => ({ loading, ownedEntities }), [loading, ownedEntities]);
794
+ }
795
+
772
796
  const EntityKindPicker = ({
773
797
  initialFilter,
774
798
  hidden
@@ -1638,6 +1662,7 @@ exports.useEntityListProvider = useEntityListProvider;
1638
1662
  exports.useEntityOwnership = useEntityOwnership;
1639
1663
  exports.useEntityTypeFilter = useEntityTypeFilter;
1640
1664
  exports.useOwnUser = useOwnUser;
1665
+ exports.useOwnedEntities = useOwnedEntities;
1641
1666
  exports.useRelatedEntities = useRelatedEntities;
1642
1667
  exports.useStarredEntities = useStarredEntities;
1643
1668
  exports.useStarredEntity = useStarredEntity;