@backstage/plugin-techdocs 0.13.4 → 0.15.1-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 CHANGED
@@ -1,5 +1,109 @@
1
1
  # @backstage/plugin-techdocs
2
2
 
3
+ ## 0.15.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 7a1dbe6ce9: The panels of `TechDocsCustomHome` now use the `useEntityOwnership` hook to resolve ownership when the `'ownedByUser'` filter predicate is used.
8
+ - Updated dependencies
9
+ - @backstage/plugin-catalog@0.10.0-next.0
10
+ - @backstage/plugin-catalog-react@0.9.0-next.0
11
+ - @backstage/core-components@0.9.1-next.0
12
+ - @backstage/catalog-model@0.13.0-next.0
13
+ - @backstage/plugin-search@0.7.3-next.0
14
+ - @backstage/integration-react@0.1.25-next.0
15
+
16
+ ## 0.15.0
17
+
18
+ ### Minor Changes
19
+
20
+ - ee3d6c6f10: **BREAKING:**
21
+ 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.
22
+
23
+ Use as following:
24
+
25
+ ```tsx
26
+ DocsTable.columns.createNameColumn();
27
+ DocsTable.columns.createOwnerColumn();
28
+ DocsTable.columns.createTypeColumn();
29
+
30
+ DocsTable.actions.createCopyDocsUrlAction();
31
+ DocsTable.actions.createStarEntityAction();
32
+ ```
33
+
34
+ - Renamed `DocsResultListItem` to `TechDocsSearchResultListItem`, leaving the old name in place as a deprecations.
35
+
36
+ - Renamed `TechDocsPage` to `TechDocsReaderPage`, leaving the old name in place as a deprecations.
37
+
38
+ - Renamed `TechDocsPageRenderFunction` to `TechDocsPageRenderFunction`, leaving the old name in place as a deprecations.
39
+
40
+ - Renamed `TechDocsPageHeader` to `TechDocsReaderPageHeader`, leaving the old name in place as a deprecations.
41
+
42
+ - `LegacyTechDocsHome` marked as deprecated and will be deleted in next release, use `TechDocsCustomHome` instead.
43
+
44
+ - `LegacyTechDocsPage` marked as deprecated and will be deleted in next release, use `TechDocsReaderPage` instead.
45
+
46
+ ### Patch Changes
47
+
48
+ - 64b430f80d: chore(deps): bump `react-text-truncate` from 0.17.0 to 0.18.0
49
+ - 899f196af5: Use `getEntityByRef` instead of `getEntityByName` in the catalog client
50
+ - f41a293231: - **DEPRECATION**: Deprecated `formatEntityRefTitle` in favor of the new `humanizeEntityRef` method instead. Please migrate to using the new method instead.
51
+ - c5fda066b1: Collapse techdocs sidebar on small devices
52
+ - f590d1681b: Removed usage of deprecated favorite utility methods.
53
+ - 5b0f9a75fa: Remove copyright from old footer in documentation generated with previous version of `mkdocs-techdocs-plugin` (`v0.2.2`).
54
+ - 0c3ba547a6: Show feedback when copying code snippet to clipboard.
55
+ - 0ca964ee0e: Fixed a bug that could cause searches in the in-context TechDocs search bar to show results from a different TechDocs site.
56
+ - 36aa63022b: Use `CompoundEntityRef` instead of `EntityName`, and `getCompoundEntityRef` instead of `getEntityName`, from `@backstage/catalog-model`.
57
+ - Updated dependencies
58
+ - @backstage/catalog-model@0.12.0
59
+ - @backstage/core-components@0.9.0
60
+ - @backstage/plugin-search@0.7.2
61
+ - @backstage/plugin-catalog@0.9.1
62
+ - @backstage/plugin-catalog-react@0.8.0
63
+ - @backstage/integration@0.8.0
64
+ - @backstage/core-plugin-api@0.8.0
65
+ - @backstage/integration-react@0.1.24
66
+
67
+ ## 0.14.0
68
+
69
+ ### Minor Changes
70
+
71
+ - 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.
72
+ - 4faae902eb: Adjust the Tech Docs page theme as a side effect of the `mkdocs-material` theme update.
73
+
74
+ If you use the `spofify/techdocs` image to build your documentation, make sure you use version `spotify/techdocs:v0.3.7`.
75
+
76
+ **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.
77
+ 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.
78
+
79
+ ````markdown
80
+ ```markdown tab="tab"
81
+ This is some markdown
82
+ ```
83
+
84
+ ```markdown tab="tab 2"
85
+ This is some markdown in tab 2
86
+ ```
87
+ ````
88
+
89
+ ### Patch Changes
90
+
91
+ - 3bbb4d98c6: Changed <TechdocsPage /> to use <NotFoundErrorPage /> from createApp
92
+ - ed09ad8093: Updated usage of the `LocationSpec` type from `@backstage/catalog-model`, which is deprecated.
93
+ - b776ce5aab: Replaced use of deprecated `useEntityListProvider` hook with `useEntityList`.
94
+ - d4f67fa728: Removed import of deprecated hook.
95
+ - 45e1706328: Continuation of [#9569](https://github.com/backstage/backstage/pull/9569), fix Tech Docs Reader search position to be the same width as content.
96
+ - 919cf2f836: Minor updates to match the new `targetRef` field of relations, and to stop consuming the `target` field
97
+ - Updated dependencies
98
+ - @backstage/plugin-catalog@0.9.0
99
+ - @backstage/core-components@0.8.10
100
+ - @backstage/plugin-catalog-react@0.7.0
101
+ - @backstage/catalog-model@0.11.0
102
+ - @backstage/core-plugin-api@0.7.0
103
+ - @backstage/integration@0.7.5
104
+ - @backstage/plugin-search@0.7.1
105
+ - @backstage/integration-react@0.1.23
106
+
3
107
  ## 0.13.4
4
108
 
5
109
  ### Patch Changes
@@ -0,0 +1,132 @@
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, useEntityOwnership } from '@backstage/plugin-catalog-react';
5
+ import { TechDocsPageWrapper, DocsTable, DocsCardGrid } from '../index.esm.js';
6
+ import { Content, Progress, WarningPanel, CodeSnippet, HeaderTabs, ContentHeader, SupportButton } from '@backstage/core-components';
7
+ import { useApi } from '@backstage/core-plugin-api';
8
+ import '@backstage/errors';
9
+ import 'event-source-polyfill';
10
+ import 'react-router-dom';
11
+ import '@backstage/integration-react';
12
+ import '@backstage/integration';
13
+ import '@material-ui/icons/FeedbackOutlined';
14
+ import 'react-dom';
15
+ import 'git-url-parse';
16
+ import '@material-ui/icons/Menu';
17
+ import 'dompurify';
18
+ import 'react-text-truncate';
19
+ import '@backstage/plugin-search';
20
+ import '@material-ui/icons/Search';
21
+ import '@material-ui/lab/Autocomplete';
22
+ import 'react-router';
23
+ import 'react-use/lib/useDebounce';
24
+ import '@material-ui/lab';
25
+ import '@material-ui/icons/Close';
26
+ import 'react-use/lib/useAsyncRetry';
27
+ import '@material-ui/icons/Code';
28
+ import '@backstage/catalog-model';
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 { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();
54
+ const Panel = panels[config.panelType];
55
+ const shownEntities = entities.filter((entity) => {
56
+ if (config.filterPredicate === "ownedByUser") {
57
+ if (loadingOwnership) {
58
+ return false;
59
+ }
60
+ return isOwnedEntity(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
+
131
+ export { TechDocsCustomHome };
132
+ //# sourceMappingURL=TechDocsCustomHome-a4f542cd.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TechDocsCustomHome-a4f542cd.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/lib/useAsync';\nimport { makeStyles } from '@material-ui/core';\nimport { CSSProperties } from '@material-ui/styles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n useEntityOwnership,\n} from '@backstage/plugin-catalog-react';\nimport { Entity } 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';\nimport { 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 { 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 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"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,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,SAAS,kBAAkB,kBAAkB;AAErD,QAAM,QAAQ,OAAO,OAAO;AAE5B,QAAM,gBAAgB,SAAS,OAAO,YAAU;AAC9C,QAAI,OAAO,oBAAoB,eAAe;AAC5C,UAAI,kBAAkB;AACpB,eAAO;AAAA;AAET,aAAO,cAAc;AAAA;AAGvB,WACE,OAAO,OAAO,oBAAoB,cAClC,OAAO,gBAAgB;AAAA;AAI3B,uGAEK,eAAD;AAAA,IAAe,OAAO,OAAO;AAAA,IAAO,aAAa,OAAO;AAAA,KACrD,UAAU,wCACR,eAA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