@backstage/plugin-catalog-react 0.0.0-nightly-20220323023253 → 0.0.0-nightly-20220326022848

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,17 +1,25 @@
1
1
  # @backstage/plugin-catalog-react
2
2
 
3
- ## 0.0.0-nightly-20220323023253
3
+ ## 0.0.0-nightly-20220326022848
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - 0ffd88a90e: Prevent permissions with types other than `ResourcePermission<'catalog-entity'>` from being used with the `useEntityPermission` hook.
8
+ - 4af82967f4: Decouple tags picker from backend entities
9
+
10
+ `EntityTagPicker` fetches all the tags independently and it doesn't require all the entities to be available client side.
11
+
7
12
  - a496cee4d1: Add support for string refs to the `EntityRefLinks` component
8
13
  - d34900af81: Added a new `NextScaffolderRouter` which will eventually replace the exiting router
9
- - Updated dependencies
10
- - @backstage/catalog-model@0.0.0-nightly-20220323023253
11
- - @backstage/integration@0.0.0-nightly-20220323023253
12
- - @backstage/core-components@0.0.0-nightly-20220323023253
13
- - @backstage/plugin-permission-common@0.0.0-nightly-20220323023253
14
- - @backstage/catalog-client@0.0.0-nightly-20220323023253
14
+ - 4431873583: Update `usePermission` usage.
15
+ - Updated dependencies
16
+ - @backstage/plugin-permission-react@0.0.0-nightly-20220326022848
17
+ - @backstage/catalog-model@0.0.0-nightly-20220326022848
18
+ - @backstage/plugin-permission-common@0.0.0-nightly-20220326022848
19
+ - @backstage/plugin-catalog-common@0.0.0-nightly-20220326022848
20
+ - @backstage/integration@0.0.0-nightly-20220326022848
21
+ - @backstage/core-components@0.0.0-nightly-20220326022848
22
+ - @backstage/catalog-client@0.0.0-nightly-20220326022848
15
23
 
16
24
  ## 1.0.1-next.0
17
25
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-react",
3
- "version": "0.0.0-nightly-20220323023253",
3
+ "version": "0.0.0-nightly-20220326022848",
4
4
  "main": "../dist/index.esm.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -17,10 +17,10 @@ import { IconButton } from '@material-ui/core';
17
17
  import { LinkProps } from '@backstage/core-components';
18
18
  import { Observable } from '@backstage/types';
19
19
  import { Overrides } from '@material-ui/core/styles/overrides';
20
- import { Permission } from '@backstage/plugin-permission-common';
21
20
  import { PropsWithChildren } from 'react';
22
21
  import { default as React_2 } from 'react';
23
22
  import { ReactNode } from 'react';
23
+ import { ResourcePermission } from '@backstage/plugin-permission-common';
24
24
  import { RouteRef } from '@backstage/core-plugin-api';
25
25
  import { ScmIntegrationRegistry } from '@backstage/integration';
26
26
  import { StyleRules } from '@material-ui/core/styles/withStyles';
