@backstage/plugin-catalog 1.22.1-next.1 → 1.23.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 +27 -0
- package/alpha/package.json +1 -1
- package/dist/components/CatalogPage/DefaultCatalogPage.esm.js.map +1 -1
- package/dist/components/CatalogTable/CatalogTable.esm.js +31 -17
- package/dist/components/CatalogTable/CatalogTable.esm.js.map +1 -1
- package/dist/components/CatalogTable/{PaginatedCatalogTable.esm.js → CursorPaginatedCatalogTable.esm.js} +3 -3
- package/dist/components/CatalogTable/CursorPaginatedCatalogTable.esm.js.map +1 -0
- package/dist/components/CatalogTable/OffsetPaginatedCatalogTable.esm.js +46 -0
- package/dist/components/CatalogTable/OffsetPaginatedCatalogTable.esm.js.map +1 -0
- package/dist/index.d.ts +2 -4
- package/package.json +16 -16
- package/dist/components/CatalogTable/PaginatedCatalogTable.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @backstage/plugin-catalog
|
|
2
2
|
|
|
3
|
+
## 1.23.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 78475c3: Allow offset mode paging in entity list provider
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- c891b69: Add `FavoriteToggle` in `core-components` to standardise favorite marking
|
|
12
|
+
- 836127c: Updated dependency `@testing-library/react` to `^16.0.0`.
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/core-components@0.14.11-next.1
|
|
15
|
+
- @backstage/plugin-catalog-react@1.13.0-next.2
|
|
16
|
+
- @backstage/integration-react@1.1.31-next.0
|
|
17
|
+
- @backstage/catalog-client@1.7.0-next.1
|
|
18
|
+
- @backstage/plugin-search-react@1.8.0-next.2
|
|
19
|
+
- @backstage/core-compat-api@0.3.0-next.2
|
|
20
|
+
- @backstage/core-plugin-api@1.9.4-next.0
|
|
21
|
+
- @backstage/frontend-plugin-api@0.8.0-next.2
|
|
22
|
+
- @backstage/plugin-permission-react@0.4.26-next.0
|
|
23
|
+
- @backstage/catalog-model@1.6.0
|
|
24
|
+
- @backstage/errors@1.2.4
|
|
25
|
+
- @backstage/types@1.1.1
|
|
26
|
+
- @backstage/plugin-catalog-common@1.0.26
|
|
27
|
+
- @backstage/plugin-scaffolder-common@1.5.5
|
|
28
|
+
- @backstage/plugin-search-common@1.2.14
|
|
29
|
+
|
|
3
30
|
## 1.22.1-next.1
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/alpha/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultCatalogPage.esm.js","sources":["../../../src/components/CatalogPage/DefaultCatalogPage.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 {\n Content,\n ContentHeader,\n CreateButton,\n PageWithHeader,\n SupportButton,\n TableColumn,\n TableProps,\n} from '@backstage/core-components';\nimport { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport {\n CatalogFilterLayout,\n
|
|
1
|
+
{"version":3,"file":"DefaultCatalogPage.esm.js","sources":["../../../src/components/CatalogPage/DefaultCatalogPage.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 {\n Content,\n ContentHeader,\n CreateButton,\n PageWithHeader,\n SupportButton,\n TableColumn,\n TableProps,\n} from '@backstage/core-components';\nimport { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport {\n CatalogFilterLayout,\n DefaultFilters,\n EntityListPagination,\n EntityListProvider,\n EntityOwnerPickerProps,\n UserListFilterKind,\n} from '@backstage/plugin-catalog-react';\nimport React, { ReactNode } from 'react';\nimport { createComponentRouteRef } from '../../routes';\nimport { CatalogTable, CatalogTableRow } from '../CatalogTable';\nimport { catalogTranslationRef } from '../../alpha/translation';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { CatalogTableColumnsFunc } from '../CatalogTable/types';\nimport { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';\nimport { usePermission } from '@backstage/plugin-permission-react';\n\n/** @internal */\nexport type BaseCatalogPageProps = {\n filters: ReactNode;\n content?: ReactNode;\n pagination?: EntityListPagination;\n};\n\n/** @internal */\nexport function BaseCatalogPage(props: BaseCatalogPageProps) {\n const { filters, content = <CatalogTable />, pagination } = props;\n const orgName =\n useApi(configApiRef).getOptionalString('organization.name') ?? 'Backstage';\n const createComponentLink = useRouteRef(createComponentRouteRef);\n const { t } = useTranslationRef(catalogTranslationRef);\n const { allowed } = usePermission({\n permission: catalogEntityCreatePermission,\n });\n\n return (\n <PageWithHeader title={t('indexPage.title', { orgName })} themeId=\"home\">\n <Content>\n <ContentHeader title=\"\">\n {allowed && (\n <CreateButton\n title={t('indexPage.createButtonTitle')}\n to={createComponentLink && createComponentLink()}\n />\n )}\n <SupportButton>{t('indexPage.supportButtonContent')}</SupportButton>\n </ContentHeader>\n <EntityListProvider pagination={pagination}>\n <CatalogFilterLayout>\n <CatalogFilterLayout.Filters>{filters}</CatalogFilterLayout.Filters>\n <CatalogFilterLayout.Content>{content}</CatalogFilterLayout.Content>\n </CatalogFilterLayout>\n </EntityListProvider>\n </Content>\n </PageWithHeader>\n );\n}\n\n/**\n * Props for root catalog pages.\n *\n * @public\n */\nexport interface DefaultCatalogPageProps {\n initiallySelectedFilter?: UserListFilterKind;\n columns?: TableColumn<CatalogTableRow>[] | CatalogTableColumnsFunc;\n actions?: TableProps<CatalogTableRow>['actions'];\n initialKind?: string;\n tableOptions?: TableProps<CatalogTableRow>['options'];\n emptyContent?: ReactNode;\n ownerPickerMode?: EntityOwnerPickerProps['mode'];\n filters?: ReactNode;\n initiallySelectedNamespaces?: string[];\n pagination?: EntityListPagination;\n}\n\nexport function DefaultCatalogPage(props: DefaultCatalogPageProps) {\n const {\n columns,\n actions,\n initiallySelectedFilter = 'owned',\n initialKind = 'component',\n tableOptions = {},\n emptyContent,\n pagination,\n ownerPickerMode,\n filters,\n initiallySelectedNamespaces,\n } = props;\n\n return (\n <BaseCatalogPage\n filters={\n filters ?? (\n <DefaultFilters\n initialKind={initialKind}\n initiallySelectedFilter={initiallySelectedFilter}\n ownerPickerMode={ownerPickerMode}\n initiallySelectedNamespaces={initiallySelectedNamespaces}\n />\n )\n }\n content={\n <CatalogTable\n columns={columns}\n actions={actions}\n tableOptions={tableOptions}\n emptyContent={emptyContent}\n />\n }\n pagination={pagination}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAmDO,SAAS,gBAAgB,KAA6B,EAAA;AAC3D,EAAA,MAAM,EAAE,OAAS,EAAA,OAAA,uCAAW,YAAa,EAAA,IAAA,CAAA,EAAI,YAAe,GAAA,KAAA,CAAA;AAC5D,EAAA,MAAM,UACJ,MAAO,CAAA,YAAY,CAAE,CAAA,iBAAA,CAAkB,mBAAmB,CAAK,IAAA,WAAA,CAAA;AACjE,EAAM,MAAA,mBAAA,GAAsB,YAAY,uBAAuB,CAAA,CAAA;AAC/D,EAAA,MAAM,EAAE,CAAA,EAAM,GAAA,iBAAA,CAAkB,qBA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KAAA,CAAA,aAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,SACE,OACE,oBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,cAAA;AAAA,QAAA;AAAA,UACC,WAAA;AAAA,UACA,uBAAA;AAAA,UACA,eAAA;AAAA,UACA,2BAAA;AAAA,SAAA;AAAA,OACF;AAAA,MAGJ,OACE,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,YAAA;AAAA,QAAA;AAAA,UACC,OAAA;AAAA,UACA,OAAA;AAAA,UACA,YAAA;AAAA,UACA,YAAA;AAAA,SAAA;AAAA,OACF;AAAA,MAEF,UAAA;AAAA,KAAA;AAAA,GACF,CAAA;AAEJ;;;;"}
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
import { RELATION_PART_OF, RELATION_OWNED_BY, stringifyEntityRef, ANNOTATION_VIEW_URL, ANNOTATION_EDIT_URL } from '@backstage/catalog-model';
|
|
2
|
-
import { WarningPanel, CodeSnippet, Table } from '@backstage/core-components';
|
|
2
|
+
import { WarningPanel, CodeSnippet, Table, FavoriteToggleIcon } from '@backstage/core-components';
|
|
3
3
|
import { useStarredEntities, useEntityList, getEntityRelations, humanizeEntityRef } from '@backstage/plugin-catalog-react';
|
|
4
4
|
import Typography from '@material-ui/core/Typography';
|
|
5
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
6
5
|
import { visuallyHidden } from '@mui/utils';
|
|
7
6
|
import EditIcon from '@material-ui/icons/Edit';
|
|
8
7
|
import OpenInNew from '@material-ui/icons/OpenInNew';
|
|
9
|
-
import Star from '@material-ui/icons/Star';
|
|
10
|
-
import StarBorder from '@material-ui/icons/StarBorder';
|
|
11
8
|
import { capitalize } from 'lodash';
|
|
12
9
|
import pluralize from 'pluralize';
|
|
13
10
|
import React, { useMemo } from 'react';
|
|
14
11
|
import { columnFactories } from './columns.esm.js';
|
|
15
|
-
import {
|
|
12
|
+
import { OffsetPaginatedCatalogTable } from './OffsetPaginatedCatalogTable.esm.js';
|
|
13
|
+
import { CursorPaginatedCatalogTable } from './CursorPaginatedCatalogTable.esm.js';
|
|
16
14
|
import { defaultCatalogTableColumnsFunc } from './defaultCatalogTableColumnsFunc.esm.js';
|
|
17
15
|
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
18
16
|
import { catalogTranslationRef } from '../../alpha/translation.esm.js';
|
|
19
17
|
|
|
20
|
-
const YellowStar = withStyles({
|
|
21
|
-
root: {
|
|
22
|
-
color: "#f3ba37"
|
|
23
|
-
}
|
|
24
|
-
})(Star);
|
|
25
18
|
const refCompare = (a, b) => {
|
|
26
19
|
const toRef = (entity) => entity.metadata.title || humanizeEntityRef(entity, {
|
|
27
20
|
defaultKind: "Component"
|
|
@@ -37,8 +30,15 @@ const CatalogTable = (props) => {
|
|
|
37
30
|
} = props;
|
|
38
31
|
const { isStarredEntity, toggleStarredEntity } = useStarredEntities();
|
|
39
32
|
const entityListContext = useEntityList();
|
|
40
|
-
const {
|
|
41
|
-
|
|
33
|
+
const {
|
|
34
|
+
loading,
|
|
35
|
+
error,
|
|
36
|
+
entities,
|
|
37
|
+
filters,
|
|
38
|
+
pageInfo,
|
|
39
|
+
totalItems,
|
|
40
|
+
paginationMode
|
|
41
|
+
} = entityListContext;
|
|
42
42
|
const tableColumns = useMemo(
|
|
43
43
|
() => typeof columns === "function" ? columns(entityListContext) : columns,
|
|
44
44
|
[columns, entityListContext]
|
|
@@ -86,7 +86,7 @@ const CatalogTable = (props) => {
|
|
|
86
86
|
const title2 = isStarred ? t("catalogTable.unStarActionTitle") : t("catalogTable.starActionTitle");
|
|
87
87
|
return {
|
|
88
88
|
cellStyle: { paddingLeft: "1em" },
|
|
89
|
-
icon: () => /* @__PURE__ */ React.createElement(
|
|
89
|
+
icon: () => /* @__PURE__ */ React.createElement(FavoriteToggleIcon, { isFavorite: isStarred }),
|
|
90
90
|
tooltip: title2,
|
|
91
91
|
onClick: () => toggleStarredEntity(entity)
|
|
92
92
|
};
|
|
@@ -110,9 +110,9 @@ const CatalogTable = (props) => {
|
|
|
110
110
|
padding: "dense",
|
|
111
111
|
...tableOptions
|
|
112
112
|
};
|
|
113
|
-
if (
|
|
113
|
+
if (paginationMode === "cursor") {
|
|
114
114
|
return /* @__PURE__ */ React.createElement(
|
|
115
|
-
|
|
115
|
+
CursorPaginatedCatalogTable,
|
|
116
116
|
{
|
|
117
117
|
columns: tableColumns,
|
|
118
118
|
emptyContent,
|
|
@@ -122,8 +122,22 @@ const CatalogTable = (props) => {
|
|
|
122
122
|
subtitle,
|
|
123
123
|
options,
|
|
124
124
|
data: entities.map(toEntityRow),
|
|
125
|
-
next: pageInfo
|
|
126
|
-
prev: pageInfo
|
|
125
|
+
next: pageInfo?.next,
|
|
126
|
+
prev: pageInfo?.prev
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
} else if (paginationMode === "offset") {
|
|
130
|
+
return /* @__PURE__ */ React.createElement(
|
|
131
|
+
OffsetPaginatedCatalogTable,
|
|
132
|
+
{
|
|
133
|
+
columns: tableColumns,
|
|
134
|
+
emptyContent,
|
|
135
|
+
isLoading: loading,
|
|
136
|
+
title,
|
|
137
|
+
actions,
|
|
138
|
+
subtitle,
|
|
139
|
+
options,
|
|
140
|
+
data: entities.map(toEntityRow)
|
|
127
141
|
}
|
|
128
142
|
);
|
|
129
143
|
}
|
|
@@ -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 { withStyles } from '@material-ui/core/styles';\nimport { visuallyHidden } from '@mui/utils';\nimport Edit from '@material-ui/icons/Edit';\nimport OpenInNew from '@material-ui/icons/OpenInNew';\nimport Star from '@material-ui/icons/Star';\nimport StarBorder from '@material-ui/icons/StarBorder';\nimport { capitalize } from 'lodash';\nimport pluralize from 'pluralize';\nimport React, { ReactNode, useMemo } from 'react';\nimport { columnFactories } from './columns';\nimport { CatalogTableColumnsFunc, CatalogTableRow } from './types';\nimport { PaginatedCatalogTable } from './PaginatedCatalogTable';\nimport { defaultCatalogTableColumnsFunc } from './defaultCatalogTableColumnsFunc';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { catalogTranslationRef } from '../../alpha/translation';\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 subtitle?: string;\n}\n\nconst YellowStar = withStyles({\n root: {\n color: '#f3ba37',\n },\n})(Star);\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/** @public */\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 const { loading, error, entities, filters, pageInfo, totalItems } =\n entityListContext;\n const enablePagination = !!pageInfo;\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: () => (\n <>\n <Typography style={visuallyHidden}>{title}</Typography>\n {isStarred ? <YellowStar /> : <StarBorder />}\n </>\n ),\n tooltip: title,\n onClick: () => toggleStarredEntity(entity),\n };\n },\n ];\n\n const currentKind = filters.kind?.value || '';\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 titlePreamble,\n currentType,\n pluralize(currentKind),\n currentCount,\n ]\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 (enablePagination) {\n return (\n <PaginatedCatalogTable\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 }\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"],"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,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,QAAA;AAAA,SACd,CAAA;AAAA,OACH,CACC,KAAK,IAAI,CAAA;AAAA,MACZ,qBAAA;AAAA,KACF;AAAA,GACF,CAAA;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 React, { 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 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/** @public */\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?.value || '';\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 titlePreamble,\n currentType,\n pluralize(currentKind),\n currentCount,\n ]\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":";;;;;;;;;;;;;;;;;AAiEA,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,WAAA;AAAA,GACd,CAAA,CAAA;AAEH,EAAA,OAAO,MAAM,CAAC,CAAA,CAAE,aAAc,CAAA,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AACxC,CAAA,CAAA;AAGa,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AACxD,EAAM,MAAA;AAAA,IACJ,OAAU,GAAA,8BAAA;AAAA,IACV,YAAA;AAAA,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GAAG,OAAA;AAAA,OACL;AAAA,MACA,KAAA;AAAA,MACA,IAAM,EAAA,IAAA;AAAA,MACN,OAAA;AAAA,MACA,QAAA;AAAA,MACA,YAAA;AAAA,KAAA;AAAA,GACF,CAAA;AAEJ,EAAA;AAEA,YAAA,CAAa,OAAU,GAAA,eAAA,CAAA;AACvB,YAAA,CAAa,kBAAqB,GAAA,8BAAA,CAAA;AAElC,SAAS,YAAY,MAAgB,EAAA;AACnC,EAAM,MAAA,qBAAA,GAAwB,kBAAmB,CAAA,MAAA,EAAQ,gBAAkB,EAAA;AAAA,IACzE,IAAM,EAAA,QAAA;AAAA,GACP,CAAA,CAAA;AACD,EAAM,MAAA,gBAAA,GAAmB,kBAAmB,CAAA,MAAA,EAAQ,iBAAiB,CAAA,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,WAAA;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,QAAA;AAAA,SACd,CAAA;AAAA,OACH,CACC,KAAK,IAAI,CAAA;AAAA,MACZ,qBAAA;AAAA,KACF;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Table } from '@backstage/core-components';
|
|
3
3
|
import { CatalogTableToolbar } from './CatalogTableToolbar.esm.js';
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function CursorPaginatedCatalogTable(props) {
|
|
6
6
|
const { columns, data, next, prev, title, isLoading, options, ...restProps } = props;
|
|
7
7
|
return /* @__PURE__ */ React.createElement(
|
|
8
8
|
Table,
|
|
@@ -37,5 +37,5 @@ function PaginatedCatalogTable(props) {
|
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export {
|
|
41
|
-
//# sourceMappingURL=
|
|
40
|
+
export { CursorPaginatedCatalogTable };
|
|
41
|
+
//# sourceMappingURL=CursorPaginatedCatalogTable.esm.js.map
|
|
@@ -0,0 +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 React from 'react';\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, title, isLoading, options, ...restProps } =\n props;\n\n return (\n <Table\n title={isLoading ? '' : title}\n columns={columns}\n data={data}\n options={{\n ...options,\n // These settings are configured to force server side pagination\n paginationPosition: 'both',\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":";;;;AA+BO,SAAS,4BAA4B,KAAmC,EAAA;AAC7E,EAAM,MAAA,EAAE,OAAS,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,OAAO,SAAW,EAAA,OAAA,EAAS,GAAG,SAAA,EAC/D,GAAA,KAAA,CAAA;AAEF,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,YAAY,EAAK,GAAA,KAAA;AAAA,MACxB,OAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,GAAG,OAAA;AAAA;AAAA,QAEH,kBAAoB,EAAA,MAAA;AAAA,QACpB,iBAAiB,EAAC;AAAA,QAClB,wBAA0B,EAAA,KAAA;AAAA,QAC1B,UAAU,MAAO,CAAA,gBAAA;AAAA,QACjB,mBAAqB,EAAA,KAAA;AAAA,OACvB;AAAA,MACA,cAAc,CAAQ,IAAA,KAAA;AACpB,QAAA,IAAI,OAAO,CAAG,EAAA;AACZ,UAAO,IAAA,IAAA,CAAA;AAAA,SACF,MAAA;AACL,UAAO,IAAA,IAAA,CAAA;AAAA,SACT;AAAA,OACF;AAAA,MACA,UAAY,EAAA;AAAA,QACV,OAAS,EAAA,mBAAA;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,SAAA;AAAA,KAAA;AAAA,GACN,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { Table } from '@backstage/core-components';
|
|
3
|
+
import { useEntityList, EntityTextFilter } from '@backstage/plugin-catalog-react';
|
|
4
|
+
|
|
5
|
+
function OffsetPaginatedCatalogTable(props) {
|
|
6
|
+
const { columns, data } = props;
|
|
7
|
+
const { updateFilters, setLimit, setOffset, limit, totalItems, offset } = useEntityList();
|
|
8
|
+
const [page, setPage] = React.useState(
|
|
9
|
+
offset && limit ? Math.floor(offset / limit) : 0
|
|
10
|
+
);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (totalItems && page * limit >= totalItems) {
|
|
13
|
+
setOffset(Math.max(0, totalItems - limit));
|
|
14
|
+
} else {
|
|
15
|
+
setOffset(Math.max(0, page * limit));
|
|
16
|
+
}
|
|
17
|
+
}, [setOffset, page, limit, totalItems]);
|
|
18
|
+
return /* @__PURE__ */ React.createElement(
|
|
19
|
+
Table,
|
|
20
|
+
{
|
|
21
|
+
columns,
|
|
22
|
+
data,
|
|
23
|
+
options: {
|
|
24
|
+
paginationPosition: "both",
|
|
25
|
+
pageSizeOptions: [5, 10, 20, 50, 100],
|
|
26
|
+
pageSize: limit,
|
|
27
|
+
emptyRowsWhenPaging: false
|
|
28
|
+
},
|
|
29
|
+
onSearchChange: (searchText) => updateFilters({
|
|
30
|
+
text: searchText ? new EntityTextFilter(searchText) : void 0
|
|
31
|
+
}),
|
|
32
|
+
page,
|
|
33
|
+
onPageChange: (newPage) => {
|
|
34
|
+
setPage(newPage);
|
|
35
|
+
},
|
|
36
|
+
onRowsPerPageChange: (pageSize) => {
|
|
37
|
+
setLimit(pageSize);
|
|
38
|
+
},
|
|
39
|
+
totalCount: totalItems,
|
|
40
|
+
localization: { pagination: { labelDisplayedRows: "" } }
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { OffsetPaginatedCatalogTable };
|
|
46
|
+
//# sourceMappingURL=OffsetPaginatedCatalogTable.esm.js.map
|
|
@@ -0,0 +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 React, { useEffect } from 'react';\n\nimport { Table, TableProps } from '@backstage/core-components';\nimport { CatalogTableRow } from './types';\nimport {\n EntityTextFilter,\n useEntityList,\n} from '@backstage/plugin-catalog-react';\n\n/**\n * @internal\n */\nexport function OffsetPaginatedCatalogTable(\n props: TableProps<CatalogTableRow>,\n) {\n const { columns, data } = props;\n const { updateFilters, setLimit, setOffset, limit, totalItems, offset } =\n useEntityList();\n const [page, setPage] = React.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 paginationPosition: 'both',\n pageSizeOptions: [5, 10, 20, 50, 100],\n pageSize: limit,\n emptyRowsWhenPaging: false,\n }}\n onSearchChange={(searchText: string) =>\n updateFilters({\n text: searchText ? new EntityTextFilter(searchText) : undefined,\n })\n }\n page={page}\n onPageChange={newPage => {\n setPage(newPage);\n }}\n onRowsPerPageChange={pageSize => {\n setLimit(pageSize);\n }}\n totalCount={totalItems}\n localization={{ pagination: { labelDisplayedRows: '' } }}\n />\n );\n}\n"],"names":[],"mappings":";;;;AA4BO,SAAS,4BACd,KACA,EAAA;AACA,EAAM,MAAA,EAAE,OAAS,EAAA,IAAA,EAAS,GAAA,KAAA,CAAA;AAC1B,EAAM,MAAA,EAAE,eAAe,QAAU,EAAA,SAAA,EAAW,OAAO,UAAY,EAAA,MAAA,KAC7D,aAAc,EAAA,CAAA;AAChB,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,KAAM,CAAA,QAAA;AAAA,IAC5B,UAAU,KAAQ,GAAA,IAAA,CAAK,KAAM,CAAA,MAAA,GAAS,KAAK,CAAI,GAAA,CAAA;AAAA,GACjD,CAAA;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,CAAA;AAAA,KACrC,MAAA;AACL,MAAA,SAAA,CAAW,IAAK,CAAA,GAAA,CAAI,CAAG,EAAA,IAAA,GAAO,KAAK,CAAC,CAAA,CAAA;AAAA,KACtC;AAAA,KACC,CAAC,SAAA,EAAW,IAAM,EAAA,KAAA,EAAO,UAAU,CAAC,CAAA,CAAA;AAEvC,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,kBAAoB,EAAA,MAAA;AAAA,QACpB,iBAAiB,CAAC,CAAA,EAAG,EAAI,EAAA,EAAA,EAAI,IAAI,GAAG,CAAA;AAAA,QACpC,QAAU,EAAA,KAAA;AAAA,QACV,mBAAqB,EAAA,KAAA;AAAA,OACvB;AAAA,MACA,cAAA,EAAgB,CAAC,UAAA,KACf,aAAc,CAAA;AAAA,QACZ,IAAM,EAAA,UAAA,GAAa,IAAI,gBAAA,CAAiB,UAAU,CAAI,GAAA,KAAA,CAAA;AAAA,OACvD,CAAA;AAAA,MAEH,IAAA;AAAA,MACA,cAAc,CAAW,OAAA,KAAA;AACvB,QAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,OACjB;AAAA,MACA,qBAAqB,CAAY,QAAA,KAAA;AAC/B,QAAA,QAAA,CAAS,QAAQ,CAAA,CAAA;AAAA,OACnB;AAAA,MACA,UAAY,EAAA,UAAA;AAAA,MACZ,cAAc,EAAE,UAAA,EAAY,EAAE,kBAAA,EAAoB,IAAK,EAAA;AAAA,KAAA;AAAA,GACzD,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Entity, CompoundEntityRef, ComponentEntity, ResourceEntity, SystemEntity } from '@backstage/catalog-model';
|
|
3
3
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
4
|
import { IconComponent, StorageApi, ApiHolder } from '@backstage/core-plugin-api';
|
|
5
|
-
import { EntityRefPresentationSnapshot, CatalogApi, EntityPresentationApi, EntityRefPresentation, StarredEntitiesApi, EntityListContextProps, UserListFilterKind, EntityOwnerPickerProps } from '@backstage/plugin-catalog-react';
|
|
5
|
+
import { EntityRefPresentationSnapshot, CatalogApi, EntityPresentationApi, EntityRefPresentation, StarredEntitiesApi, EntityListContextProps, UserListFilterKind, EntityOwnerPickerProps, EntityListPagination } from '@backstage/plugin-catalog-react';
|
|
6
6
|
import { HumanDuration, Observable } from '@backstage/types';
|
|
7
7
|
import { InfoCardVariants, TableColumn, TableProps, TableOptions } from '@backstage/core-components';
|
|
8
8
|
import * as React$1 from 'react';
|
|
@@ -511,11 +511,9 @@ interface DefaultCatalogPageProps {
|
|
|
511
511
|
tableOptions?: TableProps<CatalogTableRow>['options'];
|
|
512
512
|
emptyContent?: ReactNode;
|
|
513
513
|
ownerPickerMode?: EntityOwnerPickerProps['mode'];
|
|
514
|
-
pagination?: boolean | {
|
|
515
|
-
limit?: number;
|
|
516
|
-
};
|
|
517
514
|
filters?: ReactNode;
|
|
518
515
|
initiallySelectedNamespaces?: string[];
|
|
516
|
+
pagination?: EntityListPagination;
|
|
519
517
|
}
|
|
520
518
|
|
|
521
519
|
/** @public */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0-next.2",
|
|
4
4
|
"description": "The Backstage plugin for browsing the Backstage catalog",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin",
|
|
@@ -57,20 +57,20 @@
|
|
|
57
57
|
"test": "backstage-cli package test"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@backstage/catalog-client": "^1.
|
|
60
|
+
"@backstage/catalog-client": "^1.7.0-next.1",
|
|
61
61
|
"@backstage/catalog-model": "^1.6.0",
|
|
62
|
-
"@backstage/core-compat-api": "^0.3.0-next.
|
|
63
|
-
"@backstage/core-components": "^0.14.11-next.
|
|
64
|
-
"@backstage/core-plugin-api": "^1.9.
|
|
62
|
+
"@backstage/core-compat-api": "^0.3.0-next.2",
|
|
63
|
+
"@backstage/core-components": "^0.14.11-next.1",
|
|
64
|
+
"@backstage/core-plugin-api": "^1.9.4-next.0",
|
|
65
65
|
"@backstage/errors": "^1.2.4",
|
|
66
|
-
"@backstage/frontend-plugin-api": "^0.8.0-next.
|
|
67
|
-
"@backstage/integration-react": "^1.1.
|
|
66
|
+
"@backstage/frontend-plugin-api": "^0.8.0-next.2",
|
|
67
|
+
"@backstage/integration-react": "^1.1.31-next.0",
|
|
68
68
|
"@backstage/plugin-catalog-common": "^1.0.26",
|
|
69
|
-
"@backstage/plugin-catalog-react": "^1.
|
|
70
|
-
"@backstage/plugin-permission-react": "^0.4.
|
|
69
|
+
"@backstage/plugin-catalog-react": "^1.13.0-next.2",
|
|
70
|
+
"@backstage/plugin-permission-react": "^0.4.26-next.0",
|
|
71
71
|
"@backstage/plugin-scaffolder-common": "^1.5.5",
|
|
72
72
|
"@backstage/plugin-search-common": "^1.2.14",
|
|
73
|
-
"@backstage/plugin-search-react": "^1.8.0-next.
|
|
73
|
+
"@backstage/plugin-search-react": "^1.8.0-next.2",
|
|
74
74
|
"@backstage/types": "^1.1.1",
|
|
75
75
|
"@material-ui/core": "^4.12.2",
|
|
76
76
|
"@material-ui/icons": "^4.9.1",
|
|
@@ -86,15 +86,15 @@
|
|
|
86
86
|
"zen-observable": "^0.10.0"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@backstage/cli": "^0.27.1-next.
|
|
90
|
-
"@backstage/core-app-api": "^1.14.
|
|
91
|
-
"@backstage/dev-utils": "^1.0
|
|
92
|
-
"@backstage/frontend-test-utils": "^0.2.0-next.
|
|
89
|
+
"@backstage/cli": "^0.27.1-next.2",
|
|
90
|
+
"@backstage/core-app-api": "^1.14.3-next.0",
|
|
91
|
+
"@backstage/dev-utils": "^1.1.0-next.2",
|
|
92
|
+
"@backstage/frontend-test-utils": "^0.2.0-next.2",
|
|
93
93
|
"@backstage/plugin-permission-common": "^0.8.1",
|
|
94
|
-
"@backstage/test-utils": "^1.6.0-next.
|
|
94
|
+
"@backstage/test-utils": "^1.6.0-next.1",
|
|
95
95
|
"@testing-library/dom": "^10.0.0",
|
|
96
96
|
"@testing-library/jest-dom": "^6.0.0",
|
|
97
|
-
"@testing-library/react": "^
|
|
97
|
+
"@testing-library/react": "^16.0.0",
|
|
98
98
|
"@testing-library/user-event": "^14.0.0",
|
|
99
99
|
"@types/pluralize": "^0.0.33",
|
|
100
100
|
"swr": "^2.2.5"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PaginatedCatalogTable.esm.js","sources":["../../../src/components/CatalogTable/PaginatedCatalogTable.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 React from 'react';\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 */\nexport function PaginatedCatalogTable(props: PaginatedCatalogTableProps) {\n const { columns, data, next, prev, title, isLoading, options, ...restProps } =\n props;\n\n return (\n <Table\n title={isLoading ? '' : title}\n columns={columns}\n data={data}\n options={{\n ...options,\n // These settings are configured to force server side pagination\n paginationPosition: 'both',\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":";;;;AA8BO,SAAS,sBAAsB,KAAmC,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,IAAA,EAAM,IAAM,EAAA,IAAA,EAAM,OAAO,SAAW,EAAA,OAAA,EAAS,GAAG,SAAA,EAC/D,GAAA,KAAA,CAAA;AAEF,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,YAAY,EAAK,GAAA,KAAA;AAAA,MACxB,OAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAS,EAAA;AAAA,QACP,GAAG,OAAA;AAAA;AAAA,QAEH,kBAAoB,EAAA,MAAA;AAAA,QACpB,iBAAiB,EAAC;AAAA,QAClB,wBAA0B,EAAA,KAAA;AAAA,QAC1B,UAAU,MAAO,CAAA,gBAAA;AAAA,QACjB,mBAAqB,EAAA,KAAA;AAAA,OACvB;AAAA,MACA,cAAc,CAAQ,IAAA,KAAA;AACpB,QAAA,IAAI,OAAO,CAAG,EAAA;AACZ,UAAO,IAAA,IAAA,CAAA;AAAA,SACF,MAAA;AACL,UAAO,IAAA,IAAA,CAAA;AAAA,SACT;AAAA,OACF;AAAA,MACA,UAAY,EAAA;AAAA,QACV,OAAS,EAAA,mBAAA;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,SAAA;AAAA,KAAA;AAAA,GACN,CAAA;AAEJ;;;;"}
|