@backstage/plugin-catalog-react 1.0.1-next.0 → 1.0.1-next.3
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 +41 -0
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +4 -4
- package/dist/index.beta.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +55 -31
- package/dist/index.esm.js.map +1 -1
- package/package.json +14 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
+
## 1.0.1-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 24254fd433: build(deps): bump `@testing-library/user-event` from 13.5.0 to 14.0.0
|
|
8
|
+
- 863e7bcb7b: Updated the "unregister location" behavior in `UnregisterEntityDialog`. Removed unnecessary entity deletion requests that were sent after successfully deleting a location.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @backstage/core-components@0.9.3-next.2
|
|
11
|
+
- @backstage/core-plugin-api@1.0.1-next.0
|
|
12
|
+
- @backstage/plugin-permission-common@0.6.0-next.1
|
|
13
|
+
- @backstage/plugin-permission-react@0.4.0-next.1
|
|
14
|
+
- @backstage/integration@1.1.0-next.2
|
|
15
|
+
|
|
16
|
+
## 1.0.1-next.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 4be0d1e777: Changed catalog filter components to only pay attention to query parameters relevant to the component.
|
|
21
|
+
- 5d5fdbe541: Columns in CatalogTable now change depending on the entity kind, ensuring only relevant columns are displayed.
|
|
22
|
+
- 99063c39ae: Minor API report cleanup
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @backstage/core-components@0.9.3-next.1
|
|
25
|
+
- @backstage/catalog-model@1.0.1-next.1
|
|
26
|
+
|
|
27
|
+
## 1.0.1-next.1
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 0ffd88a90e: Prevent permissions with types other than `ResourcePermission<'catalog-entity'>` from being used with the `useEntityPermission` hook.
|
|
32
|
+
- 4af82967f4: Decouple tags picker from backend entities
|
|
33
|
+
|
|
34
|
+
`EntityTagPicker` fetches all the tags independently and it doesn't require all the entities to be available client side.
|
|
35
|
+
|
|
36
|
+
- 37b04b5a5e: Removed broken link from Labels section of entity inspector.
|
|
37
|
+
- 4431873583: Update `usePermission` usage.
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @backstage/integration@1.1.0-next.1
|
|
40
|
+
- @backstage/plugin-permission-react@0.4.0-next.0
|
|
41
|
+
- @backstage/plugin-permission-common@0.6.0-next.0
|
|
42
|
+
- @backstage/plugin-catalog-common@1.0.1-next.1
|
|
43
|
+
|
|
3
44
|
## 1.0.1-next.0
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/alpha/package.json
CHANGED
package/dist/index.alpha.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';
|
|
@@ -259,7 +259,7 @@ export declare const EntityOwnerPicker: () => JSX.Element | null;
|
|
|
259
259
|
*
|
|
260
260
|
* @public
|
|
261
261
|
*/
|
|
262
|
-
export declare const EntityProvider: (
|
|
262
|
+
export declare const EntityProvider: (props: EntityProviderProps) => JSX.Element;
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* Properties for the EntityProvider component.
|
|
@@ -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
|
-
*
|
|
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:
|
|
595
|
+
export declare function useEntityPermission(permission: ResourcePermission<'catalog-entity'>): {
|
|
596
596
|
loading: boolean;
|
|
597
597
|
allowed: boolean;
|
|
598
598
|
error?: Error;
|
package/dist/index.beta.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';
|
|
@@ -259,7 +259,7 @@ export declare const EntityOwnerPicker: () => JSX.Element | null;
|
|
|
259
259
|
*
|
|
260
260
|
* @public
|
|
261
261
|
*/
|
|
262
|
-
export declare const EntityProvider: (
|
|
262
|
+
export declare const EntityProvider: (props: EntityProviderProps) => JSX.Element;
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* Properties for the EntityProvider component.
|
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';
|
|
@@ -259,7 +259,7 @@ export declare const EntityOwnerPicker: () => JSX.Element | null;
|
|
|
259
259
|
*
|
|
260
260
|
* @public
|
|
261
261
|
*/
|
|
262
|
-
export declare const EntityProvider: (
|
|
262
|
+
export declare const EntityProvider: (props: EntityProviderProps) => JSX.Element;
|
|
263
263
|
|
|
264
264
|
/**
|
|
265
265
|
* Properties for the EntityProvider component.
|
package/dist/index.esm.js
CHANGED
|
@@ -125,12 +125,12 @@ const AsyncEntityProvider = ({
|
|
|
125
125
|
value: createVersionedValueMap({ 1: value })
|
|
126
126
|
}, children);
|
|
127
127
|
};
|
|
128
|
-
const EntityProvider = (
|
|
129
|
-
entity,
|
|
130
|
-
loading: !Boolean(entity),
|
|
128
|
+
const EntityProvider = (props) => /* @__PURE__ */ React.createElement(AsyncEntityProvider, {
|
|
129
|
+
entity: props.entity,
|
|
130
|
+
loading: !Boolean(props.entity),
|
|
131
131
|
error: void 0,
|
|
132
132
|
refresh: void 0,
|
|
133
|
-
children
|
|
133
|
+
children: props.children
|
|
134
134
|
});
|
|
135
135
|
function useEntity() {
|
|
136
136
|
const versionedHolder = useVersionedContext("entity-context");
|
|
@@ -479,16 +479,16 @@ function useEntityTypeFilter() {
|
|
|
479
479
|
const catalogApi = useApi(catalogApiRef);
|
|
480
480
|
const {
|
|
481
481
|
filters: { kind: kindFilter, type: typeFilter },
|
|
482
|
-
queryParameters,
|
|
482
|
+
queryParameters: { type: typeParameter },
|
|
483
483
|
updateFilters
|
|
484
484
|
} = useEntityList();
|
|
485
|
-
const
|
|
486
|
-
const [selectedTypes, setSelectedTypes] = useState(
|
|
485
|
+
const flattenedQueryTypes = useMemo(() => [typeParameter].flat().filter(Boolean), [typeParameter]);
|
|
486
|
+
const [selectedTypes, setSelectedTypes] = useState(flattenedQueryTypes.length ? flattenedQueryTypes : (_a = typeFilter == null ? void 0 : typeFilter.getTypes()) != null ? _a : []);
|
|
487
487
|
useEffect(() => {
|
|
488
|
-
if (
|
|
489
|
-
setSelectedTypes(
|
|
488
|
+
if (flattenedQueryTypes.length) {
|
|
489
|
+
setSelectedTypes(flattenedQueryTypes);
|
|
490
490
|
}
|
|
491
|
-
}, [
|
|
491
|
+
}, [flattenedQueryTypes]);
|
|
492
492
|
const [availableTypes, setAvailableTypes] = useState([]);
|
|
493
493
|
const kind = useMemo(() => kindFilter == null ? void 0 : kindFilter.value, [kindFilter]);
|
|
494
494
|
const {
|
|
@@ -649,7 +649,10 @@ function useEntityPermission(permission) {
|
|
|
649
649
|
allowed,
|
|
650
650
|
loading: loadingPermission,
|
|
651
651
|
error: permissionError
|
|
652
|
-
} = usePermission(
|
|
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
|
}
|
|
@@ -662,8 +665,11 @@ function useEntityPermission(permission) {
|
|
|
662
665
|
const EntityKindPicker = (props) => {
|
|
663
666
|
var _a;
|
|
664
667
|
const { initialFilter, hidden } = props;
|
|
665
|
-
const {
|
|
666
|
-
|
|
668
|
+
const {
|
|
669
|
+
updateFilters,
|
|
670
|
+
queryParameters: { kind: kindParameter }
|
|
671
|
+
} = useEntityList();
|
|
672
|
+
const [selectedKind] = useState((_a = [kindParameter].flat()[0]) != null ? _a : initialFilter);
|
|
667
673
|
useEffect(() => {
|
|
668
674
|
updateFilters({
|
|
669
675
|
kind: selectedKind ? new EntityKindFilter(selectedKind) : void 0
|
|
@@ -690,8 +696,13 @@ const checkedIcon$2 = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
|
|
|
690
696
|
const EntityLifecyclePicker = () => {
|
|
691
697
|
var _a, _b;
|
|
692
698
|
const classes = useStyles$b();
|
|
693
|
-
const {
|
|
694
|
-
|
|
699
|
+
const {
|
|
700
|
+
updateFilters,
|
|
701
|
+
backendEntities,
|
|
702
|
+
filters,
|
|
703
|
+
queryParameters: { lifecycles: lifecyclesParameter }
|
|
704
|
+
} = useEntityList();
|
|
705
|
+
const queryParamLifecycles = useMemo(() => [lifecyclesParameter].flat().filter(Boolean), [lifecyclesParameter]);
|
|
695
706
|
const [selectedLifecycles, setSelectedLifecycles] = useState(queryParamLifecycles.length ? queryParamLifecycles : (_b = (_a = filters.lifecycles) == null ? void 0 : _a.values) != null ? _b : []);
|
|
696
707
|
useEffect(() => {
|
|
697
708
|
if (queryParamLifecycles.length) {
|
|
@@ -756,8 +767,13 @@ const checkedIcon$1 = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
|
|
|
756
767
|
const EntityOwnerPicker = () => {
|
|
757
768
|
var _a, _b;
|
|
758
769
|
const classes = useStyles$a();
|
|
759
|
-
const {
|
|
760
|
-
|
|
770
|
+
const {
|
|
771
|
+
updateFilters,
|
|
772
|
+
backendEntities,
|
|
773
|
+
filters,
|
|
774
|
+
queryParameters: { owners: ownersParameter }
|
|
775
|
+
} = useEntityList();
|
|
776
|
+
const queryParamOwners = useMemo(() => [ownersParameter].flat().filter(Boolean), [ownersParameter]);
|
|
761
777
|
const [selectedOwners, setSelectedOwners] = useState(queryParamOwners.length ? queryParamOwners : (_b = (_a = filters.owners) == null ? void 0 : _a.values) != null ? _b : []);
|
|
762
778
|
useEffect(() => {
|
|
763
779
|
if (queryParamOwners.length) {
|
|
@@ -1029,8 +1045,22 @@ const checkedIcon = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
|
|
|
1029
1045
|
const EntityTagPicker = () => {
|
|
1030
1046
|
var _a, _b;
|
|
1031
1047
|
const classes = useStyles$7();
|
|
1032
|
-
const {
|
|
1033
|
-
|
|
1048
|
+
const {
|
|
1049
|
+
updateFilters,
|
|
1050
|
+
filters,
|
|
1051
|
+
queryParameters: { tags: tagsParameter }
|
|
1052
|
+
} = useEntityList();
|
|
1053
|
+
const catalogApi = useApi(catalogApiRef);
|
|
1054
|
+
const { value: availableTags } = useAsync(async () => {
|
|
1055
|
+
var _a2;
|
|
1056
|
+
const facet = "metadata.tags";
|
|
1057
|
+
const { facets } = await catalogApi.getEntityFacets({
|
|
1058
|
+
facets: [facet],
|
|
1059
|
+
filter: (_a2 = filters.kind) == null ? void 0 : _a2.getCatalogFilters()
|
|
1060
|
+
});
|
|
1061
|
+
return facets[facet].map(({ value }) => value);
|
|
1062
|
+
}, [filters.kind]);
|
|
1063
|
+
const queryParamTags = useMemo(() => [tagsParameter].flat().filter(Boolean), [tagsParameter]);
|
|
1034
1064
|
const [selectedTags, setSelectedTags] = useState(queryParamTags.length ? queryParamTags : (_b = (_a = filters.tags) == null ? void 0 : _a.values) != null ? _b : []);
|
|
1035
1065
|
useEffect(() => {
|
|
1036
1066
|
if (queryParamTags.length) {
|
|
@@ -1042,10 +1072,7 @@ const EntityTagPicker = () => {
|
|
|
1042
1072
|
tags: selectedTags.length ? new EntityTagFilter(selectedTags) : void 0
|
|
1043
1073
|
});
|
|
1044
1074
|
}, [selectedTags, updateFilters]);
|
|
1045
|
-
|
|
1046
|
-
...new Set(backendEntities.flatMap((e) => e.metadata.tags).filter(Boolean))
|
|
1047
|
-
].sort(), [backendEntities]);
|
|
1048
|
-
if (!availableTags.length)
|
|
1075
|
+
if (!(availableTags == null ? void 0 : availableTags.length))
|
|
1049
1076
|
return null;
|
|
1050
1077
|
return /* @__PURE__ */ React.createElement(Box, {
|
|
1051
1078
|
pb: 1,
|
|
@@ -1531,9 +1558,7 @@ function OverviewPage(props) {
|
|
|
1531
1558
|
entry
|
|
1532
1559
|
}))), !!Object.keys(metadata.labels || {}).length && /* @__PURE__ */ React.createElement(List, {
|
|
1533
1560
|
dense: true,
|
|
1534
|
-
subheader: /* @__PURE__ */ React.createElement(ListSubheader, null, "Labels"
|
|
1535
|
-
to: "https://backstage.io/docs/features/software-catalog/well-known-labels"
|
|
1536
|
-
}))
|
|
1561
|
+
subheader: /* @__PURE__ */ React.createElement(ListSubheader, null, "Labels")
|
|
1537
1562
|
}, Object.entries(metadata.labels).map((entry) => /* @__PURE__ */ React.createElement(KeyValueListItem, {
|
|
1538
1563
|
key: entry[0],
|
|
1539
1564
|
indent: true,
|
|
@@ -1728,9 +1753,8 @@ function useUnregisterEntityDialogState(entity) {
|
|
|
1728
1753
|
}));
|
|
1729
1754
|
}, [catalogApi, entity]);
|
|
1730
1755
|
const unregisterLocation = useCallback(async function unregisterLocationFn() {
|
|
1731
|
-
const { location: location2
|
|
1756
|
+
const { location: location2 } = prerequisites.value;
|
|
1732
1757
|
await catalogApi.removeLocationById(location2.id);
|
|
1733
|
-
await Promise.allSettled(colocatedEntities2.map((e) => catalogApi.removeEntityByUid(e.metadata.uid)));
|
|
1734
1758
|
}, [catalogApi, prerequisites]);
|
|
1735
1759
|
const deleteEntity = useCallback(async function deleteEntityFn() {
|
|
1736
1760
|
await catalogApi.removeEntityByUid(uid);
|
|
@@ -1954,20 +1978,20 @@ const UserListPicker = (props) => {
|
|
|
1954
1978
|
filters,
|
|
1955
1979
|
updateFilters,
|
|
1956
1980
|
backendEntities,
|
|
1957
|
-
queryParameters,
|
|
1981
|
+
queryParameters: { kind: kindParameter, user: userParameter },
|
|
1958
1982
|
loading: loadingBackendEntities
|
|
1959
1983
|
} = useEntityList();
|
|
1960
1984
|
const userAndGroupFilterIds = ["starred", "all"];
|
|
1961
1985
|
const filterGroups = getFilterGroups(orgName).map((filterGroup) => ({
|
|
1962
1986
|
...filterGroup,
|
|
1963
|
-
items: filterGroup.items.filter(({ id }) => ["group", "user"].some((kind) => kind ===
|
|
1987
|
+
items: filterGroup.items.filter(({ id }) => ["group", "user"].some((kind) => kind === kindParameter) ? userAndGroupFilterIds.includes(id) : !availableFilters || availableFilters.includes(id))
|
|
1964
1988
|
})).filter(({ items }) => !!items.length);
|
|
1965
1989
|
const { isStarredEntity } = useStarredEntities();
|
|
1966
1990
|
const { isOwnedEntity, loading: loadingEntityOwnership } = useEntityOwnership();
|
|
1967
1991
|
const loading = loadingBackendEntities || loadingEntityOwnership;
|
|
1968
1992
|
const ownedFilter = useMemo(() => new UserListFilter("owned", isOwnedEntity, isStarredEntity), [isOwnedEntity, isStarredEntity]);
|
|
1969
1993
|
const starredFilter = useMemo(() => new UserListFilter("starred", isOwnedEntity, isStarredEntity), [isOwnedEntity, isStarredEntity]);
|
|
1970
|
-
const queryParamUserFilter = useMemo(() => [
|
|
1994
|
+
const queryParamUserFilter = useMemo(() => [userParameter].flat()[0], [userParameter]);
|
|
1971
1995
|
const [selectedUserFilter, setSelectedUserFilter] = useState(queryParamUserFilter != null ? queryParamUserFilter : initialFilter);
|
|
1972
1996
|
const entitiesWithoutUserFilter = useMemo(() => backendEntities.filter(reduceEntityFilters(compact(Object.values({ ...filters, user: void 0 })))), [filters, backendEntities]);
|
|
1973
1997
|
const filterCounts = useMemo(() => ({
|