@backstage/plugin-catalog-react 0.0.0-nightly-20220220022427 → 0.0.0-nightly-20220223022848
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 +9 -4
- package/dist/index.d.ts +15 -10
- package/dist/index.esm.js +18 -32
- package/dist/index.esm.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20220223022848
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
+
- 3334ad47d4: Removed the deprecated `EntityContext` which have been replaced by `useEntity`, `EntityProvider` and `AsyncEntityProvider`.
|
|
7
8
|
- e2e0b6625c: Improved API documentation.
|
|
8
9
|
|
|
9
10
|
**BREAKING**: The individual table column factories (e.g. `createEntityRefColumn`) are now no longer available directly, but only through `EntityTable.columns`.
|
|
10
11
|
|
|
11
12
|
### Patch Changes
|
|
12
13
|
|
|
14
|
+
- a8331830f1: Deprecated the `useEntityKinds` hook due to low usage and utility value.
|
|
13
15
|
- 6e1cbc12a6: Updated according to the new `getEntityFacets` catalog API method
|
|
16
|
+
- b776ce5aab: Deprecated the `useEntityListProvider` hook which is now renamed to `useEntityList`
|
|
17
|
+
- 2d339b5f2c: Deprecated `useEntityFromUrl` and the `useEntityCompoundName` hooks as these have very low utility value.
|
|
14
18
|
- Updated dependencies
|
|
15
|
-
- @backstage/
|
|
16
|
-
- @backstage/
|
|
17
|
-
- @backstage/
|
|
19
|
+
- @backstage/core-components@0.0.0-nightly-20220223022848
|
|
20
|
+
- @backstage/catalog-model@0.0.0-nightly-20220223022848
|
|
21
|
+
- @backstage/integration@0.0.0-nightly-20220223022848
|
|
22
|
+
- @backstage/catalog-client@0.0.0-nightly-20220223022848
|
|
18
23
|
|
|
19
24
|
## 0.6.15
|
|
20
25
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ApiRef, StorageApi, IdentityApi } from '@backstage/core-plugin-api';
|
|
|
6
6
|
import { Observable } from '@backstage/types';
|
|
7
7
|
import * as _backstage_catalog_model from '@backstage/catalog-model';
|
|
8
8
|
import { Entity, EntityName, UserEntity } from '@backstage/catalog-model';
|
|
9
|
-
import React, { ReactNode, ComponentProps,
|
|
9
|
+
import React, { ReactNode, ComponentProps, PropsWithChildren } from 'react';
|
|
10
10
|
import { LinkProps, TableColumn } from '@backstage/core-components';
|
|
11
11
|
import { IconButton } from '@material-ui/core';
|
|
12
12
|
import { AsyncState } from 'react-use/lib/useAsync';
|
|
@@ -267,7 +267,7 @@ declare type EntityFilter = {
|
|
|
267
267
|
filterEntity?: (entity: Entity) => boolean;
|
|
268
268
|
/**
|
|
269
269
|
* Serialize the filter value to a string for query params. The UI component responsible for
|
|
270
|
-
* handling this filter should retrieve this from
|
|
270
|
+
* handling this filter should retrieve this from useEntityList.queryParameters. The
|
|
271
271
|
* value restored should be in the precedence: queryParameters `>` initialValue prop `>` default.
|
|
272
272
|
*/
|
|
273
273
|
toQueryValue?: () => string | string[];
|
|
@@ -292,11 +292,6 @@ declare type EntityLoadingStatus = {
|
|
|
292
292
|
error?: Error;
|
|
293
293
|
refresh?: VoidFunction;
|
|
294
294
|
};
|
|
295
|
-
/**
|
|
296
|
-
* @public
|
|
297
|
-
* @deprecated use `useEntity` and `EntityProvider` or `AsyncEntityProvider` instead.
|
|
298
|
-
*/
|
|
299
|
-
declare const EntityContext: Context<EntityLoadingStatus>;
|
|
300
295
|
/**
|
|
301
296
|
* Properties for the AsyncEntityProvider component.
|
|
302
297
|
*
|
|
@@ -330,7 +325,9 @@ interface EntityProviderProps {
|
|
|
330
325
|
* @public
|
|
331
326
|
*/
|
|
332
327
|
declare const EntityProvider: ({ entity, children }: EntityProviderProps) => JSX.Element;
|
|
333
|
-
/** @public
|
|
328
|
+
/** @public
|
|
329
|
+
* @deprecated will be deleted shortly due to low external usage, re-implement if needed.
|
|
330
|
+
*/
|
|
334
331
|
declare const useEntityFromUrl: () => EntityLoadingStatus;
|
|
335
332
|
/**
|
|
336
333
|
* Grab the current entity from the context and its current loading state.
|
|
@@ -347,6 +344,7 @@ declare function useEntity<T extends Entity = Entity>(): {
|
|
|
347
344
|
/**
|
|
348
345
|
* Grabs entity kind, namespace, and name from the location
|
|
349
346
|
* @public
|
|
347
|
+
* @deprecated use {@link @backstage/core-plugin-api#useRouteRefParams} instead
|
|
350
348
|
*/
|
|
351
349
|
declare const useEntityCompoundName: () => {
|
|
352
350
|
kind: string;
|
|
@@ -477,8 +475,14 @@ declare const EntityListProvider: <EntityFilters extends DefaultEntityFilters>({
|
|
|
477
475
|
/**
|
|
478
476
|
* Hook for interacting with the entity list context provided by the {@link EntityListProvider}.
|
|
479
477
|
* @public
|
|
478
|
+
* @deprecated use {@link useEntityList} instead.
|
|
480
479
|
*/
|
|
481
480
|
declare function useEntityListProvider<EntityFilters extends DefaultEntityFilters = DefaultEntityFilters>(): EntityListContextProps<EntityFilters>;
|
|
481
|
+
/**
|
|
482
|
+
* Hook for interacting with the entity list context provided by the {@link EntityListProvider}.
|
|
483
|
+
* @public
|
|
484
|
+
*/
|
|
485
|
+
declare function useEntityList<EntityFilters extends DefaultEntityFilters = DefaultEntityFilters>(): EntityListContextProps<EntityFilters>;
|
|
482
486
|
|
|
483
487
|
/** @public */
|
|
484
488
|
declare type EntityTypeReturn = {
|
|
@@ -489,7 +493,7 @@ declare type EntityTypeReturn = {
|
|
|
489
493
|
setSelectedTypes: (types: string[]) => void;
|
|
490
494
|
};
|
|
491
495
|
/**
|
|
492
|
-
* A hook built on top of `
|
|
496
|
+
* A hook built on top of `useEntityList` for enabling selection of valid `spec.type` values
|
|
493
497
|
* based on the selected EntityKindFilter.
|
|
494
498
|
* @public
|
|
495
499
|
*/
|
|
@@ -498,6 +502,7 @@ declare function useEntityTypeFilter(): EntityTypeReturn;
|
|
|
498
502
|
/**
|
|
499
503
|
* Retrieve a list of unique entity kinds present in the catalog
|
|
500
504
|
* @public
|
|
505
|
+
* @deprecated and will be removed due to low utility value.
|
|
501
506
|
*/
|
|
502
507
|
declare function useEntityKinds(): {
|
|
503
508
|
error: Error | undefined;
|
|
@@ -698,4 +703,4 @@ declare type BackstageOverrides = Overrides & {
|
|
|
698
703
|
[Name in keyof CatalogReactComponentsNameToClassKey]?: Partial<StyleRules<CatalogReactComponentsNameToClassKey[Name]>>;
|
|
699
704
|
};
|
|
700
705
|
|
|
701
|
-
export { AsyncEntityProvider, AsyncEntityProviderProps, BackstageOverrides, CatalogReactComponentsNameToClassKey, CatalogReactEntityLifecyclePickerClassKey, CatalogReactEntityOwnerPickerClassKey, CatalogReactEntitySearchBarClassKey, CatalogReactEntityTagPickerClassKey, CatalogReactUserListPickerClassKey, DefaultEntityFilters, DefaultStarredEntitiesApi,
|
|
706
|
+
export { AsyncEntityProvider, AsyncEntityProviderProps, BackstageOverrides, CatalogReactComponentsNameToClassKey, CatalogReactEntityLifecyclePickerClassKey, CatalogReactEntityOwnerPickerClassKey, CatalogReactEntitySearchBarClassKey, CatalogReactEntityTagPickerClassKey, CatalogReactUserListPickerClassKey, DefaultEntityFilters, DefaultStarredEntitiesApi, EntityFilter, EntityKindFilter, EntityKindPicker, EntityKindPickerProps, EntityLifecycleFilter, EntityLifecyclePicker, EntityListContext, EntityListContextProps, EntityListProvider, EntityLoadingStatus, EntityOwnerFilter, EntityOwnerPicker, EntityProvider, EntityProviderProps, EntityRefLink, EntityRefLinkProps, EntityRefLinks, EntityRefLinksProps, EntitySearchBar, EntitySourceLocation, EntityTable, EntityTableProps, EntityTagFilter, EntityTagPicker, EntityTextFilter, EntityTypeFilter, EntityTypePicker, EntityTypePickerProps, EntityTypeReturn, FavoriteEntity, FavoriteEntityProps, InspectEntityDialog, MockEntityListContextProvider, StarredEntitiesApi, UnregisterEntityDialog, UnregisterEntityDialogProps, UserListFilter, UserListFilterKind, UserListPicker, UserListPickerProps, catalogApiRef, catalogRouteRef, columnFactories, entityRoute, entityRouteParams, entityRouteRef, favoriteEntityIcon, favoriteEntityTooltip, formatEntityRefTitle, getEntityMetadataEditUrl, getEntityMetadataViewUrl, getEntityRelations, getEntitySourceLocation, isOwnerOf, loadCatalogOwnerRefs, loadIdentityOwnerRefs, reduceCatalogFilters, reduceEntityFilters, rootRoute, starredEntitiesApiRef, useEntity, useEntityCompoundName, useEntityFromUrl, useEntityKinds, useEntityList, useEntityListProvider, useEntityOwnership, useEntityPermission, useEntityTypeFilter, useOwnUser, useOwnedEntities, useRelatedEntities, useStarredEntities, useStarredEntity };
|
package/dist/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createApiRef, createRouteRef, useRouteRefParams, useApi, errorApiRef, u
|
|
|
3
3
|
import ObservableImpl from 'zen-observable';
|
|
4
4
|
import { stringifyEntityRef, DEFAULT_NAMESPACE, ANNOTATION_VIEW_URL, ANNOTATION_EDIT_URL, ANNOTATION_SOURCE_LOCATION, parseLocationRef, RELATION_MEMBER_OF, getEntityName, RELATION_OWNED_BY, parseEntityRef, RELATION_PART_OF, ANNOTATION_LOCATION, ANNOTATION_ORIGIN_LOCATION } from '@backstage/catalog-model';
|
|
5
5
|
import { isArray, isString, compact, isEqual, groupBy, chunk } from 'lodash';
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { useEffect, createContext, useState, useMemo, useCallback, useContext, forwardRef, useRef, useLayoutEffect, Fragment } from 'react';
|
|
7
7
|
import { Alert, Autocomplete } from '@material-ui/lab';
|
|
8
8
|
import { getOrCreateGlobalSingleton, createVersionedContext, createVersionedValueMap, useVersionedContext } from '@backstage/version-bridge';
|
|
9
9
|
import { useNavigate, useLocation } from 'react-router';
|
|
@@ -127,14 +127,6 @@ const useEntityCompoundName = () => {
|
|
|
127
127
|
return { kind, namespace, name };
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
const EntityContext = createContext({
|
|
131
|
-
entity: void 0,
|
|
132
|
-
loading: true,
|
|
133
|
-
error: void 0,
|
|
134
|
-
refresh: () => {
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
const OldEntityProvider = EntityContext.Provider;
|
|
138
130
|
const NewEntityContext = createVersionedContext("entity-context");
|
|
139
131
|
const AsyncEntityProvider = ({
|
|
140
132
|
children,
|
|
@@ -144,11 +136,9 @@ const AsyncEntityProvider = ({
|
|
|
144
136
|
refresh
|
|
145
137
|
}) => {
|
|
146
138
|
const value = { entity, loading, error, refresh };
|
|
147
|
-
return /* @__PURE__ */ React.createElement(
|
|
148
|
-
value
|
|
149
|
-
}, /* @__PURE__ */ React.createElement(NewEntityContext.Provider, {
|
|
139
|
+
return /* @__PURE__ */ React.createElement(NewEntityContext.Provider, {
|
|
150
140
|
value: createVersionedValueMap({ 1: value })
|
|
151
|
-
}, children)
|
|
141
|
+
}, children);
|
|
152
142
|
};
|
|
153
143
|
const EntityProvider = ({ entity, children }) => /* @__PURE__ */ React.createElement(AsyncEntityProvider, {
|
|
154
144
|
entity,
|
|
@@ -157,16 +147,6 @@ const EntityProvider = ({ entity, children }) => /* @__PURE__ */ React.createEle
|
|
|
157
147
|
refresh: void 0,
|
|
158
148
|
children
|
|
159
149
|
});
|
|
160
|
-
const CompatibilityProvider = ({
|
|
161
|
-
value,
|
|
162
|
-
children
|
|
163
|
-
}) => {
|
|
164
|
-
return /* @__PURE__ */ React.createElement(AsyncEntityProvider, {
|
|
165
|
-
...value,
|
|
166
|
-
children
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
EntityContext.Provider = CompatibilityProvider;
|
|
170
150
|
const useEntityFromUrl = () => {
|
|
171
151
|
const { kind, namespace, name } = useEntityCompoundName();
|
|
172
152
|
const navigate = useNavigate();
|
|
@@ -349,7 +329,13 @@ const EntityListProvider = ({
|
|
|
349
329
|
function useEntityListProvider() {
|
|
350
330
|
const context = useContext(EntityListContext);
|
|
351
331
|
if (!context)
|
|
352
|
-
throw new Error("
|
|
332
|
+
throw new Error("useEntityList must be used within EntityListProvider");
|
|
333
|
+
return context;
|
|
334
|
+
}
|
|
335
|
+
function useEntityList() {
|
|
336
|
+
const context = useContext(EntityListContext);
|
|
337
|
+
if (!context)
|
|
338
|
+
throw new Error("useEntityList must be used within EntityListProvider");
|
|
353
339
|
return context;
|
|
354
340
|
}
|
|
355
341
|
|
|
@@ -524,7 +510,7 @@ function useEntityTypeFilter() {
|
|
|
524
510
|
filters: { kind: kindFilter, type: typeFilter },
|
|
525
511
|
queryParameters,
|
|
526
512
|
updateFilters
|
|
527
|
-
} =
|
|
513
|
+
} = useEntityList();
|
|
528
514
|
const queryParamTypes = useMemo(() => [queryParameters.type].flat().filter(Boolean), [queryParameters]);
|
|
529
515
|
const [selectedTypes, setSelectedTypes] = useState(queryParamTypes.length ? queryParamTypes : (_a = typeFilter == null ? void 0 : typeFilter.getTypes()) != null ? _a : []);
|
|
530
516
|
useEffect(() => {
|
|
@@ -770,7 +756,7 @@ function useEntityPermission(permission) {
|
|
|
770
756
|
const EntityKindPicker = (props) => {
|
|
771
757
|
var _a;
|
|
772
758
|
const { initialFilter, hidden } = props;
|
|
773
|
-
const { updateFilters, queryParameters } =
|
|
759
|
+
const { updateFilters, queryParameters } = useEntityList();
|
|
774
760
|
const [selectedKind] = useState((_a = [queryParameters.kind].flat()[0]) != null ? _a : initialFilter);
|
|
775
761
|
useEffect(() => {
|
|
776
762
|
updateFilters({
|
|
@@ -798,7 +784,7 @@ const checkedIcon$2 = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
|
|
|
798
784
|
const EntityLifecyclePicker = () => {
|
|
799
785
|
var _a, _b;
|
|
800
786
|
const classes = useStyles$b();
|
|
801
|
-
const { updateFilters, backendEntities, filters, queryParameters } =
|
|
787
|
+
const { updateFilters, backendEntities, filters, queryParameters } = useEntityList();
|
|
802
788
|
const queryParamLifecycles = useMemo(() => [queryParameters.lifecycles].flat().filter(Boolean), [queryParameters]);
|
|
803
789
|
const [selectedLifecycles, setSelectedLifecycles] = useState(queryParamLifecycles.length ? queryParamLifecycles : (_b = (_a = filters.lifecycles) == null ? void 0 : _a.values) != null ? _b : []);
|
|
804
790
|
useEffect(() => {
|
|
@@ -864,7 +850,7 @@ const checkedIcon$1 = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
|
|
|
864
850
|
const EntityOwnerPicker = () => {
|
|
865
851
|
var _a, _b;
|
|
866
852
|
const classes = useStyles$a();
|
|
867
|
-
const { updateFilters, backendEntities, filters, queryParameters } =
|
|
853
|
+
const { updateFilters, backendEntities, filters, queryParameters } = useEntityList();
|
|
868
854
|
const queryParamOwners = useMemo(() => [queryParameters.owners].flat().filter(Boolean), [queryParameters]);
|
|
869
855
|
const [selectedOwners, setSelectedOwners] = useState(queryParamOwners.length ? queryParamOwners : (_b = (_a = filters.owners) == null ? void 0 : _a.values) != null ? _b : []);
|
|
870
856
|
useEffect(() => {
|
|
@@ -925,7 +911,7 @@ const useStyles$9 = makeStyles((_theme) => ({
|
|
|
925
911
|
const EntitySearchBar = () => {
|
|
926
912
|
var _a, _b;
|
|
927
913
|
const classes = useStyles$9();
|
|
928
|
-
const { filters, updateFilters } =
|
|
914
|
+
const { filters, updateFilters } = useEntityList();
|
|
929
915
|
const [search, setSearch] = useState((_b = (_a = filters.text) == null ? void 0 : _a.value) != null ? _b : "");
|
|
930
916
|
useDebounce(() => {
|
|
931
917
|
updateFilters({
|
|
@@ -1136,7 +1122,7 @@ const checkedIcon = /* @__PURE__ */ React.createElement(CheckBoxIcon, {
|
|
|
1136
1122
|
const EntityTagPicker = () => {
|
|
1137
1123
|
var _a, _b;
|
|
1138
1124
|
const classes = useStyles$7();
|
|
1139
|
-
const { updateFilters, backendEntities, filters, queryParameters } =
|
|
1125
|
+
const { updateFilters, backendEntities, filters, queryParameters } = useEntityList();
|
|
1140
1126
|
const queryParamTags = useMemo(() => [queryParameters.tags].flat().filter(Boolean), [queryParameters]);
|
|
1141
1127
|
const [selectedTags, setSelectedTags] = useState(queryParamTags.length ? queryParamTags : (_b = (_a = filters.tags) == null ? void 0 : _a.values) != null ? _b : []);
|
|
1142
1128
|
useEffect(() => {
|
|
@@ -2043,7 +2029,7 @@ const UserListPicker = (props) => {
|
|
|
2043
2029
|
backendEntities,
|
|
2044
2030
|
queryParameters,
|
|
2045
2031
|
loading: loadingBackendEntities
|
|
2046
|
-
} =
|
|
2032
|
+
} = useEntityList();
|
|
2047
2033
|
const userAndGroupFilterIds = ["starred", "all"];
|
|
2048
2034
|
const filterGroups = getFilterGroups(orgName).map((filterGroup) => ({
|
|
2049
2035
|
...filterGroup,
|
|
@@ -2144,5 +2130,5 @@ const MockEntityListContextProvider = ({
|
|
|
2144
2130
|
}, children);
|
|
2145
2131
|
};
|
|
2146
2132
|
|
|
2147
|
-
export { AsyncEntityProvider, DefaultStarredEntitiesApi,
|
|
2133
|
+
export { AsyncEntityProvider, DefaultStarredEntitiesApi, EntityKindFilter, EntityKindPicker, EntityLifecycleFilter, EntityLifecyclePicker, EntityListContext, EntityListProvider, EntityOwnerFilter, EntityOwnerPicker, EntityProvider, EntityRefLink, EntityRefLinks, EntitySearchBar, EntityTable, EntityTagFilter, EntityTagPicker, EntityTextFilter, EntityTypeFilter, EntityTypePicker, FavoriteEntity, InspectEntityDialog, MockEntityListContextProvider, UnregisterEntityDialog, UserListFilter, UserListPicker, catalogApiRef, catalogRouteRef, columnFactories, entityRoute, entityRouteParams, entityRouteRef, favoriteEntityIcon, favoriteEntityTooltip, formatEntityRefTitle, getEntityMetadataEditUrl, getEntityMetadataViewUrl, getEntityRelations, getEntitySourceLocation, isOwnerOf, loadCatalogOwnerRefs, loadIdentityOwnerRefs, reduceCatalogFilters, reduceEntityFilters, rootRoute, starredEntitiesApiRef, useEntity, useEntityCompoundName, useEntityFromUrl, useEntityKinds, useEntityList, useEntityListProvider, useEntityOwnership, useEntityPermission, useEntityTypeFilter, useOwnUser, useOwnedEntities, useRelatedEntities, useStarredEntities, useStarredEntity };
|
|
2148
2134
|
//# sourceMappingURL=index.esm.js.map
|