@backstage/plugin-catalog-react 1.13.1 → 1.14.0-next.2
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 +64 -3
- package/alpha/package.json +1 -1
- package/dist/alpha.d.ts +0 -2
- package/dist/components/EntityRefLink/EntityRefLink.esm.js +3 -1
- package/dist/components/EntityRefLink/EntityRefLink.esm.js.map +1 -1
- package/dist/{testUtils/providers.esm.js → deprecated.esm.js} +2 -2
- package/dist/deprecated.esm.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.esm.js +1 -1
- package/dist/testUtils/MockEntityListContextProvider.esm.js +47 -0
- package/dist/testUtils/MockEntityListContextProvider.esm.js.map +1 -0
- package/dist/testUtils/catalogApiMock.esm.js +54 -0
- package/dist/testUtils/catalogApiMock.esm.js.map +1 -0
- package/dist/testUtils.d.ts +48 -0
- package/dist/testUtils.esm.js +3 -0
- package/dist/testUtils.esm.js.map +1 -0
- package/package.json +37 -22
- package/testUtils/package.json +7 -0
- package/dist/testUtils/providers.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,73 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-react
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.14.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0801db6: Add catalog service mocks under the `/testUtils` subpath export.
|
|
8
|
+
|
|
9
|
+
You can now use e.g. `const catalog = catalogApiMock.mock()` in your test and then do assertions on `catalog.getEntities` without awkward type casting.
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
6
12
|
|
|
7
13
|
- Updated dependencies
|
|
8
|
-
- @backstage/
|
|
9
|
-
- @backstage/
|
|
14
|
+
- @backstage/frontend-test-utils@0.2.1-next.2
|
|
15
|
+
- @backstage/catalog-client@1.7.1-next.0
|
|
16
|
+
- @backstage/catalog-model@1.7.0
|
|
17
|
+
- @backstage/core-compat-api@0.3.1-next.2
|
|
18
|
+
- @backstage/core-components@0.15.1-next.2
|
|
19
|
+
- @backstage/core-plugin-api@1.10.0-next.1
|
|
20
|
+
- @backstage/errors@1.2.4
|
|
21
|
+
- @backstage/frontend-plugin-api@0.9.0-next.2
|
|
22
|
+
- @backstage/integration-react@1.2.0-next.2
|
|
23
|
+
- @backstage/types@1.1.1
|
|
24
|
+
- @backstage/version-bridge@1.0.10-next.0
|
|
25
|
+
- @backstage/plugin-catalog-common@1.1.0
|
|
26
|
+
- @backstage/plugin-permission-common@0.8.1
|
|
27
|
+
- @backstage/plugin-permission-react@0.4.27-next.1
|
|
28
|
+
|
|
29
|
+
## 1.14.0-next.1
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- 6812980: Added a new prop, `disableTooltip` to the `EntityRefLink` component
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- e969dc7: Move `@types/react` to a peer dependency.
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @backstage/core-components@0.15.1-next.1
|
|
40
|
+
- @backstage/frontend-plugin-api@0.9.0-next.1
|
|
41
|
+
- @backstage/integration-react@1.2.0-next.1
|
|
42
|
+
- @backstage/core-compat-api@0.3.1-next.1
|
|
43
|
+
- @backstage/core-plugin-api@1.10.0-next.1
|
|
44
|
+
- @backstage/plugin-permission-react@0.4.27-next.1
|
|
45
|
+
- @backstage/version-bridge@1.0.10-next.0
|
|
46
|
+
- @backstage/catalog-client@1.7.0
|
|
47
|
+
- @backstage/catalog-model@1.7.0
|
|
48
|
+
- @backstage/errors@1.2.4
|
|
49
|
+
- @backstage/types@1.1.1
|
|
50
|
+
- @backstage/plugin-catalog-common@1.1.0
|
|
51
|
+
- @backstage/plugin-permission-common@0.8.1
|
|
52
|
+
|
|
53
|
+
## 1.13.1-next.0
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- Updated dependencies
|
|
58
|
+
- @backstage/frontend-plugin-api@0.9.0-next.0
|
|
59
|
+
- @backstage/core-compat-api@0.3.1-next.0
|
|
60
|
+
- @backstage/core-components@0.15.1-next.0
|
|
61
|
+
- @backstage/core-plugin-api@1.10.0-next.0
|
|
62
|
+
- @backstage/catalog-client@1.7.0
|
|
63
|
+
- @backstage/catalog-model@1.7.0
|
|
64
|
+
- @backstage/errors@1.2.4
|
|
65
|
+
- @backstage/integration-react@1.1.32-next.0
|
|
66
|
+
- @backstage/types@1.1.1
|
|
67
|
+
- @backstage/version-bridge@1.0.9
|
|
68
|
+
- @backstage/plugin-catalog-common@1.1.0
|
|
69
|
+
- @backstage/plugin-permission-common@0.8.1
|
|
70
|
+
- @backstage/plugin-permission-react@0.4.27-next.0
|
|
10
71
|
|
|
11
72
|
## 1.13.0
|
|
12
73
|
|
package/alpha/package.json
CHANGED
package/dist/alpha.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ declare function isOwnerOf(owner: Entity, entity: Entity): boolean;
|
|
|
25
25
|
*/
|
|
26
26
|
declare const EntityCardBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
27
27
|
kind: "entity-card";
|
|
28
|
-
namespace: undefined;
|
|
29
28
|
name: undefined;
|
|
30
29
|
params: {
|
|
31
30
|
loader: () => Promise<JSX.Element>;
|
|
@@ -55,7 +54,6 @@ declare const EntityCardBlueprint: _backstage_frontend_plugin_api.ExtensionBluep
|
|
|
55
54
|
*/
|
|
56
55
|
declare const EntityContentBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
57
56
|
kind: "entity-content";
|
|
58
|
-
namespace: undefined;
|
|
59
57
|
name: undefined;
|
|
60
58
|
params: {
|
|
61
59
|
loader: () => Promise<JSX.Element>;
|
|
@@ -14,6 +14,7 @@ const EntityRefLink = forwardRef(
|
|
|
14
14
|
title,
|
|
15
15
|
children,
|
|
16
16
|
hideIcon,
|
|
17
|
+
disableTooltip,
|
|
17
18
|
...linkProps
|
|
18
19
|
} = props;
|
|
19
20
|
const entityRoute = useEntityRoute(props.entityRef);
|
|
@@ -23,7 +24,8 @@ const EntityRefLink = forwardRef(
|
|
|
23
24
|
entityRef,
|
|
24
25
|
defaultKind,
|
|
25
26
|
defaultNamespace,
|
|
26
|
-
hideIcon
|
|
27
|
+
hideIcon,
|
|
28
|
+
disableTooltip
|
|
27
29
|
}
|
|
28
30
|
);
|
|
29
31
|
return /* @__PURE__ */ React.createElement(Link, { ...linkProps, ref, to: entityRoute }, content);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityRefLink.esm.js","sources":["../../../src/components/EntityRefLink/EntityRefLink.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CompoundEntityRef,\n DEFAULT_NAMESPACE,\n Entity,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport { Link, LinkProps } from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport React, { forwardRef } from 'react';\nimport { entityRouteRef } from '../../routes';\nimport { EntityDisplayName } from '../EntityDisplayName';\n\n/**\n * Props for {@link EntityRefLink}.\n *\n * @public\n */\nexport type EntityRefLinkProps = {\n entityRef: Entity | CompoundEntityRef | string;\n defaultKind?: string;\n defaultNamespace?: string;\n /** @deprecated This option should no longer be used; presentation is requested through the {@link entityPresentationApiRef} instead */\n title?: string;\n children?: React.ReactNode;\n hideIcon?: boolean;\n} & Omit<LinkProps, 'to'>;\n\n/**\n * Shows a clickable link to an entity.\n *\n * @public\n */\nexport const EntityRefLink = forwardRef<any, EntityRefLinkProps>(\n (props, ref) => {\n const {\n entityRef,\n defaultKind,\n defaultNamespace,\n title,\n children,\n hideIcon,\n ...linkProps\n } = props;\n const entityRoute = useEntityRoute(props.entityRef);\n\n const content = children ?? title ?? (\n <EntityDisplayName\n entityRef={entityRef}\n defaultKind={defaultKind}\n defaultNamespace={defaultNamespace}\n hideIcon={hideIcon}\n />\n );\n\n return (\n <Link {...linkProps} ref={ref} to={entityRoute}>\n {content}\n </Link>\n );\n },\n) as (props: EntityRefLinkProps) => JSX.Element;\n\n// Hook that computes the route to a given entity / ref. This is a bit\n// contrived, because it tries to retain the casing of the entity name if\n// present, but not of other parts. This is in an attempt to make slightly more\n// nice-looking URLs.\nfunction useEntityRoute(\n entityRef: Entity | CompoundEntityRef | string,\n): string {\n const entityRoute = useRouteRef(entityRouteRef);\n\n let kind;\n let namespace;\n let name;\n\n if (typeof entityRef === 'string') {\n const parsed = parseEntityRef(entityRef);\n kind = parsed.kind;\n namespace = parsed.namespace;\n name = parsed.name;\n } else if ('metadata' in entityRef) {\n kind = entityRef.kind;\n namespace = entityRef.metadata.namespace;\n name = entityRef.metadata.name;\n } else {\n kind = entityRef.kind;\n namespace = entityRef.namespace;\n name = entityRef.name;\n }\n\n kind = kind.toLocaleLowerCase('en-US');\n namespace = namespace?.toLocaleLowerCase('en-US') ?? DEFAULT_NAMESPACE;\n\n const routeParams = {\n kind: encodeURIComponent(kind),\n namespace: encodeURIComponent(namespace),\n name: encodeURIComponent(name),\n };\n\n return entityRoute(routeParams);\n}\n"],"names":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"EntityRefLink.esm.js","sources":["../../../src/components/EntityRefLink/EntityRefLink.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n CompoundEntityRef,\n DEFAULT_NAMESPACE,\n Entity,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport { Link, LinkProps } from '@backstage/core-components';\nimport { useRouteRef } from '@backstage/core-plugin-api';\nimport React, { forwardRef } from 'react';\nimport { entityRouteRef } from '../../routes';\nimport { EntityDisplayName } from '../EntityDisplayName';\n\n/**\n * Props for {@link EntityRefLink}.\n *\n * @public\n */\nexport type EntityRefLinkProps = {\n entityRef: Entity | CompoundEntityRef | string;\n defaultKind?: string;\n defaultNamespace?: string;\n /** @deprecated This option should no longer be used; presentation is requested through the {@link entityPresentationApiRef} instead */\n title?: string;\n children?: React.ReactNode;\n hideIcon?: boolean;\n disableTooltip?: boolean;\n} & Omit<LinkProps, 'to'>;\n\n/**\n * Shows a clickable link to an entity.\n *\n * @public\n */\nexport const EntityRefLink = forwardRef<any, EntityRefLinkProps>(\n (props, ref) => {\n const {\n entityRef,\n defaultKind,\n defaultNamespace,\n title,\n children,\n hideIcon,\n disableTooltip,\n ...linkProps\n } = props;\n const entityRoute = useEntityRoute(props.entityRef);\n\n const content = children ?? title ?? (\n <EntityDisplayName\n entityRef={entityRef}\n defaultKind={defaultKind}\n defaultNamespace={defaultNamespace}\n hideIcon={hideIcon}\n disableTooltip={disableTooltip}\n />\n );\n\n return (\n <Link {...linkProps} ref={ref} to={entityRoute}>\n {content}\n </Link>\n );\n },\n) as (props: EntityRefLinkProps) => JSX.Element;\n\n// Hook that computes the route to a given entity / ref. This is a bit\n// contrived, because it tries to retain the casing of the entity name if\n// present, but not of other parts. This is in an attempt to make slightly more\n// nice-looking URLs.\nfunction useEntityRoute(\n entityRef: Entity | CompoundEntityRef | string,\n): string {\n const entityRoute = useRouteRef(entityRouteRef);\n\n let kind;\n let namespace;\n let name;\n\n if (typeof entityRef === 'string') {\n const parsed = parseEntityRef(entityRef);\n kind = parsed.kind;\n namespace = parsed.namespace;\n name = parsed.name;\n } else if ('metadata' in entityRef) {\n kind = entityRef.kind;\n namespace = entityRef.metadata.namespace;\n name = entityRef.metadata.name;\n } else {\n kind = entityRef.kind;\n namespace = entityRef.namespace;\n name = entityRef.name;\n }\n\n kind = kind.toLocaleLowerCase('en-US');\n namespace = namespace?.toLocaleLowerCase('en-US') ?? DEFAULT_NAMESPACE;\n\n const routeParams = {\n kind: encodeURIComponent(kind),\n namespace: encodeURIComponent(namespace),\n name: encodeURIComponent(name),\n };\n\n return entityRoute(routeParams);\n}\n"],"names":[],"mappings":";;;;;;;AAiDO,MAAM,aAAgB,GAAA,UAAA;AAAA,EAC3B,CAAC,OAAO,GAAQ,KAAA;AACd,IAAM,MAAA;AAAA,MACJ,SAAA;AAAA,MACA,WAAA;AAAA,MACA,gBAAA;AAAA,MACA,KAAA;AAAA,MACA,QAAA;AAAA,MACA,QAAA;AAAA,MACA,cAAA;AAAA,MACA,GAAG,SAAA;AAAA,KACD,GAAA,KAAA,CAAA;AACJ,IAAM,MAAA,WAAA,GAAc,cAAe,CAAA,KAAA,CAAM,SAAS,CAAA,CAAA;AAElD,IAAM,MAAA,OAAA,GAAU,YAAY,KAC1B,oBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,iBAAA;AAAA,MAAA;AAAA,QACC,SAAA;AAAA,QACA,WAAA;AAAA,QACA,gBAAA;AAAA,QACA,QAAA;AAAA,QACA,cAAA;AAAA,OAAA;AAAA,KACF,CAAA;AAGF,IAAA,2CACG,IAAM,EAAA,EAAA,GAAG,WAAW,GAAU,EAAA,EAAA,EAAI,eAChC,OACH,CAAA,CAAA;AAAA,GAEJ;AACF,EAAA;AAMA,SAAS,eACP,SACQ,EAAA;AACR,EAAM,MAAA,WAAA,GAAc,YAAY,cAAc,CAAA,CAAA;AAE9C,EAAI,IAAA,IAAA,CAAA;AACJ,EAAI,IAAA,SAAA,CAAA;AACJ,EAAI,IAAA,IAAA,CAAA;AAEJ,EAAI,IAAA,OAAO,cAAc,QAAU,EAAA;AACjC,IAAM,MAAA,MAAA,GAAS,eAAe,SAAS,CAAA,CAAA;AACvC,IAAA,IAAA,GAAO,MAAO,CAAA,IAAA,CAAA;AACd,IAAA,SAAA,GAAY,MAAO,CAAA,SAAA,CAAA;AACnB,IAAA,IAAA,GAAO,MAAO,CAAA,IAAA,CAAA;AAAA,GAChB,MAAA,IAAW,cAAc,SAAW,EAAA;AAClC,IAAA,IAAA,GAAO,SAAU,CAAA,IAAA,CAAA;AACjB,IAAA,SAAA,GAAY,UAAU,QAAS,CAAA,SAAA,CAAA;AAC/B,IAAA,IAAA,GAAO,UAAU,QAAS,CAAA,IAAA,CAAA;AAAA,GACrB,MAAA;AACL,IAAA,IAAA,GAAO,SAAU,CAAA,IAAA,CAAA;AACjB,IAAA,SAAA,GAAY,SAAU,CAAA,SAAA,CAAA;AACtB,IAAA,IAAA,GAAO,SAAU,CAAA,IAAA,CAAA;AAAA,GACnB;AAEA,EAAO,IAAA,GAAA,IAAA,CAAK,kBAAkB,OAAO,CAAA,CAAA;AACrC,EAAY,SAAA,GAAA,SAAA,EAAW,iBAAkB,CAAA,OAAO,CAAK,IAAA,iBAAA,CAAA;AAErD,EAAA,MAAM,WAAc,GAAA;AAAA,IAClB,IAAA,EAAM,mBAAmB,IAAI,CAAA;AAAA,IAC7B,SAAA,EAAW,mBAAmB,SAAS,CAAA;AAAA,IACvC,IAAA,EAAM,mBAAmB,IAAI,CAAA;AAAA,GAC/B,CAAA;AAEA,EAAA,OAAO,YAAY,WAAW,CAAA,CAAA;AAChC;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback, useMemo } from 'react';
|
|
2
|
-
import { EntityListContext } from '
|
|
2
|
+
import { EntityListContext } from './hooks/useEntityListProvider.esm.js';
|
|
3
3
|
|
|
4
4
|
function MockEntityListContextProvider(props) {
|
|
5
5
|
const { children, value } = props;
|
|
@@ -44,4 +44,4 @@ function MockEntityListContextProvider(props) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export { MockEntityListContextProvider };
|
|
47
|
-
//# sourceMappingURL=
|
|
47
|
+
//# sourceMappingURL=deprecated.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecated.esm.js","sources":["../src/deprecated.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n PropsWithChildren,\n useCallback,\n useMemo,\n useState,\n} from 'react';\nimport {\n DefaultEntityFilters,\n EntityListContext,\n EntityListContextProps,\n} from './hooks/useEntityListProvider';\n\n/**\n * @public\n * @deprecated Moved to `@backstage/plugin-catalog-react/testUtils`\n */\nexport function MockEntityListContextProvider<\n T extends DefaultEntityFilters = DefaultEntityFilters,\n>(\n props: PropsWithChildren<{\n value?: Partial<EntityListContextProps<T>>;\n }>,\n) {\n const { children, value } = props;\n\n // Provides a default implementation that stores filter state, for testing components that\n // reflect filter state.\n const [filters, setFilters] = useState<T>(value?.filters ?? ({} as T));\n\n const updateFilters = useCallback(\n (update: Partial<T> | ((prevFilters: T) => Partial<T>)) => {\n setFilters(prevFilters => {\n const newFilters =\n typeof update === 'function' ? update(prevFilters) : update;\n return { ...prevFilters, ...newFilters };\n });\n },\n [],\n );\n\n // Memoize the default values since pickers have useEffect triggers on these; naively defaulting\n // below with `?? <X>` breaks referential equality on subsequent updates.\n const defaultValues = useMemo(\n () => ({\n entities: [],\n backendEntities: [],\n queryParameters: {},\n }),\n [],\n );\n\n const resolvedValue: EntityListContextProps<T> = useMemo(\n () => ({\n entities: value?.entities ?? defaultValues.entities,\n backendEntities: value?.backendEntities ?? defaultValues.backendEntities,\n updateFilters: value?.updateFilters ?? updateFilters,\n filters,\n loading: value?.loading ?? false,\n queryParameters: value?.queryParameters ?? defaultValues.queryParameters,\n error: value?.error,\n totalItems:\n value?.totalItems ?? (value?.entities ?? defaultValues.entities).length,\n limit: value?.limit ?? 20,\n offset: value?.offset,\n setLimit: value?.setLimit ?? (() => {}),\n setOffset: value?.setOffset,\n paginationMode: value?.paginationMode ?? 'none',\n }),\n [value, defaultValues, filters, updateFilters],\n );\n\n return (\n <EntityListContext.Provider value={resolvedValue}>\n {children}\n </EntityListContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;AAgCO,SAAS,8BAGd,KAGA,EAAA;AACA,EAAM,MAAA,EAAE,QAAU,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAI5B,EAAM,MAAA,CAAC,SAAS,UAAU,CAAA,GAAI,SAAY,KAAO,EAAA,OAAA,IAAY,EAAQ,CAAA,CAAA;AAErE,EAAA,MAAM,aAAgB,GAAA,WAAA;AAAA,IACpB,CAAC,MAA0D,KAAA;AACzD,MAAA,UAAA,CAAW,CAAe,WAAA,KAAA;AACxB,QAAA,MAAM,aACJ,OAAO,MAAA,KAAW,UAAa,GAAA,MAAA,CAAO,WAAW,CAAI,GAAA,MAAA,CAAA;AACvD,QAAA,OAAO,EAAE,GAAG,WAAa,EAAA,GAAG,UAAW,EAAA,CAAA;AAAA,OACxC,CAAA,CAAA;AAAA,KACH;AAAA,IACA,EAAC;AAAA,GACH,CAAA;AAIA,EAAA,MAAM,aAAgB,GAAA,OAAA;AAAA,IACpB,OAAO;AAAA,MACL,UAAU,EAAC;AAAA,MACX,iBAAiB,EAAC;AAAA,MAClB,iBAAiB,EAAC;AAAA,KACpB,CAAA;AAAA,IACA,EAAC;AAAA,GACH,CAAA;AAEA,EAAA,MAAM,aAA2C,GAAA,OAAA;AAAA,IAC/C,OAAO;AAAA,MACL,QAAA,EAAU,KAAO,EAAA,QAAA,IAAY,aAAc,CAAA,QAAA;AAAA,MAC3C,eAAA,EAAiB,KAAO,EAAA,eAAA,IAAmB,aAAc,CAAA,eAAA;AAAA,MACzD,aAAA,EAAe,OAAO,aAAiB,IAAA,aAAA;AAAA,MACvC,OAAA;AAAA,MACA,OAAA,EAAS,OAAO,OAAW,IAAA,KAAA;AAAA,MAC3B,eAAA,EAAiB,KAAO,EAAA,eAAA,IAAmB,aAAc,CAAA,eAAA;AAAA,MACzD,OAAO,KAAO,EAAA,KAAA;AAAA,MACd,YACE,KAAO,EAAA,UAAA,IAAA,CAAe,KAAO,EAAA,QAAA,IAAY,cAAc,QAAU,EAAA,MAAA;AAAA,MACnE,KAAA,EAAO,OAAO,KAAS,IAAA,EAAA;AAAA,MACvB,QAAQ,KAAO,EAAA,MAAA;AAAA,MACf,QAAA,EAAU,KAAO,EAAA,QAAA,KAAa,MAAM;AAAA,OAAC,CAAA;AAAA,MACrC,WAAW,KAAO,EAAA,SAAA;AAAA,MAClB,cAAA,EAAgB,OAAO,cAAkB,IAAA,MAAA;AAAA,KAC3C,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,aAAe,EAAA,OAAA,EAAS,aAAa,CAAA;AAAA,GAC/C,CAAA;AAEA,EAAA,2CACG,iBAAkB,CAAA,QAAA,EAAlB,EAA2B,KAAA,EAAO,iBAChC,QACH,CAAA,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -339,6 +339,7 @@ type EntityRefLinkProps = {
|
|
|
339
339
|
title?: string;
|
|
340
340
|
children?: React__default.ReactNode;
|
|
341
341
|
hideIcon?: boolean;
|
|
342
|
+
disableTooltip?: boolean;
|
|
342
343
|
} & Omit<LinkProps, 'to'>;
|
|
343
344
|
/**
|
|
344
345
|
* Shows a clickable link to an entity.
|
|
@@ -928,11 +929,6 @@ declare function entityRouteParams(entity: Entity): {
|
|
|
928
929
|
readonly name: string;
|
|
929
930
|
};
|
|
930
931
|
|
|
931
|
-
/** @public */
|
|
932
|
-
declare function MockEntityListContextProvider<T extends DefaultEntityFilters = DefaultEntityFilters>(props: PropsWithChildren<{
|
|
933
|
-
value?: Partial<EntityListContextProps<T>>;
|
|
934
|
-
}>): React__default.JSX.Element;
|
|
935
|
-
|
|
936
932
|
/** @public */
|
|
937
933
|
type CatalogReactComponentsNameToClassKey = {
|
|
938
934
|
CatalogReactUserListPicker: CatalogReactUserListPickerClassKey;
|
|
@@ -972,4 +968,12 @@ type EntitySourceLocation = {
|
|
|
972
968
|
/** @public */
|
|
973
969
|
declare function getEntitySourceLocation(entity: Entity, scmIntegrationsApi: typeof scmIntegrationsApiRef.T): EntitySourceLocation | undefined;
|
|
974
970
|
|
|
971
|
+
/**
|
|
972
|
+
* @public
|
|
973
|
+
* @deprecated Moved to `@backstage/plugin-catalog-react/testUtils`
|
|
974
|
+
*/
|
|
975
|
+
declare function MockEntityListContextProvider<T extends DefaultEntityFilters = DefaultEntityFilters>(props: PropsWithChildren<{
|
|
976
|
+
value?: Partial<EntityListContextProps<T>>;
|
|
977
|
+
}>): React__default.JSX.Element;
|
|
978
|
+
|
|
975
979
|
export { type AllowedEntityFilters, AsyncEntityProvider, type AsyncEntityProviderProps, type BackstageOverrides, CatalogFilterLayout, type CatalogReactComponentsNameToClassKey, type CatalogReactEntityAutocompletePickerClassKey, type CatalogReactEntityDisplayNameClassKey, type CatalogReactEntityLifecyclePickerClassKey, type CatalogReactEntityNamespacePickerClassKey, type CatalogReactEntityOwnerPickerClassKey, type CatalogReactEntityProcessingStatusPickerClassKey, type CatalogReactEntitySearchBarClassKey, type CatalogReactEntityTagPickerClassKey, type CatalogReactUserListPickerClassKey, type DefaultEntityFilters, DefaultFilters, type DefaultFiltersProps, EntityAutocompletePicker, type EntityAutocompletePickerProps, EntityDisplayName, type EntityDisplayNameProps, EntityErrorFilter, type EntityFilter, EntityKindFilter, EntityKindPicker, type EntityKindPickerProps, EntityLifecycleFilter, EntityLifecyclePicker, EntityListContext, type EntityListContextProps, type EntityListPagination, EntityListProvider, type EntityListProviderProps, type EntityLoadingStatus, EntityNamespaceFilter, EntityNamespacePicker, type EntityNamespacePickerProps, EntityOrphanFilter, EntityOwnerFilter, EntityOwnerPicker, type EntityOwnerPickerProps, EntityPeekAheadPopover, type EntityPeekAheadPopoverProps, type EntityPresentationApi, EntityProcessingStatusPicker, EntityProvider, type EntityProviderProps, EntityRefLink, type EntityRefLinkProps, EntityRefLinks, type EntityRefLinksProps, type EntityRefPresentation, type EntityRefPresentationSnapshot, EntitySearchBar, type EntitySourceLocation, EntityTable, type EntityTableProps, EntityTagFilter, EntityTagPicker, type EntityTagPickerProps, EntityTextFilter, EntityTypeFilter, EntityTypePicker, type EntityTypePickerProps, EntityUserFilter, FavoriteEntity, type FavoriteEntityProps, type FixedWidthFormControlLabelClassKey, InspectEntityDialog, MissingAnnotationEmptyState, type MissingAnnotationEmptyStateClassKey, MockEntityListContextProvider, MockStarredEntitiesApi, type PaginationMode, type StarredEntitiesApi, UnregisterEntityDialog, type UnregisterEntityDialogProps, UserListFilter, type UserListFilterKind, UserListPicker, type UserListPickerProps, catalogApiRef, columnFactories, defaultEntityPresentation, entityPresentationApiRef, entityRouteParams, entityRouteRef, getEntityRelations, getEntitySourceLocation, humanizeEntityRef, starredEntitiesApiRef, useAsyncEntity, useEntity, useEntityList, useEntityOwnership, useEntityPresentation, useEntityTypeFilter, useRelatedEntities, useStarredEntities, useStarredEntity };
|
package/dist/index.esm.js
CHANGED
|
@@ -37,8 +37,8 @@ export { useStarredEntity } from './hooks/useStarredEntity.esm.js';
|
|
|
37
37
|
export { useEntityOwnership } from './hooks/useEntityOwnership.esm.js';
|
|
38
38
|
export { EntityErrorFilter, EntityKindFilter, EntityLifecycleFilter, EntityNamespaceFilter, EntityOrphanFilter, EntityOwnerFilter, EntityTagFilter, EntityTextFilter, EntityTypeFilter, EntityUserFilter, UserListFilter } from './filters.esm.js';
|
|
39
39
|
export { entityRouteParams, entityRouteRef } from './routes.esm.js';
|
|
40
|
-
export { MockEntityListContextProvider } from './testUtils/providers.esm.js';
|
|
41
40
|
export { getEntityRelations } from './utils/getEntityRelations.esm.js';
|
|
42
41
|
export { getEntitySourceLocation } from './utils/getEntitySourceLocation.esm.js';
|
|
43
42
|
import '@backstage/catalog-model';
|
|
43
|
+
export { MockEntityListContextProvider } from './deprecated.esm.js';
|
|
44
44
|
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useState, useCallback, useMemo } from 'react';
|
|
2
|
+
import { EntityListContext } from '@backstage/plugin-catalog-react';
|
|
3
|
+
|
|
4
|
+
function MockEntityListContextProvider(props) {
|
|
5
|
+
const { children, value } = props;
|
|
6
|
+
const [filters, setFilters] = useState(value?.filters ?? {});
|
|
7
|
+
const updateFilters = useCallback(
|
|
8
|
+
(update) => {
|
|
9
|
+
setFilters((prevFilters) => {
|
|
10
|
+
const newFilters = typeof update === "function" ? update(prevFilters) : update;
|
|
11
|
+
return { ...prevFilters, ...newFilters };
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
[]
|
|
15
|
+
);
|
|
16
|
+
const defaultValues = useMemo(
|
|
17
|
+
() => ({
|
|
18
|
+
entities: [],
|
|
19
|
+
backendEntities: [],
|
|
20
|
+
queryParameters: {}
|
|
21
|
+
}),
|
|
22
|
+
[]
|
|
23
|
+
);
|
|
24
|
+
const resolvedValue = useMemo(
|
|
25
|
+
() => ({
|
|
26
|
+
entities: value?.entities ?? defaultValues.entities,
|
|
27
|
+
backendEntities: value?.backendEntities ?? defaultValues.backendEntities,
|
|
28
|
+
updateFilters: value?.updateFilters ?? updateFilters,
|
|
29
|
+
filters,
|
|
30
|
+
loading: value?.loading ?? false,
|
|
31
|
+
queryParameters: value?.queryParameters ?? defaultValues.queryParameters,
|
|
32
|
+
error: value?.error,
|
|
33
|
+
totalItems: value?.totalItems ?? (value?.entities ?? defaultValues.entities).length,
|
|
34
|
+
limit: value?.limit ?? 20,
|
|
35
|
+
offset: value?.offset,
|
|
36
|
+
setLimit: value?.setLimit ?? (() => {
|
|
37
|
+
}),
|
|
38
|
+
setOffset: value?.setOffset,
|
|
39
|
+
paginationMode: value?.paginationMode ?? "none"
|
|
40
|
+
}),
|
|
41
|
+
[value, defaultValues, filters, updateFilters]
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ React.createElement(EntityListContext.Provider, { value: resolvedValue }, children);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { MockEntityListContextProvider };
|
|
47
|
+
//# sourceMappingURL=MockEntityListContextProvider.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MockEntityListContextProvider.esm.js","sources":["../../src/testUtils/MockEntityListContextProvider.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n PropsWithChildren,\n useCallback,\n useMemo,\n useState,\n} from 'react';\nimport {\n DefaultEntityFilters,\n EntityListContext,\n EntityListContextProps,\n} from '@backstage/plugin-catalog-react';\n\n/**\n * Simplifies testing of code that uses the entity list hooks.\n *\n * @public\n */\nexport function MockEntityListContextProvider<\n T extends DefaultEntityFilters = DefaultEntityFilters,\n>(\n props: PropsWithChildren<{\n value?: Partial<EntityListContextProps<T>>;\n }>,\n) {\n const { children, value } = props;\n\n // Provides a default implementation that stores filter state, for testing components that\n // reflect filter state.\n const [filters, setFilters] = useState<T>(value?.filters ?? ({} as T));\n\n const updateFilters = useCallback(\n (update: Partial<T> | ((prevFilters: T) => Partial<T>)) => {\n setFilters(prevFilters => {\n const newFilters =\n typeof update === 'function' ? update(prevFilters) : update;\n return { ...prevFilters, ...newFilters };\n });\n },\n [],\n );\n\n // Memoize the default values since pickers have useEffect triggers on these; naively defaulting\n // below with `?? <X>` breaks referential equality on subsequent updates.\n const defaultValues = useMemo(\n () => ({\n entities: [],\n backendEntities: [],\n queryParameters: {},\n }),\n [],\n );\n\n const resolvedValue: EntityListContextProps<T> = useMemo(\n () => ({\n entities: value?.entities ?? defaultValues.entities,\n backendEntities: value?.backendEntities ?? defaultValues.backendEntities,\n updateFilters: value?.updateFilters ?? updateFilters,\n filters,\n loading: value?.loading ?? false,\n queryParameters: value?.queryParameters ?? defaultValues.queryParameters,\n error: value?.error,\n totalItems:\n value?.totalItems ?? (value?.entities ?? defaultValues.entities).length,\n limit: value?.limit ?? 20,\n offset: value?.offset,\n setLimit: value?.setLimit ?? (() => {}),\n setOffset: value?.setOffset,\n paginationMode: value?.paginationMode ?? 'none',\n }),\n [value, defaultValues, filters, updateFilters],\n );\n\n return (\n <EntityListContext.Provider value={resolvedValue}>\n {children}\n </EntityListContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;AAiCO,SAAS,8BAGd,KAGA,EAAA;AACA,EAAM,MAAA,EAAE,QAAU,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAI5B,EAAM,MAAA,CAAC,SAAS,UAAU,CAAA,GAAI,SAAY,KAAO,EAAA,OAAA,IAAY,EAAQ,CAAA,CAAA;AAErE,EAAA,MAAM,aAAgB,GAAA,WAAA;AAAA,IACpB,CAAC,MAA0D,KAAA;AACzD,MAAA,UAAA,CAAW,CAAe,WAAA,KAAA;AACxB,QAAA,MAAM,aACJ,OAAO,MAAA,KAAW,UAAa,GAAA,MAAA,CAAO,WAAW,CAAI,GAAA,MAAA,CAAA;AACvD,QAAA,OAAO,EAAE,GAAG,WAAa,EAAA,GAAG,UAAW,EAAA,CAAA;AAAA,OACxC,CAAA,CAAA;AAAA,KACH;AAAA,IACA,EAAC;AAAA,GACH,CAAA;AAIA,EAAA,MAAM,aAAgB,GAAA,OAAA;AAAA,IACpB,OAAO;AAAA,MACL,UAAU,EAAC;AAAA,MACX,iBAAiB,EAAC;AAAA,MAClB,iBAAiB,EAAC;AAAA,KACpB,CAAA;AAAA,IACA,EAAC;AAAA,GACH,CAAA;AAEA,EAAA,MAAM,aAA2C,GAAA,OAAA;AAAA,IAC/C,OAAO;AAAA,MACL,QAAA,EAAU,KAAO,EAAA,QAAA,IAAY,aAAc,CAAA,QAAA;AAAA,MAC3C,eAAA,EAAiB,KAAO,EAAA,eAAA,IAAmB,aAAc,CAAA,eAAA;AAAA,MACzD,aAAA,EAAe,OAAO,aAAiB,IAAA,aAAA;AAAA,MACvC,OAAA;AAAA,MACA,OAAA,EAAS,OAAO,OAAW,IAAA,KAAA;AAAA,MAC3B,eAAA,EAAiB,KAAO,EAAA,eAAA,IAAmB,aAAc,CAAA,eAAA;AAAA,MACzD,OAAO,KAAO,EAAA,KAAA;AAAA,MACd,YACE,KAAO,EAAA,UAAA,IAAA,CAAe,KAAO,EAAA,QAAA,IAAY,cAAc,QAAU,EAAA,MAAA;AAAA,MACnE,KAAA,EAAO,OAAO,KAAS,IAAA,EAAA;AAAA,MACvB,QAAQ,KAAO,EAAA,MAAA;AAAA,MACf,QAAA,EAAU,KAAO,EAAA,QAAA,KAAa,MAAM;AAAA,OAAC,CAAA;AAAA,MACrC,WAAW,KAAO,EAAA,SAAA;AAAA,MAClB,cAAA,EAAgB,OAAO,cAAkB,IAAA,MAAA;AAAA,KAC3C,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,aAAe,EAAA,OAAA,EAAS,aAAa,CAAA;AAAA,GAC/C,CAAA;AAEA,EAAA,2CACG,iBAAkB,CAAA,QAAA,EAAlB,EAA2B,KAAA,EAAO,iBAChC,QACH,CAAA,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createApiFactory } from '@backstage/frontend-plugin-api';
|
|
2
|
+
import { InMemoryCatalogClient } from '@backstage/catalog-client/testUtils';
|
|
3
|
+
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
4
|
+
|
|
5
|
+
function simpleMock(ref, mockFactory) {
|
|
6
|
+
return (partialImpl) => {
|
|
7
|
+
const mock = mockFactory();
|
|
8
|
+
if (partialImpl) {
|
|
9
|
+
for (const [key, impl] of Object.entries(partialImpl)) {
|
|
10
|
+
if (typeof impl === "function") {
|
|
11
|
+
mock[key].mockImplementation(impl);
|
|
12
|
+
} else {
|
|
13
|
+
mock[key] = impl;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return Object.assign(mock, {
|
|
18
|
+
factory: createApiFactory({
|
|
19
|
+
api: ref,
|
|
20
|
+
deps: {},
|
|
21
|
+
factory: () => mock
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function catalogApiMock(options) {
|
|
27
|
+
return new InMemoryCatalogClient(options);
|
|
28
|
+
}
|
|
29
|
+
((catalogApiMock2) => {
|
|
30
|
+
catalogApiMock2.factory = (options) => createApiFactory({
|
|
31
|
+
api: catalogApiRef,
|
|
32
|
+
deps: {},
|
|
33
|
+
factory: () => new InMemoryCatalogClient(options)
|
|
34
|
+
});
|
|
35
|
+
catalogApiMock2.mock = simpleMock(catalogApiRef, () => ({
|
|
36
|
+
getEntities: jest.fn(),
|
|
37
|
+
getEntitiesByRefs: jest.fn(),
|
|
38
|
+
queryEntities: jest.fn(),
|
|
39
|
+
getEntityAncestors: jest.fn(),
|
|
40
|
+
getEntityByRef: jest.fn(),
|
|
41
|
+
removeEntityByUid: jest.fn(),
|
|
42
|
+
refreshEntity: jest.fn(),
|
|
43
|
+
getEntityFacets: jest.fn(),
|
|
44
|
+
getLocationById: jest.fn(),
|
|
45
|
+
getLocationByRef: jest.fn(),
|
|
46
|
+
addLocation: jest.fn(),
|
|
47
|
+
removeLocationById: jest.fn(),
|
|
48
|
+
getLocationByEntity: jest.fn(),
|
|
49
|
+
validateEntity: jest.fn()
|
|
50
|
+
}));
|
|
51
|
+
})(catalogApiMock || (catalogApiMock = {}));
|
|
52
|
+
|
|
53
|
+
export { catalogApiMock };
|
|
54
|
+
//# sourceMappingURL=catalogApiMock.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalogApiMock.esm.js","sources":["../../src/testUtils/catalogApiMock.ts"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiFactory,\n ApiRef,\n createApiFactory,\n} from '@backstage/frontend-plugin-api';\nimport { InMemoryCatalogClient } from '@backstage/catalog-client/testUtils';\nimport { Entity } from '@backstage/catalog-model';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { CatalogApi } from '@backstage/catalog-client';\nimport { ApiMock } from '@backstage/frontend-test-utils';\n\n/** @internal */\nfunction simpleMock<TApi>(\n ref: ApiRef<TApi>,\n mockFactory: () => jest.Mocked<TApi>,\n): (partialImpl?: Partial<TApi>) => ApiMock<TApi> {\n return partialImpl => {\n const mock = mockFactory();\n if (partialImpl) {\n for (const [key, impl] of Object.entries(partialImpl)) {\n if (typeof impl === 'function') {\n (mock as any)[key].mockImplementation(impl);\n } else {\n (mock as any)[key] = impl;\n }\n }\n }\n return Object.assign(mock, {\n factory: createApiFactory({\n api: ref,\n deps: {},\n factory: () => mock,\n }),\n }) as ApiMock<TApi>;\n };\n}\n\n/**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n *\n * @public\n */\nexport function catalogApiMock(options?: { entities?: Entity[] }): CatalogApi {\n return new InMemoryCatalogClient(options);\n}\n\n/**\n * A collection of mock functionality for the catalog service.\n *\n * @public\n */\nexport namespace catalogApiMock {\n /**\n * Creates a fake catalog client that handles entities in memory storage. Note\n * that this client may be severely limited in functionality, and advanced\n * functions may not be available at all.\n */\n export const factory = (options?: {\n entities?: Entity[];\n }): ApiFactory<CatalogApi, CatalogApi, {}> =>\n createApiFactory({\n api: catalogApiRef,\n deps: {},\n factory: () => new InMemoryCatalogClient(options),\n });\n /**\n * Creates a catalog client whose methods are mock functions, possibly with\n * some of them overloaded by the caller.\n */\n export const mock = simpleMock(catalogApiRef, () => ({\n getEntities: jest.fn(),\n getEntitiesByRefs: jest.fn(),\n queryEntities: jest.fn(),\n getEntityAncestors: jest.fn(),\n getEntityByRef: jest.fn(),\n removeEntityByUid: jest.fn(),\n refreshEntity: jest.fn(),\n getEntityFacets: jest.fn(),\n getLocationById: jest.fn(),\n getLocationByRef: jest.fn(),\n addLocation: jest.fn(),\n removeLocationById: jest.fn(),\n getLocationByEntity: jest.fn(),\n validateEntity: jest.fn(),\n }));\n}\n"],"names":["catalogApiMock"],"mappings":";;;;AA4BA,SAAS,UAAA,CACP,KACA,WACgD,EAAA;AAChD,EAAA,OAAO,CAAe,WAAA,KAAA;AACpB,IAAA,MAAM,OAAO,WAAY,EAAA,CAAA;AACzB,IAAA,IAAI,WAAa,EAAA;AACf,MAAA,KAAA,MAAW,CAAC,GAAK,EAAA,IAAI,KAAK,MAAO,CAAA,OAAA,CAAQ,WAAW,CAAG,EAAA;AACrD,QAAI,IAAA,OAAO,SAAS,UAAY,EAAA;AAC9B,UAAC,IAAa,CAAA,GAAG,CAAE,CAAA,kBAAA,CAAmB,IAAI,CAAA,CAAA;AAAA,SACrC,MAAA;AACL,UAAC,IAAA,CAAa,GAAG,CAAI,GAAA,IAAA,CAAA;AAAA,SACvB;AAAA,OACF;AAAA,KACF;AACA,IAAO,OAAA,MAAA,CAAO,OAAO,IAAM,EAAA;AAAA,MACzB,SAAS,gBAAiB,CAAA;AAAA,QACxB,GAAK,EAAA,GAAA;AAAA,QACL,MAAM,EAAC;AAAA,QACP,SAAS,MAAM,IAAA;AAAA,OAChB,CAAA;AAAA,KACF,CAAA,CAAA;AAAA,GACH,CAAA;AACF,CAAA;AASO,SAAS,eAAe,OAA+C,EAAA;AAC5E,EAAO,OAAA,IAAI,sBAAsB,OAAO,CAAA,CAAA;AAC1C,CAAA;AAAA,CAOO,CAAUA,eAAV,KAAA;AAME,EAAMA,eAAA,CAAA,OAAA,GAAU,CAAC,OAAA,KAGtB,gBAAiB,CAAA;AAAA,IACf,GAAK,EAAA,aAAA;AAAA,IACL,MAAM,EAAC;AAAA,IACP,OAAS,EAAA,MAAM,IAAI,qBAAA,CAAsB,OAAO,CAAA;AAAA,GACjD,CAAA,CAAA;AAKI,EAAMA,eAAA,CAAA,IAAA,GAAO,UAAW,CAAA,aAAA,EAAe,OAAO;AAAA,IACnD,WAAA,EAAa,KAAK,EAAG,EAAA;AAAA,IACrB,iBAAA,EAAmB,KAAK,EAAG,EAAA;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAG,EAAA;AAAA,IACvB,kBAAA,EAAoB,KAAK,EAAG,EAAA;AAAA,IAC5B,cAAA,EAAgB,KAAK,EAAG,EAAA;AAAA,IACxB,iBAAA,EAAmB,KAAK,EAAG,EAAA;AAAA,IAC3B,aAAA,EAAe,KAAK,EAAG,EAAA;AAAA,IACvB,eAAA,EAAiB,KAAK,EAAG,EAAA;AAAA,IACzB,eAAA,EAAiB,KAAK,EAAG,EAAA;AAAA,IACzB,gBAAA,EAAkB,KAAK,EAAG,EAAA;AAAA,IAC1B,WAAA,EAAa,KAAK,EAAG,EAAA;AAAA,IACrB,kBAAA,EAAoB,KAAK,EAAG,EAAA;AAAA,IAC5B,mBAAA,EAAqB,KAAK,EAAG,EAAA;AAAA,IAC7B,cAAA,EAAgB,KAAK,EAAG,EAAA;AAAA,GACxB,CAAA,CAAA,CAAA;AAAA,CAjCa,EAAA,cAAA,KAAA,cAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ApiFactory } from '@backstage/frontend-plugin-api';
|
|
2
|
+
import { Entity } from '@backstage/catalog-model';
|
|
3
|
+
import { CatalogApi } from '@backstage/catalog-client';
|
|
4
|
+
import { ApiMock } from '@backstage/frontend-test-utils';
|
|
5
|
+
import React__default, { PropsWithChildren } from 'react';
|
|
6
|
+
import { DefaultEntityFilters, EntityListContextProps } from '@backstage/plugin-catalog-react';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a fake catalog client that handles entities in memory storage. Note
|
|
10
|
+
* that this client may be severely limited in functionality, and advanced
|
|
11
|
+
* functions may not be available at all.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
declare function catalogApiMock(options?: {
|
|
16
|
+
entities?: Entity[];
|
|
17
|
+
}): CatalogApi;
|
|
18
|
+
/**
|
|
19
|
+
* A collection of mock functionality for the catalog service.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
declare namespace catalogApiMock {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a fake catalog client that handles entities in memory storage. Note
|
|
26
|
+
* that this client may be severely limited in functionality, and advanced
|
|
27
|
+
* functions may not be available at all.
|
|
28
|
+
*/
|
|
29
|
+
const factory: (options?: {
|
|
30
|
+
entities?: Entity[];
|
|
31
|
+
}) => ApiFactory<CatalogApi, CatalogApi, {}>;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a catalog client whose methods are mock functions, possibly with
|
|
34
|
+
* some of them overloaded by the caller.
|
|
35
|
+
*/
|
|
36
|
+
const mock: (partialImpl?: Partial<CatalogApi> | undefined) => ApiMock<CatalogApi>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Simplifies testing of code that uses the entity list hooks.
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
declare function MockEntityListContextProvider<T extends DefaultEntityFilters = DefaultEntityFilters>(props: PropsWithChildren<{
|
|
45
|
+
value?: Partial<EntityListContextProps<T>>;
|
|
46
|
+
}>): React__default.JSX.Element;
|
|
47
|
+
|
|
48
|
+
export { MockEntityListContextProvider, catalogApiMock };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testUtils.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0-next.2",
|
|
4
4
|
"description": "A frontend library that helps other Backstage plugins interact with the catalog",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library",
|
|
@@ -38,13 +38,19 @@
|
|
|
38
38
|
"types": "./dist/alpha.d.ts",
|
|
39
39
|
"default": "./dist/alpha.esm.js"
|
|
40
40
|
},
|
|
41
|
+
"./testUtils": {
|
|
42
|
+
"import": "./dist/testUtils.esm.js",
|
|
43
|
+
"types": "./dist/testUtils.d.ts",
|
|
44
|
+
"default": "./dist/testUtils.esm.js"
|
|
45
|
+
},
|
|
41
46
|
"./package.json": "./package.json"
|
|
42
47
|
},
|
|
43
48
|
"main": "./dist/index.esm.js",
|
|
44
49
|
"types": "./dist/index.d.ts",
|
|
45
50
|
"files": [
|
|
46
51
|
"dist",
|
|
47
|
-
"alpha"
|
|
52
|
+
"alpha",
|
|
53
|
+
"testUtils"
|
|
48
54
|
],
|
|
49
55
|
"scripts": {
|
|
50
56
|
"build": "backstage-cli package build",
|
|
@@ -56,24 +62,24 @@
|
|
|
56
62
|
"test": "backstage-cli package test"
|
|
57
63
|
},
|
|
58
64
|
"dependencies": {
|
|
59
|
-
"@backstage/catalog-client": "
|
|
60
|
-
"@backstage/catalog-model": "
|
|
61
|
-
"@backstage/core-compat-api": "
|
|
62
|
-
"@backstage/core-components": "
|
|
63
|
-
"@backstage/core-plugin-api": "
|
|
64
|
-
"@backstage/errors": "
|
|
65
|
-
"@backstage/frontend-plugin-api": "
|
|
66
|
-
"@backstage/
|
|
67
|
-
"@backstage/
|
|
68
|
-
"@backstage/plugin-
|
|
69
|
-
"@backstage/plugin-permission-
|
|
70
|
-
"@backstage/
|
|
71
|
-
"@backstage/
|
|
65
|
+
"@backstage/catalog-client": "1.7.1-next.0",
|
|
66
|
+
"@backstage/catalog-model": "1.7.0",
|
|
67
|
+
"@backstage/core-compat-api": "0.3.1-next.2",
|
|
68
|
+
"@backstage/core-components": "0.15.1-next.2",
|
|
69
|
+
"@backstage/core-plugin-api": "1.10.0-next.1",
|
|
70
|
+
"@backstage/errors": "1.2.4",
|
|
71
|
+
"@backstage/frontend-plugin-api": "0.9.0-next.2",
|
|
72
|
+
"@backstage/frontend-test-utils": "0.2.1-next.2",
|
|
73
|
+
"@backstage/integration-react": "1.2.0-next.2",
|
|
74
|
+
"@backstage/plugin-catalog-common": "1.1.0",
|
|
75
|
+
"@backstage/plugin-permission-common": "0.8.1",
|
|
76
|
+
"@backstage/plugin-permission-react": "0.4.27-next.1",
|
|
77
|
+
"@backstage/types": "1.1.1",
|
|
78
|
+
"@backstage/version-bridge": "1.0.10-next.0",
|
|
72
79
|
"@material-ui/core": "^4.12.2",
|
|
73
80
|
"@material-ui/icons": "^4.9.1",
|
|
74
81
|
"@material-ui/lab": "4.0.0-alpha.61",
|
|
75
82
|
"@react-hookz/web": "^24.0.0",
|
|
76
|
-
"@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
77
83
|
"classnames": "^2.2.6",
|
|
78
84
|
"lodash": "^4.17.21",
|
|
79
85
|
"material-ui-popup-state": "^1.9.3",
|
|
@@ -83,23 +89,32 @@
|
|
|
83
89
|
"zen-observable": "^0.10.0"
|
|
84
90
|
},
|
|
85
91
|
"devDependencies": {
|
|
86
|
-
"@backstage/cli": "
|
|
87
|
-
"@backstage/core-app-api": "
|
|
88
|
-
"@backstage/
|
|
89
|
-
"@backstage/plugin-
|
|
90
|
-
"@backstage/
|
|
91
|
-
"@backstage/test-utils": "^1.6.0",
|
|
92
|
+
"@backstage/cli": "0.28.0-next.2",
|
|
93
|
+
"@backstage/core-app-api": "1.15.1-next.1",
|
|
94
|
+
"@backstage/plugin-catalog-common": "1.1.0",
|
|
95
|
+
"@backstage/plugin-scaffolder-common": "1.5.6",
|
|
96
|
+
"@backstage/test-utils": "1.6.1-next.2",
|
|
92
97
|
"@testing-library/dom": "^10.0.0",
|
|
93
98
|
"@testing-library/jest-dom": "^6.0.0",
|
|
94
99
|
"@testing-library/react": "^16.0.0",
|
|
95
100
|
"@testing-library/user-event": "^14.0.0",
|
|
101
|
+
"@types/react": "^18.0.0",
|
|
96
102
|
"@types/zen-observable": "^0.8.0",
|
|
103
|
+
"react": "^18.0.2",
|
|
104
|
+
"react-dom": "^18.0.2",
|
|
105
|
+
"react-router-dom": "^6.3.0",
|
|
97
106
|
"react-test-renderer": "^16.13.1"
|
|
98
107
|
},
|
|
99
108
|
"peerDependencies": {
|
|
109
|
+
"@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
100
110
|
"react": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
101
111
|
"react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
|
|
102
112
|
"react-router-dom": "6.0.0-beta.0 || ^6.3.0"
|
|
103
113
|
},
|
|
114
|
+
"peerDependenciesMeta": {
|
|
115
|
+
"@types/react": {
|
|
116
|
+
"optional": true
|
|
117
|
+
}
|
|
118
|
+
},
|
|
104
119
|
"module": "./dist/index.esm.js"
|
|
105
120
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"providers.esm.js","sources":["../../src/testUtils/providers.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, {\n PropsWithChildren,\n useCallback,\n useMemo,\n useState,\n} from 'react';\nimport {\n DefaultEntityFilters,\n EntityListContext,\n EntityListContextProps,\n} from '../hooks/useEntityListProvider';\n\n/** @public */\nexport function MockEntityListContextProvider<\n T extends DefaultEntityFilters = DefaultEntityFilters,\n>(\n props: PropsWithChildren<{\n value?: Partial<EntityListContextProps<T>>;\n }>,\n) {\n const { children, value } = props;\n\n // Provides a default implementation that stores filter state, for testing components that\n // reflect filter state.\n const [filters, setFilters] = useState<T>(value?.filters ?? ({} as T));\n\n const updateFilters = useCallback(\n (update: Partial<T> | ((prevFilters: T) => Partial<T>)) => {\n setFilters(prevFilters => {\n const newFilters =\n typeof update === 'function' ? update(prevFilters) : update;\n return { ...prevFilters, ...newFilters };\n });\n },\n [],\n );\n\n // Memoize the default values since pickers have useEffect triggers on these; naively defaulting\n // below with `?? <X>` breaks referential equality on subsequent updates.\n const defaultValues = useMemo(\n () => ({\n entities: [],\n backendEntities: [],\n queryParameters: {},\n }),\n [],\n );\n\n const resolvedValue: EntityListContextProps<T> = useMemo(\n () => ({\n entities: value?.entities ?? defaultValues.entities,\n backendEntities: value?.backendEntities ?? defaultValues.backendEntities,\n updateFilters: value?.updateFilters ?? updateFilters,\n filters,\n loading: value?.loading ?? false,\n queryParameters: value?.queryParameters ?? defaultValues.queryParameters,\n error: value?.error,\n totalItems:\n value?.totalItems ?? (value?.entities ?? defaultValues.entities).length,\n limit: value?.limit ?? 20,\n offset: value?.offset,\n setLimit: value?.setLimit ?? (() => {}),\n setOffset: value?.setOffset,\n paginationMode: value?.paginationMode ?? 'none',\n }),\n [value, defaultValues, filters, updateFilters],\n );\n\n return (\n <EntityListContext.Provider value={resolvedValue}>\n {children}\n </EntityListContext.Provider>\n );\n}\n"],"names":[],"mappings":";;;AA6BO,SAAS,8BAGd,KAGA,EAAA;AACA,EAAM,MAAA,EAAE,QAAU,EAAA,KAAA,EAAU,GAAA,KAAA,CAAA;AAI5B,EAAM,MAAA,CAAC,SAAS,UAAU,CAAA,GAAI,SAAY,KAAO,EAAA,OAAA,IAAY,EAAQ,CAAA,CAAA;AAErE,EAAA,MAAM,aAAgB,GAAA,WAAA;AAAA,IACpB,CAAC,MAA0D,KAAA;AACzD,MAAA,UAAA,CAAW,CAAe,WAAA,KAAA;AACxB,QAAA,MAAM,aACJ,OAAO,MAAA,KAAW,UAAa,GAAA,MAAA,CAAO,WAAW,CAAI,GAAA,MAAA,CAAA;AACvD,QAAA,OAAO,EAAE,GAAG,WAAa,EAAA,GAAG,UAAW,EAAA,CAAA;AAAA,OACxC,CAAA,CAAA;AAAA,KACH;AAAA,IACA,EAAC;AAAA,GACH,CAAA;AAIA,EAAA,MAAM,aAAgB,GAAA,OAAA;AAAA,IACpB,OAAO;AAAA,MACL,UAAU,EAAC;AAAA,MACX,iBAAiB,EAAC;AAAA,MAClB,iBAAiB,EAAC;AAAA,KACpB,CAAA;AAAA,IACA,EAAC;AAAA,GACH,CAAA;AAEA,EAAA,MAAM,aAA2C,GAAA,OAAA;AAAA,IAC/C,OAAO;AAAA,MACL,QAAA,EAAU,KAAO,EAAA,QAAA,IAAY,aAAc,CAAA,QAAA;AAAA,MAC3C,eAAA,EAAiB,KAAO,EAAA,eAAA,IAAmB,aAAc,CAAA,eAAA;AAAA,MACzD,aAAA,EAAe,OAAO,aAAiB,IAAA,aAAA;AAAA,MACvC,OAAA;AAAA,MACA,OAAA,EAAS,OAAO,OAAW,IAAA,KAAA;AAAA,MAC3B,eAAA,EAAiB,KAAO,EAAA,eAAA,IAAmB,aAAc,CAAA,eAAA;AAAA,MACzD,OAAO,KAAO,EAAA,KAAA;AAAA,MACd,YACE,KAAO,EAAA,UAAA,IAAA,CAAe,KAAO,EAAA,QAAA,IAAY,cAAc,QAAU,EAAA,MAAA;AAAA,MACnE,KAAA,EAAO,OAAO,KAAS,IAAA,EAAA;AAAA,MACvB,QAAQ,KAAO,EAAA,MAAA;AAAA,MACf,QAAA,EAAU,KAAO,EAAA,QAAA,KAAa,MAAM;AAAA,OAAC,CAAA;AAAA,MACrC,WAAW,KAAO,EAAA,SAAA;AAAA,MAClB,cAAA,EAAgB,OAAO,cAAkB,IAAA,MAAA;AAAA,KAC3C,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,aAAe,EAAA,OAAA,EAAS,aAAa,CAAA;AAAA,GAC/C,CAAA;AAEA,EAAA,2CACG,iBAAkB,CAAA,QAAA,EAAlB,EAA2B,KAAA,EAAO,iBAChC,QACH,CAAA,CAAA;AAEJ;;;;"}
|