@@ -585,14 +585,14 @@ export declare function useEntityOwnership(): {
585
585
  * A thin wrapper around the
586
586
  * {@link @backstage/plugin-permission-react#usePermission} hook which uses the
587
587
  * current entity in context to make an authorization request for the given
588
- * permission.
588
+ * {@link @backstage/plugin-catalog-common#CatalogEntityPermission}.
589
589
  *
590
590
  * Note: this hook blocks the permission request until the entity has loaded in
591
591
  * context. If you have the entityRef and need concurrent requests, use the
592
592
  * `usePermission` hook directly.
593
593
  * @alpha
594
594
  */
595
- export declare function useEntityPermission(permission: Permission): {
595
+ export declare function useEntityPermission(permission: ResourcePermission<'catalog-entity'>): {
596
596
  loading: boolean;
597
597
  allowed: boolean;
598
598
  error?: Error;
@@ -17,10 +17,10 @@ import { IconButton } from '@material-ui/core';
17
17
  import { LinkProps } from '@backstage/core-components';
18
18
  import { Observable } from '@backstage/types';
19
19
  import { Overrides } from '@material-ui/core/styles/overrides';
20
- import { Permission } from '@backstage/plugin-permission-common';
21
20
  import { PropsWithChildren } from 'react';
22
21
  import { default as React_2 } from 'react';
23
22
  import { ReactNode } from 'react';
23
+ import { ResourcePermission } from '@backstage/plugin-permission-common';
24
24
  import { RouteRef } from '@backstage/core-plugin-api';
25
25
  import { ScmIntegrationRegistry } from '@backstage/integration';
26
26
  import { StyleRules } from '@material-ui/core/styles/withStyles';
package/dist/index.d.ts CHANGED
@@ -17,10 +17,10 @@ import { IconButton } from '@material-ui/core';
17
17
  import { LinkProps } from '@backstage/core-components';
18
18
  import { Observable } from '@backstage/types';
19
19
  import { Overrides } from '@material-ui/core/styles/overrides';
20
- import { Permission } from '@backstage/plugin-permission-common';
21
20
  import { PropsWithChildren } from 'react';
22
21
  import { default as React_2 } from 'react';
23
22
  import { ReactNode } from 'react';
23
+ import { ResourcePermission } from '@backstage/plugin-permission-common';
24
24
  import { RouteRef } from '@backstage/core-plugin-api';
25
25
  import { ScmIntegrationRegistry } from '@backstage/integration';
26
26
  import { StyleRules } from '@material-ui/core/styles/withStyles';
package/dist/index.esm.js CHANGED
@@ -649,7 +649,10 @@ function useEntityPermission(permission) {
649
649
  allowed,
650
650
  loading: loadingPermission,
651
651
  error: permissionError
652
- } = usePermission(permission, entity ? stringifyEntityRef(entity) : void 0);
652
+ } = usePermission({
653
+ permission,
654
+ resourceRef: entity ? stringifyEntityRef(entity) : void 0
655
+ });
653
656
  if (loadingEntity || loadingPermission) {
654
657
  return { loading: true, allowed: false };
655
658
  }
@@ -1029,7 +1032,17 @@ const checkedIcon = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
1029
1032
  const EntityTagPicker = () => {
1030
1033
  var _a, _b;
1031
1034
  const classes = useStyles$7();
1032
- const { updateFilters, backendEntities, filters, queryParameters } = useEntityList();
1035
+ const { updateFilters, filters, queryParameters } = useEntityList();
1036
+ const catalogApi = useApi(catalogApiRef);
1037
+ const { value: availableTags } = useAsync(async () => {
1038
+ var _a2;
1039
+ const facet = "metadata.tags";
1040
+ const { facets } = await catalogApi.getEntityFacets({
1041
+ facets: [facet],
1042
+ filter: (_a2 = filters.kind) == null ? void 0 : _a2.getCatalogFilters()
1043
+ });
1044
+ return facets[facet].map(({ value }) => value);
1045
+ }, [filters.kind]);
1033
1046
  const queryParamTags = useMemo(() => [queryParameters.tags].flat().filter(Boolean), [queryParameters]);
1034
1047
  const [selectedTags, setSelectedTags] = useState(queryParamTags.length ? queryParamTags : (_b = (_a = filters.tags) == null ? void 0 : _a.values) != null ? _b : []);
1035
1048
  useEffect(() => {
@@ -1042,10 +1055,7 @@ const EntityTagPicker = () => {
1042
1055
  tags: selectedTags.length ? new EntityTagFilter(selectedTags) : void 0
1043
1056
  });
1044
1057
  }, [selectedTags, updateFilters]);
1045
- const availableTags = useMemo(() => [
1046
- ...new Set(backendEntities.flatMap((e) => e.metadata.tags).filter(Boolean))
1047
- ].sort(), [backendEntities]);
1048
- if (!availableTags.length)
1058
+ if (!(availableTags == null ? void 0 : availableTags.length))
1049
1059
  return null;
1050
1060
  return /* @__PURE__ */ React.createElement(Box, {
1051
1061
  pb: 1,