@backstage/plugin-techdocs 1.17.7-next.1 → 1.17.8-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/config.schema.json +57 -0
- package/dist/alpha.d.ts +45 -1
- package/dist/alpha.esm.js +1 -0
- package/dist/alpha.esm.js.map +1 -1
- package/dist/home/components/DefaultTechDocsHome.esm.js +4 -1
- package/dist/home/components/DefaultTechDocsHome.esm.js.map +1 -1
- package/dist/home/components/Grids/InfoCardGrid.esm.js +1 -1
- package/dist/home/components/Grids/InfoCardGrid.esm.js.map +1 -1
- package/dist/home/components/Tables/CursorPaginatedDocsTable.esm.js +18 -1
- package/dist/home/components/Tables/CursorPaginatedDocsTable.esm.js.map +1 -1
- package/dist/home/components/Tables/DocsTable.esm.js +24 -6
- package/dist/home/components/Tables/DocsTable.esm.js.map +1 -1
- package/dist/home/components/Tables/EntityListDocsTable.esm.js +9 -11
- package/dist/home/components/Tables/EntityListDocsTable.esm.js.map +1 -1
- package/dist/home/components/Tables/OffsetPaginatedDocsTable.esm.js +18 -1
- package/dist/home/components/Tables/OffsetPaginatedDocsTable.esm.js.map +1 -1
- package/dist/home/components/Tables/actions.esm.js +5 -4
- package/dist/home/components/Tables/actions.esm.js.map +1 -1
- package/dist/home/components/Tables/columns.esm.js +13 -5
- package/dist/home/components/Tables/columns.esm.js.map +1 -1
- package/dist/home/components/TechDocsCustomHome.esm.js +6 -9
- package/dist/home/components/TechDocsCustomHome.esm.js.map +1 -1
- package/dist/home/components/TechDocsPageWrapper.esm.js +6 -2
- package/dist/home/components/TechDocsPageWrapper.esm.js.map +1 -1
- package/dist/index.d.ts +40 -56
- package/dist/plugins/techdocs/package.json.esm.js +1 -1
- package/dist/reader/components/TechDocsBuildLogs.esm.js +8 -4
- package/dist/reader/components/TechDocsBuildLogs.esm.js.map +1 -1
- package/dist/reader/components/TechDocsNotFound.esm.js +5 -2
- package/dist/reader/components/TechDocsNotFound.esm.js.map +1 -1
- package/dist/reader/components/TechDocsReaderPageHeader/TechDocsReaderPageHeader.esm.js +12 -3
- package/dist/reader/components/TechDocsReaderPageHeader/TechDocsReaderPageHeader.esm.js.map +1 -1
- package/dist/reader/components/TechDocsReaderPageSubheader/TechDocsReaderPageSubheader.esm.js +4 -1
- package/dist/reader/components/TechDocsReaderPageSubheader/TechDocsReaderPageSubheader.esm.js.map +1 -1
- package/dist/reader/components/TechDocsRedirectNotification/TechDocsRedirectNotification.esm.js +4 -1
- package/dist/reader/components/TechDocsRedirectNotification/TechDocsRedirectNotification.esm.js.map +1 -1
- package/dist/reader/components/TechDocsStateIndicator.esm.js +9 -6
- package/dist/reader/components/TechDocsStateIndicator.esm.js.map +1 -1
- package/dist/search/components/TechDocsSearch.esm.js +7 -2
- package/dist/search/components/TechDocsSearch.esm.js.map +1 -1
- package/dist/translation.esm.js +89 -0
- package/dist/translation.esm.js.map +1 -1
- package/package.json +20 -20
- package/config.d.ts +0 -73
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import { Table } from '@backstage/core-components';
|
|
4
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
|
+
import { techdocsTranslationRef } from '../../../translation.esm.js';
|
|
4
6
|
import { useEntityList, EntityTextFilter } from '@backstage/plugin-catalog-react';
|
|
5
7
|
|
|
6
8
|
function OffsetPaginatedDocsTable(props) {
|
|
7
9
|
const { actions, columns, data, isLoading, options, title } = props;
|
|
8
10
|
const { updateFilters, setLimit, setOffset, limit, totalItems, offset } = useEntityList();
|
|
11
|
+
const { t } = useTranslationRef(techdocsTranslationRef);
|
|
9
12
|
const [page, setPage] = useState(
|
|
10
13
|
offset && limit ? Math.floor(offset / limit) : 0
|
|
11
14
|
);
|
|
@@ -42,7 +45,21 @@ function OffsetPaginatedDocsTable(props) {
|
|
|
42
45
|
setLimit(pageSize);
|
|
43
46
|
},
|
|
44
47
|
totalCount: totalItems,
|
|
45
|
-
localization: {
|
|
48
|
+
localization: {
|
|
49
|
+
header: {
|
|
50
|
+
actions: t("table.header.actions")
|
|
51
|
+
},
|
|
52
|
+
toolbar: {
|
|
53
|
+
searchPlaceholder: t("table.toolbar.searchPlaceholder")
|
|
54
|
+
},
|
|
55
|
+
pagination: {
|
|
56
|
+
labelDisplayedRows: "",
|
|
57
|
+
labelRowsSelect: t("table.pagination.labelRowsSelect")
|
|
58
|
+
},
|
|
59
|
+
body: {
|
|
60
|
+
emptyDataSourceMessage: t("table.body.emptyDataSourceMessage")
|
|
61
|
+
}
|
|
62
|
+
},
|
|
46
63
|
isLoading
|
|
47
64
|
}
|
|
48
65
|
);
|
|
@@ -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 { 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, title } = 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 title={title}\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: {
|
|
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 { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { techdocsTranslationRef } from '../../../translation';\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, title } = props;\n const { updateFilters, setLimit, setOffset, limit, totalItems, offset } =\n useEntityList();\n const { t } = useTranslationRef(techdocsTranslationRef);\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 title={title}\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={{\n header: {\n actions: t('table.header.actions'),\n },\n toolbar: {\n searchPlaceholder: t('table.toolbar.searchPlaceholder'),\n },\n pagination: {\n labelDisplayedRows: '',\n labelRowsSelect: t('table.pagination.labelRowsSelect'),\n },\n body: {\n emptyDataSourceMessage: t('table.body.emptyDataSourceMessage'),\n },\n }}\n isLoading={isLoading}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;;AA8BO,SAAS,yBAAyB,KAAA,EAAiC;AACxE,EAAA,MAAM,EAAE,OAAA,EAAS,OAAA,EAAS,MAAM,SAAA,EAAW,OAAA,EAAS,OAAM,GAAI,KAAA;AAC9D,EAAA,MAAM,EAAE,eAAe,QAAA,EAAU,SAAA,EAAW,OAAO,UAAA,EAAY,MAAA,KAC7D,aAAA,EAAc;AAChB,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,sBAAsB,CAAA;AACtD,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAA;AAAA,IACtB,UAAU,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,MAAA,GAAS,KAAK,CAAA,GAAI;AAAA,GACjD;AAEA,EAAA,SAAA,CAAU,MAAM;A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AAS;AAAA,UACP,iBAAA,EAAmB,EAAE,iCAAiC;AAAA,SACxD;AAAA,QACA,UAAA,EAAY;AAAA,UACV,kBAAA,EAAoB,EAAA;AAAA,UACpB,eAAA,EAAiB,EAAE,kCAAkC;AAAA,SACvD;AAAA,QACA,IAAA,EAAM;AAAA,UACJ,sBAAA,EAAwB,EAAE,mCAAmC;AAAA;AAC/D,OACF;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -3,23 +3,24 @@ import ShareIcon from '@material-ui/icons/Share';
|
|
|
3
3
|
import { FavoriteToggleIcon } from '@backstage/core-components';
|
|
4
4
|
|
|
5
5
|
const actionFactories = {
|
|
6
|
-
createCopyDocsUrlAction(copyToClipboard) {
|
|
6
|
+
createCopyDocsUrlAction(copyToClipboard, t) {
|
|
7
7
|
return (row) => {
|
|
8
8
|
return {
|
|
9
9
|
icon: () => /* @__PURE__ */ jsx(ShareIcon, { fontSize: "small" }),
|
|
10
|
-
tooltip: "Click to copy documentation link to clipboard",
|
|
10
|
+
tooltip: t?.("table.actions.copyDocsUrl", {}) ?? "Click to copy documentation link to clipboard",
|
|
11
11
|
onClick: () => copyToClipboard(`${window.location.origin}${row.resolved.docsUrl}`)
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
|
-
createStarEntityAction(isStarredEntity, toggleStarredEntity) {
|
|
15
|
+
createStarEntityAction(isStarredEntity, toggleStarredEntity, t) {
|
|
16
16
|
return (row) => {
|
|
17
17
|
const entity = row.entity;
|
|
18
18
|
const isStarred = isStarredEntity(entity);
|
|
19
|
+
const tooltip = isStarred ? t?.("table.actions.removeFromFavorites", {}) ?? "Remove from favorites" : t?.("table.actions.addToFavorites", {}) ?? "Add to favorites";
|
|
19
20
|
return {
|
|
20
21
|
cellStyle: { paddingLeft: "1em" },
|
|
21
22
|
icon: () => /* @__PURE__ */ jsx(FavoriteToggleIcon, { isFavorite: isStarred }),
|
|
22
|
-
tooltip
|
|
23
|
+
tooltip,
|
|
23
24
|
onClick: () => toggleStarredEntity(entity)
|
|
24
25
|
};
|
|
25
26
|
};
|
|
@@ -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 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
|
|
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';\nimport type { TranslationFunction } from '@backstage/core-plugin-api/alpha';\nimport type { techdocsTranslationRef } from '../../../translation';\n\ntype InternalTranslationFunctionType = TranslationFunction<\n typeof techdocsTranslationRef extends { T: infer T } ? T : never\n>;\n\n/**\n * Not directly exported, but through DocsTable.actions and EntityListDocsTable.actions\n *\n * @public\n */\nexport const actionFactories = {\n createCopyDocsUrlAction(\n copyToClipboard: Function,\n t?: InternalTranslationFunctionType,\n ) {\n return (row: DocsTableRow) => {\n return {\n icon: () => <ShareIcon fontSize=\"small\" />,\n tooltip:\n t?.('table.actions.copyDocsUrl', {}) ??\n '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 t?: InternalTranslationFunctionType,\n ) {\n return (row: DocsTableRow) => {\n const entity = row.entity;\n const isStarred = isStarredEntity(entity);\n const tooltip = isStarred\n ? t?.('table.actions.removeFromFavorites', {}) ??\n 'Remove from favorites'\n : t?.('table.actions.addToFavorites', {}) ?? 'Add to favorites';\n return {\n cellStyle: { paddingLeft: '1em' },\n icon: () => <FavoriteToggleIcon isFavorite={isStarred} />,\n tooltip,\n onClick: () => toggleStarredEntity(entity),\n };\n };\n },\n};\n"],"names":[],"mappings":";;;;AA+BO,MAAM,eAAA,GAAkB;AAAA,EAC7B,uBAAA,CACE,iBACA,CAAA,EACA;AACA,IAAA,OAAO,CAAC,GAAA,KAAsB;AAC5B,MAAA,OAAO;AAAA,QACL,IAAA,EAAM,sBAAM,GAAA,CAAC,SAAA,EAAA,EAAU,UAAS,OAAA,EAAQ,CAAA;AAAA,QACxC,OAAA,EACE,CAAA,GAAI,2BAAA,EAA6B,EAAE,CAAA,IACnC,+CAAA;AAAA,QACF,OAAA,EAAS,MACP,eAAA,CAAgB,CAAA,EAAG,MAAA,CAAO,QAAA,CAAS,MAAM,CAAA,EAAG,GAAA,CAAI,QAAA,CAAS,OAAO,CAAA,CAAE;AAAA,OACtE;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AAAA,EACA,sBAAA,CACE,eAAA,EACA,mBAAA,EACA,CAAA,EACA;AACA,IAAA,OAAO,CAAC,GAAA,KAAsB;AAC5B,MAAA,MAAM,SAAS,GAAA,CAAI,MAAA;AACnB,MAAA,MAAM,SAAA,GAAY,gBAAgB,MAAM,CAAA;AACxC,MAAA,MAAM,OAAA,GAAU,SAAA,GACZ,CAAA,GAAI,mCAAA,EAAqC,EAAE,CAAA,IAC3C,uBAAA,GACA,CAAA,GAAI,8BAAA,EAAgC,EAAE,CAAA,IAAK,kBAAA;AAC/C,MAAA,OAAO;AAAA,QACL,SAAA,EAAW,EAAE,WAAA,EAAa,KAAA,EAAM;AAAA,QAChC,IAAA,EAAM,sBAAM,GAAA,CAAC,kBAAA,EAAA,EAAmB,YAAY,SAAA,EAAW,CAAA;AAAA,QACvD,OAAA;AAAA,QACA,OAAA,EAAS,MAAM,mBAAA,CAAoB,MAAM;AAAA,OAC3C;AAAA,IACF,CAAA;AAAA,EACF;AACF;;;;"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { SubvalueCell, Link } from '@backstage/core-components';
|
|
3
3
|
import { EntityRefLinks } from '@backstage/plugin-catalog-react';
|
|
4
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
|
+
import { techdocsTranslationRef } from '../../../translation.esm.js';
|
|
4
6
|
|
|
5
7
|
function customTitle(entity) {
|
|
6
8
|
return entity.metadata.title || entity.metadata.name;
|
|
7
9
|
}
|
|
10
|
+
const TableColumnTitle = ({
|
|
11
|
+
translationKey
|
|
12
|
+
}) => {
|
|
13
|
+
const { t } = useTranslationRef(techdocsTranslationRef);
|
|
14
|
+
return /* @__PURE__ */ jsx(Fragment, { children: t(`table.columns.${translationKey}`) });
|
|
15
|
+
};
|
|
8
16
|
const columnFactories = {
|
|
9
17
|
createTitleColumn(options) {
|
|
10
18
|
const nameCol = columnFactories.createNameColumn();
|
|
@@ -16,7 +24,7 @@ const columnFactories = {
|
|
|
16
24
|
},
|
|
17
25
|
createNameColumn() {
|
|
18
26
|
return {
|
|
19
|
-
title: "
|
|
27
|
+
title: /* @__PURE__ */ jsx(TableColumnTitle, { translationKey: "document" }),
|
|
20
28
|
field: "entity.metadata.name",
|
|
21
29
|
highlight: true,
|
|
22
30
|
searchable: true,
|
|
@@ -37,7 +45,7 @@ const columnFactories = {
|
|
|
37
45
|
},
|
|
38
46
|
createOwnerColumn() {
|
|
39
47
|
return {
|
|
40
|
-
title: "
|
|
48
|
+
title: /* @__PURE__ */ jsx(TableColumnTitle, { translationKey: "owner" }),
|
|
41
49
|
field: "resolved.ownedByRelationsTitle",
|
|
42
50
|
render: ({ resolved }) => /* @__PURE__ */ jsx(
|
|
43
51
|
EntityRefLinks,
|
|
@@ -50,13 +58,13 @@ const columnFactories = {
|
|
|
50
58
|
},
|
|
51
59
|
createKindColumn() {
|
|
52
60
|
return {
|
|
53
|
-
title: "
|
|
61
|
+
title: /* @__PURE__ */ jsx(TableColumnTitle, { translationKey: "kind" }),
|
|
54
62
|
field: "entity.kind"
|
|
55
63
|
};
|
|
56
64
|
},
|
|
57
65
|
createTypeColumn() {
|
|
58
66
|
return {
|
|
59
|
-
title: "
|
|
67
|
+
title: /* @__PURE__ */ jsx(TableColumnTitle, { translationKey: "type" }),
|
|
60
68
|
field: "entity.spec.type"
|
|
61
69
|
};
|
|
62
70
|
}
|
|
@@ -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 { 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:
|
|
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 { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { techdocsTranslationRef } from '../../../translation';\nimport { DocsTableRow } from './types';\n\nfunction customTitle(entity: Entity): string {\n return entity.metadata.title || entity.metadata.name;\n}\n\n/**\n * Component for translating table column titles\n * @alpha\n */\nconst TableColumnTitle = ({\n translationKey,\n}: {\n translationKey: 'document' | 'owner' | 'kind' | 'type';\n}) => {\n const { t } = useTranslationRef(techdocsTranslationRef);\n return <>{t(`table.columns.${translationKey}`)}</>;\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: <TableColumnTitle translationKey=\"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: <TableColumnTitle translationKey=\"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: <TableColumnTitle translationKey=\"kind\" />,\n field: 'entity.kind',\n };\n },\n createTypeColumn(): TableColumn<DocsTableRow> {\n return {\n title: <TableColumnTitle translationKey=\"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":";;;;;;AAuBA,SAAS,YAAY,MAAA,EAAwB;AAC3C,EAAA,OAAO,MAAA,CAAO,QAAA,CAAS,KAAA,IAAS,MAAA,CAAO,QAAA,CAAS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.esm.js';
|
|
13
13
|
import { TechDocsIndexPage } from './TechDocsIndexPage.esm.js';
|
|
14
14
|
import { useApi } from '@backstage/core-plugin-api';
|
|
15
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
16
|
+
import { techdocsTranslationRef } from '../../translation.esm.js';
|
|
15
17
|
import { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common';
|
|
16
18
|
|
|
17
19
|
const panels = {
|
|
@@ -43,7 +45,8 @@ const CustomDocsPanel = ({
|
|
|
43
45
|
}
|
|
44
46
|
return typeof config.filterPredicate === "function" && config.filterPredicate(entity);
|
|
45
47
|
});
|
|
46
|
-
const
|
|
48
|
+
const { t } = useTranslationRef(techdocsTranslationRef);
|
|
49
|
+
const Header = config.panelProps?.CustomHeader || (() => /* @__PURE__ */ jsx(ContentHeader, { title: config.title, description: config.description, children: index === 0 ? /* @__PURE__ */ jsx(SupportButton, { children: t("home.supportButton") }) : null }));
|
|
47
50
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
48
51
|
/* @__PURE__ */ jsx(Header, {}),
|
|
49
52
|
/* @__PURE__ */ jsx("div", { className: classes.panelContainer, children: /* @__PURE__ */ jsx(EntityListProvider, { children: /* @__PURE__ */ jsx(
|
|
@@ -60,6 +63,7 @@ const TechDocsCustomHome = (props) => {
|
|
|
60
63
|
const { tabsConfig, filter, CustomPageWrapper } = props;
|
|
61
64
|
const [selectedTab, setSelectedTab] = useState(0);
|
|
62
65
|
const catalogApi = useApi(catalogApiRef);
|
|
66
|
+
const { t } = useTranslationRef(techdocsTranslationRef);
|
|
63
67
|
const {
|
|
64
68
|
value: entities,
|
|
65
69
|
loading,
|
|
@@ -88,14 +92,7 @@ const TechDocsCustomHome = (props) => {
|
|
|
88
92
|
return /* @__PURE__ */ jsx(TechDocsPageWrapper, { CustomPageWrapper, children: /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(Progress, {}) }) });
|
|
89
93
|
}
|
|
90
94
|
if (error) {
|
|
91
|
-
return /* @__PURE__ */ jsx(TechDocsPageWrapper, { CustomPageWrapper, children: /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(
|
|
92
|
-
WarningPanel,
|
|
93
|
-
{
|
|
94
|
-
severity: "error",
|
|
95
|
-
title: "Could not load available documentation.",
|
|
96
|
-
children: /* @__PURE__ */ jsx(CodeSnippet, { language: "text", text: error.toString() })
|
|
97
|
-
}
|
|
98
|
-
) }) });
|
|
95
|
+
return /* @__PURE__ */ jsx(TechDocsPageWrapper, { CustomPageWrapper, children: /* @__PURE__ */ jsx(Content, { children: /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: t("error.couldNotLoad"), children: /* @__PURE__ */ jsx(CodeSnippet, { language: "text", text: error.toString() }) }) }) });
|
|
99
96
|
}
|
|
100
97
|
return /* @__PURE__ */ jsxs(TechDocsPageWrapper, { CustomPageWrapper, children: [
|
|
101
98
|
/* @__PURE__ */ jsx(
|
|
@@ -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 { 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 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 = 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":";;;;;;;;;;;;;;;;AA8CA,MAAM,MAAA,GAAS;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,CAAA,KAIM;AACJ,EAAA,MAAM,YAAY,UAAA,CAAW;AAAA,IAC3B,cAAA,EAAgB;AAAA,MACd,YAAA,EAAc,MAAA;AAAA,MACd,GAAI,MAAA,CAAO,QAAA,GAAW,MAAA,CAAO,WAAW;AAAC;AAC3C,GACD,CAAA;AACD,EAAA,MAAM,UAAU,SAAA,EAAU;AAC1B,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAA,EAAkB,aAAA,KAAkB,kBAAA,EAAmB;AAExE,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA;AAErC,EAAA,MAAM,aAAA,GAAgB,QAAA,CAAS,MAAA,CAAO,CAAA,MAAA,KAAU;AAC9C,IAAA,IAAI,MAAA,CAAO,oBAAoB,aAAA,EAAe;AAC5C,MAAA,IAAI,gBAAA,EAAkB;AACpB,QAA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AAe,WAAA;AAAA,QACf,QAAA,EAAU,CAAA,KAAA,KAAS,cAAA,CAAe,KAAK,CAAA;AAAA,QACvC,MAAM,UAAA,CAAW,GAAA,CAAI,CAAC,EAAE,KAAA,IAAS,KAAA,MAAW;AAAA,UAC1C,EAAA,EAAI,MAAM,QAAA,EAAS;AAAA,UACnB;AAAA,SACF,CAAE;AAAA;AAAA,KACJ;AAAA,oBACA,GAAA,CAAC,WAAQ,aAAA,EAAY,kBAAA,EAClB,2BAAiB,MAAA,CAAO,GAAA,CAAI,CAAC,MAAA,EAAQ,KAAA,qBACpC,GAAA;AAAA,MAAC,eAAA;AAAA,MAAA;AAAA,QAEC,MAAA;AAAA,QACA,QAAA,EAAU,CAAC,CAAC,QAAA,GAAW,WAAW,EAAC;AAAA,QACnC;AAAA,OAAA;AAAA,MAHK;AAAA,KAKR,CAAA,EACH;AAAA,GAAA,EACF,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 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 { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { techdocsTranslationRef } from '../../translation';\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 { t } = useTranslationRef(techdocsTranslationRef);\n const Header: FC =\n config.panelProps?.CustomHeader ||\n (() => (\n <ContentHeader title={config.title} description={config.description}>\n {index === 0 ? (\n <SupportButton>{t('home.supportButton')}</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 = useApi(catalogApiRef);\n const { t } = useTranslationRef(techdocsTranslationRef);\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 severity=\"error\" title={t('error.couldNotLoad')}>\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":";;;;;;;;;;;;;;;;;;AAgDA,MAAM,MAAA,GAAS;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,CAAA,KAIM;AACJ,EAAA,MAAM,YAAY,UAAA,CAAW;AAAA,IAC3B,cAAA,EAAgB;AAAA,MACd,YAAA,EAAc,MAAA;AAAA,MACd,GAAI,MAAA,CAAO,QAAA,GAAW,MAAA,CAAO,WAAW;AAAC;AAC3C,GACD,CAAA;AACD,EAAA,MAAM,UAAU,SAAA,EAAU;AAC1B,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAA,EAAkB,aAAA,KAAkB,kBAAA,EAAmB;AAExE,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,SAAS,CAAA;AAErC,EAAA,MAAM,aAAA,GAAgB,QAAA,CAAS,MAAA,CAAO,CAAA,MAAA,KAAU;AAC9C,IAAA,IAAI,M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A,EAAS,MAAA,EAAO,IAAA,EAAM,MAAM,QAAA,EAAS,EAAG,CAAA,EACvD,CAAA,EACF,CAAA,EACF,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACE,IAAA,CAAC,uBAAoB,iBAAA,EACnB,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,aAAA,EAAe,WAAA;AAAA,QACf,QAAA,EAAU,CAAA,KAAA,KAAS,cAAA,CAAe,KAAK,CAAA;AAAA,QACvC,MAAM,UAAA,CAAW,GAAA,CAAI,CAAC,EAAE,KAAA,IAAS,KAAA,MAAW;AAAA,UAC1C,EAAA,EAAI,MAAM,QAAA,EAAS;AAAA,UACnB;AAAA,SACF,CAAE;AAAA;AAAA,KACJ;AAAA,oBACA,GAAA,CAAC,WAAQ,aAAA,EAAY,kBAAA,EAClB,2BAAiB,MAAA,CAAO,GAAA,CAAI,CAAC,MAAA,EAAQ,KAAA,qBACpC,GAAA;AAAA,MAAC,eAAA;AAAA,MAAA;AAAA,QAEC,MAAA;AAAA,QACA,QAAA,EAAU,CAAC,CAAC,QAAA,GAAW,WAAW,EAAC;AAAA,QACnC;AAAA,OAAA;AAAA,MAHK;AAAA,KAKR,CAAA,EACH;AAAA,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { PageWithHeader } from '@backstage/core-components';
|
|
3
3
|
import { useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
4
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
5
|
+
import { techdocsTranslationRef } from '../../translation.esm.js';
|
|
4
6
|
|
|
5
7
|
const TechDocsPageWrapper = (props) => {
|
|
6
8
|
const { children, CustomPageWrapper } = props;
|
|
7
9
|
const configApi = useApi(configApiRef);
|
|
8
|
-
const
|
|
10
|
+
const { t } = useTranslationRef(techdocsTranslationRef);
|
|
11
|
+
const orgName = configApi.getOptionalString("organization.name") ?? "Backstage";
|
|
12
|
+
const generatedSubtitle = t("pageWrapper.subtitle", { orgName });
|
|
9
13
|
return /* @__PURE__ */ jsx(Fragment, { children: CustomPageWrapper ? /* @__PURE__ */ jsx(CustomPageWrapper, { children }) : /* @__PURE__ */ jsx(
|
|
10
14
|
PageWithHeader,
|
|
11
15
|
{
|
|
12
|
-
title: "
|
|
16
|
+
title: t("pageWrapper.title"),
|
|
13
17
|
subtitle: generatedSubtitle,
|
|
14
18
|
themeId: "documentation",
|
|
15
19
|
children
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TechDocsPageWrapper.esm.js","sources":["../../../src/home/components/TechDocsPageWrapper.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 { ReactNode, FC } from 'react';\n\nimport { PageWithHeader } from '@backstage/core-components';\nimport { useApi, configApiRef } from '@backstage/core-plugin-api';\n\n/**\n * Props for {@link TechDocsPageWrapper}\n *\n * @public\n */\nexport type TechDocsPageWrapperProps = {\n children?: ReactNode;\n CustomPageWrapper?: FC<{ children?: ReactNode }>;\n};\n\n/**\n * Component wrapping a TechDocs page with Page and Header components\n *\n * @public\n */\nexport const TechDocsPageWrapper = (props: TechDocsPageWrapperProps) => {\n const { children, CustomPageWrapper } = props;\n const configApi = useApi(configApiRef);\n const
|
|
1
|
+
{"version":3,"file":"TechDocsPageWrapper.esm.js","sources":["../../../src/home/components/TechDocsPageWrapper.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 { ReactNode, FC } from 'react';\n\nimport { PageWithHeader } from '@backstage/core-components';\nimport { useApi, configApiRef } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { techdocsTranslationRef } from '../../translation';\n\n/**\n * Props for {@link TechDocsPageWrapper}\n *\n * @public\n */\nexport type TechDocsPageWrapperProps = {\n children?: ReactNode;\n CustomPageWrapper?: FC<{ children?: ReactNode }>;\n};\n\n/**\n * Component wrapping a TechDocs page with Page and Header components\n *\n * @public\n */\nexport const TechDocsPageWrapper = (props: TechDocsPageWrapperProps) => {\n const { children, CustomPageWrapper } = props;\n const configApi = useApi(configApiRef);\n const { t } = useTranslationRef(techdocsTranslationRef);\n const orgName =\n configApi.getOptionalString('organization.name') ?? 'Backstage';\n const generatedSubtitle = t('pageWrapper.subtitle', { orgName });\n\n return (\n <>\n {CustomPageWrapper ? (\n <CustomPageWrapper>{children}</CustomPageWrapper>\n ) : (\n <PageWithHeader\n title={t('pageWrapper.title')}\n subtitle={generatedSubtitle}\n themeId=\"documentation\"\n >\n {children}\n </PageWithHeader>\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;AAsCO,MAAM,mBAAA,GAAsB,CAAC,KAAA,KAAoC;AACtE,EAAA,MAAM,EAAE,QAAA,EAAU,iBAAA,EAAkB,GAAI,KAAA;AACxC,EAAA,MAAM,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,sBAAsB,CAAA;AACtD,EAAA,MAAM,OAAA,GACJ,SAAA,CAAU,iBAAA,CAAkB,mBAAmB,CAAA,IAAK,WAAA;AACtD,EAAA,MAAM,iBAAA,GAAoB,CAAA,CAAE,sBAAA,EAAwB,EAAE,SAAS,CAAA;AAE/D,EAAA,uBACE,GAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA,iBAAA,mBACC,GAAA,CAAC,iBAAA,EAAA,EAAmB,UAAS,CAAA,mBAE7B,GAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,EAAE,mBAAmB,CAAA;AAAA,MAC5B,QAAA,EAAU,iBAAA;AAAA,MACV,OAAA,EAAQ,eAAA;AAAA,MAEP;AAAA;AAAA,GACH,EAEJ,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
|
6
6
|
import { DiscoveryApi, FetchApi, IdentityApi } from '@backstage/core-plugin-api';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import * as react from 'react';
|
|
9
|
-
import { ReactNode, PropsWithChildren, FC } from 'react';
|
|
9
|
+
import { ReactNode, PropsWithChildren, JSX as JSX$1, FC } from 'react';
|
|
10
10
|
import { ThemeOptions } from '@material-ui/core/styles';
|
|
11
11
|
import { ToolbarProps } from '@material-ui/core/Toolbar';
|
|
12
12
|
import { TableColumn, TableProps, TableOptions } from '@backstage/core-components';
|
|
@@ -394,6 +394,38 @@ type DocsTableRow = {
|
|
|
394
394
|
ownedByRelations: CompoundEntityRef[];
|
|
395
395
|
};
|
|
396
396
|
};
|
|
397
|
+
/**
|
|
398
|
+
* Column factory functions for DocsTable
|
|
399
|
+
* @public
|
|
400
|
+
*/
|
|
401
|
+
interface DocsTableColumnFactories {
|
|
402
|
+
createTitleColumn(options?: {
|
|
403
|
+
hidden?: boolean;
|
|
404
|
+
}): TableColumn<DocsTableRow>;
|
|
405
|
+
createNameColumn(): TableColumn<DocsTableRow>;
|
|
406
|
+
createOwnerColumn(): TableColumn<DocsTableRow>;
|
|
407
|
+
createKindColumn(): TableColumn<DocsTableRow>;
|
|
408
|
+
createTypeColumn(): TableColumn<DocsTableRow>;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Action factory functions for DocsTable
|
|
412
|
+
* @public
|
|
413
|
+
*/
|
|
414
|
+
interface DocsTableActionFactories {
|
|
415
|
+
createCopyDocsUrlAction(copyToClipboard: Function, t?: Function): (row: DocsTableRow) => {
|
|
416
|
+
icon: () => JSX$1.Element;
|
|
417
|
+
tooltip: string;
|
|
418
|
+
onClick: () => void;
|
|
419
|
+
};
|
|
420
|
+
createStarEntityAction(isStarredEntity: Function, toggleStarredEntity: Function, t?: Function): (row: DocsTableRow) => {
|
|
421
|
+
cellStyle: {
|
|
422
|
+
paddingLeft: string;
|
|
423
|
+
};
|
|
424
|
+
icon: () => JSX$1.Element;
|
|
425
|
+
tooltip: string;
|
|
426
|
+
onClick: () => void;
|
|
427
|
+
};
|
|
428
|
+
}
|
|
397
429
|
|
|
398
430
|
/**
|
|
399
431
|
* Props for {@link EntityListDocsTable}.
|
|
@@ -406,36 +438,12 @@ type EntityListDocsTableProps = {
|
|
|
406
438
|
options?: TableOptions<DocsTableRow>;
|
|
407
439
|
};
|
|
408
440
|
/**
|
|
409
|
-
* Component which renders a table with entities from catalog.
|
|
410
|
-
*
|
|
411
441
|
* @public
|
|
412
442
|
*/
|
|
413
443
|
declare const EntityListDocsTable: {
|
|
414
|
-
(props: EntityListDocsTableProps):
|
|
415
|
-
columns:
|
|
416
|
-
|
|
417
|
-
hidden?: boolean;
|
|
418
|
-
}): TableColumn<DocsTableRow>;
|
|
419
|
-
createNameColumn(): TableColumn<DocsTableRow>;
|
|
420
|
-
createOwnerColumn(): TableColumn<DocsTableRow>;
|
|
421
|
-
createKindColumn(): TableColumn<DocsTableRow>;
|
|
422
|
-
createTypeColumn(): TableColumn<DocsTableRow>;
|
|
423
|
-
};
|
|
424
|
-
actions: {
|
|
425
|
-
createCopyDocsUrlAction(copyToClipboard: Function): (row: DocsTableRow) => {
|
|
426
|
-
icon: () => react_jsx_runtime.JSX.Element;
|
|
427
|
-
tooltip: string;
|
|
428
|
-
onClick: () => any;
|
|
429
|
-
};
|
|
430
|
-
createStarEntityAction(isStarredEntity: Function, toggleStarredEntity: Function): (row: DocsTableRow) => {
|
|
431
|
-
cellStyle: {
|
|
432
|
-
paddingLeft: string;
|
|
433
|
-
};
|
|
434
|
-
icon: () => react_jsx_runtime.JSX.Element;
|
|
435
|
-
tooltip: string;
|
|
436
|
-
onClick: () => any;
|
|
437
|
-
};
|
|
438
|
-
};
|
|
444
|
+
(props: EntityListDocsTableProps): JSX.Element | null;
|
|
445
|
+
columns: DocsTableColumnFactories;
|
|
446
|
+
actions: DocsTableActionFactories;
|
|
439
447
|
};
|
|
440
448
|
|
|
441
449
|
/**
|
|
@@ -452,36 +460,12 @@ type DocsTableProps = {
|
|
|
452
460
|
options?: TableOptions<DocsTableRow>;
|
|
453
461
|
};
|
|
454
462
|
/**
|
|
455
|
-
* Component which renders a table documents
|
|
456
|
-
*
|
|
457
463
|
* @public
|
|
458
464
|
*/
|
|
459
465
|
declare const DocsTable: {
|
|
460
|
-
(props: DocsTableProps):
|
|
461
|
-
columns:
|
|
462
|
-
|
|
463
|
-
hidden?: boolean;
|
|
464
|
-
}): TableColumn<DocsTableRow>;
|
|
465
|
-
createNameColumn(): TableColumn<DocsTableRow>;
|
|
466
|
-
createOwnerColumn(): TableColumn<DocsTableRow>;
|
|
467
|
-
createKindColumn(): TableColumn<DocsTableRow>;
|
|
468
|
-
createTypeColumn(): TableColumn<DocsTableRow>;
|
|
469
|
-
};
|
|
470
|
-
actions: {
|
|
471
|
-
createCopyDocsUrlAction(copyToClipboard: Function): (row: DocsTableRow) => {
|
|
472
|
-
icon: () => react_jsx_runtime.JSX.Element;
|
|
473
|
-
tooltip: string;
|
|
474
|
-
onClick: () => any;
|
|
475
|
-
};
|
|
476
|
-
createStarEntityAction(isStarredEntity: Function, toggleStarredEntity: Function): (row: DocsTableRow) => {
|
|
477
|
-
cellStyle: {
|
|
478
|
-
paddingLeft: string;
|
|
479
|
-
};
|
|
480
|
-
icon: () => react_jsx_runtime.JSX.Element;
|
|
481
|
-
tooltip: string;
|
|
482
|
-
onClick: () => any;
|
|
483
|
-
};
|
|
484
|
-
};
|
|
466
|
+
(props: DocsTableProps): JSX.Element | null;
|
|
467
|
+
columns: DocsTableColumnFactories;
|
|
468
|
+
actions: DocsTableActionFactories;
|
|
485
469
|
};
|
|
486
470
|
|
|
487
471
|
/**
|
|
@@ -729,4 +713,4 @@ type DeprecatedTechDocsMetadata = TechDocsMetadata;
|
|
|
729
713
|
type DeprecatedTechDocsEntityMetadata = TechDocsEntityMetadata;
|
|
730
714
|
|
|
731
715
|
export { CustomDocsPanel, DefaultTechDocsHome, DocsCardGrid, DocsTable, LegacyEmbeddedDocsRouter as EmbeddedDocsRouter, EntityListDocsGrid, EntityListDocsTable, EntityTechdocsContent, InfoCardGrid, Reader, Router, TechDocsClient, TechDocsCustomHome, TechDocsIndexPage, TechDocsPageWrapper, TechDocsPicker, TechDocsReaderLayout, TechDocsReaderPage, TechDocsReaderPageContent, TechDocsReaderPageHeader, TechDocsReaderPageSubheader, TechDocsReaderProvider, TechDocsSearch, TechDocsSearchResultListItem, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef };
|
|
732
|
-
export type { BackstageOverrides, CatalogReactComponentsNameToClassKey, ContentStateTypes, DefaultTechDocsHomeProps, DocsCardGridProps, DocsGroupConfig, DocsTableProps, DocsTableRow, EntityListDocsGridPageProps, EntityListDocsTableProps, InfoCardGridClassKey, InfoCardGridProps, PanelConfig, PanelProps, PanelType, ReaderState, SyncResult, TabConfig, TabsConfig, TechDocsApi, TechDocsCustomHomeProps, DeprecatedTechDocsEntityMetadata as TechDocsEntityMetadata, TechDocsIndexPageProps, DeprecatedTechDocsMetadata as TechDocsMetadata, TechDocsPageWrapperProps, TechDocsReaderLayoutProps, TechDocsReaderPageContentProps, TechDocsReaderPageHeaderProps, TechDocsReaderPageProps, TechDocsReaderPageRenderFunction, TechDocsReaderProviderProps, TechDocsReaderProviderRenderFunction, TechDocsSearchProps, TechDocsSearchResultListItemProps, TechDocsStorageApi };
|
|
716
|
+
export type { BackstageOverrides, CatalogReactComponentsNameToClassKey, ContentStateTypes, DefaultTechDocsHomeProps, DocsCardGridProps, DocsGroupConfig, DocsTableActionFactories, DocsTableColumnFactories, DocsTableProps, DocsTableRow, EntityListDocsGridPageProps, EntityListDocsTableProps, InfoCardGridClassKey, InfoCardGridProps, PanelConfig, PanelProps, PanelType, ReaderState, SyncResult, TabConfig, TabsConfig, TechDocsApi, TechDocsCustomHomeProps, DeprecatedTechDocsEntityMetadata as TechDocsEntityMetadata, TechDocsIndexPageProps, DeprecatedTechDocsMetadata as TechDocsMetadata, TechDocsPageWrapperProps, TechDocsReaderLayoutProps, TechDocsReaderPageContentProps, TechDocsReaderPageHeaderProps, TechDocsReaderPageProps, TechDocsReaderPageRenderFunction, TechDocsReaderProviderProps, TechDocsReaderProviderRenderFunction, TechDocsSearchProps, TechDocsSearchResultListItemProps, TechDocsStorageApi };
|
|
@@ -8,6 +8,8 @@ import Typography from '@material-ui/core/Typography';
|
|
|
8
8
|
import { makeStyles, createStyles } from '@material-ui/core/styles';
|
|
9
9
|
import Close from '@material-ui/icons/Close';
|
|
10
10
|
import { useState } from 'react';
|
|
11
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
12
|
+
import { techdocsTranslationRef } from '../../translation.esm.js';
|
|
11
13
|
|
|
12
14
|
const useDrawerStyles = makeStyles(
|
|
13
15
|
(theme) => createStyles({
|
|
@@ -35,7 +37,8 @@ const TechDocsBuildLogsDrawerContent = ({
|
|
|
35
37
|
onClose
|
|
36
38
|
}) => {
|
|
37
39
|
const classes = useDrawerStyles();
|
|
38
|
-
const
|
|
40
|
+
const { t } = useTranslationRef(techdocsTranslationRef);
|
|
41
|
+
const logText = buildLog.length === 0 ? t("buildLogs.waitingForLogs") : buildLog.join("\n");
|
|
39
42
|
return /* @__PURE__ */ jsxs(
|
|
40
43
|
Grid,
|
|
41
44
|
{
|
|
@@ -55,11 +58,11 @@ const TechDocsBuildLogsDrawerContent = ({
|
|
|
55
58
|
spacing: 0,
|
|
56
59
|
wrap: "nowrap",
|
|
57
60
|
children: [
|
|
58
|
-
/* @__PURE__ */ jsx(Typography, { variant: "h5", children: "
|
|
61
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h5", children: t("buildLogs.title") }),
|
|
59
62
|
/* @__PURE__ */ jsx(
|
|
60
63
|
IconButton,
|
|
61
64
|
{
|
|
62
|
-
title: "
|
|
65
|
+
title: t("buildLogs.closeDrawer"),
|
|
63
66
|
onClick: onClose,
|
|
64
67
|
color: "inherit",
|
|
65
68
|
children: /* @__PURE__ */ jsx(Close, {})
|
|
@@ -77,8 +80,9 @@ const TechDocsBuildLogsDrawerContent = ({
|
|
|
77
80
|
const TechDocsBuildLogs = ({ buildLog }) => {
|
|
78
81
|
const classes = useDrawerStyles();
|
|
79
82
|
const [open, setOpen] = useState(false);
|
|
83
|
+
const { t } = useTranslationRef(techdocsTranslationRef);
|
|
80
84
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
81
|
-
/* @__PURE__ */ jsx(Button, { color: "inherit", onClick: () => setOpen(true), children: "
|
|
85
|
+
/* @__PURE__ */ jsx(Button, { color: "inherit", onClick: () => setOpen(true), children: t("buildLogs.showBuildLogs") }),
|
|
82
86
|
/* @__PURE__ */ jsx(
|
|
83
87
|
Drawer,
|
|
84
88
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TechDocsBuildLogs.esm.js","sources":["../../../src/reader/components/TechDocsBuildLogs.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 { LogViewer } from '@backstage/core-components';\nimport Button from '@material-ui/core/Button';\nimport Drawer from '@material-ui/core/Drawer';\nimport Grid from '@material-ui/core/Grid';\nimport IconButton from '@material-ui/core/IconButton';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport Close from '@material-ui/icons/Close';\nimport { useState } from 'react';\n\nconst useDrawerStyles = makeStyles((theme: Theme) =>\n createStyles({\n paper: {\n width: '100%',\n [theme.breakpoints.up('sm')]: {\n width: '75%',\n },\n [theme.breakpoints.up('md')]: {\n width: '50%',\n },\n padding: theme.spacing(2.5),\n },\n root: {\n height: '100%',\n overflow: 'hidden',\n },\n logs: {\n background: theme.palette.background.default,\n },\n }),\n);\n\nexport const TechDocsBuildLogsDrawerContent = ({\n buildLog,\n onClose,\n}: {\n buildLog: string[];\n onClose: () => void;\n}) => {\n const classes = useDrawerStyles();\n const logText =\n buildLog.length === 0 ? '
|
|
1
|
+
{"version":3,"file":"TechDocsBuildLogs.esm.js","sources":["../../../src/reader/components/TechDocsBuildLogs.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 { LogViewer } from '@backstage/core-components';\nimport Button from '@material-ui/core/Button';\nimport Drawer from '@material-ui/core/Drawer';\nimport Grid from '@material-ui/core/Grid';\nimport IconButton from '@material-ui/core/IconButton';\nimport Typography from '@material-ui/core/Typography';\nimport { createStyles, makeStyles, Theme } from '@material-ui/core/styles';\nimport Close from '@material-ui/icons/Close';\nimport { useState } from 'react';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { techdocsTranslationRef } from '../../translation';\n\nconst useDrawerStyles = makeStyles((theme: Theme) =>\n createStyles({\n paper: {\n width: '100%',\n [theme.breakpoints.up('sm')]: {\n width: '75%',\n },\n [theme.breakpoints.up('md')]: {\n width: '50%',\n },\n padding: theme.spacing(2.5),\n },\n root: {\n height: '100%',\n overflow: 'hidden',\n },\n logs: {\n background: theme.palette.background.default,\n },\n }),\n);\n\nexport const TechDocsBuildLogsDrawerContent = ({\n buildLog,\n onClose,\n}: {\n buildLog: string[];\n onClose: () => void;\n}) => {\n const classes = useDrawerStyles();\n const { t } = useTranslationRef(techdocsTranslationRef);\n const logText =\n buildLog.length === 0 ? t('buildLogs.waitingForLogs') : buildLog.join('\\n');\n return (\n <Grid\n container\n direction=\"column\"\n className={classes.root}\n spacing={0}\n wrap=\"nowrap\"\n >\n <Grid\n item\n container\n justifyContent=\"space-between\"\n alignItems=\"center\"\n spacing={0}\n wrap=\"nowrap\"\n >\n <Typography variant=\"h5\">{t('buildLogs.title')}</Typography>\n <IconButton\n key=\"dismiss\"\n title={t('buildLogs.closeDrawer')}\n onClick={onClose}\n color=\"inherit\"\n >\n <Close />\n </IconButton>\n </Grid>\n <Grid item xs>\n <LogViewer text={logText} classes={{ root: classes.logs }} />\n </Grid>\n </Grid>\n );\n};\n\nexport const TechDocsBuildLogs = ({ buildLog }: { buildLog: string[] }) => {\n const classes = useDrawerStyles();\n const [open, setOpen] = useState(false);\n const { t } = useTranslationRef(techdocsTranslationRef);\n\n return (\n <>\n <Button color=\"inherit\" onClick={() => setOpen(true)}>\n {t('buildLogs.showBuildLogs')}\n </Button>\n <Drawer\n classes={{ paper: classes.paper }}\n anchor=\"right\"\n open={open}\n onClose={() => setOpen(false)}\n >\n <TechDocsBuildLogsDrawerContent\n buildLog={buildLog}\n onClose={() => setOpen(false)}\n />\n </Drawer>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AA4BA,MAAM,eAAA,GAAkB,UAAA;AAAA,EAAW,CAAC,UAClC,YAAA,CAAa;AAAA,IACX,KAAA,EAAO;AAAA,MACL,KAAA,EAAO,MAAA;AAAA,MACP,CAAC,KAAA,CAAM,WAAA,CAAY,EAAA,CAAG,IAAI,CAAC,GAAG;AAAA,QAC5B,KAAA,EAAO;AAAA,OACT;AAAA,MACA,CAAC,KAAA,CAAM,WAAA,CAAY,EAAA,CAAG,IAAI,CAAC,GAAG;AAAA,QAC5B,KAAA,EAAO;AAAA,OACT;AAAA,MACA,OAAA,EAAS,KAAA,CAAM,OAAA,CAAQ,GAAG;AAAA,KAC5B;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,MAAA,EAAQ,MAAA;AAAA,MACR,QAAA,EAAU;AAAA,KACZ;AAAA,IACA,IAAA,EAAM;AAAA,MACJ,UAAA,EAAY,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW;AAAA;AACvC,GACD;AACH,CAAA;AAEO,MAAM,iCAAiC,CAAC;AAAA,EAC7C,QAAA;AAAA,EACA;AACF,CAAA,KAGM;AACJ,EAAA,MAAM,UAAU,eAAA,EAAgB;AAChC,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,sBAAsB,CAAA;AACtD,EAAA,MAAM,OAAA,GACJ,SAAS,MAAA,KAAW,CAAA,GAAI,EAAE,0BAA0B,CAAA,GAAI,QAAA,CAAS,IAAA,CAAK,IAAI,CAAA;AAC5E,EAAA,uBACE,IAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAS,IAAA;AAAA,MACT,SAAA,EAAU,QAAA;AAAA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AA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,MAAA,EAAA,EAAO,KAAA,EAAM,SAAA,EAAU,OAAA,EAAS,MAAM,QAAQ,IAAI,CAAA,EAChD,QAAA,EAAA,CAAA,CAAE,yBAAyB,CAAA,EAC9B,CAAA;AAAA,oBACA,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,OAAA,EAAS,EAAE,KAAA,EAAO,OAAA,CAAQ,KAAA,EAAM;AAAA,QAChC,MAAA,EAAO,OAAA;AAAA,QACP,IAAA;AAAA,QACA,OAAA,EAAS,MAAM,OAAA,CAAQ,KAAK,CAAA;AAAA,QAE5B,QAAA,kBAAA,GAAA;AAAA,UAAC,8BAAA;AAAA,UAAA;AAAA,YACC,QAAA;AAAA,YACA,OAAA,EAAS,MAAM,OAAA,CAAQ,KAAK;AAAA;AAAA;AAC9B;AAAA;AACF,GAAA,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import { useApi, configApiRef, useAnalytics } from '@backstage/core-plugin-api';
|
|
4
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
4
5
|
import { ErrorPage } from '@backstage/core-components';
|
|
5
6
|
import { useTechDocsReaderPage } from '@backstage/plugin-techdocs-react';
|
|
6
7
|
import { useLocation } from 'react-router-dom';
|
|
8
|
+
import { techdocsTranslationRef } from '../../translation.esm.js';
|
|
7
9
|
|
|
8
10
|
const TechDocsNotFound = ({ errorMessage }) => {
|
|
9
11
|
const techdocsBuilder = useApi(configApiRef).getOptionalString("techdocs.builder");
|
|
10
12
|
const analyticsApi = useAnalytics();
|
|
11
13
|
const { entityRef } = useTechDocsReaderPage();
|
|
12
14
|
const location = useLocation();
|
|
15
|
+
const { t } = useTranslationRef(techdocsTranslationRef);
|
|
13
16
|
useEffect(() => {
|
|
14
17
|
const { pathname, search, hash } = location;
|
|
15
18
|
analyticsApi.captureEvent("not-found", `${pathname}${search}${hash}`, {
|
|
@@ -18,13 +21,13 @@ const TechDocsNotFound = ({ errorMessage }) => {
|
|
|
18
21
|
}, [analyticsApi, entityRef, location]);
|
|
19
22
|
let additionalInfo = "";
|
|
20
23
|
if (![void 0, "local"].includes(techdocsBuilder)) {
|
|
21
|
-
additionalInfo = "
|
|
24
|
+
additionalInfo = t("notFound.builderNote");
|
|
22
25
|
}
|
|
23
26
|
return /* @__PURE__ */ jsx(
|
|
24
27
|
ErrorPage,
|
|
25
28
|
{
|
|
26
29
|
status: "404",
|
|
27
|
-
statusMessage: errorMessage || "
|
|
30
|
+
statusMessage: errorMessage || t("notFound.title"),
|
|
28
31
|
additionalInfo
|
|
29
32
|
}
|
|
30
33
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TechDocsNotFound.esm.js","sources":["../../../src/reader/components/TechDocsNotFound.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport { useApi, configApiRef, useAnalytics } from '@backstage/core-plugin-api';\nimport { ErrorPage } from '@backstage/core-components';\nimport { useTechDocsReaderPage } from '@backstage/plugin-techdocs-react';\nimport { useLocation } from 'react-router-dom';\n\ntype Props = {\n errorMessage?: string;\n};\n\nexport const TechDocsNotFound = ({ errorMessage }: Props) => {\n const techdocsBuilder =\n useApi(configApiRef).getOptionalString('techdocs.builder');\n const analyticsApi = useAnalytics();\n const { entityRef } = useTechDocsReaderPage();\n const location = useLocation();\n\n useEffect(() => {\n const { pathname, search, hash } = location;\n analyticsApi.captureEvent('not-found', `${pathname}${search}${hash}`, {\n attributes: entityRef,\n });\n }, [analyticsApi, entityRef, location]);\n\n let additionalInfo = '';\n if (![undefined, 'local'].includes(techdocsBuilder)) {\n additionalInfo
|
|
1
|
+
{"version":3,"file":"TechDocsNotFound.esm.js","sources":["../../../src/reader/components/TechDocsNotFound.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect } from 'react';\nimport { useApi, configApiRef, useAnalytics } from '@backstage/core-plugin-api';\nimport { useTranslationRef } from '@backstage/core-plugin-api/alpha';\nimport { ErrorPage } from '@backstage/core-components';\nimport { useTechDocsReaderPage } from '@backstage/plugin-techdocs-react';\nimport { useLocation } from 'react-router-dom';\nimport { techdocsTranslationRef } from '../../translation';\n\ntype Props = {\n errorMessage?: string;\n};\n\nexport const TechDocsNotFound = ({ errorMessage }: Props) => {\n const techdocsBuilder =\n useApi(configApiRef).getOptionalString('techdocs.builder');\n const analyticsApi = useAnalytics();\n const { entityRef } = useTechDocsReaderPage();\n const location = useLocation();\n const { t } = useTranslationRef(techdocsTranslationRef);\n\n useEffect(() => {\n const { pathname, search, hash } = location;\n analyticsApi.captureEvent('not-found', `${pathname}${search}${hash}`, {\n attributes: entityRef,\n });\n }, [analyticsApi, entityRef, location]);\n\n let additionalInfo = '';\n if (![undefined, 'local'].includes(techdocsBuilder)) {\n additionalInfo = t('notFound.builderNote');\n }\n\n return (\n <ErrorPage\n status=\"404\"\n statusMessage={errorMessage || t('notFound.title')}\n additionalInfo={additionalInfo}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AA4BO,MAAM,gBAAA,GAAmB,CAAC,EAAE,YAAA,EAAa,KAAa;AAC3D,EAAA,MAAM,eAAA,GACJ,MAAA,CAAO,YAAY,CAAA,CAAE,kBAAkB,kBAAkB,CAAA;AAC3D,EAAA,MAAM,eAAe,YAAA,EAAa;AAClC,EAAA,MAAM,EAAE,SAAA,EAAU,GAAI,qBAAA,EAAsB;AAC5C,EAAA,MAAM,WAAW,WAAA,EAAY;AAC7B,EAAA,MAAM,EAAE,CAAA,EAAE,GAAI,iBAAA,CAAkB,sBAAsB,CAAA;AAEtD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,EAAE,QAAA,EAAU,MAAA,EAAQ,IAAA,EAAK,GAAI,QAAA;AACnC,IAAA,YAAA,CAAa,YAAA,CAAa,aAAa,CAAA,EAAG,QAAQ,GAAG,MAAM,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI;AAAA,MACpE,UAAA,EAAY;AAAA,KACb,CAAA;AAAA,EACH,CAAA,EAAG,CAAC,YAAA,EAAc,SAAA,EAAW,QAAQ,CAAC,CAAA;AAEtC,EAAA,IAAI,cAAA,GAAiB,EAAA;AACrB,EAAA,IAAI,CAAC,CAAC,MAAA,EAAW,OAAO,CAAA,CAAE,QAAA,CAAS,eAAe,CAAA,EAAG;AACnD,IAAA,cAAA,GAAiB,EAAE,sBAAsB,CAAA;AAAA,EAC3C;AAEA,EAAA,uBACE,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,MAAA,EAAO,KAAA;AAAA,MACP,aAAA,EAAe,YAAA,IAAgB,CAAA,CAAE,gBAAgB,CAAA;AAAA,MACjD;AAAA;AAAA,GACF;AAEJ;;;;"}
|