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

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,27 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
+ ## 0.6.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 3d87019269: The `entityRouteRef` is now a well-known route that should be imported directly from `@backstage/plugin-catalog-react`. It is guaranteed to be globally unique across duplicate installations of the `@backstage/plugin-catalog-react`, starting at this version.
8
+
9
+ Deprecated `entityRoute` in favor of `entityRouteRef`.
10
+
11
+ Deprecated `rootRoute` and `catalogRouteRef`. If you want to refer to the catalog index page from a public plugin you now need to use an `ExternalRouteRef` instead. For private plugins it is possible to take the shortcut of referring directly to `catalogPlugin.routes.indexPage` instead.
12
+
13
+ - 2916a83b9c: Deprecated `loadIdentityOwnerRefs`, since they can now be retrieved as `ownershipEntityRefs` from `identityApi.getBackstageIdentity()` instead.
14
+ - 51fbedc445: Migrated usage of deprecated `IdentityApi` methods.
15
+ - c54c0d9d10: Add useEntityPermission hook
16
+ - Updated dependencies
17
+ - @backstage/plugin-permission-react@0.3.0
18
+ - @backstage/core-components@0.8.5
19
+ - @backstage/integration@0.7.2
20
+ - @backstage/plugin-permission-common@0.4.0
21
+ - @backstage/core-plugin-api@0.6.0
22
+ - @backstage/catalog-model@0.9.10
23
+ - @backstage/catalog-client@0.5.5
24
+
3
25
  ## 0.6.12-next.0
4
26
 
5
27
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -21,6 +21,7 @@ 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 pluginPermissionReact = require('@backstage/plugin-permission-react');
24
25
  var CheckBoxIcon = require('@material-ui/icons/CheckBox');
25
26
  var CheckBoxOutlineBlankIcon = require('@material-ui/icons/CheckBoxOutlineBlank');
26
27
  var ExpandMoreIcon = require('@material-ui/icons/ExpandMore');
@@ -127,11 +128,11 @@ const rootRoute = corePluginApi.createRouteRef({
127
128
  id: "catalog"
128
129
  });
129
130
  const catalogRouteRef = rootRoute;
130
- const entityRoute = corePluginApi.createRouteRef({
131
+ const entityRouteRef = versionBridge.getOrCreateGlobalSingleton("catalog:entity-route-ref", () => corePluginApi.createRouteRef({
131
132
  id: "catalog:entity",
132
133
  params: ["namespace", "kind", "name"]
133
- });
134
- const entityRouteRef = entityRoute;
134
+ }));
135
+ const entityRoute = entityRouteRef;
135
136
  function entityRouteParams(entity) {
136
137
  var _a, _b;
137
138
  return {
@@ -779,6 +780,22 @@ function useOwnedEntities(allowedKinds) {
779
780
  return React.useMemo(() => ({ loading, ownedEntities }), [loading, ownedEntities]);
780
781
  }
781
782
 
783
+ function useEntityPermission(permission) {
784
+ const { entity, loading: loadingEntity, error: entityError } = useEntity();
785
+ const {
786
+ allowed,
787
+ loading: loadingPermission,
788
+ error: permissionError
789
+ } = pluginPermissionReact.usePermission(permission, entity ? catalogModel.stringifyEntityRef(entity) : void 0);
790
+ if (loadingEntity || loadingPermission) {
791
+ return { loading: true, allowed: false };
792
+ }
793
+ if (entityError) {
794
+ return { loading: false, allowed: false, error: entityError };
795
+ }
796
+ return { loading: false, allowed, error: permissionError };
797
+ }
798
+
782
799
  const EntityKindPicker = ({
783
800
  initialFilter,
784
801
  hidden
@@ -1648,6 +1665,7 @@ exports.useEntityFromUrl = useEntityFromUrl;
1648
1665
  exports.useEntityKinds = useEntityKinds;
1649
1666
  exports.useEntityListProvider = useEntityListProvider;
1650
1667
  exports.useEntityOwnership = useEntityOwnership;
1668
+ exports.useEntityPermission = useEntityPermission;
1651
1669
  exports.useEntityTypeFilter = useEntityTypeFilter;
1652
1670
  exports.useOwnUser = useOwnUser;
1653
1671
  exports.useOwnedEntities = useOwnedEntities;