@backstage/plugin-techdocs 0.13.3 → 0.15.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 CHANGED
@@ -1,5 +1,117 @@
1
1
  # @backstage/plugin-techdocs
2
2
 
3
+ ## 0.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ee3d6c6f10: **BREAKING:**
8
+ Table column utilities `createNameColumn`, `createOwnerColumn`, `createTypeColumn` as well as actions utilities `createCopyDocsUrlAction` and `createStarEntityAction` are no longer directly exported. Instead accessible through DocsTable and EntityListDocsTable.
9
+
10
+ Use as following:
11
+
12
+ ```tsx
13
+ DocsTable.columns.createNameColumn();
14
+ DocsTable.columns.createOwnerColumn();
15
+ DocsTable.columns.createTypeColumn();
16
+
17
+ DocsTable.actions.createCopyDocsUrlAction();
18
+ DocsTable.actions.createStarEntityAction();
19
+ ```
20
+
21
+ - Renamed `DocsResultListItem` to `TechDocsSearchResultListItem`, leaving the old name in place as a deprecations.
22
+
23
+ - Renamed `TechDocsPage` to `TechDocsReaderPage`, leaving the old name in place as a deprecations.
24
+
25
+ - Renamed `TechDocsPageRenderFunction` to `TechDocsPageRenderFunction`, leaving the old name in place as a deprecations.
26
+
27
+ - Renamed `TechDocsPageHeader` to `TechDocsReaderPageHeader`, leaving the old name in place as a deprecations.
28
+
29
+ - `LegacyTechDocsHome` marked as deprecated and will be deleted in next release, use `TechDocsCustomHome` instead.
30
+
31
+ - `LegacyTechDocsPage` marked as deprecated and will be deleted in next release, use `TechDocsReaderPage` instead.
32
+
33
+ ### Patch Changes
34
+
35
+ - 64b430f80d: chore(deps): bump `react-text-truncate` from 0.17.0 to 0.18.0
36
+ - 899f196af5: Use `getEntityByRef` instead of `getEntityByName` in the catalog client
37
+ - f41a293231: - **DEPRECATION**: Deprecated `formatEntityRefTitle` in favor of the new `humanizeEntityRef` method instead. Please migrate to using the new method instead.
38
+ - c5fda066b1: Collapse techdocs sidebar on small devices
39
+ - f590d1681b: Removed usage of deprecated favorite utility methods.
40
+ - 5b0f9a75fa: Remove copyright from old footer in documentation generated with previous version of `mkdocs-techdocs-plugin` (`v0.2.2`).
41
+ - 0c3ba547a6: Show feedback when copying code snippet to clipboard.
42
+ - 0ca964ee0e: Fixed a bug that could cause searches in the in-context TechDocs search bar to show results from a different TechDocs site.
43
+ - 36aa63022b: Use `CompoundEntityRef` instead of `EntityName`, and `getCompoundEntityRef` instead of `getEntityName`, from `@backstage/catalog-model`.
44
+ - Updated dependencies
45
+ - @backstage/catalog-model@0.12.0
46
+ - @backstage/core-components@0.9.0
47
+ - @backstage/plugin-search@0.7.2
48
+ - @backstage/plugin-catalog@0.9.1
49
+ - @backstage/plugin-catalog-react@0.8.0
50
+ - @backstage/integration@0.8.0
51
+ - @backstage/core-plugin-api@0.8.0
52
+ - @backstage/integration-react@0.1.24
53
+
54
+ ## 0.14.0
55
+
56
+ ### Minor Changes
57
+
58
+ - 2262fe19c9: **BREAKING**: Removed support for passing in an explicit `entity` prop to entity page extensions, which has been deprecated for a long time. This is only a breaking change at the TypeScript level, as this property was already ignored.
59
+ - 4faae902eb: Adjust the Tech Docs page theme as a side effect of the `mkdocs-material` theme update.
60
+
61
+ If you use the `spofify/techdocs` image to build your documentation, make sure you use version `spotify/techdocs:v0.3.7`.
62
+
63
+ **Breaking**: The `PyMdown` extensions have also been updated and some syntax may have changed, so it is recommended that you check the extension's documentation if something stops working.
64
+ For example, the syntax of tags below was deprecated in `PyMdown` extensions `v.7.0` and in `v.8.0.0` it has been removed. This means that the old syntax specified below no longer works.
65
+
66
+ ````markdown
67
+ ```markdown tab="tab"
68
+ This is some markdown
69
+ ```
70
+
71
+ ```markdown tab="tab 2"
72
+ This is some markdown in tab 2
73
+ ```
74
+ ````
75
+
76
+ ### Patch Changes
77
+
78
+ - 3bbb4d98c6: Changed <TechdocsPage /> to use <NotFoundErrorPage /> from createApp
79
+ - ed09ad8093: Updated usage of the `LocationSpec` type from `@backstage/catalog-model`, which is deprecated.
80
+ - b776ce5aab: Replaced use of deprecated `useEntityListProvider` hook with `useEntityList`.
81
+ - d4f67fa728: Removed import of deprecated hook.
82
+ - 45e1706328: Continuation of [#9569](https://github.com/backstage/backstage/pull/9569), fix Tech Docs Reader search position to be the same width as content.
83
+ - 919cf2f836: Minor updates to match the new `targetRef` field of relations, and to stop consuming the `target` field
84
+ - Updated dependencies
85
+ - @backstage/plugin-catalog@0.9.0
86
+ - @backstage/core-components@0.8.10
87
+ - @backstage/plugin-catalog-react@0.7.0
88
+ - @backstage/catalog-model@0.11.0
89
+ - @backstage/core-plugin-api@0.7.0
90
+ - @backstage/integration@0.7.5
91
+ - @backstage/plugin-search@0.7.1
92
+ - @backstage/integration-react@0.1.23
93
+
94
+ ## 0.13.4
95
+
96
+ ### Patch Changes
97
+
98
+ - 1ed305728b: Bump `node-fetch` to version 2.6.7 and `cross-fetch` to version 3.1.5
99
+ - c77c5c7eb6: Added `backstage.role` to `package.json`
100
+ - 6553985cd4: Match text size of admonitions to main content text size.
101
+ - 9df7b43e1a: Improve overall appearance of highlighted code in docs.
102
+ - Updated dependencies
103
+ - @backstage/core-components@0.8.9
104
+ - @backstage/core-plugin-api@0.6.1
105
+ - @backstage/errors@0.2.1
106
+ - @backstage/integration@0.7.3
107
+ - @backstage/integration-react@0.1.22
108
+ - @backstage/plugin-catalog@0.8.0
109
+ - @backstage/plugin-catalog-react@0.6.15
110
+ - @backstage/plugin-search@0.7.0
111
+ - @backstage/catalog-model@0.10.0
112
+ - @backstage/config@0.1.14
113
+ - @backstage/theme@0.2.15
114
+
3
115
  ## 0.13.3
4
116
 
5
117
  ### Patch Changes
@@ -0,0 +1,143 @@
1
+ import React, { useState } from 'react';
2
+ import useAsync from 'react-use/lib/useAsync';
3
+ import { makeStyles } from '@material-ui/core';
4
+ import { catalogApiRef, CATALOG_FILTER_EXISTS, isOwnerOf } from '@backstage/plugin-catalog-react';
5
+ import { parseEntityRef, DEFAULT_NAMESPACE } from '@backstage/catalog-model';
6
+ import { TechDocsPageWrapper, DocsTable, DocsCardGrid } from '../index.esm.js';
7
+ import { Content, Progress, WarningPanel, CodeSnippet, HeaderTabs, ContentHeader, SupportButton } from '@backstage/core-components';
8
+ import { useApi, identityApiRef } from '@backstage/core-plugin-api';
9
+ import '@backstage/errors';
10
+ import 'event-source-polyfill';
11
+ import 'react-router-dom';
12
+ import '@backstage/integration-react';
13
+ import '@backstage/integration';
14
+ import '@material-ui/icons/FeedbackOutlined';
15
+ import 'react-dom';
16
+ import 'git-url-parse';
17
+ import '@material-ui/icons/Menu';
18
+ import 'dompurify';
19
+ import 'react-text-truncate';
20
+ import '@backstage/plugin-search';
21
+ import '@material-ui/icons/Search';
22
+ import '@material-ui/lab/Autocomplete';
23
+ import 'react-router';
24
+ import 'react-use/lib/useDebounce';
25
+ import '@material-ui/lab';
26
+ import '@material-ui/icons/Close';
27
+ import 'react-use/lib/useAsyncRetry';
28
+ import '@material-ui/icons/Code';
29
+ import 'react-use/lib/useCopyToClipboard';
30
+ import 'lodash';
31
+ import '@material-ui/icons/Share';
32
+ import '@material-ui/styles';
33
+ import '@material-ui/icons/Star';
34
+ import '@material-ui/icons/StarBorder';
35
+ import '@backstage/plugin-catalog';
36
+
37
+ const panels = {
38
+ DocsTable,
39
+ DocsCardGrid
40
+ };
41
+ const CustomPanel = ({
42
+ config,
43
+ entities,
44
+ index
45
+ }) => {
46
+ const useStyles = makeStyles({
47
+ panelContainer: {
48
+ marginBottom: "2rem",
49
+ ...config.panelCSS ? config.panelCSS : {}
50
+ }
51
+ });
52
+ const classes = useStyles();
53
+ const { value: user } = useOwnUser();
54
+ const Panel = panels[config.panelType];
55
+ const shownEntities = entities.filter((entity) => {
56
+ if (config.filterPredicate === "ownedByUser") {
57
+ if (!user) {
58
+ return false;
59
+ }
60
+ return isOwnerOf(user, entity);
61
+ }
62
+ return typeof config.filterPredicate === "function" && config.filterPredicate(entity);
63
+ });
64
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ContentHeader, {
65
+ title: config.title,
66
+ description: config.description
67
+ }, index === 0 ? /* @__PURE__ */ React.createElement(SupportButton, null, "Discover documentation in your ecosystem.") : null), /* @__PURE__ */ React.createElement("div", {
68
+ className: classes.panelContainer
69
+ }, /* @__PURE__ */ React.createElement(Panel, {
70
+ "data-testid": "techdocs-custom-panel",
71
+ entities: shownEntities
72
+ })));
73
+ };
74
+ const TechDocsCustomHome = (props) => {
75
+ const { tabsConfig } = props;
76
+ const [selectedTab, setSelectedTab] = useState(0);
77
+ const catalogApi = useApi(catalogApiRef);
78
+ const {
79
+ value: entities,
80
+ loading,
81
+ error
82
+ } = useAsync(async () => {
83
+ const response = await catalogApi.getEntities({
84
+ filter: {
85
+ "metadata.annotations.backstage.io/techdocs-ref": CATALOG_FILTER_EXISTS
86
+ },
87
+ fields: [
88
+ "apiVersion",
89
+ "kind",
90
+ "metadata",
91
+ "relations",
92
+ "spec.owner",
93
+ "spec.type"
94
+ ]
95
+ });
96
+ return response.items.filter((entity) => {
97
+ var _a;
98
+ return !!((_a = entity.metadata.annotations) == null ? void 0 : _a["backstage.io/techdocs-ref"]);
99
+ });
100
+ });
101
+ const currentTabConfig = tabsConfig[selectedTab];
102
+ if (loading) {
103
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Progress, null)));
104
+ }
105
+ if (error) {
106
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(WarningPanel, {
107
+ severity: "error",
108
+ title: "Could not load available documentation."
109
+ }, /* @__PURE__ */ React.createElement(CodeSnippet, {
110
+ language: "text",
111
+ text: error.toString()
112
+ }))));
113
+ }
114
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(HeaderTabs, {
115
+ selectedIndex: selectedTab,
116
+ onChange: (index) => setSelectedTab(index),
117
+ tabs: tabsConfig.map(({ label }, index) => ({
118
+ id: index.toString(),
119
+ label
120
+ }))
121
+ }), /* @__PURE__ */ React.createElement(Content, {
122
+ "data-testid": "techdocs-content"
123
+ }, currentTabConfig.panels.map((config, index) => /* @__PURE__ */ React.createElement(CustomPanel, {
124
+ key: index,
125
+ config,
126
+ entities: !!entities ? entities : [],
127
+ index
128
+ }))));
129
+ };
130
+ function useOwnUser() {
131
+ const catalogApi = useApi(catalogApiRef);
132
+ const identityApi = useApi(identityApiRef);
133
+ return useAsync(async () => {
134
+ const identity = await identityApi.getBackstageIdentity();
135
+ return catalogApi.getEntityByRef(parseEntityRef(identity.userEntityRef, {
136
+ defaultKind: "User",
137
+ defaultNamespace: DEFAULT_NAMESPACE
138
+ }));
139
+ }, [catalogApi, identityApi]);
140
+ }
141
+
142
+ export { TechDocsCustomHome };
143
+ //# sourceMappingURL=TechDocsCustomHome-4e5e8594.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TechDocsCustomHome-4e5e8594.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, { AsyncState } from 'react-use/lib/useAsync';\nimport { makeStyles } from '@material-ui/core';\nimport { CSSProperties } from '@material-ui/styles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n isOwnerOf,\n} from '@backstage/plugin-catalog-react';\nimport {\n DEFAULT_NAMESPACE,\n Entity,\n parseEntityRef,\n UserEntity,\n} from '@backstage/catalog-model';\nimport { DocsTable } from './Tables';\nimport { DocsCardGrid } from './Grids';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\n\nimport {\n CodeSnippet,\n Content,\n HeaderTabs,\n Progress,\n WarningPanel,\n SupportButton,\n ContentHeader,\n} from '@backstage/core-components';\n\nimport { identityApiRef, useApi } from '@backstage/core-plugin-api';\n\nconst panels = {\n DocsTable: DocsTable,\n DocsCardGrid: DocsCardGrid,\n};\n\n/**\n * Available panel types\n *\n * @public\n */\nexport type PanelType = 'DocsCardGrid' | 'DocsTable';\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}\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\nconst CustomPanel = ({\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 { value: user } = useOwnUser();\n\n const Panel = panels[config.panelType];\n\n const shownEntities = entities.filter(entity => {\n if (config.filterPredicate === 'ownedByUser') {\n if (!user) {\n return false;\n }\n return isOwnerOf(user, entity);\n }\n\n return (\n typeof config.filterPredicate === 'function' &&\n config.filterPredicate(entity)\n );\n });\n\n return (\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 <div className={classes.panelContainer}>\n <Panel data-testid=\"techdocs-custom-panel\" entities={shownEntities} />\n </div>\n </>\n );\n};\n\n/**\n * Props for {@link TechDocsCustomHome}\n *\n * @public\n */\nexport type TechDocsCustomHomeProps = {\n tabsConfig: TabsConfig;\n};\n\nexport const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {\n const { tabsConfig } = 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 'metadata.annotations.backstage.io/techdocs-ref': 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?.['backstage.io/techdocs-ref'];\n });\n });\n\n const currentTabConfig = tabsConfig[selectedTab];\n\n if (loading) {\n return (\n <TechDocsPageWrapper>\n <Content>\n <Progress />\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n if (error) {\n return (\n <TechDocsPageWrapper>\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>\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 <CustomPanel\n key={index}\n config={config}\n entities={!!entities ? entities : []}\n index={index}\n />\n ))}\n </Content>\n </TechDocsPageWrapper>\n );\n};\n\nfunction useOwnUser(): AsyncState<UserEntity | undefined> {\n const catalogApi = useApi(catalogApiRef);\n const identityApi = useApi(identityApiRef);\n\n return useAsync(async () => {\n const identity = await identityApi.getBackstageIdentity();\n // TODO(freben): Defensively parse with defaults even though getEntityByRef\n // supports the string form, since some auth resolvers have been known to\n // return incomplete refs (just the name part) historically. This can be\n // simplified in the future to just pass the ref immediately to\n // getEntityByRef.\n return catalogApi.getEntityByRef(\n parseEntityRef(identity.userEntityRef, {\n defaultKind: 'User',\n defaultNamespace: DEFAULT_NAMESPACE,\n }),\n ) as Promise<UserEntity | undefined>;\n }, [catalogApi, identityApi]);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAM,SAAS;AAAA,EACb;AAAA,EACA;AAAA;AAwCF,MAAM,cAAc,CAAC;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,MAKI;AACJ,QAAM,YAAY,WAAW;AAAA,IAC3B,gBAAgB;AAAA,MACd,cAAc;AAAA,SACV,OAAO,WAAW,OAAO,WAAW;AAAA;AAAA;AAG5C,QAAM,UAAU;AAChB,QAAM,EAAE,OAAO,SAAS;AAExB,QAAM,QAAQ,OAAO,OAAO;AAE5B,QAAM,gBAAgB,SAAS,OAAO,YAAU;AAC9C,QAAI,OAAO,oBAAoB,eAAe;AAC5C,UAAI,CAAC,MAAM;AACT,eAAO;AAAA;AAET,aAAO,UAAU,MAAM;AAAA;AAGzB,WACE,OAAO,OAAO,oBAAoB,cAClC,OAAO,gBAAgB;AAAA;AAI3B,uGAEK,eAAD;AAAA,IAAe,OAAO,OAAO;AAAA,IAAO,aAAa,OAAO;AAAA,KACrD,UAAU,wCACR,eAAD,MAAe,+CAGb,2CAEL,OAAD;AAAA,IAAK,WAAW,QAAQ;AAAA,yCACrB,OAAD;AAAA,IAAO,eAAY;AAAA,IAAwB,UAAU;AAAA;AAAA;MAehD,qBAAqB,CAAC,UAAmC;AACpE,QAAM,EAAE,eAAe;AACvB,QAAM,CAAC,aAAa,kBAAkB,SAAiB;AACvD,QAAM,aAAyB,OAAO;AAEtC,QAAM;AAAA,IACJ,OAAO;AAAA,IACP;AAAA,IACA;AAAA,MACE,SAAS,YAAY;AACvB,UAAM,WAAW,MAAM,WAAW,YAAY;AAAA,MAC5C,QAAQ;AAAA,QACN,kDAAkD;AAAA;AAAA,MAEpD,QAAQ;AAAA,QACN;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA;AAGJ,WAAO,SAAS,MAAM,OAAO,CAAC,WAAmB;AA5KrD;AA6KM,aAAO,CAAC,eAAQ,SAAS,gBAAhB,mBAA8B;AAAA;AAAA;AAI3C,QAAM,mBAAmB,WAAW;AAEpC,MAAI,SAAS;AACX,+CACG,qBAAD,0CACG,SAAD,0CACG,UAAD;AAAA;AAMR,MAAI,OAAO;AACT,+CACG,qBAAD,0CACG,SAAD,0CACG,cAAD;AAAA,MACE,UAAS;AAAA,MACT,OAAM;AAAA,2CAEL,aAAD;AAAA,MAAa,UAAS;AAAA,MAAO,MAAM,MAAM;AAAA;AAAA;AAOnD,6CACG,qBAAD,0CACG,YAAD;AAAA,IACE,eAAe;AAAA,IACf,UAAU,WAAS,eAAe;AAAA,IAClC,MAAM,WAAW,IAAI,CAAC,EAAE,SAAS;AAAW,MAC1C,IAAI,MAAM;AAAA,MACV;AAAA;AAAA,0CAGH,SAAD;AAAA,IAAS,eAAY;AAAA,KAClB,iBAAiB,OAAO,IAAI,CAAC,QAAQ,8CACnC,aAAD;AAAA,IACE,KAAK;AAAA,IACL;AAAA,IACA,UAAU,CAAC,CAAC,WAAW,WAAW;AAAA,IAClC;AAAA;AAAA;AAQZ,sBAA0D;AACxD,QAAM,aAAa,OAAO;AAC1B,QAAM,cAAc,OAAO;AAE3B,SAAO,SAAS,YAAY;AAC1B,UAAM,WAAW,MAAM,YAAY;AAMnC,WAAO,WAAW,eAChB,eAAe,SAAS,eAAe;AAAA,MACrC,aAAa;AAAA,MACb,kBAAkB;AAAA;AAAA,KAGrB,CAAC,YAAY;AAAA;;;;"}