@backstage/plugin-techdocs 1.12.5-next.1 → 1.12.5-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/dist/EntityPageDocs.esm.js +11 -8
- package/dist/EntityPageDocs.esm.js.map +1 -1
- package/dist/Router.esm.js +15 -12
- package/dist/Router.esm.js.map +1 -1
- package/dist/alpha.d.ts +6 -6
- package/dist/alpha.esm.js +14 -10
- package/dist/alpha.esm.js.map +1 -1
- package/dist/home/components/DefaultTechDocsHome.esm.js +21 -10
- package/dist/home/components/DefaultTechDocsHome.esm.js.map +1 -1
- package/dist/home/components/Grids/DocsCardGrid.esm.js +26 -22
- package/dist/home/components/Grids/DocsCardGrid.esm.js.map +1 -1
- package/dist/home/components/Grids/EntityListDocsGrid.esm.js +22 -14
- package/dist/home/components/Grids/EntityListDocsGrid.esm.js.map +1 -1
- package/dist/home/components/Grids/InfoCardGrid.esm.js +19 -17
- package/dist/home/components/Grids/InfoCardGrid.esm.js.map +1 -1
- package/dist/home/components/Tables/CursorPaginatedDocsTable.esm.js +2 -2
- package/dist/home/components/Tables/CursorPaginatedDocsTable.esm.js.map +1 -1
- package/dist/home/components/Tables/DocsTable.esm.js +8 -8
- package/dist/home/components/Tables/DocsTable.esm.js.map +1 -1
- package/dist/home/components/Tables/EntityListDocsTable.esm.js +8 -8
- package/dist/home/components/Tables/EntityListDocsTable.esm.js.map +1 -1
- package/dist/home/components/Tables/OffsetPaginatedDocsTable.esm.js +4 -3
- package/dist/home/components/Tables/OffsetPaginatedDocsTable.esm.js.map +1 -1
- package/dist/home/components/Tables/actions.esm.js +3 -3
- package/dist/home/components/Tables/actions.esm.js.map +1 -1
- package/dist/home/components/Tables/columns.esm.js +4 -4
- package/dist/home/components/Tables/columns.esm.js.map +1 -1
- package/dist/home/components/TechDocsCustomHome.esm.js +41 -34
- package/dist/home/components/TechDocsCustomHome.esm.js.map +1 -1
- package/dist/home/components/TechDocsIndexPage.esm.js +2 -2
- package/dist/home/components/TechDocsIndexPage.esm.js.map +1 -1
- package/dist/home/components/TechDocsPageWrapper.esm.js +6 -6
- package/dist/home/components/TechDocsPageWrapper.esm.js.map +1 -1
- package/dist/index.d.ts +39 -38
- package/dist/reader/components/TechDocsBuildLogs.esm.js +48 -40
- package/dist/reader/components/TechDocsBuildLogs.esm.js.map +1 -1
- package/dist/reader/components/TechDocsNotFound.esm.js +3 -2
- package/dist/reader/components/TechDocsNotFound.esm.js.map +1 -1
- package/dist/reader/components/TechDocsReaderPage/TechDocsReaderPage.esm.js +18 -13
- package/dist/reader/components/TechDocsReaderPage/TechDocsReaderPage.esm.js.map +1 -1
- package/dist/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.esm.js +19 -11
- package/dist/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.esm.js.map +1 -1
- package/dist/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContentAddons.esm.js +6 -2
- package/dist/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContentAddons.esm.js.map +1 -1
- package/dist/reader/components/TechDocsReaderPageHeader/TechDocsReaderPageHeader.esm.js +55 -44
- package/dist/reader/components/TechDocsReaderPageHeader/TechDocsReaderPageHeader.esm.js.map +1 -1
- package/dist/reader/components/TechDocsReaderPageSubheader/TechDocsReaderPageSubheader.esm.js +33 -27
- package/dist/reader/components/TechDocsReaderPageSubheader/TechDocsReaderPageSubheader.esm.js.map +1 -1
- package/dist/reader/components/TechDocsReaderProvider.esm.js +4 -3
- package/dist/reader/components/TechDocsReaderProvider.esm.js.map +1 -1
- package/dist/reader/components/TechDocsRedirectNotification/TechDocsRedirectNotification.esm.js +7 -6
- package/dist/reader/components/TechDocsRedirectNotification/TechDocsRedirectNotification.esm.js.map +1 -1
- package/dist/reader/components/TechDocsStateIndicator.esm.js +43 -36
- package/dist/reader/components/TechDocsStateIndicator.esm.js.map +1 -1
- package/dist/reader/transformers/addGitFeedbackLink.esm.js +2 -2
- package/dist/reader/transformers/addGitFeedbackLink.esm.js.map +1 -1
- package/dist/reader/transformers/addSidebarToggle.esm.js +2 -2
- package/dist/reader/transformers/addSidebarToggle.esm.js.map +1 -1
- package/dist/reader/transformers/copyToClipboard.esm.js +16 -15
- package/dist/reader/transformers/copyToClipboard.esm.js.map +1 -1
- package/dist/reader/transformers/handleMetaRedirects.esm.js +2 -2
- package/dist/reader/transformers/handleMetaRedirects.esm.js.map +1 -1
- package/dist/search/components/TechDocsSearch.esm.js +5 -4
- package/dist/search/components/TechDocsSearch.esm.js.map +1 -1
- package/dist/search/components/TechDocsSearchResultListItem.esm.js +28 -20
- package/dist/search/components/TechDocsSearchResultListItem.esm.js.map +1 -1
- package/package.json +20 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityListDocsGrid.esm.js","sources":["../../../../src/home/components/Grids/EntityListDocsGrid.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 { DocsCardGrid } from './DocsCardGrid';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n CodeSnippet,\n Content,\n ContentHeader,\n Link,\n Progress,\n WarningPanel,\n} from '@backstage/core-components';\nimport {\n useEntityList,\n useEntityOwnership,\n} from '@backstage/plugin-catalog-react';\nimport Typography from '@material-ui/core/Typography';\nimport
|
|
1
|
+
{"version":3,"file":"EntityListDocsGrid.esm.js","sources":["../../../../src/home/components/Grids/EntityListDocsGrid.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 { DocsCardGrid } from './DocsCardGrid';\nimport { Entity } from '@backstage/catalog-model';\nimport {\n CodeSnippet,\n Content,\n ContentHeader,\n Link,\n Progress,\n WarningPanel,\n} from '@backstage/core-components';\nimport {\n useEntityList,\n useEntityOwnership,\n} from '@backstage/plugin-catalog-react';\nimport Typography from '@material-ui/core/Typography';\nimport { ReactNode } from 'react';\n\n/**\n * Props for {@link EntityListDocsGrid}\n *\n * @public\n */\nexport type DocsGroupConfig = {\n title: ReactNode;\n filterPredicate: ((entity: Entity) => boolean) | string;\n};\n\n/**\n * Props for {@link EntityListDocsGrid}\n *\n * @public\n */\nexport type EntityListDocsGridPageProps = {\n groups?: DocsGroupConfig[];\n};\n\nconst allEntitiesGroup: DocsGroupConfig = {\n title: 'All Documentation',\n filterPredicate: () => true,\n};\n\nconst EntityListDocsGridGroup = (props: {\n group: DocsGroupConfig;\n entities: Entity[];\n}) => {\n const { entities, group } = props;\n const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();\n\n const shownEntities = entities.filter(entity => {\n if (group.filterPredicate === 'ownedByUser') {\n if (loadingOwnership) {\n return false;\n }\n return isOwnedEntity(entity);\n }\n\n return (\n typeof group.filterPredicate === 'function' &&\n group.filterPredicate(entity)\n );\n });\n\n const titleComponent: ReactNode = (() => {\n return typeof group.title === 'string' ? (\n <ContentHeader title={group.title} />\n ) : (\n group.title\n );\n })();\n\n if (shownEntities.length === 0) {\n return null;\n }\n\n return (\n <Content>\n {titleComponent}\n <DocsCardGrid entities={shownEntities} />\n </Content>\n );\n};\n\n/**\n * Component responsible to get entities from entity list context and pass down to DocsCardGrid\n *\n * @public\n */\nexport const EntityListDocsGrid = (props: EntityListDocsGridPageProps) => {\n const { loading, error, entities } = useEntityList();\n\n if (error) {\n return (\n <WarningPanel\n severity=\"error\"\n title=\"Could not load available documentation.\"\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n );\n }\n\n if (loading) {\n return <Progress />;\n }\n\n if (entities.length === 0) {\n return (\n <div data-testid=\"doc-not-found\">\n <Typography variant=\"body2\">\n No documentation found that match your filter. Learn more about{' '}\n <Link to=\"https://backstage.io/docs/features/techdocs/creating-and-publishing\">\n publishing documentation\n </Link>\n .\n </Typography>\n </div>\n );\n }\n\n entities.sort((a, b) =>\n (a.metadata.title ?? a.metadata.name).localeCompare(\n b.metadata.title ?? b.metadata.name,\n ),\n );\n\n return (\n <Content>\n {(props.groups || [allEntitiesGroup]).map((group, index: number) => (\n <EntityListDocsGridGroup\n entities={entities}\n group={group}\n key={`${group.title}-${index}`}\n />\n ))}\n </Content>\n );\n};\n"],"names":[],"mappings":";;;;;;AAoDA,MAAM,gBAAoC,GAAA;AAAA,EACxC,KAAO,EAAA,mBAAA;AAAA,EACP,iBAAiB,MAAM;AACzB,CAAA;AAEA,MAAM,uBAAA,GAA0B,CAAC,KAG3B,KAAA;AACJ,EAAM,MAAA,EAAE,QAAU,EAAA,KAAA,EAAU,GAAA,KAAA;AAC5B,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAkB,EAAA,aAAA,KAAkB,kBAAmB,EAAA;AAExE,EAAM,MAAA,aAAA,GAAgB,QAAS,CAAA,MAAA,CAAO,CAAU,MAAA,KAAA;AAC9C,IAAI,IAAA,KAAA,CAAM,oBAAoB,aAAe,EAAA;AAC3C,MAAA,IAAI,gBAAkB,EAAA;AACpB,QAAO,OAAA,KAAA;AAAA;AAET,MAAA,OAAO,cAAc,MAAM,CAAA;AAAA;AAG7B,IAAA,OACE,OAAO,KAAM,CAAA,eAAA,KAAoB,UACjC,IAAA,KAAA,CAAM,gBAAgB,MAAM,CAAA;A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AA,CAAA;AAAA,MAAO;AAAA,KAAA,EAET,CACF,EAAA,CAAA;AAAA;AAIJ,EAAS,QAAA,CAAA,IAAA;AAAA,IAAK,CAAC,GAAG,CACf,KAAA,CAAA,CAAA,CAAE,SAAS,KAAS,IAAA,CAAA,CAAE,SAAS,IAAM,EAAA,aAAA;AAAA,MACpC,CAAE,CAAA,QAAA,CAAS,KAAS,IAAA,CAAA,CAAE,QAAS,CAAA;AAAA;AACjC,GACF;AAEA,EACE,uBAAA,GAAA,CAAC,OACG,EAAA,EAAA,QAAA,EAAA,CAAA,KAAA,CAAM,MAAU,IAAA,CAAC,gBAAgB,CAAG,EAAA,GAAA,CAAI,CAAC,KAAA,EAAO,KAChD,qBAAA,GAAA;AAAA,IAAC,uBAAA;AAAA,IAAA;AAAA,MACC,QAAA;AAAA,MACA;AAAA,KAAA;AAAA,IACK,CAAG,EAAA,KAAA,CAAM,KAAK,CAAA,CAAA,EAAI,KAAK,CAAA;AAAA,GAE/B,CACH,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import useAsync from 'react-use/esm/useAsync';
|
|
3
3
|
import { stringifyEntityRef } from '@backstage/catalog-model';
|
|
4
4
|
import { useRouteRef, useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
@@ -48,27 +48,29 @@ const InfoCardGrid = (props) => {
|
|
|
48
48
|
)
|
|
49
49
|
);
|
|
50
50
|
});
|
|
51
|
-
if (loading) return /* @__PURE__ */
|
|
51
|
+
if (loading) return /* @__PURE__ */ jsx(Progress, {});
|
|
52
52
|
if (!entities || !entities?.length) return null;
|
|
53
|
-
return /* @__PURE__ */
|
|
53
|
+
return /* @__PURE__ */ jsx(ItemCardGrid, { "data-testid": "info-card-container", children: entities.map((entity) => /* @__PURE__ */ jsxs(
|
|
54
54
|
InfoCard,
|
|
55
55
|
{
|
|
56
|
-
key: entity.metadata.name,
|
|
57
56
|
"data-testid": entity?.metadata?.title,
|
|
58
|
-
title: entityRefToPresentation?.get(stringifyEntityRef(entity))?.primaryTitle
|
|
57
|
+
title: entityRefToPresentation?.get(stringifyEntityRef(entity))?.primaryTitle,
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx("div", { children: entity?.metadata?.description }),
|
|
60
|
+
/* @__PURE__ */ jsx("div", { className: classes.linkSpacer }),
|
|
61
|
+
/* @__PURE__ */ jsx(
|
|
62
|
+
Link,
|
|
63
|
+
{
|
|
64
|
+
to: linkRoute(entity),
|
|
65
|
+
className: classes.readMoreLink,
|
|
66
|
+
"data-testid": "read-docs-link",
|
|
67
|
+
children: linkContent || "Read Docs"
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
]
|
|
59
71
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
/* @__PURE__ */ React.createElement(
|
|
63
|
-
Link,
|
|
64
|
-
{
|
|
65
|
-
to: linkRoute(entity),
|
|
66
|
-
className: classes.readMoreLink,
|
|
67
|
-
"data-testid": "read-docs-link"
|
|
68
|
-
},
|
|
69
|
-
linkContent || "Read Docs"
|
|
70
|
-
)
|
|
71
|
-
)));
|
|
72
|
+
entity.metadata.name
|
|
73
|
+
)) });
|
|
72
74
|
};
|
|
73
75
|
|
|
74
76
|
export { InfoCardGrid };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoCardGrid.esm.js","sources":["../../../../src/home/components/Grids/InfoCardGrid.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
|
|
1
|
+
{"version":3,"file":"InfoCardGrid.esm.js","sources":["../../../../src/home/components/Grids/InfoCardGrid.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 useAsync from 'react-use/esm/useAsync';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi, useRouteRef, configApiRef } from '@backstage/core-plugin-api';\nimport {\n ItemCardGrid,\n InfoCard,\n Link,\n Progress,\n} from '@backstage/core-components';\nimport {\n EntityRefPresentationSnapshot,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { rootDocsRouteRef } from '../../../routes';\nimport { toLowerMaybe } from '../../../helpers';\n\n/** @public */\nexport type InfoCardGridClassKey = 'linkSpacer' | 'readMoreLink';\n\nconst useStyles = makeStyles(\n theme => ({\n linkSpacer: {\n paddingTop: theme.spacing(0.2),\n },\n readMoreLink: {\n paddingTop: theme.spacing(0.2),\n },\n }),\n { name: 'BackstageInfoCardGrid' },\n);\n\n/**\n * Props for {@link InfoCardGrid}\n *\n * @public\n */\nexport type InfoCardGridProps = {\n entities: Entity[] | undefined;\n linkContent?: string | JSX.Element;\n linkDestination?: (entity: Entity) => string | undefined;\n};\n\n/**\n * Component which accepts a list of entities and renders a info card for each entity\n *\n * @public\n */\nexport const InfoCardGrid = (props: InfoCardGridProps) => {\n const { entities, linkContent, linkDestination } = props;\n const classes = useStyles();\n const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);\n const config = useApi(configApiRef);\n const linkRoute = (entity: Entity) => {\n if (linkDestination) {\n const destination = linkDestination(entity);\n if (destination) {\n return destination;\n }\n }\n return getRouteToReaderPageFor({\n namespace: toLowerMaybe(entity.metadata.namespace ?? 'default', config),\n kind: toLowerMaybe(entity.kind, config),\n name: toLowerMaybe(entity.metadata.name, config),\n });\n };\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const { value: entityRefToPresentation, loading } = useAsync(async () => {\n return new Map<string, EntityRefPresentationSnapshot>(\n await Promise.all(\n entities?.map(async entity => {\n const presentation = await entityPresentationApi.forEntity(entity)\n .promise;\n return [stringifyEntityRef(entity), presentation] as [\n string,\n EntityRefPresentationSnapshot,\n ];\n }) || [],\n ),\n );\n });\n if (loading) return <Progress />;\n if (!entities || !entities?.length) return null;\n return (\n <ItemCardGrid data-testid=\"info-card-container\">\n {entities.map(entity => (\n <InfoCard\n key={entity.metadata.name}\n data-testid={entity?.metadata?.title}\n title={\n entityRefToPresentation?.get(stringifyEntityRef(entity))\n ?.primaryTitle\n }\n >\n <div>{entity?.metadata?.description}</div>\n <div className={classes.linkSpacer} />\n <Link\n to={linkRoute(entity)}\n className={classes.readMoreLink}\n data-testid=\"read-docs-link\"\n >\n {linkContent || 'Read Docs'}\n </Link>\n </InfoCard>\n ))}\n </ItemCardGrid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAoCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAU,KAAA,MAAA;AAAA,IACR,UAAY,EAAA;AAAA,MACV,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,GAAG;AAAA,KAC/B;AAAA,IACA,YAAc,EAAA;AAAA,MACZ,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,GAAG;AAAA;AAC/B,GACF,CAAA;AAAA,EACA,EAAE,MAAM,uBAAwB;AAClC,CAAA;AAkBa,MAAA,YAAA,GAAe,CAAC,KAA6B,KAAA;AACxD,EAAA,MAAM,EAAE,QAAA,EAAU,WAAa,EAAA,eAAA,EAAoB,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AAe,OAAA,IAAA;AAC3C,EAAA,2BACG,YAAa,EAAA,EAAA,aAAA,EAAY,qBACvB,EAAA,QAAA,EAAA,QAAA,CAAS,IAAI,CACZ,MAAA,qBAAA,IAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MAEC,aAAA,EAAa,QAAQ,QAAU,EAAA,KAAA;AAAA,MAC/B,OACE,uBAAyB,EAAA,GAAA,CAAI,kBAAmB,CAAA,MAAM,CAAC,CACnD,EAAA,YAAA;AAAA,MAGN,QAAA,EAAA;AAAA,wBAAC,GAAA,CAAA,KAAA,EAAA,EAAK,QAAQ,EAAA,MAAA,EAAA,QAAA,EAAU,WAAY,EAAA,CAAA;AAAA,wBACnC,GAAA,CAAA,KAAA,EAAA,EAAI,SAAW,EAAA,OAAA,CAAQ,UAAY,EAAA,CAAA;AAAA,wBACpC,GAAA;AAAA,UAAC,IAAA;AAAA,UAAA;AAAA,YACC,EAAA,EAAI,UAAU,MAAM,CAAA;AAAA,YACpB,WAAW,OAAQ,CAAA,YAAA;AAAA,YACnB,aAAY,EAAA,gBAAA;AAAA,YAEX,QAAe,EAAA,WAAA,IAAA;AAAA;AAAA;AAClB;AAAA,KAAA;AAAA,IAfK,OAAO,QAAS,CAAA;AAAA,GAiBxB,CACH,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Table } from '@backstage/core-components';
|
|
3
3
|
|
|
4
4
|
function CursorPaginatedDocsTable(props) {
|
|
@@ -13,7 +13,7 @@ function CursorPaginatedDocsTable(props) {
|
|
|
13
13
|
options,
|
|
14
14
|
...restProps
|
|
15
15
|
} = props;
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
17
17
|
Table,
|
|
18
18
|
{
|
|
19
19
|
title: isLoading ? "" : title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorPaginatedDocsTable.esm.js","sources":["../../../../src/home/components/Tables/CursorPaginatedDocsTable.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"CursorPaginatedDocsTable.esm.js","sources":["../../../../src/home/components/Tables/CursorPaginatedDocsTable.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Table, TableProps } from '@backstage/core-components';\nimport { DocsTableRow } from './types';\n\ntype PaginatedDocsTableProps = {\n prev?(): void;\n next?(): void;\n} & TableProps<DocsTableRow>;\n\n/**\n * @internal\n */\n\nexport function CursorPaginatedDocsTable(props: PaginatedDocsTableProps) {\n const {\n actions,\n columns,\n data,\n next,\n prev,\n title,\n isLoading,\n options,\n ...restProps\n } = props;\n\n return (\n <Table\n title={isLoading ? '' : title}\n columns={columns}\n data={data}\n options={{\n paginationPosition: 'both',\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 actionsColumnIndex: -1,\n }}\n onPageChange={page => {\n if (page > 0) {\n next?.();\n } else {\n prev?.();\n }\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 isLoading={isLoading}\n {...restProps}\n />\n );\n}\n"],"names":[],"mappings":";;;AA4BO,SAAS,yBAAyB,KAAgC,EAAA;AACvE,EAAM,MAAA;AAAA,IACJ,OAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,SAAA;AAAA,IACA,OAAA;AAAA,IACA,GAAG;AAAA,GACD,GAAA,KAAA;AAEJ,EACE,uBAAA,GAAA;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,kBAAoB,EAAA,MAAA;AAAA,QACpB,GAAG,OAAA;AAAA;AAAA,QAEH,iBAAiB,EAAC;AAAA,QAClB,wBAA0B,EAAA,KAAA;AAAA,QAC1B,UAAU,MAAO,CAAA,gBAAA;AAAA,QACjB,mBAAqB,EAAA,KAAA;AAAA,QACrB,kBAAoB,EAAA,CAAA;AAAA,OACtB;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,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,MACvD,SAAA;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import useCopyToClipboard from 'react-use/esm/useCopyToClipboard';
|
|
3
3
|
import { useRouteRef, useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
4
4
|
import { rootDocsRouteRef } from '../../../routes.esm.js';
|
|
@@ -23,7 +23,7 @@ const DocsTable = (props) => {
|
|
|
23
23
|
];
|
|
24
24
|
const pageSize = 20;
|
|
25
25
|
const paging = documents && documents.length > pageSize;
|
|
26
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ jsx(Fragment, { children: loading || documents && documents.length > 0 ? /* @__PURE__ */ jsx(
|
|
27
27
|
Table,
|
|
28
28
|
{
|
|
29
29
|
isLoading: loading,
|
|
@@ -39,23 +39,23 @@ const DocsTable = (props) => {
|
|
|
39
39
|
actions: actions || defaultActions,
|
|
40
40
|
title: title ? `${title} (${documents.length})` : `All (${documents.length})`
|
|
41
41
|
}
|
|
42
|
-
) : /* @__PURE__ */
|
|
42
|
+
) : /* @__PURE__ */ jsx(
|
|
43
43
|
EmptyState,
|
|
44
44
|
{
|
|
45
45
|
missing: "data",
|
|
46
46
|
title: "No documents to show",
|
|
47
47
|
description: "Create your own document. Check out our Getting Started Information",
|
|
48
|
-
action: /* @__PURE__ */
|
|
48
|
+
action: /* @__PURE__ */ jsx(
|
|
49
49
|
LinkButton,
|
|
50
50
|
{
|
|
51
51
|
color: "primary",
|
|
52
52
|
to: "https://backstage.io/docs/features/techdocs/getting-started",
|
|
53
|
-
variant: "contained"
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
variant: "contained",
|
|
54
|
+
children: "DOCS"
|
|
55
|
+
}
|
|
56
56
|
)
|
|
57
57
|
}
|
|
58
|
-
));
|
|
58
|
+
) });
|
|
59
59
|
};
|
|
60
60
|
DocsTable.columns = columnFactories;
|
|
61
61
|
DocsTable.actions = actionFactories;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocsTable.esm.js","sources":["../../../../src/home/components/Tables/DocsTable.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
|
|
1
|
+
{"version":3,"file":"DocsTable.esm.js","sources":["../../../../src/home/components/Tables/DocsTable.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 useCopyToClipboard from 'react-use/esm/useCopyToClipboard';\n\nimport { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport { Entity } from '@backstage/catalog-model';\nimport { rootDocsRouteRef } from '../../../routes';\nimport {\n EmptyState,\n LinkButton,\n Table,\n TableColumn,\n TableOptions,\n TableProps,\n} from '@backstage/core-components';\nimport { actionFactories } from './actions';\nimport { columnFactories, defaultColumns } from './columns';\nimport { DocsTableRow } from './types';\nimport { entitiesToDocsMapper } from './helpers';\n\n/**\n * Props for {@link DocsTable}.\n *\n * @public\n */\nexport type DocsTableProps = {\n entities: Entity[] | undefined;\n title?: string | undefined;\n loading?: boolean | undefined;\n columns?: TableColumn<DocsTableRow>[];\n actions?: TableProps<DocsTableRow>['actions'];\n options?: TableOptions<DocsTableRow>;\n};\n\n/**\n * Component which renders a table documents\n *\n * @public\n */\nexport const DocsTable = (props: DocsTableProps) => {\n const { entities, title, loading, columns, actions, options } = props;\n const [, copyToClipboard] = useCopyToClipboard();\n const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);\n const config = useApi(configApiRef);\n if (!entities) return null;\n\n const documents = entitiesToDocsMapper(\n entities,\n getRouteToReaderPageFor,\n config,\n );\n\n const defaultActions: TableProps<DocsTableRow>['actions'] = [\n actionFactories.createCopyDocsUrlAction(copyToClipboard),\n ];\n\n const pageSize = 20;\n const paging = documents && documents.length > pageSize;\n\n return (\n <>\n {loading || (documents && documents.length > 0) ? (\n <Table<DocsTableRow>\n isLoading={loading}\n options={{\n paging,\n pageSize,\n search: true,\n actionsColumnIndex: -1,\n ...options,\n }}\n data={documents}\n columns={columns || defaultColumns}\n actions={actions || defaultActions}\n title={\n title\n ? `${title} (${documents.length})`\n : `All (${documents.length})`\n }\n />\n ) : (\n <EmptyState\n missing=\"data\"\n title=\"No documents to show\"\n description=\"Create your own document. Check out our Getting Started Information\"\n action={\n <LinkButton\n color=\"primary\"\n to=\"https://backstage.io/docs/features/techdocs/getting-started\"\n variant=\"contained\"\n >\n DOCS\n </LinkButton>\n }\n />\n )}\n </>\n );\n};\n\nDocsTable.columns = columnFactories;\nDocsTable.actions = actionFactories;\n"],"names":[],"mappings":";;;;;;;;;AAqDa,MAAA,SAAA,GAAY,CAAC,KAA0B,KAAA;AAClD,EAAA,MAAM,EAAE,QAAU,EAAA,KAAA,EAAO,SAAS,OAAS,EAAA,OAAA,EAAS,SAAY,GAAA,KAAA;AAChE,EAAA,MAAM,GAAG,eAAe,CAAA,GAAI,kBAAmB,EAAA;AAC/C,EAAM,MAAA,uBAAA,GAA0B,YAAY,gBAAgB,CAAA;AAC5D,EAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA;AAClC,EAAI,IAAA,CAAC,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AAAA;AAED;AAAA,GAIR,EAAA,CAAA;AAEJ;AAEA,SAAA,CAAU,OAAU,GAAA,eAAA;AACpB,SAAA,CAAU,OAAU,GAAA,eAAA;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import useCopyToClipboard from 'react-use/esm/useCopyToClipboard';
|
|
3
3
|
import { capitalize } from 'lodash';
|
|
4
4
|
import { WarningPanel, CodeSnippet } from '@backstage/core-components';
|
|
@@ -33,7 +33,7 @@ const EntityListDocsTable = (props) => {
|
|
|
33
33
|
config
|
|
34
34
|
);
|
|
35
35
|
if (paginationMode === "cursor") {
|
|
36
|
-
return /* @__PURE__ */
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
37
|
CursorPaginatedDocsTable,
|
|
38
38
|
{
|
|
39
39
|
columns: columns || defaultColumns,
|
|
@@ -47,7 +47,7 @@ const EntityListDocsTable = (props) => {
|
|
|
47
47
|
}
|
|
48
48
|
);
|
|
49
49
|
} else if (paginationMode === "offset") {
|
|
50
|
-
return /* @__PURE__ */
|
|
50
|
+
return /* @__PURE__ */ jsx(
|
|
51
51
|
OffsetPaginatedDocsTable,
|
|
52
52
|
{
|
|
53
53
|
columns: columns || defaultColumns,
|
|
@@ -60,16 +60,16 @@ const EntityListDocsTable = (props) => {
|
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
if (error) {
|
|
63
|
-
return /* @__PURE__ */
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
64
|
WarningPanel,
|
|
65
65
|
{
|
|
66
66
|
severity: "error",
|
|
67
|
-
title: "Could not load available documentation."
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
title: "Could not load available documentation.",
|
|
68
|
+
children: /* @__PURE__ */ jsx(CodeSnippet, { language: "text", text: error.toString() })
|
|
69
|
+
}
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ jsx(
|
|
73
73
|
DocsTable,
|
|
74
74
|
{
|
|
75
75
|
title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityListDocsTable.esm.js","sources":["../../../../src/home/components/Tables/EntityListDocsTable.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
|
|
1
|
+
{"version":3,"file":"EntityListDocsTable.esm.js","sources":["../../../../src/home/components/Tables/EntityListDocsTable.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 useCopyToClipboard from 'react-use/esm/useCopyToClipboard';\nimport { capitalize } from 'lodash';\nimport {\n CodeSnippet,\n TableColumn,\n TableOptions,\n TableProps,\n WarningPanel,\n} from '@backstage/core-components';\nimport { configApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';\nimport {\n useEntityList,\n useStarredEntities,\n} from '@backstage/plugin-catalog-react';\nimport { DocsTable } from './DocsTable';\nimport { OffsetPaginatedDocsTable } from './OffsetPaginatedDocsTable';\nimport { CursorPaginatedDocsTable } from './CursorPaginatedDocsTable';\nimport { actionFactories } from './actions';\nimport { columnFactories, defaultColumns } from './columns';\nimport { DocsTableRow } from './types';\nimport { rootDocsRouteRef } from '../../../routes';\nimport { entitiesToDocsMapper } from './helpers';\n\n/**\n * Props for {@link EntityListDocsTable}.\n *\n * @public\n */\nexport type EntityListDocsTableProps = {\n columns?: TableColumn<DocsTableRow>[];\n actions?: TableProps<DocsTableRow>['actions'];\n options?: TableOptions<DocsTableRow>;\n};\n\n/**\n * Component which renders a table with entities from catalog.\n *\n * @public\n */\nexport const EntityListDocsTable = (props: EntityListDocsTableProps) => {\n const { columns, actions, options } = props;\n const { loading, error, entities, filters, paginationMode, pageInfo } =\n useEntityList();\n const { isStarredEntity, toggleStarredEntity } = useStarredEntities();\n const [, copyToClipboard] = useCopyToClipboard();\n const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);\n const config = useApi(configApiRef);\n\n const title = capitalize(filters.user?.value ?? 'all');\n\n const defaultActions = [\n actionFactories.createCopyDocsUrlAction(copyToClipboard),\n actionFactories.createStarEntityAction(\n isStarredEntity,\n toggleStarredEntity,\n ),\n ];\n\n const documents = entitiesToDocsMapper(\n entities,\n getRouteToReaderPageFor,\n config,\n );\n\n if (paginationMode === 'cursor') {\n return (\n <CursorPaginatedDocsTable\n columns={columns || defaultColumns}\n isLoading={loading}\n title={title}\n actions={actions || defaultActions}\n options={options}\n data={documents}\n next={pageInfo?.next}\n prev={pageInfo?.prev}\n />\n );\n } else if (paginationMode === 'offset') {\n return (\n <OffsetPaginatedDocsTable\n columns={columns || defaultColumns}\n isLoading={loading}\n title={title}\n actions={actions || defaultActions}\n options={options}\n data={documents}\n />\n );\n }\n\n if (error) {\n return (\n <WarningPanel\n severity=\"error\"\n title=\"Could not load available documentation.\"\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n );\n }\n\n return (\n <DocsTable\n title={title}\n entities={entities}\n loading={loading}\n actions={actions || defaultActions}\n columns={columns}\n options={options}\n />\n );\n};\n\nEntityListDocsTable.columns = columnFactories;\nEntityListDocsTable.act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GAAA;AAAA,MAAC,wBAAA;AAAA,MAAA;AAAA,QACC,SAAS,OAAW,IAAA,cAAA;AAAA,QACpB,SAAW,EAAA,OAAA;AAAA,QACX,KAAA;AAAA,QACA,SAAS,OAAW,IAAA,cAAA;AAAA,QACpB,OAAA;AAAA,QACA,IAAM,EAAA;AAAA;AAAA,KACR;AAAA;AAIJ,EAAA,IAAI,KAAO,EAAA;AACT,IACE,uBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,QAAS,EAAA,OAAA;AAAA,QACT,KAAM,EAAA,yCAAA;AAAA,QAEN,8BAAC,WAAY,EAAA,EAAA,QAAA,EAAS,QAAO,IAAM,EAAA,KAAA,CAAM,UAAY,EAAA;AAAA;AAAA,KACvD;AAAA;AAIJ,EACE,uBAAA,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,QAAA;AAAA,MACA,OAAA;AAAA,MACA,SAAS,OAAW,IAAA,cAAA;AAAA,MACpB,OAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;AAEA,mBAAA,CAAoB,OAAU,GAAA,eAAA;AAC9B,mBAAA,CAAoB,OAAU,GAAA,eAAA;;;;"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
2
3
|
import { Table } from '@backstage/core-components';
|
|
3
4
|
import { useEntityList, EntityTextFilter } from '@backstage/plugin-catalog-react';
|
|
4
5
|
|
|
5
6
|
function OffsetPaginatedDocsTable(props) {
|
|
6
7
|
const { actions, columns, data, isLoading, options } = props;
|
|
7
8
|
const { updateFilters, setLimit, setOffset, limit, totalItems, offset } = useEntityList();
|
|
8
|
-
const [page, setPage] =
|
|
9
|
+
const [page, setPage] = useState(
|
|
9
10
|
offset && limit ? Math.floor(offset / limit) : 0
|
|
10
11
|
);
|
|
11
12
|
useEffect(() => {
|
|
@@ -15,7 +16,7 @@ function OffsetPaginatedDocsTable(props) {
|
|
|
15
16
|
setOffset(Math.max(0, page * limit));
|
|
16
17
|
}
|
|
17
18
|
}, [setOffset, page, limit, totalItems]);
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
19
20
|
Table,
|
|
20
21
|
{
|
|
21
22
|
columns,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OffsetPaginatedDocsTable.esm.js","sources":["../../../../src/home/components/Tables/OffsetPaginatedDocsTable.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"OffsetPaginatedDocsTable.esm.js","sources":["../../../../src/home/components/Tables/OffsetPaginatedDocsTable.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useState, useEffect } from 'react';\n\nimport { Table, TableProps } from '@backstage/core-components';\nimport { DocsTableRow } from './types';\nimport {\n EntityTextFilter,\n useEntityList,\n} from '@backstage/plugin-catalog-react';\n\n/**\n * @internal\n */\nexport function OffsetPaginatedDocsTable(props: TableProps<DocsTableRow>) {\n const { actions, columns, data, isLoading, options } = props;\n const { updateFilters, setLimit, setOffset, limit, totalItems, offset } =\n useEntityList();\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<DocsTableRow>\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 actionsColumnIndex: -1,\n ...options,\n }}\n actions={actions}\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 isLoading={isLoading}\n />\n );\n}\n"],"names":[],"mappings":";;;;;AA4BO,SAAS,yBAAyB,KAAiC,EAAA;AACxE,EAAA,MAAM,EAAE,OAAS,EAAA,OAAA,EAAS,IAAM,EAAA,SAAA,EAAW,SAAY,GAAA,KAAA;AACvD,EAAM,MAAA,EAAE,eAAe,QAAU,EAAA,SAAA,EAAW,OAAO,UAAY,EAAA,MAAA,KAC7D,aAAc,EAAA;AAChB,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,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,QACrB,kBAAoB,EAAA,CAAA,CAAA;AAAA,QACpB,GAAG;AAAA,OACL;AAAA,MACA,OAAA;AAAA,MACA,cAAA,EAAgB,CAAC,UAAA,KACf,aAAc,CAAA;AAAA,QACZ,IAAM,EAAA,UAAA,GAAa,IAAI,gBAAA,CAAiB,UAAU,CAAI,GAAA,KAAA;AAAA,OACvD,CAAA;AAAA,MAEH,IAAA;AAAA,MACA,cAAc,CAAW,OAAA,KAAA;AACvB,QAAA,OAAA,CAAQ,OAAO,CAAA;AAAA,OACjB;AAAA,MACA,qBAAqB,CAAY,QAAA,KAAA;AAC/B,QAAA,QAAA,CAAS,QAAQ,CAAA;AAAA,OACnB;AAAA,MACA,UAAY,EAAA,UAAA;AAAA,MACZ,cAAc,EAAE,UAAA,EAAY,EAAE,kBAAA,EAAoB,IAAK,EAAA;AAAA,MACvD;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import ShareIcon from '@material-ui/icons/Share';
|
|
3
3
|
import { FavoriteToggleIcon } from '@backstage/core-components';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ const actionFactories = {
|
|
|
6
6
|
createCopyDocsUrlAction(copyToClipboard) {
|
|
7
7
|
return (row) => {
|
|
8
8
|
return {
|
|
9
|
-
icon: () => /* @__PURE__ */
|
|
9
|
+
icon: () => /* @__PURE__ */ jsx(ShareIcon, { fontSize: "small" }),
|
|
10
10
|
tooltip: "Click to copy documentation link to clipboard",
|
|
11
11
|
onClick: () => copyToClipboard(`${window.location.origin}${row.resolved.docsUrl}`)
|
|
12
12
|
};
|
|
@@ -18,7 +18,7 @@ const actionFactories = {
|
|
|
18
18
|
const isStarred = isStarredEntity(entity);
|
|
19
19
|
return {
|
|
20
20
|
cellStyle: { paddingLeft: "1em" },
|
|
21
|
-
icon: () => /* @__PURE__ */
|
|
21
|
+
icon: () => /* @__PURE__ */ jsx(FavoriteToggleIcon, { isFavorite: isStarred }),
|
|
22
22
|
tooltip: isStarred ? "Remove from favorites" : "Add to favorites",
|
|
23
23
|
onClick: () => toggleStarredEntity(entity)
|
|
24
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.esm.js","sources":["../../../../src/home/components/Tables/actions.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
|
|
1
|
+
{"version":3,"file":"actions.esm.js","sources":["../../../../src/home/components/Tables/actions.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 ShareIcon from '@material-ui/icons/Share';\nimport { DocsTableRow } from './types';\nimport { FavoriteToggleIcon } from '@backstage/core-components';\n\n/**\n * Not directly exported, but through DocsTable.actions and EntityListDocsTable.actions\n *\n * @public\n */\nexport const actionFactories = {\n createCopyDocsUrlAction(copyToClipboard: Function) {\n return (row: DocsTableRow) => {\n return {\n icon: () => <ShareIcon fontSize=\"small\" />,\n tooltip: 'Click to copy documentation link to clipboard',\n onClick: () =>\n copyToClipboard(`${window.location.origin}${row.resolved.docsUrl}`),\n };\n };\n },\n createStarEntityAction(\n isStarredEntity: Function,\n toggleStarredEntity: Function,\n ) {\n return (row: DocsTableRow) => {\n const entity = row.entity;\n const isStarred = isStarredEntity(entity);\n return {\n cellStyle: { paddingLeft: '1em' },\n icon: () => <FavoriteToggleIcon isFavorite={isStarred} />,\n tooltip: isStarred ? 'Remove from favorites' : 'Add to favorites',\n onClick: () => toggleStarredEntity(entity),\n };\n };\n },\n};\n"],"names":[],"mappings":";;;;AAyBO,MAAM,eAAkB,GAAA;AAAA,EAC7B,wBAAwB,eAA2B,EAAA;AACjD,IAAA,OAAO,CAAC,GAAsB,KAAA;AAC5B,MAAO,OAAA;AAAA,QACL,IAAM,EAAA,sBAAO,GAAA,CAAA,SAAA,EAAA,EAAU,UAAS,OAAQ,EAAA,CAAA;AAAA,QACxC,OAAS,EAAA,+CAAA;AAAA,QACT,OAAA,EAAS,MACP,eAAA,CAAgB,CAAG,EAAA,MAAA,CAAO,QAAS,CAAA,MAAM,CAAG,EAAA,GAAA,CAAI,QAAS,CAAA,OAAO,CAAE,CAAA;AAAA,OACtE;AAAA,KACF;AAAA,GACF;AAAA,EACA,sBAAA,CACE,iBACA,mBACA,EAAA;AACA,IAAA,OAAO,CAAC,GAAsB,KAAA;AAC5B,MAAA,MAAM,SAAS,GAAI,CAAA,MAAA;AACnB,MAAM,MAAA,SAAA,GAAY,gBAAgB,MAAM,CAAA;AACxC,MAAO,OAAA;AAAA,QACL,SAAA,EAAW,EAAE,WAAA,EAAa,KAAM,EAAA;AAAA,QAChC,IAAM,EAAA,sBAAO,GAAA,CAAA,kBAAA,EAAA,EAAmB,YAAY,SAAW,EAAA,CAAA;AAAA,QACvD,OAAA,EAAS,YAAY,uBAA0B,GAAA,kBAAA;AAAA,QAC/C,OAAA,EAAS,MAAM,mBAAA,CAAoB,MAAM;AAAA,OAC3C;AAAA,KACF;AAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { SubvalueCell, Link } from '@backstage/core-components';
|
|
3
3
|
import { EntityRefLinks } from '@backstage/plugin-catalog-react';
|
|
4
4
|
|
|
@@ -26,10 +26,10 @@ const columnFactories = {
|
|
|
26
26
|
const title2 = customTitle(row2.entity).toLocaleLowerCase();
|
|
27
27
|
return title1.localeCompare(title2);
|
|
28
28
|
},
|
|
29
|
-
render: (row) => /* @__PURE__ */
|
|
29
|
+
render: (row) => /* @__PURE__ */ jsx(
|
|
30
30
|
SubvalueCell,
|
|
31
31
|
{
|
|
32
|
-
value: /* @__PURE__ */
|
|
32
|
+
value: /* @__PURE__ */ jsx(Link, { to: row.resolved.docsUrl, children: customTitle(row.entity) }),
|
|
33
33
|
subvalue: row.entity.metadata.description
|
|
34
34
|
}
|
|
35
35
|
)
|
|
@@ -39,7 +39,7 @@ const columnFactories = {
|
|
|
39
39
|
return {
|
|
40
40
|
title: "Owner",
|
|
41
41
|
field: "resolved.ownedByRelationsTitle",
|
|
42
|
-
render: ({ resolved }) => /* @__PURE__ */
|
|
42
|
+
render: ({ resolved }) => /* @__PURE__ */ jsx(
|
|
43
43
|
EntityRefLinks,
|
|
44
44
|
{
|
|
45
45
|
entityRefs: resolved.ownedByRelations,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columns.esm.js","sources":["../../../../src/home/components/Tables/columns.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
|
|
1
|
+
{"version":3,"file":"columns.esm.js","sources":["../../../../src/home/components/Tables/columns.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 { Link, SubvalueCell, TableColumn } from '@backstage/core-components';\nimport { EntityRefLinks } from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { DocsTableRow } from './types';\n\nfunction customTitle(entity: Entity): string {\n return entity.metadata.title || entity.metadata.name;\n}\n\n/**\n * Not directly exported, but through DocsTable.columns and EntityListDocsTable.columns\n *\n * @public\n */\nexport const columnFactories = {\n createTitleColumn(options?: { hidden?: boolean }): TableColumn<DocsTableRow> {\n const nameCol = columnFactories.createNameColumn();\n return {\n ...nameCol,\n field: 'entity.metadata.title',\n hidden: options?.hidden,\n };\n },\n createNameColumn(): TableColumn<DocsTableRow> {\n return {\n title: 'Document',\n field: 'entity.metadata.name',\n highlight: true,\n searchable: true,\n defaultSort: 'asc',\n customSort: (row1, row2) => {\n const title1 = customTitle(row1.entity).toLocaleLowerCase();\n const title2 = customTitle(row2.entity).toLocaleLowerCase();\n return title1.localeCompare(title2);\n },\n render: (row: DocsTableRow) => (\n <SubvalueCell\n value={\n <Link to={row.resolved.docsUrl}>{customTitle(row.entity)}</Link>\n }\n subvalue={row.entity.metadata.description}\n />\n ),\n };\n },\n createOwnerColumn(): TableColumn<DocsTableRow> {\n return {\n title: 'Owner',\n field: 'resolved.ownedByRelationsTitle',\n render: ({ resolved }) => (\n <EntityRefLinks\n entityRefs={resolved.ownedByRelations}\n defaultKind=\"group\"\n />\n ),\n };\n },\n createKindColumn(): TableColumn<DocsTableRow> {\n return {\n title: 'Kind',\n field: 'entity.kind',\n };\n },\n createTypeColumn(): TableColumn<DocsTableRow> {\n return {\n title: 'Type',\n field: 'entity.spec.type',\n };\n },\n};\n\nexport const defaultColumns: TableColumn<DocsTableRow>[] = [\n columnFactories.createTitleColumn({ hidden: true }),\n columnFactories.createNameColumn(),\n columnFactories.createOwnerColumn(),\n columnFactories.createKindColumn(),\n columnFactories.createTypeColumn(),\n];\n"],"names":[],"mappings":";;;;AAqBA,SAAS,YAAY,MAAwB,EAAA;AAC3C,EAAA,OAAO,MAAO,CAAA,QAAA,CAAS,KAAS,IAAA,MAAA,CAAO,QAAS,CAAA,IAAA;AAClD;AAOO,MAAM,eAAkB,GAAA;AAAA,EAC7B,kBAAkB,OAA2D,EAAA;AAC3E,IAAM,MAAA,OAAA,GAAU,gBAAgB,gBAAiB,EAAA;AACjD,IAAO,OAAA;AAAA,MACL,GAAG,OAAA;AAAA,MACH,KAAO,EAAA,uBAAA;AAAA,MACP,QAAQ,OAAS,EAAA;AAAA,KACnB;AAAA,GACF;AAAA,EACA,gBAA8C,GAAA;AAC5C,IAAO,OAAA;AAAA,MACL,KAAO,EAAA,UAAA;AAAA,MACP,KAAO,EAAA,sBAAA;AAAA,MACP,SAAW,EAAA,IAAA;AAAA,MACX,UAAY,EAAA,IAA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,EAAE,MAAA,EAAQ,MAAM,CAAA;AAAA,EAClD,gBAAgB,gBAAiB,EAAA;AAAA,EACjC,gBAAgB,iBAAkB,EAAA;AAAA,EAClC,gBAAgB,gBAAiB,EAAA;AAAA,EACjC,gBAAgB,gBAAiB;AACnC;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import useAsync from 'react-use/esm/useAsync';
|
|
3
4
|
import { makeStyles } from '@material-ui/core/styles';
|
|
4
5
|
import { useEntityOwnership, EntityListProvider, catalogApiRef, CATALOG_FILTER_EXISTS } from '@backstage/plugin-catalog-react';
|
|
@@ -42,15 +43,18 @@ const CustomDocsPanel = ({
|
|
|
42
43
|
}
|
|
43
44
|
return typeof config.filterPredicate === "function" && config.filterPredicate(entity);
|
|
44
45
|
});
|
|
45
|
-
const Header = config.panelProps?.CustomHeader || (() => /* @__PURE__ */
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
const Header = config.panelProps?.CustomHeader || (() => /* @__PURE__ */ jsx(ContentHeader, { title: config.title, description: config.description, children: index === 0 ? /* @__PURE__ */ jsx(SupportButton, { children: "Discover documentation in your ecosystem." }) : null }));
|
|
47
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Header, {}),
|
|
49
|
+
/* @__PURE__ */ jsx("div", { className: classes.panelContainer, children: /* @__PURE__ */ jsx(EntityListProvider, { children: /* @__PURE__ */ jsx(
|
|
50
|
+
Panel,
|
|
51
|
+
{
|
|
52
|
+
"data-testid": "techdocs-custom-panel",
|
|
53
|
+
entities: shownEntities,
|
|
54
|
+
...config.panelProps
|
|
55
|
+
}
|
|
56
|
+
) }) })
|
|
57
|
+
] });
|
|
54
58
|
};
|
|
55
59
|
const TechDocsCustomHome = (props) => {
|
|
56
60
|
const { tabsConfig, filter, CustomPageWrapper } = props;
|
|
@@ -81,37 +85,40 @@ const TechDocsCustomHome = (props) => {
|
|
|
81
85
|
});
|
|
82
86
|
const currentTabConfig = tabsConfig[selectedTab];
|
|
83
87
|
if (loading) {
|
|
84
|
-
return /* @__PURE__ */
|
|
88
|
+
return /* @__PURE__ */ jsx(TechDocsPageWrapper, { CustomPageWrapper, children: /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(Progress, {}) }) });
|
|
85
89
|
}
|
|
86
90
|
if (error) {
|
|
87
|
-
return /* @__PURE__ */
|
|
91
|
+
return /* @__PURE__ */ jsx(TechDocsPageWrapper, { CustomPageWrapper, children: /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(
|
|
88
92
|
WarningPanel,
|
|
89
93
|
{
|
|
90
94
|
severity: "error",
|
|
91
|
-
title: "Could not load available documentation."
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
)));
|
|
95
|
+
title: "Could not load available documentation.",
|
|
96
|
+
children: /* @__PURE__ */ jsx(CodeSnippet, { language: "text", text: error.toString() })
|
|
97
|
+
}
|
|
98
|
+
) }) });
|
|
95
99
|
}
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
return /* @__PURE__ */ jsxs(TechDocsPageWrapper, { CustomPageWrapper, children: [
|
|
101
|
+
/* @__PURE__ */ jsx(
|
|
102
|
+
HeaderTabs,
|
|
103
|
+
{
|
|
104
|
+
selectedIndex: selectedTab,
|
|
105
|
+
onChange: (index) => setSelectedTab(index),
|
|
106
|
+
tabs: tabsConfig.map(({ label }, index) => ({
|
|
107
|
+
id: index.toString(),
|
|
108
|
+
label
|
|
109
|
+
}))
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
/* @__PURE__ */ jsx(Content, { "data-testid": "techdocs-content", children: currentTabConfig.panels.map((config, index) => /* @__PURE__ */ jsx(
|
|
113
|
+
CustomDocsPanel,
|
|
114
|
+
{
|
|
115
|
+
config,
|
|
116
|
+
entities: !!entities ? entities : [],
|
|
117
|
+
index
|
|
118
|
+
},
|
|
112
119
|
index
|
|
113
|
-
}
|
|
114
|
-
)
|
|
120
|
+
)) })
|
|
121
|
+
] });
|
|
115
122
|
};
|
|
116
123
|
|
|
117
124
|
export { CustomDocsPanel, TechDocsCustomHome };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TechDocsCustomHome.esm.js","sources":["../../../src/home/components/TechDocsCustomHome.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { CSSProperties } from '@material-ui/styles/withStyles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n useEntityOwnership,\n EntityListProvider,\n} from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { DocsTable, DocsTableRow } from './Tables';\nimport { DocsCardGrid, InfoCardGrid } from './Grids';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\nimport { TechDocsIndexPage } from './TechDocsIndexPage';\n\nimport {\n CodeSnippet,\n Content,\n HeaderTabs,\n Progress,\n WarningPanel,\n SupportButton,\n ContentHeader,\n TableOptions,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common';\nimport { EntityFilterQuery } from '@backstage/catalog-client';\n\nconst panels = {\n DocsTable: DocsTable,\n DocsCardGrid: DocsCardGrid,\n TechDocsIndexPage: TechDocsIndexPage,\n InfoCardGrid: InfoCardGrid,\n};\n\n/**\n * Available panel types\n *\n * @public\n */\nexport type PanelType =\n | 'DocsCardGrid'\n | 'DocsTable'\n | 'TechDocsIndexPage'\n | 'InfoCardGrid';\n\n/**\n * Type representing Panel props\n *\n * @public\n */\nexport interface PanelProps {\n options?: TableOptions<DocsTableRow>;\n linkContent?: string | JSX.Element;\n linkDestination?: (entity: Entity) => string | undefined;\n PageWrapper?: React.FC;\n CustomHeader?: React.FC;\n}\n\n/**\n * Type representing a TechDocsCustomHome panel.\n *\n * @public\n */\nexport interface PanelConfig {\n title: string;\n description: string;\n panelType: PanelType;\n panelCSS?: CSSProperties;\n filterPredicate: ((entity: Entity) => boolean) | string;\n panelProps?: PanelProps;\n}\n\n/**\n * Type representing a TechDocsCustomHome tab.\n *\n * @public\n */\nexport interface TabConfig {\n label: string;\n panels: PanelConfig[];\n}\n\n/**\n * Type representing a list of TechDocsCustomHome tabs.\n *\n * @public\n */\nexport type TabsConfig = TabConfig[];\n\n/**\n * Component which can be used to render entities in a custom way.\n *\n * @public\n */\nexport const CustomDocsPanel = ({\n config,\n entities,\n index,\n}: {\n config: PanelConfig;\n entities: Entity[];\n index: number;\n}) => {\n const useStyles = makeStyles({\n panelContainer: {\n marginBottom: '2rem',\n ...(config.panelCSS ? config.panelCSS : {}),\n },\n });\n const classes = useStyles();\n const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();\n\n const Panel = panels[config.panelType];\n\n const shownEntities = entities.filter(entity => {\n if (config.filterPredicate === 'ownedByUser') {\n if (loadingOwnership) {\n return false;\n }\n return isOwnedEntity(entity);\n }\n\n return (\n typeof config.filterPredicate === 'function' &&\n config.filterPredicate(entity)\n );\n });\n\n const Header: React.FC =\n config.panelProps?.CustomHeader ||\n (() => (\n <ContentHeader title={config.title} description={config.description}>\n {index === 0 ? (\n <SupportButton>\n Discover documentation in your ecosystem.\n </SupportButton>\n ) : null}\n </ContentHeader>\n ));\n\n return (\n <>\n <Header />\n <div className={classes.panelContainer}>\n <EntityListProvider>\n <Panel\n data-testid=\"techdocs-custom-panel\"\n entities={shownEntities}\n {...config.panelProps}\n />\n </EntityListProvider>\n </div>\n </>\n );\n};\n\n/**\n * Props for {@link TechDocsCustomHome}\n *\n * @public\n */\nexport type TechDocsCustomHomeProps = {\n tabsConfig: TabsConfig;\n filter?: EntityFilterQuery;\n CustomPageWrapper?: React.FC;\n};\n\nexport const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {\n const { tabsConfig, filter, CustomPageWrapper } = props;\n const [selectedTab, setSelectedTab] = useState<number>(0);\n const catalogApi: CatalogApi = useApi(catalogApiRef);\n\n const {\n value: entities,\n loading,\n error,\n } = useAsync(async () => {\n const response = await catalogApi.getEntities({\n filter: {\n ...filter,\n [`metadata.annotations.${TECHDOCS_ANNOTATION}`]: CATALOG_FILTER_EXISTS,\n },\n fields: [\n 'apiVersion',\n 'kind',\n 'metadata',\n 'relations',\n 'spec.owner',\n 'spec.type',\n ],\n });\n return response.items.filter((entity: Entity) => {\n return !!entity.metadata.annotations?.[TECHDOCS_ANNOTATION];\n });\n });\n\n const currentTabConfig = tabsConfig[selectedTab];\n\n if (loading) {\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <Content>\n <Progress />\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n if (error) {\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <Content>\n <WarningPanel\n severity=\"error\"\n title=\"Could not load available documentation.\"\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <HeaderTabs\n selectedIndex={selectedTab}\n onChange={index => setSelectedTab(index)}\n tabs={tabsConfig.map(({ label }, index) => ({\n id: index.toString(),\n label,\n }))}\n />\n <Content data-testid=\"techdocs-content\">\n {currentTabConfig.panels.map((config, index) => (\n <CustomDocsPanel\n key={index}\n config={config}\n entities={!!entities ? entities : []}\n index={index}\n />\n ))}\n </Content>\n </TechDocsPageWrapper>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA+CA,MAAM,MAAS,GAAA;AAAA,EACb,SAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF,CAAA;AA8DO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,MAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,YAAY,UAAW,CAAA;AAAA,IAC3B,cAAgB,EAAA;AAAA,MACd,YAAc,EAAA,MAAA;AAAA,MACd,GAAI,MAAA,CAAO,QAAW,GAAA,MAAA,CAAO,WAAW;AAAC;AAC3C,GACD,CAAA;AACD,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAkB,EAAA,aAAA,KAAkB,kBAAmB,EAAA;AAExE,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,MAAA,CAAO,SAAS,CAAA;AAErC,EAAM,MAAA,aAAA,GAAgB,QAAS,CAAA,MAAA,CAAO,CAAU,MAAA,KAAA;AAC9C,IAAI,IAAA,MAAA,CAAO,oBAAoB,aAAe,EAAA;AAC5C,MAAA,IAAI,gBAAkB,EAAA;AACpB,QAAO,OAAA,KAAA;AAAA;AAET,MAAA,OAAO,cAAc,MAAM,CAAA;AAAA;AAG7B,IAAA,OACE,OAAO,MAAO,CAAA,eAAA,KAAoB,UAClC,IAAA,MAAA,CAAO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AE,KAAA,IAAS,KAAW,MAAA;AAAA,QAC1C,EAAA,EAAI,MAAM,QAAS,EAAA;AAAA,QACnB;AAAA,OACA,CAAA;AAAA;AAAA,GACJ,kBACC,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,aAAY,EAAA,kBAAA,EAAA,EAClB,iBAAiB,MAAO,CAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,KACpC,qBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,GAAK,EAAA,KAAA;AAAA,MACL,MAAA;AAAA,MACA,QAAU,EAAA,CAAC,CAAC,QAAA,GAAW,WAAW,EAAC;AAAA,MACnC;AAAA;AAAA,GAEH,CACH,CACF,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"TechDocsCustomHome.esm.js","sources":["../../../src/home/components/TechDocsCustomHome.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 { FC, useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { CSSProperties } from '@material-ui/styles/withStyles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n useEntityOwnership,\n EntityListProvider,\n} from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { DocsTable, DocsTableRow } from './Tables';\nimport { DocsCardGrid, InfoCardGrid } from './Grids';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\nimport { TechDocsIndexPage } from './TechDocsIndexPage';\n\nimport {\n CodeSnippet,\n Content,\n HeaderTabs,\n Progress,\n WarningPanel,\n SupportButton,\n ContentHeader,\n TableOptions,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common';\nimport { EntityFilterQuery } from '@backstage/catalog-client';\n\nconst panels = {\n DocsTable: DocsTable,\n DocsCardGrid: DocsCardGrid,\n TechDocsIndexPage: TechDocsIndexPage,\n InfoCardGrid: InfoCardGrid,\n};\n\n/**\n * Available panel types\n *\n * @public\n */\nexport type PanelType =\n | 'DocsCardGrid'\n | 'DocsTable'\n | 'TechDocsIndexPage'\n | 'InfoCardGrid';\n\n/**\n * Type representing Panel props\n *\n * @public\n */\nexport interface PanelProps {\n options?: TableOptions<DocsTableRow>;\n linkContent?: string | JSX.Element;\n linkDestination?: (entity: Entity) => string | undefined;\n PageWrapper?: FC;\n CustomHeader?: FC;\n}\n\n/**\n * Type representing a TechDocsCustomHome panel.\n *\n * @public\n */\nexport interface PanelConfig {\n title: string;\n description: string;\n panelType: PanelType;\n panelCSS?: CSSProperties;\n filterPredicate: ((entity: Entity) => boolean) | string;\n panelProps?: PanelProps;\n}\n\n/**\n * Type representing a TechDocsCustomHome tab.\n *\n * @public\n */\nexport interface TabConfig {\n label: string;\n panels: PanelConfig[];\n}\n\n/**\n * Type representing a list of TechDocsCustomHome tabs.\n *\n * @public\n */\nexport type TabsConfig = TabConfig[];\n\n/**\n * Component which can be used to render entities in a custom way.\n *\n * @public\n */\nexport const CustomDocsPanel = ({\n config,\n entities,\n index,\n}: {\n config: PanelConfig;\n entities: Entity[];\n index: number;\n}) => {\n const useStyles = makeStyles({\n panelContainer: {\n marginBottom: '2rem',\n ...(config.panelCSS ? config.panelCSS : {}),\n },\n });\n const classes = useStyles();\n const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();\n\n const Panel = panels[config.panelType];\n\n const shownEntities = entities.filter(entity => {\n if (config.filterPredicate === 'ownedByUser') {\n if (loadingOwnership) {\n return false;\n }\n return isOwnedEntity(entity);\n }\n\n return (\n typeof config.filterPredicate === 'function' &&\n config.filterPredicate(entity)\n );\n });\n\n const Header: FC =\n config.panelProps?.CustomHeader ||\n (() => (\n <ContentHeader title={config.title} description={config.description}>\n {index === 0 ? (\n <SupportButton>\n Discover documentation in your ecosystem.\n </SupportButton>\n ) : null}\n </ContentHeader>\n ));\n\n return (\n <>\n <Header />\n <div className={classes.panelContainer}>\n <EntityListProvider>\n <Panel\n data-testid=\"techdocs-custom-panel\"\n entities={shownEntities}\n {...config.panelProps}\n />\n </EntityListProvider>\n </div>\n </>\n );\n};\n\n/**\n * Props for {@link TechDocsCustomHome}\n *\n * @public\n */\nexport type TechDocsCustomHomeProps = {\n tabsConfig: TabsConfig;\n filter?: EntityFilterQuery;\n CustomPageWrapper?: FC;\n};\n\nexport const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {\n const { tabsConfig, filter, CustomPageWrapper } = props;\n const [selectedTab, setSelectedTab] = useState<number>(0);\n const catalogApi: CatalogApi = useApi(catalogApiRef);\n\n const {\n value: entities,\n loading,\n error,\n } = useAsync(async () => {\n const response = await catalogApi.getEntities({\n filter: {\n ...filter,\n [`metadata.annotations.${TECHDOCS_ANNOTATION}`]: CATALOG_FILTER_EXISTS,\n },\n fields: [\n 'apiVersion',\n 'kind',\n 'metadata',\n 'relations',\n 'spec.owner',\n 'spec.type',\n ],\n });\n return response.items.filter((entity: Entity) => {\n return !!entity.metadata.annotations?.[TECHDOCS_ANNOTATION];\n });\n });\n\n const currentTabConfig = tabsConfig[selectedTab];\n\n if (loading) {\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <Content>\n <Progress />\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n if (error) {\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <Content>\n <WarningPanel\n severity=\"error\"\n title=\"Could not load available documentation.\"\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <HeaderTabs\n selectedIndex={selectedTab}\n onChange={index => setSelectedTab(index)}\n tabs={tabsConfig.map(({ label }, index) => ({\n id: index.toString(),\n label,\n }))}\n />\n <Content data-testid=\"techdocs-content\">\n {currentTabConfig.panels.map((config, index) => (\n <CustomDocsPanel\n key={index}\n config={config}\n entities={!!entities ? entities : []}\n index={index}\n />\n ))}\n </Content>\n </TechDocsPageWrapper>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+CA,MAAM,MAAS,GAAA;AAAA,EACb,SAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF,CAAA;AA8DO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,MAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,YAAY,UAAW,CAAA;AAAA,IAC3B,cAAgB,EAAA;AAAA,MACd,YAAc,EAAA,MAAA;AAAA,MACd,GAAI,MAAA,CAAO,QAAW,GAAA,MAAA,CAAO,WAAW;AAAC;AAC3C,GACD,CAAA;AACD,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAkB,EAAA,aAAA,KAAkB,kBAAmB,EAAA;AAExE,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,MAAA,CAAO,SAAS,CAAA;AAErC,EAAM,MAAA,aAAA,GAAgB,QAAS,CAAA,MAAA,CAAO,CAAU,MAAA,KAAA;AAC9C,IAAI,IAAA,MAAA,CAAO,oBAAoB,aAAe,EAAA;AAC5C,MAAA,IAAI,gBAAkB,EAAA;AACpB,QAAO,OAAA,KAAA;AAAA;AAET,MAAA,OAAO,cAAc,MAAM,CAAA;AAAA;AAG7B,IAAA,OACE,OAAO,MAAO,CAAA,eAAA,KAAoB,UAClC,IAA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