@backstage/plugin-catalog 1.29.1-next.2 → 1.30.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/alpha/pages.esm.js +40 -27
- package/dist/alpha/pages.esm.js.map +1 -1
- package/dist/alpha.d.ts +30 -10
- package/dist/components/CatalogTable/CatalogTable.esm.js.map +1 -1
- package/dist/components/CatalogTable/CursorPaginatedCatalogTable.esm.js +0 -1
- package/dist/components/CatalogTable/CursorPaginatedCatalogTable.esm.js.map +1 -1
- package/dist/components/CatalogTable/OffsetPaginatedCatalogTable.esm.js +2 -8
- package/dist/components/CatalogTable/OffsetPaginatedCatalogTable.esm.js.map +1 -1
- package/package.json +23 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @backstage/plugin-catalog
|
|
2
2
|
|
|
3
|
+
## 1.30.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 970cb48: Show the pagination text for the offset-paginated catalog table, and remove the pagination bar from the top of the `CatalogTable` when pagination is enabled.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- fb58f20: Internal update to use the new `pluginId` option of `createFrontendPlugin`.
|
|
12
|
+
- 2ddbc50: A new `filter` parameter has been added to `EntityContextMenuItemBlueprint` to make it easier to configure which entities a menu item should appear for. The `filter` parameter is a function which accepts an entity and returns a boolean.
|
|
13
|
+
- bf85d37: Fix for missing `routeRef` when using `core-plugin-api` in a dialog context
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @backstage/frontend-plugin-api@0.10.2
|
|
16
|
+
- @backstage/core-components@0.17.2
|
|
17
|
+
- @backstage/catalog-model@1.7.4
|
|
18
|
+
- @backstage/core-compat-api@0.4.2
|
|
19
|
+
- @backstage/plugin-search-react@1.9.0
|
|
20
|
+
- @backstage/plugin-catalog-react@1.18.0
|
|
21
|
+
- @backstage/core-plugin-api@1.10.7
|
|
22
|
+
- @backstage/catalog-client@1.10.0
|
|
23
|
+
- @backstage/integration-react@1.2.7
|
|
24
|
+
- @backstage/plugin-permission-react@0.4.34
|
|
25
|
+
- @backstage/errors@1.2.7
|
|
26
|
+
- @backstage/types@1.2.1
|
|
27
|
+
- @backstage/version-bridge@1.0.11
|
|
28
|
+
- @backstage/plugin-catalog-common@1.1.4
|
|
29
|
+
- @backstage/plugin-scaffolder-common@1.5.11
|
|
30
|
+
- @backstage/plugin-search-common@1.2.18
|
|
31
|
+
|
|
32
|
+
## 1.30.0-next.3
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- 970cb48: Show the pagination text for the offset-paginated catalog table, and remove the pagination bar from the top of the `CatalogTable` when pagination is enabled.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies
|
|
41
|
+
- @backstage/plugin-search-react@1.9.0-next.2
|
|
42
|
+
- @backstage/core-compat-api@0.4.2-next.3
|
|
43
|
+
- @backstage/core-components@0.17.2-next.1
|
|
44
|
+
- @backstage/core-plugin-api@1.10.7-next.0
|
|
45
|
+
- @backstage/plugin-catalog-react@1.18.0-next.3
|
|
46
|
+
- @backstage/catalog-client@1.10.0-next.0
|
|
47
|
+
- @backstage/catalog-model@1.7.3
|
|
48
|
+
- @backstage/errors@1.2.7
|
|
49
|
+
- @backstage/frontend-plugin-api@0.10.2-next.1
|
|
50
|
+
- @backstage/integration-react@1.2.7-next.3
|
|
51
|
+
- @backstage/types@1.2.1
|
|
52
|
+
- @backstage/version-bridge@1.0.11
|
|
53
|
+
- @backstage/plugin-catalog-common@1.1.4-next.0
|
|
54
|
+
- @backstage/plugin-permission-react@0.4.34-next.1
|
|
55
|
+
- @backstage/plugin-scaffolder-common@1.5.11-next.0
|
|
56
|
+
- @backstage/plugin-search-common@1.2.18-next.0
|
|
57
|
+
|
|
3
58
|
## 1.29.1-next.2
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
package/dist/alpha/pages.esm.js
CHANGED
|
@@ -2,11 +2,10 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { convertLegacyRouteRef, compatWrapper } from '@backstage/core-compat-api';
|
|
3
3
|
import { PageBlueprint, createExtensionInput, coreExtensionData } from '@backstage/frontend-plugin-api';
|
|
4
4
|
import { entityRouteRef, AsyncEntityProvider } from '@backstage/plugin-catalog-react';
|
|
5
|
-
import { EntityHeaderBlueprint, EntityContentBlueprint, defaultEntityContentGroups } from '@backstage/plugin-catalog-react/alpha';
|
|
5
|
+
import { EntityHeaderBlueprint, EntityContentBlueprint, EntityContextMenuItemBlueprint, defaultEntityContentGroups } from '@backstage/plugin-catalog-react/alpha';
|
|
6
6
|
import { rootRouteRef } from '../routes.esm.js';
|
|
7
7
|
import { useEntityFromUrl } from '../components/CatalogEntityPage/useEntityFromUrl.esm.js';
|
|
8
8
|
import { buildFilterFn } from './filter/FilterWrapper.esm.js';
|
|
9
|
-
import { EntityHeader } from './components/EntityHeader/EntityHeader.esm.js';
|
|
10
9
|
|
|
11
10
|
const catalogPage = PageBlueprint.makeWithOverrides({
|
|
12
11
|
inputs: {
|
|
@@ -42,7 +41,10 @@ const catalogEntityPage = PageBlueprint.makeWithOverrides({
|
|
|
42
41
|
EntityContentBlueprint.dataRefs.filterExpression.optional(),
|
|
43
42
|
EntityContentBlueprint.dataRefs.group.optional()
|
|
44
43
|
]),
|
|
45
|
-
contextMenuItems: createExtensionInput([
|
|
44
|
+
contextMenuItems: createExtensionInput([
|
|
45
|
+
coreExtensionData.reactElement,
|
|
46
|
+
EntityContextMenuItemBlueprint.dataRefs.filterFunction.optional()
|
|
47
|
+
])
|
|
46
48
|
},
|
|
47
49
|
config: {
|
|
48
50
|
schema: {
|
|
@@ -55,12 +57,13 @@ const catalogEntityPage = PageBlueprint.makeWithOverrides({
|
|
|
55
57
|
routeRef: convertLegacyRouteRef(entityRouteRef),
|
|
56
58
|
loader: async () => {
|
|
57
59
|
const { EntityLayout } = await import('./components/EntityLayout/index.esm.js');
|
|
58
|
-
const menuItems = inputs.contextMenuItems.map(
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
const menuItems = inputs.contextMenuItems.map((item) => ({
|
|
61
|
+
element: item.get(coreExtensionData.reactElement),
|
|
62
|
+
filter: item.get(EntityContextMenuItemBlueprint.dataRefs.filterFunction) ?? (() => true)
|
|
63
|
+
}));
|
|
61
64
|
const header = inputs.header?.get(
|
|
62
65
|
EntityHeaderBlueprint.dataRefs.element
|
|
63
|
-
)
|
|
66
|
+
);
|
|
64
67
|
let groups = Object.entries(defaultEntityContentGroups).reduce(
|
|
65
68
|
(rest, group) => {
|
|
66
69
|
const [groupId, groupValue] = group;
|
|
@@ -92,26 +95,36 @@ const catalogEntityPage = PageBlueprint.makeWithOverrides({
|
|
|
92
95
|
group.items.push(output);
|
|
93
96
|
}
|
|
94
97
|
const Component = () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
const entityFromUrl = useEntityFromUrl();
|
|
99
|
+
const { entity } = entityFromUrl;
|
|
100
|
+
const filteredMenuItems = entity ? menuItems.filter((i) => i.filter(entity)).map((i) => i.element) : [];
|
|
101
|
+
return /* @__PURE__ */ jsx(AsyncEntityProvider, { ...entityFromUrl, children: /* @__PURE__ */ jsx(
|
|
102
|
+
EntityLayout,
|
|
103
|
+
{
|
|
104
|
+
header,
|
|
105
|
+
contextMenuItems: filteredMenuItems,
|
|
106
|
+
children: Object.values(groups).flatMap(
|
|
107
|
+
({ title, items }) => items.map((output) => /* @__PURE__ */ jsx(
|
|
108
|
+
EntityLayout.Route,
|
|
109
|
+
{
|
|
110
|
+
group: title,
|
|
111
|
+
path: output.get(coreExtensionData.routePath),
|
|
112
|
+
title: output.get(EntityContentBlueprint.dataRefs.title),
|
|
113
|
+
if: buildFilterFn(
|
|
114
|
+
output.get(
|
|
115
|
+
EntityContentBlueprint.dataRefs.filterFunction
|
|
116
|
+
),
|
|
117
|
+
output.get(
|
|
118
|
+
EntityContentBlueprint.dataRefs.filterExpression
|
|
119
|
+
)
|
|
120
|
+
),
|
|
121
|
+
children: output.get(coreExtensionData.reactElement)
|
|
122
|
+
},
|
|
123
|
+
output.get(coreExtensionData.routePath)
|
|
124
|
+
))
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
) });
|
|
115
128
|
};
|
|
116
129
|
return compatWrapper(/* @__PURE__ */ jsx(Component, {}));
|
|
117
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages.esm.js","sources":["../../src/alpha/pages.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n coreExtensionData,\n createExtensionInput,\n PageBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n AsyncEntityProvider,\n entityRouteRef,\n} from '@backstage/plugin-catalog-react';\nimport {\n EntityHeaderBlueprint,\n EntityContentBlueprint,\n defaultEntityContentGroups,\n} from '@backstage/plugin-catalog-react/alpha';\nimport { rootRouteRef } from '../routes';\nimport { useEntityFromUrl } from '../components/CatalogEntityPage/useEntityFromUrl';\nimport { buildFilterFn } from './filter/FilterWrapper';\nimport { EntityHeader } from './components/EntityHeader';\n\nexport const catalogPage = PageBlueprint.makeWithOverrides({\n inputs: {\n filters: createExtensionInput([coreExtensionData.reactElement]),\n },\n factory(originalFactory, { inputs }) {\n return originalFactory({\n defaultPath: '/catalog',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: async () => {\n const { BaseCatalogPage } = await import('../components/CatalogPage');\n const filters = inputs.filters.map(filter =>\n filter.get(coreExtensionData.reactElement),\n );\n return compatWrapper(<BaseCatalogPage filters={<>{filters}</>} />);\n },\n });\n },\n});\n\nexport const catalogEntityPage = PageBlueprint.makeWithOverrides({\n name: 'entity',\n inputs: {\n header: createExtensionInput(\n [EntityHeaderBlueprint.dataRefs.element.optional()],\n { singleton: true, optional: true },\n ),\n contents: createExtensionInput([\n coreExtensionData.reactElement,\n coreExtensionData.routePath,\n coreExtensionData.routeRef.optional(),\n EntityContentBlueprint.dataRefs.title,\n EntityContentBlueprint.dataRefs.filterFunction.optional(),\n EntityContentBlueprint.dataRefs.filterExpression.optional(),\n EntityContentBlueprint.dataRefs.group.optional(),\n ]),\n contextMenuItems: createExtensionInput([coreExtensionData.reactElement]),\n },\n config: {\n schema: {\n groups: z =>\n z\n .array(z.record(z.string(), z.object({ title: z.string() })))\n .optional(),\n },\n },\n factory(originalFactory, { config, inputs }) {\n return originalFactory({\n defaultPath: '/catalog/:namespace/:kind/:name',\n routeRef: convertLegacyRouteRef(entityRouteRef),\n loader: async () => {\n const { EntityLayout } = await import('./components/EntityLayout');\n\n const menuItems = inputs.contextMenuItems.map(item =>\n item.get(coreExtensionData.reactElement),\n );\n\n type Groups = Record<\n string,\n { title: string; items: Array<(typeof inputs.contents)[0]> }\n >;\n\n const header = inputs.header?.get(\n EntityHeaderBlueprint.dataRefs.element,\n ) ?? <EntityHeader contextMenuItems={menuItems} />;\n\n let groups = Object.entries(defaultEntityContentGroups).reduce<Groups>(\n (rest, group) => {\n const [groupId, groupValue] = group;\n return {\n ...rest,\n [groupId]: { title: groupValue, items: [] },\n };\n },\n {},\n );\n\n // config groups override default groups\n if (config.groups) {\n groups = config.groups.reduce<Groups>((rest, group) => {\n const [groupId, groupValue] = Object.entries(group)[0];\n return {\n ...rest,\n [groupId]: { title: groupValue.title, items: [] },\n };\n }, {});\n }\n\n for (const output of inputs.contents) {\n const itemId = output.node.spec.id;\n const itemTitle = output.get(EntityContentBlueprint.dataRefs.title);\n const itemGroup = output.get(EntityContentBlueprint.dataRefs.group);\n const group = itemGroup && groups[itemGroup];\n if (!group) {\n groups[itemId] = { title: itemTitle, items: [output] };\n continue;\n }\n group.items.push(output);\n }\n\n const Component = () => {\n return (\n <AsyncEntityProvider {...useEntityFromUrl()}>\n <EntityLayout header={header} contextMenuItems={menuItems}>\n {Object.values(groups).flatMap(({ title, items }) =>\n items.map(output => (\n <EntityLayout.Route\n group={title}\n key={output.get(coreExtensionData.routePath)}\n path={output.get(coreExtensionData.routePath)}\n title={output.get(EntityContentBlueprint.dataRefs.title)}\n if={buildFilterFn(\n output.get(\n EntityContentBlueprint.dataRefs.filterFunction,\n ),\n output.get(\n EntityContentBlueprint.dataRefs.filterExpression,\n ),\n )}\n >\n {output.get(coreExtensionData.reactElement)}\n </EntityLayout.Route>\n )),\n )}\n </EntityLayout>\n </AsyncEntityProvider>\n );\n };\n\n return compatWrapper(<Component />);\n },\n });\n },\n});\n\nexport default [catalogPage, catalogEntityPage];\n"],"names":[],"mappings":";;;;;;;;;;AAuCa,MAAA,WAAA,GAAc,cAAc,iBAAkB,CAAA;AAAA,EACzD,MAAQ,EAAA;AAAA,IACN,OAAS,EAAA,oBAAA,CAAqB,CAAC,iBAAA,CAAkB,YAAY,CAAC;AAAA,GAChE;AAAA,EACA,OAAQ,CAAA,eAAA,EAAiB,EAAE,MAAA,EAAU,EAAA;AACnC,IAAA,OAAO,eAAgB,CAAA;AAAA,MACrB,WAAa,EAAA,UAAA;AAAA,MACb,QAAA,EAAU,sBA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A,gBACC,KAAO,EAAA,KAAA;AAAA,gBAEP,IAAM,EAAA,MAAA,CAAO,GAAI,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAAA,gBAC5C,KAAO,EAAA,MAAA,CAAO,GAAI,CAAA,sBAAA,CAAuB,SAAS,KAAK,CAAA;AAAA,gBACvD,EAAI,EAAA,aAAA;AAAA,kBACF,MAAO,CAAA,GAAA;AAAA,oBACL,uBAAuB,QAAS,CAAA;AAAA,mBAClC;AAAA,kBACA,MAAO,CAAA,GAAA;AAAA,oBACL,uBAAuB,QAAS,CAAA;AAAA;AAClC,iBACF;AAAA,gBAEC,QAAA,EAAA,MAAA,CAAO,GAAI,CAAA,iBAAA,CAAkB,YAAY;AAAA,eAAA;AAAA,cAZrC,MAAA,CAAO,GAAI,CAAA,iBAAA,CAAkB,SAAS;AAAA,aAc9C;AAAA,aAEL,CACF,EAAA,CAAA;AAAA,SAEJ;AAEA,QAAO,OAAA,aAAA,iBAAe,GAAA,CAAA,SAAA,EAAA,EAAU,CAAE,CAAA;AAAA;AACpC,KACD,CAAA;AAAA;AAEL,CAAC;AAED,YAAe,CAAC,aAAa,iBAAiB,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"pages.esm.js","sources":["../../src/alpha/pages.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 compatWrapper,\n convertLegacyRouteRef,\n} from '@backstage/core-compat-api';\nimport {\n coreExtensionData,\n createExtensionInput,\n PageBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n AsyncEntityProvider,\n entityRouteRef,\n} from '@backstage/plugin-catalog-react';\nimport {\n EntityHeaderBlueprint,\n EntityContentBlueprint,\n defaultEntityContentGroups,\n EntityContextMenuItemBlueprint,\n} from '@backstage/plugin-catalog-react/alpha';\nimport { rootRouteRef } from '../routes';\nimport { useEntityFromUrl } from '../components/CatalogEntityPage/useEntityFromUrl';\nimport { buildFilterFn } from './filter/FilterWrapper';\n\nexport const catalogPage = PageBlueprint.makeWithOverrides({\n inputs: {\n filters: createExtensionInput([coreExtensionData.reactElement]),\n },\n factory(originalFactory, { inputs }) {\n return originalFactory({\n defaultPath: '/catalog',\n routeRef: convertLegacyRouteRef(rootRouteRef),\n loader: async () => {\n const { BaseCatalogPage } = await import('../components/CatalogPage');\n const filters = inputs.filters.map(filter =>\n filter.get(coreExtensionData.reactElement),\n );\n return compatWrapper(<BaseCatalogPage filters={<>{filters}</>} />);\n },\n });\n },\n});\n\nexport const catalogEntityPage = PageBlueprint.makeWithOverrides({\n name: 'entity',\n inputs: {\n header: createExtensionInput(\n [EntityHeaderBlueprint.dataRefs.element.optional()],\n { singleton: true, optional: true },\n ),\n contents: createExtensionInput([\n coreExtensionData.reactElement,\n coreExtensionData.routePath,\n coreExtensionData.routeRef.optional(),\n EntityContentBlueprint.dataRefs.title,\n EntityContentBlueprint.dataRefs.filterFunction.optional(),\n EntityContentBlueprint.dataRefs.filterExpression.optional(),\n EntityContentBlueprint.dataRefs.group.optional(),\n ]),\n contextMenuItems: createExtensionInput([\n coreExtensionData.reactElement,\n EntityContextMenuItemBlueprint.dataRefs.filterFunction.optional(),\n ]),\n },\n config: {\n schema: {\n groups: z =>\n z\n .array(z.record(z.string(), z.object({ title: z.string() })))\n .optional(),\n },\n },\n factory(originalFactory, { config, inputs }) {\n return originalFactory({\n defaultPath: '/catalog/:namespace/:kind/:name',\n routeRef: convertLegacyRouteRef(entityRouteRef),\n loader: async () => {\n const { EntityLayout } = await import('./components/EntityLayout');\n\n const menuItems = inputs.contextMenuItems.map(item => ({\n element: item.get(coreExtensionData.reactElement),\n filter:\n item.get(EntityContextMenuItemBlueprint.dataRefs.filterFunction) ??\n (() => true),\n }));\n\n type Groups = Record<\n string,\n { title: string; items: Array<(typeof inputs.contents)[0]> }\n >;\n\n const header = inputs.header?.get(\n EntityHeaderBlueprint.dataRefs.element,\n );\n\n let groups = Object.entries(defaultEntityContentGroups).reduce<Groups>(\n (rest, group) => {\n const [groupId, groupValue] = group;\n return {\n ...rest,\n [groupId]: { title: groupValue, items: [] },\n };\n },\n {},\n );\n\n // config groups override default groups\n if (config.groups) {\n groups = config.groups.reduce<Groups>((rest, group) => {\n const [groupId, groupValue] = Object.entries(group)[0];\n return {\n ...rest,\n [groupId]: { title: groupValue.title, items: [] },\n };\n }, {});\n }\n\n for (const output of inputs.contents) {\n const itemId = output.node.spec.id;\n const itemTitle = output.get(EntityContentBlueprint.dataRefs.title);\n const itemGroup = output.get(EntityContentBlueprint.dataRefs.group);\n const group = itemGroup && groups[itemGroup];\n if (!group) {\n groups[itemId] = { title: itemTitle, items: [output] };\n continue;\n }\n group.items.push(output);\n }\n\n const Component = () => {\n const entityFromUrl = useEntityFromUrl();\n const { entity } = entityFromUrl;\n const filteredMenuItems = entity\n ? menuItems.filter(i => i.filter(entity)).map(i => i.element)\n : [];\n\n return (\n <AsyncEntityProvider {...entityFromUrl}>\n <EntityLayout\n header={header}\n contextMenuItems={filteredMenuItems}\n >\n {Object.values(groups).flatMap(({ title, items }) =>\n items.map(output => (\n <EntityLayout.Route\n group={title}\n key={output.get(coreExtensionData.routePath)}\n path={output.get(coreExtensionData.routePath)}\n title={output.get(EntityContentBlueprint.dataRefs.title)}\n if={buildFilterFn(\n output.get(\n EntityContentBlueprint.dataRefs.filterFunction,\n ),\n output.get(\n EntityContentBlueprint.dataRefs.filterExpression,\n ),\n )}\n >\n {output.get(coreExtensionData.reactElement)}\n </EntityLayout.Route>\n )),\n )}\n </EntityLayout>\n </AsyncEntityProvider>\n );\n };\n\n return compatWrapper(<Component />);\n },\n });\n },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MAAA,CAAO,GAAI,CAAA,iBAAA,CAAkB,SAAS;AAAA,iBAc9C;AAAA;AACH;AAAA,WAEJ,EAAA,CAAA;AAAA,SAEJ;AAEA,QAAO,OAAA,aAAA,iBAAe,GAAA,CAAA,SAAA,EAAA,EAAU,CAAE,CAAA;AAAA;AACpC,KACD,CAAA;AAAA;AAEL,CAAC;AAED,YAAe,CAAC,aAAa,iBAAiB,CAAA;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -481,27 +481,45 @@ declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{
|
|
|
481
481
|
"entity-context-menu-item:catalog/copy-entity-url": _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
482
482
|
kind: "entity-context-menu-item";
|
|
483
483
|
name: "copy-entity-url";
|
|
484
|
-
config: {
|
|
485
|
-
|
|
486
|
-
|
|
484
|
+
config: {
|
|
485
|
+
filter: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
486
|
+
};
|
|
487
|
+
configInput: {
|
|
488
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
489
|
+
};
|
|
490
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
491
|
+
optional: true;
|
|
492
|
+
}>;
|
|
487
493
|
inputs: {};
|
|
488
494
|
params: _backstage_plugin_catalog_react_alpha.EntityContextMenuItemParams;
|
|
489
495
|
}>;
|
|
490
496
|
"entity-context-menu-item:catalog/inspect-entity": _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
491
497
|
kind: "entity-context-menu-item";
|
|
492
498
|
name: "inspect-entity";
|
|
493
|
-
config: {
|
|
494
|
-
|
|
495
|
-
|
|
499
|
+
config: {
|
|
500
|
+
filter: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
501
|
+
};
|
|
502
|
+
configInput: {
|
|
503
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
504
|
+
};
|
|
505
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
506
|
+
optional: true;
|
|
507
|
+
}>;
|
|
496
508
|
inputs: {};
|
|
497
509
|
params: _backstage_plugin_catalog_react_alpha.EntityContextMenuItemParams;
|
|
498
510
|
}>;
|
|
499
511
|
"entity-context-menu-item:catalog/unregister-entity": _backstage_frontend_plugin_api.ExtensionDefinition<{
|
|
500
512
|
kind: "entity-context-menu-item";
|
|
501
513
|
name: "unregister-entity";
|
|
502
|
-
config: {
|
|
503
|
-
|
|
504
|
-
|
|
514
|
+
config: {
|
|
515
|
+
filter: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
516
|
+
};
|
|
517
|
+
configInput: {
|
|
518
|
+
filter?: _backstage_plugin_catalog_react_alpha.EntityPredicate | undefined;
|
|
519
|
+
};
|
|
520
|
+
output: _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
521
|
+
optional: true;
|
|
522
|
+
}>;
|
|
505
523
|
inputs: {};
|
|
506
524
|
params: _backstage_plugin_catalog_react_alpha.EntityContextMenuItemParams;
|
|
507
525
|
}>;
|
|
@@ -583,7 +601,9 @@ declare const _default: _backstage_frontend_plugin_api.FrontendPlugin<{
|
|
|
583
601
|
singleton: false;
|
|
584
602
|
optional: false;
|
|
585
603
|
}>;
|
|
586
|
-
contextMenuItems: _backstage_frontend_plugin_api.ExtensionInput<_backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}
|
|
604
|
+
contextMenuItems: _backstage_frontend_plugin_api.ExtensionInput<_backstage_frontend_plugin_api.ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | _backstage_frontend_plugin_api.ConfigurableExtensionDataRef<(entity: _backstage_catalog_model.Entity) => boolean, "catalog.entity-filter-function", {
|
|
605
|
+
optional: true;
|
|
606
|
+
}>, {
|
|
587
607
|
singleton: false;
|
|
588
608
|
optional: false;
|
|
589
609
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogTable.esm.js","sources":["../../../src/components/CatalogTable/CatalogTable.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 */\nimport {\n ANNOTATION_EDIT_URL,\n ANNOTATION_VIEW_URL,\n Entity,\n RELATION_OWNED_BY,\n RELATION_PART_OF,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n CodeSnippet,\n Table,\n TableColumn,\n TableProps,\n WarningPanel,\n} from '@backstage/core-components';\nimport {\n getEntityRelations,\n humanizeEntityRef,\n useEntityList,\n useStarredEntities,\n} from '@backstage/plugin-catalog-react';\nimport Typography from '@material-ui/core/Typography';\nimport { visuallyHidden } from '@mui/utils';\nimport Edit from '@material-ui/icons/Edit';\nimport OpenInNew from '@material-ui/icons/OpenInNew';\nimport { capitalize } from 'lodash';\nimport pluralize from 'pluralize';\nimport { ReactNode, useMemo } from 'react';\nimport { columnFactories } from './columns';\nimport { CatalogTableColumnsFunc, CatalogTableRow } from './types';\nimport { OffsetPaginatedCatalogTable } from './OffsetPaginatedCatalogTable';\nimport { CursorPaginatedCatalogTable } from './CursorPaginatedCatalogTable';\nimport { defaultCatalogTableColumnsFunc } from './defaultCatalogTableColumnsFunc';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { catalogTranslationRef } from '../../alpha/translation';\nimport { FavoriteToggleIcon } from '@backstage/core-components';\n\n/**\n * Props for {@link CatalogTable}.\n *\n * @public\n */\nexport interface CatalogTableProps {\n columns?: TableColumn<CatalogTableRow>[] | CatalogTableColumnsFunc;\n actions?: TableProps<CatalogTableRow>['actions'];\n tableOptions?: TableProps<CatalogTableRow>['options'];\n emptyContent?: ReactNode;\n /**\n * A static title to use for the table. If not provided, a title will be\n * generated based on the current Kind and Type filters and total number of items.\n */\n title?: string;\n subtitle?: string;\n}\n\nconst refCompare = (a: Entity, b: Entity) => {\n const toRef = (entity: Entity) =>\n entity.metadata.title ||\n humanizeEntityRef(entity, {\n defaultKind: 'Component',\n });\n\n return toRef(a).localeCompare(toRef(b));\n};\n\n/**\n * CatalogTable is a wrapper around the Table component that is pre-configured\n * to display catalog entities.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/features/software-catalog/catalog-customization}\n *\n * @public\n */\nexport const CatalogTable = (props: CatalogTableProps) => {\n const {\n columns = defaultCatalogTableColumnsFunc,\n tableOptions,\n subtitle,\n emptyContent,\n } = props;\n const { isStarredEntity, toggleStarredEntity } = useStarredEntities();\n const entityListContext = useEntityList();\n\n const {\n loading,\n error,\n entities,\n filters,\n pageInfo,\n totalItems,\n paginationMode,\n } = entityListContext;\n\n const tableColumns = useMemo(\n () =>\n typeof columns === 'function' ? columns(entityListContext) : columns,\n [columns, entityListContext],\n );\n const { t } = useTranslationRef(catalogTranslationRef);\n\n if (error) {\n return (\n <div>\n <WarningPanel\n severity=\"error\"\n title={t('catalogTable.warningPanelTitle')}\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n </div>\n );\n }\n\n const defaultActions: TableProps<CatalogTableRow>['actions'] = [\n ({ entity }) => {\n const url = entity.metadata.annotations?.[ANNOTATION_VIEW_URL];\n const title = t('catalogTable.viewActionTitle');\n\n return {\n icon: () => (\n <>\n <Typography style={visuallyHidden}>{title}</Typography>\n <OpenInNew fontSize=\"small\" />\n </>\n ),\n tooltip: title,\n disabled: !url,\n onClick: () => {\n if (!url) return;\n window.open(url, '_blank');\n },\n };\n },\n ({ entity }) => {\n const url = entity.metadata.annotations?.[ANNOTATION_EDIT_URL];\n const title = t('catalogTable.editActionTitle');\n\n return {\n icon: () => (\n <>\n <Typography style={visuallyHidden}>{title}</Typography>\n <Edit fontSize=\"small\" />\n </>\n ),\n tooltip: title,\n disabled: !url,\n onClick: () => {\n if (!url) return;\n window.open(url, '_blank');\n },\n };\n },\n ({ entity }) => {\n const isStarred = isStarredEntity(entity);\n const title = isStarred\n ? t('catalogTable.unStarActionTitle')\n : t('catalogTable.starActionTitle');\n\n return {\n cellStyle: { paddingLeft: '1em' },\n icon: () => <FavoriteToggleIcon isFavorite={isStarred} />,\n tooltip: title,\n onClick: () => toggleStarredEntity(entity),\n };\n },\n ];\n\n const currentKind = filters.kind?.label || '';\n const currentType = filters.type?.value || '';\n const currentCount = typeof totalItems === 'number' ? `(${totalItems})` : '';\n // TODO(timbonicus): remove the title from the CatalogTable once using EntitySearchBar\n const titlePreamble = capitalize(filters.user?.value ?? 'all');\n const title =\n props.title ||\n [titlePreamble, currentType, pluralize(currentKind), currentCount]\n .filter(s => s)\n .join(' ');\n\n const actions = props.actions || defaultActions;\n const options = {\n actionsColumnIndex: -1,\n loadingType: 'linear' as const,\n showEmptyDataSourceMessage: !loading,\n padding: 'dense' as const,\n ...tableOptions,\n };\n\n if (paginationMode === 'cursor') {\n return (\n <CursorPaginatedCatalogTable\n columns={tableColumns}\n emptyContent={emptyContent}\n isLoading={loading}\n title={title}\n actions={actions}\n subtitle={subtitle}\n options={options}\n data={entities.map(toEntityRow)}\n next={pageInfo?.next}\n prev={pageInfo?.prev}\n />\n );\n } else if (paginationMode === 'offset') {\n return (\n <OffsetPaginatedCatalogTable\n columns={tableColumns}\n emptyContent={emptyContent}\n isLoading={loading}\n title={title}\n actions={actions}\n subtitle={subtitle}\n options={options}\n data={entities.map(toEntityRow)}\n />\n );\n }\n\n const rows = entities.sort(refCompare).map(toEntityRow);\n const pageSize = 20;\n const showPagination = rows.length > pageSize;\n\n return (\n <Table<CatalogTableRow>\n isLoading={loading}\n columns={tableColumns}\n options={{\n paging: showPagination,\n pageSize: pageSize,\n pageSizeOptions: [20, 50, 100],\n ...options,\n }}\n title={title}\n data={rows}\n actions={actions}\n subtitle={subtitle}\n emptyContent={emptyContent}\n />\n );\n};\n\nCatalogTable.columns = columnFactories;\nCatalogTable.defaultColumnsFunc = defaultCatalogTableColumnsFunc;\n\nfunction toEntityRow(entity: Entity) {\n const partOfSystemRelations = getEntityRelations(entity, RELATION_PART_OF, {\n kind: 'system',\n });\n const ownedByRelations = getEntityRelations(entity, RELATION_OWNED_BY);\n\n return {\n entity,\n resolved: {\n // This name is here for backwards compatibility mostly; the\n // presentation of refs in the table should in general be handled with\n // EntityRefLink / EntityName components\n name: humanizeEntityRef(entity, {\n defaultKind: 'Component',\n }),\n entityRef: stringifyEntityRef(entity),\n ownedByRelationsTitle: ownedByRelations\n .map(r => humanizeEntityRef(r, { defaultKind: 'group' }))\n .join(', '),\n ownedByRelations,\n partOfSystemRelationTitle: partOfSystemRelations\n .map(r =>\n humanizeEntityRef(r, {\n defaultKind: 'system',\n }),\n )\n .join(', '),\n partOfSystemRelations,\n },\n };\n}\n"],"names":["title","Edit"],"mappings":";;;;;;;;;;;;;;;;;;AAsEA,MAAM,UAAA,GAAa,CAAC,CAAA,EAAW,CAAc,KAAA;AAC3C,EAAA,MAAM,QAAQ,CAAC,MAAA,KACb,OAAO,QAAS,CAAA,KAAA,IAChB,kBAAkB,MAAQ,EAAA;AAAA,IACxB,WAAa,EAAA;AAAA,GACd,CAAA;AAEH,EAAA,OAAO,MAAM,CAAC,CAAA,CA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;AACvB,YAAA,CAAa,kBAAqB,GAAA,8BAAA;AAElC,SAAS,YAAY,MAAgB,EAAA;AACnC,EAAM,MAAA,qBAAA,GAAwB,kBAAmB,CAAA,MAAA,EAAQ,gBAAkB,EAAA;AAAA,IACzE,IAAM,EAAA;AAAA,GACP,CAAA;AACD,EAAM,MAAA,gBAAA,GAAmB,kBAAmB,CAAA,MAAA,EAAQ,iBAAiB,CAAA;AAErE,EAAO,OAAA;AAAA,IACL,MAAA;AAAA,IACA,QAAU,EAAA;AAAA;AAAA;AAAA;AAAA,MAIR,IAAA,EAAM,kBAAkB,MAAQ,EAAA;AAAA,QAC9B,WAAa,EAAA;AAAA,OACd,CAAA;AAAA,MACD,SAAA,EAAW,mBAAmB,MAAM,CAAA;AAAA,MACpC,qBAAuB,EAAA,gBAAA,CACpB,GAAI,CAAA,CAAA,CAAA,KAAK,iBAAkB,CAAA,CAAA,EAAG,EAAE,WAAA,EAAa,OAAQ,EAAC,CAAC,CAAA,CACvD,KAAK,IAAI,CAAA;AAAA,MACZ,gBAAA;AAAA,MACA,2BAA2B,qBACxB,CAAA,GAAA;AAAA,QAAI,CAAA,CAAA,KACH,kBAAkB,CAAG,EAAA;AAAA,UACnB,WAAa,EAAA;AAAA,SACd;AAAA,OACH,CACC,KAAK,IAAI,CAAA;AAAA,MACZ;AAAA;AACF,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"CatalogTable.esm.js","sources":["../../../src/components/CatalogTable/CatalogTable.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 */\nimport {\n ANNOTATION_EDIT_URL,\n ANNOTATION_VIEW_URL,\n Entity,\n RELATION_OWNED_BY,\n RELATION_PART_OF,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n CodeSnippet,\n Table,\n TableColumn,\n TableProps,\n WarningPanel,\n} from '@backstage/core-components';\nimport {\n getEntityRelations,\n humanizeEntityRef,\n useEntityList,\n useStarredEntities,\n} from '@backstage/plugin-catalog-react';\nimport Typography from '@material-ui/core/Typography';\nimport { visuallyHidden } from '@mui/utils';\nimport Edit from '@material-ui/icons/Edit';\nimport OpenInNew from '@material-ui/icons/OpenInNew';\nimport { capitalize } from 'lodash';\nimport pluralize from 'pluralize';\nimport { ReactNode, useMemo } from 'react';\nimport { columnFactories } from './columns';\nimport { CatalogTableColumnsFunc, CatalogTableRow } from './types';\nimport { OffsetPaginatedCatalogTable } from './OffsetPaginatedCatalogTable';\nimport { CursorPaginatedCatalogTable } from './CursorPaginatedCatalogTable';\nimport { defaultCatalogTableColumnsFunc } from './defaultCatalogTableColumnsFunc';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { catalogTranslationRef } from '../../alpha';\nimport { FavoriteToggleIcon } from '@backstage/core-components';\n\n/**\n * Props for {@link CatalogTable}.\n *\n * @public\n */\nexport interface CatalogTableProps {\n columns?: TableColumn<CatalogTableRow>[] | CatalogTableColumnsFunc;\n actions?: TableProps<CatalogTableRow>['actions'];\n tableOptions?: TableProps<CatalogTableRow>['options'];\n emptyContent?: ReactNode;\n /**\n * A static title to use for the table. If not provided, a title will be\n * generated based on the current Kind and Type filters and total number of items.\n */\n title?: string;\n subtitle?: string;\n}\n\nconst refCompare = (a: Entity, b: Entity) => {\n const toRef = (entity: Entity) =>\n entity.metadata.title ||\n humanizeEntityRef(entity, {\n defaultKind: 'Component',\n });\n\n return toRef(a).localeCompare(toRef(b));\n};\n\n/**\n * CatalogTable is a wrapper around the Table component that is pre-configured\n * to display catalog entities.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/features/software-catalog/catalog-customization}\n *\n * @public\n */\nexport const CatalogTable = (props: CatalogTableProps) => {\n const {\n columns = defaultCatalogTableColumnsFunc,\n tableOptions,\n subtitle,\n emptyContent,\n } = props;\n const { isStarredEntity, toggleStarredEntity } = useStarredEntities();\n const entityListContext = useEntityList();\n\n const {\n loading,\n error,\n entities,\n filters,\n pageInfo,\n totalItems,\n paginationMode,\n } = entityListContext;\n\n const tableColumns = useMemo(\n () =>\n typeof columns === 'function' ? columns(entityListContext) : columns,\n [columns, entityListContext],\n );\n const { t } = useTranslationRef(catalogTranslationRef);\n\n if (error) {\n return (\n <div>\n <WarningPanel\n severity=\"error\"\n title={t('catalogTable.warningPanelTitle')}\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n </div>\n );\n }\n\n const defaultActions: TableProps<CatalogTableRow>['actions'] = [\n ({ entity }) => {\n const url = entity.metadata.annotations?.[ANNOTATION_VIEW_URL];\n const title = t('catalogTable.viewActionTitle');\n\n return {\n icon: () => (\n <>\n <Typography style={visuallyHidden}>{title}</Typography>\n <OpenInNew fontSize=\"small\" />\n </>\n ),\n tooltip: title,\n disabled: !url,\n onClick: () => {\n if (!url) return;\n window.open(url, '_blank');\n },\n };\n },\n ({ entity }) => {\n const url = entity.metadata.annotations?.[ANNOTATION_EDIT_URL];\n const title = t('catalogTable.editActionTitle');\n\n return {\n icon: () => (\n <>\n <Typography style={visuallyHidden}>{title}</Typography>\n <Edit fontSize=\"small\" />\n </>\n ),\n tooltip: title,\n disabled: !url,\n onClick: () => {\n if (!url) return;\n window.open(url, '_blank');\n },\n };\n },\n ({ entity }) => {\n const isStarred = isStarredEntity(entity);\n const title = isStarred\n ? t('catalogTable.unStarActionTitle')\n : t('catalogTable.starActionTitle');\n\n return {\n cellStyle: { paddingLeft: '1em' },\n icon: () => <FavoriteToggleIcon isFavorite={isStarred} />,\n tooltip: title,\n onClick: () => toggleStarredEntity(entity),\n };\n },\n ];\n\n const currentKind = filters.kind?.label || '';\n const currentType = filters.type?.value || '';\n const currentCount = typeof totalItems === 'number' ? `(${totalItems})` : '';\n // TODO(timbonicus): remove the title from the CatalogTable once using EntitySearchBar\n const titlePreamble = capitalize(filters.user?.value ?? 'all');\n const title =\n props.title ||\n [titlePreamble, currentType, pluralize(currentKind), currentCount]\n .filter(s => s)\n .join(' ');\n\n const actions = props.actions || defaultActions;\n const options: TableProps['options'] = {\n actionsColumnIndex: -1,\n loadingType: 'linear' as const,\n showEmptyDataSourceMessage: !loading,\n padding: 'dense' as const,\n ...tableOptions,\n };\n\n if (paginationMode === 'cursor') {\n return (\n <CursorPaginatedCatalogTable\n columns={tableColumns}\n emptyContent={emptyContent}\n isLoading={loading}\n title={title}\n actions={actions}\n subtitle={subtitle}\n options={options}\n data={entities.map(toEntityRow)}\n next={pageInfo?.next}\n prev={pageInfo?.prev}\n />\n );\n } else if (paginationMode === 'offset') {\n return (\n <OffsetPaginatedCatalogTable\n columns={tableColumns}\n emptyContent={emptyContent}\n isLoading={loading}\n title={title}\n actions={actions}\n subtitle={subtitle}\n options={options}\n data={entities.map(toEntityRow)}\n />\n );\n }\n\n const rows = entities.sort(refCompare).map(toEntityRow);\n const pageSize = 20;\n const showPagination = rows.length > pageSize;\n\n return (\n <Table<CatalogTableRow>\n isLoading={loading}\n columns={tableColumns}\n options={{\n paging: showPagination,\n pageSize: pageSize,\n pageSizeOptions: [20, 50, 100],\n ...options,\n }}\n title={title}\n data={rows}\n actions={actions}\n subtitle={subtitle}\n emptyContent={emptyContent}\n />\n );\n};\n\nCatalogTable.columns = columnFactories;\nCatalogTable.defaultColumnsFunc = defaultCatalogTableColumnsFunc;\n\nfunction toEntityRow(entity: Entity) {\n const partOfSystemRelations = getEntityRelations(entity, RELATION_PART_OF, {\n kind: 'system',\n });\n const ownedByRelations = getEntityRelations(entity, RELATION_OWNED_BY);\n\n return {\n entity,\n resolved: {\n // This name is here for backwards compatibility mostly; the\n // presentation of refs in the table should in general be handled with\n // EntityRefLink / EntityName components\n name: humanizeEntityRef(entity, {\n defaultKind: 'Component',\n }),\n entityRef: stringifyEntityRef(entity),\n ownedByRelationsTitle: ownedByRelations\n .map(r => humanizeEntityRef(r, { defaultKind: 'group' }))\n .join(', '),\n ownedByRelations,\n partOfSystemRelationTitle: partOfSystemRelations\n .map(r =>\n humanizeEntityRef(r, {\n defaultKind: 'system',\n }),\n )\n .join(', '),\n partOfSystemRelations,\n },\n };\n}\n"],"names":["title","Edit"],"mappings":";;;;;;;;;;;;;;;;;;AAsEA,MAAM,UAAA,GAAa,CAAC,CAAA,EAAW,CAAc,KAAA;AAC3C,EAAA,MAAM,QAAQ,CAAC,MAAA,KACb,OAAO,QAAS,CAAA,KAAA,IAChB,kBAAkB,MAAQ,EAAA;AAAA,IACxB,WAAa,EAAA;AAAA,GACd,CAAA;AAEH,EAAA,OAAO,MAAM,CAAC,CAAA,CAAE,aAAc,CAAA,KAAA,CAAM,CAAC,CAAC,CAAA;AACxC,CAAA;AAYa,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AACxD,EAAM,MAAA;AAAA,IACJ,OAAU,GAAA,8BAAA;AAAA,IACV,YAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAA,MAAM,EAAE,eAAA,EAAiB,mBAAoB,EAAA,GAAI,kBAAmB,EAAA;AACpE,EAAA,MAAM,oBAAoB,aAAc,EAAA;AAExC,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACE,GAAA,iBAAA;AAEJ,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACnB,MACE,OAAO,OAAA,KAAY,UAAa,GAAA,OAAA,CAAQ,iBAAiB,CAAI,GAAA,OAAA;AAAA,IAC/D,CAAC,SAAS,iBAAiB;AAAA,GAC7B;AACA,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,i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,QAAI,CAAA,CAAA,KACH,kBAAkB,CAAG,EAAA;AAAA,UACnB,WAAa,EAAA;AAAA,SACd;AAAA,OACH,CACC,KAAK,IAAI,CAAA;AAAA,MACZ;AAAA;AACF,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorPaginatedCatalogTable.esm.js","sources":["../../../src/components/CatalogTable/CursorPaginatedCatalogTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { Table, TableProps } from '@backstage/core-components';\nimport { CatalogTableRow } from './types';\nimport { CatalogTableToolbar } from './CatalogTableToolbar';\n\ntype PaginatedCatalogTableProps = {\n prev?(): void;\n next?(): void;\n} & TableProps<CatalogTableRow>;\n\n/**\n * @internal\n */\n\nexport function CursorPaginatedCatalogTable(props: PaginatedCatalogTableProps) {\n const { columns, data, next, prev, options, ...restProps } = props;\n\n return (\n <Table\n columns={columns}\n data={data}\n options={{\n
|
|
1
|
+
{"version":3,"file":"CursorPaginatedCatalogTable.esm.js","sources":["../../../src/components/CatalogTable/CursorPaginatedCatalogTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { Table, TableProps } from '@backstage/core-components';\nimport { CatalogTableRow } from './types';\nimport { CatalogTableToolbar } from './CatalogTableToolbar';\n\ntype PaginatedCatalogTableProps = {\n prev?(): void;\n next?(): void;\n} & TableProps<CatalogTableRow>;\n\n/**\n * @internal\n */\n\nexport function CursorPaginatedCatalogTable(props: PaginatedCatalogTableProps) {\n const { columns, data, next, prev, options, ...restProps } = props;\n\n return (\n <Table\n columns={columns}\n data={data}\n options={{\n ...options,\n // These settings are configured to force server side pagination\n pageSizeOptions: [],\n showFirstLastPageButtons: false,\n pageSize: Number.MAX_SAFE_INTEGER,\n emptyRowsWhenPaging: false,\n }}\n onPageChange={page => {\n if (page > 0) {\n next?.();\n } else {\n prev?.();\n }\n }}\n components={{\n Toolbar: CatalogTableToolbar,\n }}\n /* this will enable the prev button accordingly */\n page={prev ? 1 : 0}\n /* this will enable the next button accordingly */\n totalCount={next ? Number.MAX_VALUE : Number.MAX_SAFE_INTEGER}\n localization={{ pagination: { labelDisplayedRows: '' } }}\n {...restProps}\n />\n );\n}\n"],"names":[],"mappings":";;;;AA6BO,SAAS,4BAA4B,KAAmC,EAAA;AAC7E,EAAM,MAAA,EAAE,SAAS,IAAM,EAAA,IAAA,EAAM,MAAM,OAAS,EAAA,GAAG,WAAc,GAAA,KAAA;AAE7D,EACE,uBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,GAAG,OAAA;AAAA;AAAA,QAEH,iBAAiB,EAAC;AAAA,QAClB,wBAA0B,EAAA,KAAA;AAAA,QAC1B,UAAU,MAAO,CAAA,gBAAA;AAAA,QACjB,mBAAqB,EAAA;AAAA,OACvB;AAAA,MACA,cAAc,CAAQ,IAAA,KAAA;AACpB,QAAA,IAAI,OAAO,CAAG,EAAA;AACZ,UAAO,IAAA,IAAA;AAAA,SACF,MAAA;AACL,UAAO,IAAA,IAAA;AAAA;AACT,OACF;AAAA,MACA,UAAY,EAAA;AAAA,QACV,OAAS,EAAA;AAAA,OACX;AAAA,MAEA,IAAA,EAAM,OAAO,CAAI,GAAA,CAAA;AAAA,MAEjB,UAAY,EAAA,IAAA,GAAO,MAAO,CAAA,SAAA,GAAY,MAAO,CAAA,gBAAA;AAAA,MAC7C,cAAc,EAAE,UAAA,EAAY,EAAE,kBAAA,EAAoB,IAAK,EAAA;AAAA,MACtD,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
|
|
@@ -23,7 +23,6 @@ function OffsetPaginatedCatalogTable(props) {
|
|
|
23
23
|
columns,
|
|
24
24
|
data,
|
|
25
25
|
options: {
|
|
26
|
-
paginationPosition: "both",
|
|
27
26
|
pageSizeOptions: [5, 10, 20, 50, 100],
|
|
28
27
|
pageSize: limit,
|
|
29
28
|
emptyRowsWhenPaging: false,
|
|
@@ -33,14 +32,9 @@ function OffsetPaginatedCatalogTable(props) {
|
|
|
33
32
|
Toolbar: CatalogTableToolbar
|
|
34
33
|
},
|
|
35
34
|
page,
|
|
36
|
-
onPageChange:
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
onRowsPerPageChange: (pageSize) => {
|
|
40
|
-
setLimit(pageSize);
|
|
41
|
-
},
|
|
35
|
+
onPageChange: setPage,
|
|
36
|
+
onRowsPerPageChange: setLimit,
|
|
42
37
|
totalCount: totalItems,
|
|
43
|
-
localization: { pagination: { labelDisplayedRows: "" } },
|
|
44
38
|
...restProps
|
|
45
39
|
}
|
|
46
40
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OffsetPaginatedCatalogTable.esm.js","sources":["../../../src/components/CatalogTable/OffsetPaginatedCatalogTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { useState, useEffect } from 'react';\n\nimport { Table, TableProps } from '@backstage/core-components';\nimport { CatalogTableRow } from './types';\nimport { useEntityList } from '@backstage/plugin-catalog-react';\nimport { CatalogTableToolbar } from './CatalogTableToolbar';\n\n/**\n * @internal\n */\nexport function OffsetPaginatedCatalogTable(\n props: TableProps<CatalogTableRow>,\n) {\n const { columns, data, options, ...restProps } = props;\n const { setLimit, setOffset, limit, totalItems, offset } = useEntityList();\n\n const [page, setPage] = useState(\n offset && limit ? Math.floor(offset / limit) : 0,\n );\n\n useEffect(() => {\n if (totalItems && page * limit >= totalItems) {\n setOffset!(Math.max(0, totalItems - limit));\n } else {\n setOffset!(Math.max(0, page * limit));\n }\n }, [setOffset, page, limit, totalItems]);\n\n return (\n <Table\n columns={columns}\n data={data}\n options={{\n
|
|
1
|
+
{"version":3,"file":"OffsetPaginatedCatalogTable.esm.js","sources":["../../../src/components/CatalogTable/OffsetPaginatedCatalogTable.tsx"],"sourcesContent":["/*\n * Copyright 2023 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 { useState, useEffect } from 'react';\n\nimport { Table, TableProps } from '@backstage/core-components';\nimport { CatalogTableRow } from './types';\nimport { useEntityList } from '@backstage/plugin-catalog-react';\nimport { CatalogTableToolbar } from './CatalogTableToolbar';\n\n/**\n * @internal\n */\nexport function OffsetPaginatedCatalogTable(\n props: TableProps<CatalogTableRow>,\n) {\n const { columns, data, options, ...restProps } = props;\n const { setLimit, setOffset, limit, totalItems, offset } = useEntityList();\n\n const [page, setPage] = useState(\n offset && limit ? Math.floor(offset / limit) : 0,\n );\n\n useEffect(() => {\n if (totalItems && page * limit >= totalItems) {\n setOffset!(Math.max(0, totalItems - limit));\n } else {\n setOffset!(Math.max(0, page * limit));\n }\n }, [setOffset, page, limit, totalItems]);\n\n return (\n <Table\n columns={columns}\n data={data}\n options={{\n pageSizeOptions: [5, 10, 20, 50, 100],\n pageSize: limit,\n emptyRowsWhenPaging: false,\n ...options,\n }}\n components={{\n Toolbar: CatalogTableToolbar,\n }}\n page={page}\n onPageChange={setPage}\n onRowsPerPageChange={setLimit}\n totalCount={totalItems}\n {...restProps}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;AA0BO,SAAS,4BACd,KACA,EAAA;AACA,EAAA,MAAM,EAAE,OAAS,EAAA,IAAA,EAAM,OAAS,EAAA,GAAG,WAAc,GAAA,KAAA;AACjD,EAAA,MAAM,EAAE,QAAU,EAAA,SAAA,EAAW,OAAO,UAAY,EAAA,MAAA,KAAW,aAAc,EAAA;AAEzE,EAAM,MAAA,CAAC,IAAM,EAAA,OAAO,CAAI,GAAA,QAAA;AAAA,IACtB,UAAU,KAAQ,GAAA,IAAA,CAAK,KAAM,CAAA,MAAA,GAAS,KAAK,CAAI,GAAA;AAAA,GACjD;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,UAAA,IAAc,IAAO,GAAA,KAAA,IAAS,UAAY,EAAA;AAC5C,MAAA,SAAA,CAAW,IAAK,CAAA,GAAA,CAAI,CAAG,EAAA,UAAA,GAAa,KAAK,CAAC,CAAA;AAAA,KACrC,MAAA;AACL,MAAA,SAAA,CAAW,IAAK,CAAA,GAAA,CAAI,CAAG,EAAA,IAAA,GAAO,KAAK,CAAC,CAAA;AAAA;AACtC,KACC,CAAC,SAAA,EAAW,IAAM,EAAA,KAAA,EAAO,UAAU,CAAC,CAAA;AAEvC,EACE,uBAAA,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,iBAAiB,CAAC,CAAA,EAAG,EAAI,EAAA,EAAA,EAAI,IAAI,GAAG,CAAA;AAAA,QACpC,QAAU,EAAA,KAAA;AAAA,QACV,mBAAqB,EAAA,KAAA;AAAA,QACrB,GAAG;AAAA,OACL;AAAA,MACA,UAAY,EAAA;AAAA,QACV,OAAS,EAAA;AAAA,OACX;AAAA,MACA,IAAA;AAAA,MACA,YAAc,EAAA,OAAA;AAAA,MACd,mBAAqB,EAAA,QAAA;AAAA,MACrB,UAAY,EAAA,UAAA;AAAA,MACX,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"description": "The Backstage plugin for browsing the Backstage catalog",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin",
|
|
@@ -70,22 +70,22 @@
|
|
|
70
70
|
"test": "backstage-cli package test"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@backstage/catalog-client": "1.10.0
|
|
74
|
-
"@backstage/catalog-model": "1.7.
|
|
75
|
-
"@backstage/core-compat-api": "0.4.2
|
|
76
|
-
"@backstage/core-components": "0.17.2
|
|
77
|
-
"@backstage/core-plugin-api": "1.10.7
|
|
78
|
-
"@backstage/errors": "1.2.7",
|
|
79
|
-
"@backstage/frontend-plugin-api": "0.10.2
|
|
80
|
-
"@backstage/integration-react": "1.2.7
|
|
81
|
-
"@backstage/plugin-catalog-common": "1.1.4
|
|
82
|
-
"@backstage/plugin-catalog-react": "1.18.0
|
|
83
|
-
"@backstage/plugin-permission-react": "0.4.34
|
|
84
|
-
"@backstage/plugin-scaffolder-common": "1.5.11
|
|
85
|
-
"@backstage/plugin-search-common": "1.2.18
|
|
86
|
-
"@backstage/plugin-search-react": "1.9.0
|
|
87
|
-
"@backstage/types": "1.2.1",
|
|
88
|
-
"@backstage/version-bridge": "1.0.11",
|
|
73
|
+
"@backstage/catalog-client": "^1.10.0",
|
|
74
|
+
"@backstage/catalog-model": "^1.7.4",
|
|
75
|
+
"@backstage/core-compat-api": "^0.4.2",
|
|
76
|
+
"@backstage/core-components": "^0.17.2",
|
|
77
|
+
"@backstage/core-plugin-api": "^1.10.7",
|
|
78
|
+
"@backstage/errors": "^1.2.7",
|
|
79
|
+
"@backstage/frontend-plugin-api": "^0.10.2",
|
|
80
|
+
"@backstage/integration-react": "^1.2.7",
|
|
81
|
+
"@backstage/plugin-catalog-common": "^1.1.4",
|
|
82
|
+
"@backstage/plugin-catalog-react": "^1.18.0",
|
|
83
|
+
"@backstage/plugin-permission-react": "^0.4.34",
|
|
84
|
+
"@backstage/plugin-scaffolder-common": "^1.5.11",
|
|
85
|
+
"@backstage/plugin-search-common": "^1.2.18",
|
|
86
|
+
"@backstage/plugin-search-react": "^1.9.0",
|
|
87
|
+
"@backstage/types": "^1.2.1",
|
|
88
|
+
"@backstage/version-bridge": "^1.0.11",
|
|
89
89
|
"@material-ui/core": "^4.12.2",
|
|
90
90
|
"@material-ui/icons": "^4.9.1",
|
|
91
91
|
"@material-ui/lab": "4.0.0-alpha.61",
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"zen-observable": "^0.10.0"
|
|
101
101
|
},
|
|
102
102
|
"devDependencies": {
|
|
103
|
-
"@backstage/cli": "0.32.1
|
|
104
|
-
"@backstage/core-app-api": "1.
|
|
105
|
-
"@backstage/dev-utils": "1.1.10
|
|
106
|
-
"@backstage/frontend-test-utils": "0.3.2
|
|
107
|
-
"@backstage/plugin-permission-common": "0.9.0
|
|
108
|
-
"@backstage/test-utils": "1.7.8
|
|
103
|
+
"@backstage/cli": "^0.32.1",
|
|
104
|
+
"@backstage/core-app-api": "^1.17.0",
|
|
105
|
+
"@backstage/dev-utils": "^1.1.10",
|
|
106
|
+
"@backstage/frontend-test-utils": "^0.3.2",
|
|
107
|
+
"@backstage/plugin-permission-common": "^0.9.0",
|
|
108
|
+
"@backstage/test-utils": "^1.7.8",
|
|
109
109
|
"@testing-library/dom": "^10.0.0",
|
|
110
110
|
"@testing-library/jest-dom": "^6.0.0",
|
|
111
111
|
"@testing-library/react": "^16.0.0",
|