@backstage/plugin-catalog-react 0.6.10 → 0.6.13-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 +55 -0
- package/dist/index.cjs.js +33 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +45 -11
- package/dist/index.esm.js +34 -41
- package/dist/index.esm.js.map +1 -1
- package/package.json +14 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
+
## 0.6.13-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/core-components@0.8.7-next.0
|
|
9
|
+
|
|
10
|
+
## 0.6.12
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 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.
|
|
15
|
+
|
|
16
|
+
Deprecated `entityRoute` in favor of `entityRouteRef`.
|
|
17
|
+
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
- 2916a83b9c: Deprecated `loadIdentityOwnerRefs`, since they can now be retrieved as `ownershipEntityRefs` from `identityApi.getBackstageIdentity()` instead.
|
|
21
|
+
- 51fbedc445: Migrated usage of deprecated `IdentityApi` methods.
|
|
22
|
+
- c54c0d9d10: Add useEntityPermission hook
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @backstage/plugin-permission-react@0.3.0
|
|
25
|
+
- @backstage/core-components@0.8.5
|
|
26
|
+
- @backstage/integration@0.7.2
|
|
27
|
+
- @backstage/plugin-permission-common@0.4.0
|
|
28
|
+
- @backstage/core-plugin-api@0.6.0
|
|
29
|
+
- @backstage/catalog-model@0.9.10
|
|
30
|
+
- @backstage/catalog-client@0.5.5
|
|
31
|
+
|
|
32
|
+
## 0.6.12-next.0
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- 2916a83b9c: Deprecated `loadIdentityOwnerRefs`, since they can now be retrieved as `ownershipEntityRefs` from `identityApi.getBackstageIdentity()` instead.
|
|
37
|
+
- 51fbedc445: Migrated usage of deprecated `IdentityApi` methods.
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @backstage/core-components@0.8.5-next.0
|
|
40
|
+
- @backstage/core-plugin-api@0.6.0-next.0
|
|
41
|
+
- @backstage/catalog-model@0.9.10-next.0
|
|
42
|
+
- @backstage/catalog-client@0.5.5-next.0
|
|
43
|
+
- @backstage/integration@0.7.2-next.0
|
|
44
|
+
|
|
45
|
+
## 0.6.11
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- 5333451def: Cleaned up API exports
|
|
50
|
+
- Updated dependencies
|
|
51
|
+
- @backstage/integration@0.7.1
|
|
52
|
+
- @backstage/core-components@0.8.4
|
|
53
|
+
- @backstage/core-plugin-api@0.5.0
|
|
54
|
+
- @backstage/errors@0.2.0
|
|
55
|
+
- @backstage/catalog-client@0.5.4
|
|
56
|
+
- @backstage/catalog-model@0.9.9
|
|
57
|
+
|
|
3
58
|
## 0.6.10
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -21,7 +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
|
|
24
|
+
var pluginPermissionReact = require('@backstage/plugin-permission-react');
|
|
25
25
|
var CheckBoxIcon = require('@material-ui/icons/CheckBox');
|
|
26
26
|
var CheckBoxOutlineBlankIcon = require('@material-ui/icons/CheckBoxOutlineBlank');
|
|
27
27
|
var ExpandMoreIcon = require('@material-ui/icons/ExpandMore');
|
|
@@ -46,7 +46,6 @@ var useMountedState__default = /*#__PURE__*/_interopDefaultLegacy(useMountedStat
|
|
|
46
46
|
var useAsync__default = /*#__PURE__*/_interopDefaultLegacy(useAsync);
|
|
47
47
|
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
48
48
|
var useObservable__default = /*#__PURE__*/_interopDefaultLegacy(useObservable);
|
|
49
|
-
var jwtDecoder__default = /*#__PURE__*/_interopDefaultLegacy(jwtDecoder);
|
|
50
49
|
var CheckBoxIcon__default = /*#__PURE__*/_interopDefaultLegacy(CheckBoxIcon);
|
|
51
50
|
var CheckBoxOutlineBlankIcon__default = /*#__PURE__*/_interopDefaultLegacy(CheckBoxOutlineBlankIcon);
|
|
52
51
|
var ExpandMoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExpandMoreIcon);
|
|
@@ -129,11 +128,11 @@ const rootRoute = corePluginApi.createRouteRef({
|
|
|
129
128
|
id: "catalog"
|
|
130
129
|
});
|
|
131
130
|
const catalogRouteRef = rootRoute;
|
|
132
|
-
const
|
|
131
|
+
const entityRouteRef = versionBridge.getOrCreateGlobalSingleton("catalog:entity-route-ref", () => corePluginApi.createRouteRef({
|
|
133
132
|
id: "catalog:entity",
|
|
134
133
|
params: ["namespace", "kind", "name"]
|
|
135
|
-
});
|
|
136
|
-
const
|
|
134
|
+
}));
|
|
135
|
+
const entityRoute = entityRouteRef;
|
|
137
136
|
function entityRouteParams(entity) {
|
|
138
137
|
var _a, _b;
|
|
139
138
|
return {
|
|
@@ -624,11 +623,13 @@ function useEntityKinds() {
|
|
|
624
623
|
function useOwnUser() {
|
|
625
624
|
const catalogApi = corePluginApi.useApi(catalogApiRef);
|
|
626
625
|
const identityApi = corePluginApi.useApi(corePluginApi.identityApiRef);
|
|
627
|
-
return useAsync__default["default"](() =>
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
626
|
+
return useAsync__default["default"](async () => {
|
|
627
|
+
const identity = await identityApi.getBackstageIdentity();
|
|
628
|
+
return catalogApi.getEntityByName(catalogModel.parseEntityRef(identity.userEntityRef, {
|
|
629
|
+
defaultKind: "User",
|
|
630
|
+
defaultNamespace: catalogModel.ENTITY_DEFAULT_NAMESPACE
|
|
631
|
+
}));
|
|
632
|
+
}, [catalogApi, identityApi]);
|
|
632
633
|
}
|
|
633
634
|
|
|
634
635
|
const BATCH_SIZE = 20;
|
|
@@ -712,34 +713,9 @@ function useStarredEntity(entityOrRef) {
|
|
|
712
713
|
};
|
|
713
714
|
}
|
|
714
715
|
|
|
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
716
|
async function loadIdentityOwnerRefs(identityApi) {
|
|
727
|
-
const
|
|
728
|
-
|
|
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;
|
|
717
|
+
const identity = await identityApi.getBackstageIdentity();
|
|
718
|
+
return identity.ownershipEntityRefs;
|
|
743
719
|
}
|
|
744
720
|
async function loadCatalogOwnerRefs(catalogApi, identityOwnerRefs) {
|
|
745
721
|
const result = new Array();
|
|
@@ -761,9 +737,9 @@ function useEntityOwnership() {
|
|
|
761
737
|
const identityApi = corePluginApi.useApi(corePluginApi.identityApiRef);
|
|
762
738
|
const catalogApi = corePluginApi.useApi(catalogApiRef);
|
|
763
739
|
const { loading, value: refs } = useAsync__default["default"](async () => {
|
|
764
|
-
const
|
|
765
|
-
const catalogRefs = await loadCatalogOwnerRefs(catalogApi,
|
|
766
|
-
return /* @__PURE__ */ new Set([...
|
|
740
|
+
const { ownershipEntityRefs } = await identityApi.getBackstageIdentity();
|
|
741
|
+
const catalogRefs = await loadCatalogOwnerRefs(catalogApi, ownershipEntityRefs);
|
|
742
|
+
return /* @__PURE__ */ new Set([...ownershipEntityRefs, ...catalogRefs]);
|
|
767
743
|
}, []);
|
|
768
744
|
const isOwnedEntity = React.useMemo(() => {
|
|
769
745
|
const myOwnerRefs = new Set(refs != null ? refs : []);
|
|
@@ -804,6 +780,22 @@ function useOwnedEntities(allowedKinds) {
|
|
|
804
780
|
return React.useMemo(() => ({ loading, ownedEntities }), [loading, ownedEntities]);
|
|
805
781
|
}
|
|
806
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
|
+
|
|
807
799
|
const EntityKindPicker = ({
|
|
808
800
|
initialFilter,
|
|
809
801
|
hidden
|
|
@@ -1673,6 +1665,7 @@ exports.useEntityFromUrl = useEntityFromUrl;
|
|
|
1673
1665
|
exports.useEntityKinds = useEntityKinds;
|
|
1674
1666
|
exports.useEntityListProvider = useEntityListProvider;
|
|
1675
1667
|
exports.useEntityOwnership = useEntityOwnership;
|
|
1668
|
+
exports.useEntityPermission = useEntityPermission;
|
|
1676
1669
|
exports.useEntityTypeFilter = useEntityTypeFilter;
|
|
1677
1670
|
exports.useOwnUser = useOwnUser;
|
|
1678
1671
|
exports.useOwnedEntities = useOwnedEntities;
|