@backstage/plugin-techdocs 0.0.0-nightly-20220224022833 → 0.0.0-nightly-20220226022353

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,6 +1,45 @@
1
1
  # @backstage/plugin-techdocs
2
2
 
3
- ## 0.0.0-nightly-20220224022833
3
+ ## 0.0.0-nightly-20220226022353
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
+ - c5fda066b1: Collapse techdocs sidebar on small devices
36
+ - 5b0f9a75fa: Remove copyright from old footer in documentation generated with previous version of `mkdocs-techdocs-plugin` (`v0.2.2`).
37
+ - 0ca964ee0e: Fixed a bug that could cause searches in the in-context TechDocs search bar to show results from a different TechDocs site.
38
+ - Updated dependencies
39
+ - @backstage/integration@0.0.0-nightly-20220226022353
40
+ - @backstage/core-components@0.0.0-nightly-20220226022353
41
+
42
+ ## 0.14.0
4
43
 
5
44
  ### Minor Changes
6
45
 
@@ -31,12 +70,14 @@
31
70
  - 45e1706328: Continuation of [#9569](https://github.com/backstage/backstage/pull/9569), fix Tech Docs Reader search position to be the same width as content.
32
71
  - 919cf2f836: Minor updates to match the new `targetRef` field of relations, and to stop consuming the `target` field
33
72
  - Updated dependencies
34
- - @backstage/plugin-catalog@0.0.0-nightly-20220224022833
35
- - @backstage/core-components@0.0.0-nightly-20220224022833
36
- - @backstage/plugin-catalog-react@0.0.0-nightly-20220224022833
37
- - @backstage/catalog-model@0.0.0-nightly-20220224022833
38
- - @backstage/integration@0.0.0-nightly-20220224022833
39
- - @backstage/plugin-search@0.0.0-nightly-20220224022833
73
+ - @backstage/plugin-catalog@0.9.0
74
+ - @backstage/core-components@0.8.10
75
+ - @backstage/plugin-catalog-react@0.7.0
76
+ - @backstage/catalog-model@0.11.0
77
+ - @backstage/core-plugin-api@0.7.0
78
+ - @backstage/integration@0.7.5
79
+ - @backstage/plugin-search@0.7.1
80
+ - @backstage/integration-react@0.1.23
40
81
 
41
82
  ## 0.13.4
42
83
 
@@ -0,0 +1,140 @@
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 '@backstage/plugin-catalog';
33
+
34
+ const panels = {
35
+ DocsTable,
36
+ DocsCardGrid
37
+ };
38
+ const CustomPanel = ({
39
+ config,
40
+ entities,
41
+ index
42
+ }) => {
43
+ const useStyles = makeStyles({
44
+ panelContainer: {
45
+ marginBottom: "2rem",
46
+ ...config.panelCSS ? config.panelCSS : {}
47
+ }
48
+ });
49
+ const classes = useStyles();
50
+ const { value: user } = useOwnUser();
51
+ const Panel = panels[config.panelType];
52
+ const shownEntities = entities.filter((entity) => {
53
+ if (config.filterPredicate === "ownedByUser") {
54
+ if (!user) {
55
+ return false;
56
+ }
57
+ return isOwnerOf(user, entity);
58
+ }
59
+ return typeof config.filterPredicate === "function" && config.filterPredicate(entity);
60
+ });
61
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ContentHeader, {
62
+ title: config.title,
63
+ description: config.description
64
+ }, index === 0 ? /* @__PURE__ */ React.createElement(SupportButton, null, "Discover documentation in your ecosystem.") : null), /* @__PURE__ */ React.createElement("div", {
65
+ className: classes.panelContainer
66
+ }, /* @__PURE__ */ React.createElement(Panel, {
67
+ "data-testid": "techdocs-custom-panel",
68
+ entities: shownEntities
69
+ })));
70
+ };
71
+ const TechDocsCustomHome = (props) => {
72
+ const { tabsConfig } = props;
73
+ const [selectedTab, setSelectedTab] = useState(0);
74
+ const catalogApi = useApi(catalogApiRef);
75
+ const {
76
+ value: entities,
77
+ loading,
78
+ error
79
+ } = useAsync(async () => {
80
+ const response = await catalogApi.getEntities({
81
+ filter: {
82
+ "metadata.annotations.backstage.io/techdocs-ref": CATALOG_FILTER_EXISTS
83
+ },
84
+ fields: [
85
+ "apiVersion",
86
+ "kind",
87
+ "metadata",
88
+ "relations",
89
+ "spec.owner",
90
+ "spec.type"
91
+ ]
92
+ });
93
+ return response.items.filter((entity) => {
94
+ var _a;
95
+ return !!((_a = entity.metadata.annotations) == null ? void 0 : _a["backstage.io/techdocs-ref"]);
96
+ });
97
+ });
98
+ const currentTabConfig = tabsConfig[selectedTab];
99
+ if (loading) {
100
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Progress, null)));
101
+ }
102
+ if (error) {
103
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(WarningPanel, {
104
+ severity: "error",
105
+ title: "Could not load available documentation."
106
+ }, /* @__PURE__ */ React.createElement(CodeSnippet, {
107
+ language: "text",
108
+ text: error.toString()
109
+ }))));
110
+ }
111
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(HeaderTabs, {
112
+ selectedIndex: selectedTab,
113
+ onChange: (index) => setSelectedTab(index),
114
+ tabs: tabsConfig.map(({ label }, index) => ({
115
+ id: index.toString(),
116
+ label
117
+ }))
118
+ }), /* @__PURE__ */ React.createElement(Content, {
119
+ "data-testid": "techdocs-content"
120
+ }, currentTabConfig.panels.map((config, index) => /* @__PURE__ */ React.createElement(CustomPanel, {
121
+ key: index,
122
+ config,
123
+ entities: !!entities ? entities : [],
124
+ index
125
+ }))));
126
+ };
127
+ function useOwnUser() {
128
+ const catalogApi = useApi(catalogApiRef);
129
+ const identityApi = useApi(identityApiRef);
130
+ return useAsync(async () => {
131
+ const identity = await identityApi.getBackstageIdentity();
132
+ return catalogApi.getEntityByName(parseEntityRef(identity.userEntityRef, {
133
+ defaultKind: "User",
134
+ defaultNamespace: DEFAULT_NAMESPACE
135
+ }));
136
+ }, [catalogApi, identityApi]);
137
+ }
138
+
139
+ export { TechDocsCustomHome };
140
+ //# sourceMappingURL=TechDocsCustomHome-41bd3ef9.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TechDocsCustomHome-41bd3ef9.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 return catalogApi.getEntityByName(\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,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