@backstage/plugin-techdocs 1.12.2-next.1 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,162 +1,25 @@
1
1
  # @backstage/plugin-techdocs
2
2
 
3
- ## 1.12.2-next.1
3
+ ## 1.12.2
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 524f0af: Add missing route ref to the `/alpha` entity content extension.
8
- - 58ec9e7: Removed older versions of React packages as a preparatory step for upgrading to React 19. This commit does not introduce any functional changes, but removes dependencies on previous React versions, allowing for a cleaner upgrade path in subsequent commits.
7
+ - 5f0a446: Add missing route ref to the `/alpha` entity content extension.
9
8
  - Updated dependencies
10
- - @backstage/core-components@0.16.4-next.0
11
- - @backstage/frontend-plugin-api@0.9.5-next.1
12
- - @backstage/integration-react@1.2.4-next.0
13
- - @backstage/core-compat-api@0.3.6-next.1
14
- - @backstage/core-plugin-api@1.10.4-next.0
15
- - @backstage/plugin-techdocs-react@1.2.14-next.0
16
- - @backstage/plugin-catalog-react@1.15.2-next.1
17
- - @backstage/plugin-search-react@1.8.6-next.1
18
- - @backstage/plugin-auth-react@0.1.12-next.0
19
- - @backstage/theme@0.6.4-next.0
20
- - @backstage/catalog-client@1.9.1
21
9
  - @backstage/catalog-model@1.7.3
22
10
  - @backstage/config@1.3.2
23
- - @backstage/errors@1.2.7
24
- - @backstage/integration@1.16.1
25
- - @backstage/plugin-search-common@1.2.17
26
- - @backstage/plugin-techdocs-common@0.1.0
27
-
28
- ## 1.12.2-next.0
29
-
30
- ### Patch Changes
31
-
32
- - f4be934: Changed the base URL in addLinkClickListener from window.location.origin to app.baseUrl for improved path handling. This fixes an issue where Backstage, when running on a subpath, was unable to handle non-Backstage URLs of the same origin correctly.
33
- - 1f40e6b: Add optional props to `TechDocCustomHome` to allow for more flexibility:
34
-
35
- ```tsx
36
- import { TechDocsCustomHome } from '@backstage/plugin-techdocs';
37
- //...
38
-
39
- const options = { emptyRowsWhenPaging: false };
40
- const linkDestination = (entity: Entity): string | undefined => {
41
- return entity.metadata.annotations?.['external-docs'];
42
- };
43
- const techDocsTabsConfig = [
44
- {
45
- label: 'Recommended Documentation',
46
- panels: [
47
- {
48
- title: 'Golden Path',
49
- description: 'Documentation about standards to follow',
50
- panelType: 'DocsCardGrid',
51
- panelProps: { CustomHeader: () => <ContentHeader title='Golden Path'/> },
52
- filterPredicate: entity =>
53
- entity?.metadata?.tags?.includes('golden-path') ?? false,
54
- },
55
- {
56
- title: 'Recommended',
57
- description: 'Useful documentation',
58
- panelType: 'InfoCardGrid',
59
- panelProps: {
60
- CustomHeader: () => <ContentHeader title='Recommended' />
61
- linkDestination: linkDestination,
62
- },
63
- filterPredicate: entity =>
64
- entity?.metadata?.tags?.includes('recommended') ?? false,
65
- },
66
- ],
67
- },
68
- {
69
- label: 'Browse All',
70
- panels: [
71
- {
72
- description: 'Browse all docs',
73
- filterPredicate: filterEntity,
74
- panelType: 'TechDocsIndexPage',
75
- title: 'All',
76
- panelProps: { PageWrapper: React.Fragment, CustomHeader: React.Fragment, options: options },
77
- },
78
- ],
79
- },
80
- ];
81
-
82
- const AppRoutes = () => {
83
- <FlatRoutes>
84
- <Route
85
- path="/docs"
86
- element={
87
- <TechDocsCustomHome
88
- tabsConfig={techDocsTabsConfig}
89
- filter={{
90
- kind: ['Location', 'Resource', 'Component'],
91
- 'metadata.annotations.featured-docs': CATALOG_FILTER_EXISTS,
92
- }}
93
- CustomPageWrapper={({ children }: React.PropsWithChildren<{}>) => (<PageWithHeader title="Docs" themeId="documentation">{children}</PageWithHeader>)}
94
- />
95
- }
96
- />
97
- </FlatRoutes>;
98
- };
99
- ```
100
-
101
- Add new Grid option called `InfoCardGrid` which is a more customizable card option for the Docs grid.
102
-
103
- ```tsx
104
- <InfoCardGrid
105
- entities={entities}
106
- linkContent="Learn more"
107
- linkDestination={entity => entity.metadata['external-docs']}
108
- />
109
- ```
110
-
111
- Expose existing `CustomDocsPanel` so that it can be used independently if desired.
112
-
113
- ```tsx
114
- const panels: PanelConfig[] = [
115
- {
116
- description: '',
117
- filterPredicate: entity => {},
118
- panelType: 'InfoCardGrid',
119
- title: 'Standards',
120
- panelProps: {
121
- CustomHeader: () => <ContentHeader title='Recommended' />
122
- linkDestination: linkDestination,
123
- },
124
- },
125
- {
126
- description: '',
127
- filterPredicate: entity => {},
128
- panelType: 'DocsCardGrid',
129
- title: 'Contribute',
130
- },
131
- ];
132
- {
133
- panels.map((config, index) => (
134
- <CustomDocsPanel
135
- key={index}
136
- config={config}
137
- entities={!!entities ? entities : []}
138
- index={index}
139
- />
140
- ));
141
- }
142
- ```
143
-
144
- - Updated dependencies
145
- - @backstage/plugin-search-react@1.8.6-next.0
146
- - @backstage/frontend-plugin-api@0.9.5-next.0
147
- - @backstage/catalog-client@1.9.1
148
- - @backstage/catalog-model@1.7.3
149
- - @backstage/config@1.3.2
150
- - @backstage/core-compat-api@0.3.6-next.0
11
+ - @backstage/core-compat-api@0.3.5
151
12
  - @backstage/core-components@0.16.3
152
13
  - @backstage/core-plugin-api@1.10.3
153
14
  - @backstage/errors@1.2.7
15
+ - @backstage/frontend-plugin-api@0.9.4
154
16
  - @backstage/integration@1.16.1
155
17
  - @backstage/integration-react@1.2.3
156
18
  - @backstage/theme@0.6.3
157
19
  - @backstage/plugin-auth-react@0.1.11
158
- - @backstage/plugin-catalog-react@1.15.2-next.0
20
+ - @backstage/plugin-catalog-react@1.15.1
159
21
  - @backstage/plugin-search-common@1.2.17
22
+ - @backstage/plugin-search-react@1.8.5
160
23
  - @backstage/plugin-techdocs-common@0.1.0
161
24
  - @backstage/plugin-techdocs-react@1.2.13
162
25
 
@@ -12,21 +12,9 @@ const DefaultTechDocsHome = (props) => {
12
12
  columns,
13
13
  actions,
14
14
  ownerPickerMode,
15
- pagination,
16
- options,
17
- PageWrapper,
18
- CustomHeader
15
+ pagination
19
16
  } = props;
20
- const Wrapper = PageWrapper ? PageWrapper : TechDocsPageWrapper;
21
- const Header = CustomHeader || (() => /* @__PURE__ */ React.createElement(ContentHeader, { title: "" }, /* @__PURE__ */ React.createElement(SupportButton, null, "Discover documentation in your ecosystem.")));
22
- return /* @__PURE__ */ React.createElement(Wrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Header, null), /* @__PURE__ */ React.createElement(EntityListProvider, { pagination }, /* @__PURE__ */ React.createElement(CatalogFilterLayout, null, /* @__PURE__ */ React.createElement(CatalogFilterLayout.Filters, null, /* @__PURE__ */ React.createElement(TechDocsPicker, null), /* @__PURE__ */ React.createElement(UserListPicker, { initialFilter }), /* @__PURE__ */ React.createElement(EntityOwnerPicker, { mode: ownerPickerMode }), /* @__PURE__ */ React.createElement(EntityTagPicker, null)), /* @__PURE__ */ React.createElement(CatalogFilterLayout.Content, null, /* @__PURE__ */ React.createElement(
23
- EntityListDocsTable,
24
- {
25
- actions,
26
- columns,
27
- options
28
- }
29
- ))))));
17
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(ContentHeader, { title: "" }, /* @__PURE__ */ React.createElement(SupportButton, null, "Discover documentation in your ecosystem.")), /* @__PURE__ */ React.createElement(EntityListProvider, { pagination }, /* @__PURE__ */ React.createElement(CatalogFilterLayout, null, /* @__PURE__ */ React.createElement(CatalogFilterLayout.Filters, null, /* @__PURE__ */ React.createElement(TechDocsPicker, null), /* @__PURE__ */ React.createElement(UserListPicker, { initialFilter }), /* @__PURE__ */ React.createElement(EntityOwnerPicker, { mode: ownerPickerMode }), /* @__PURE__ */ React.createElement(EntityTagPicker, null)), /* @__PURE__ */ React.createElement(CatalogFilterLayout.Content, null, /* @__PURE__ */ React.createElement(EntityListDocsTable, { actions, columns }))))));
30
18
  };
31
19
 
32
20
  export { DefaultTechDocsHome };
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultTechDocsHome.esm.js","sources":["../../../src/home/components/DefaultTechDocsHome.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 from 'react';\nimport {\n Content,\n ContentHeader,\n SupportButton,\n} from '@backstage/core-components';\nimport {\n CatalogFilterLayout,\n EntityListProvider,\n EntityOwnerPicker,\n EntityTagPicker,\n UserListPicker,\n} from '@backstage/plugin-catalog-react';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\nimport { TechDocsPicker } from './TechDocsPicker';\nimport { EntityListDocsTable } from './Tables';\nimport { TechDocsIndexPageProps } from './TechDocsIndexPage';\n\n/**\n * Props for {@link DefaultTechDocsHome}\n *\n * @public\n * @deprecated Please use `TechDocsIndexPageProps` instead.\n */\nexport type DefaultTechDocsHomeProps = TechDocsIndexPageProps;\n\n/**\n * Component which renders a default documentation landing page.\n *\n * @public\n */\nexport const DefaultTechDocsHome = (props: TechDocsIndexPageProps) => {\n const {\n initialFilter = 'owned',\n columns,\n actions,\n ownerPickerMode,\n pagination,\n options,\n PageWrapper,\n CustomHeader,\n } = props;\n const Wrapper: React.FC<{\n children: React.ReactNode;\n }> = PageWrapper ? PageWrapper : TechDocsPageWrapper;\n const Header: React.FC =\n CustomHeader ||\n (() => (\n <ContentHeader title=\"\">\n <SupportButton>Discover documentation in your ecosystem.</SupportButton>\n </ContentHeader>\n ));\n return (\n <Wrapper>\n <Content>\n <Header />\n <EntityListProvider pagination={pagination}>\n <CatalogFilterLayout>\n <CatalogFilterLayout.Filters>\n <TechDocsPicker />\n <UserListPicker initialFilter={initialFilter} />\n <EntityOwnerPicker mode={ownerPickerMode} />\n <EntityTagPicker />\n </CatalogFilterLayout.Filters>\n <CatalogFilterLayout.Content>\n <EntityListDocsTable\n actions={actions}\n columns={columns}\n options={options}\n />\n </CatalogFilterLayout.Content>\n </CatalogFilterLayout>\n </EntityListProvider>\n </Content>\n </Wrapper>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA+Ca,MAAA,mBAAA,GAAsB,CAAC,KAAkC,KAAA;AACpE,EAAM,MAAA;AAAA,IACJ,aAAgB,GAAA,OAAA;AAAA,IAChB,OAAA;AAAA,IACA,OAAA;AAAA,IACA,eAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EAAM,MAAA,OAAA,GAED,cAAc,WAAc,GAAA,mBAAA;AACjC,EAAM,MAAA,MAAA,GACJ,YACC,KAAA,sBACE,KAAA,CAAA,aAAA,CAAA,aAAA,EAAA,EAAc,OAAM,EACnB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,IAAA,EAAA,2CAAyC,CAC1D,CAAA,CAAA;AAEJ,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA,sCACE,MAAO,EAAA,IAAA,CAAA,kBACP,KAAA,CAAA,aAAA,CAAA,kBAAA,EAAA,EAAmB,8BACjB,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA,IAAA,kBACE,KAAA,CAAA,aAAA,CAAA,mBAAA,CAAoB,SAApB,IACC,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,IAAA,CAAA,sCACf,cAAe,EAAA,EAAA,aAAA,EAA8B,CAC9C,kBAAA,KAAA,CAAA,aAAA,CAAC,qBAAkB,IAAM,EAAA,eAAA,EAAiB,CAC1C,kBAAA,KAAA,CAAA,aAAA,CAAC,qBAAgB,CACnB,CAAA,kBACC,KAAA,CAAA,aAAA,CAAA,mBAAA,CAAoB,SAApB,IACC,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,mBAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,OAAA;AAAA,MACA;AAAA;AAAA,GAEJ,CACF,CACF,CACF,CACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"DefaultTechDocsHome.esm.js","sources":["../../../src/home/components/DefaultTechDocsHome.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 from 'react';\nimport {\n Content,\n ContentHeader,\n SupportButton,\n} from '@backstage/core-components';\nimport {\n CatalogFilterLayout,\n EntityListProvider,\n EntityOwnerPicker,\n EntityTagPicker,\n UserListPicker,\n} from '@backstage/plugin-catalog-react';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\nimport { TechDocsPicker } from './TechDocsPicker';\nimport { EntityListDocsTable } from './Tables';\nimport { TechDocsIndexPageProps } from './TechDocsIndexPage';\n\n/**\n * Props for {@link DefaultTechDocsHome}\n *\n * @public\n * @deprecated Please use `TechDocsIndexPageProps` instead.\n */\nexport type DefaultTechDocsHomeProps = TechDocsIndexPageProps;\n\n/**\n * Component which renders a default documentation landing page.\n *\n * @public\n */\nexport const DefaultTechDocsHome = (props: TechDocsIndexPageProps) => {\n const {\n initialFilter = 'owned',\n columns,\n actions,\n ownerPickerMode,\n pagination,\n } = props;\n return (\n <TechDocsPageWrapper>\n <Content>\n <ContentHeader title=\"\">\n <SupportButton>\n Discover documentation in your ecosystem.\n </SupportButton>\n </ContentHeader>\n <EntityListProvider pagination={pagination}>\n <CatalogFilterLayout>\n <CatalogFilterLayout.Filters>\n <TechDocsPicker />\n <UserListPicker initialFilter={initialFilter} />\n <EntityOwnerPicker mode={ownerPickerMode} />\n <EntityTagPicker />\n </CatalogFilterLayout.Filters>\n <CatalogFilterLayout.Content>\n <EntityListDocsTable actions={actions} columns={columns} />\n </CatalogFilterLayout.Content>\n </CatalogFilterLayout>\n </EntityListProvider>\n </Content>\n </TechDocsPageWrapper>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA+Ca,MAAA,mBAAA,GAAsB,CAAC,KAAkC,KAAA;AACpE,EAAM,MAAA;AAAA,IACJ,aAAgB,GAAA,OAAA;AAAA,IAChB,OAAA;AAAA,IACA,OAAA;AAAA,IACA,eAAA;AAAA,IACA;AAAA,GACE,GAAA,KAAA;AACJ,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,2CACE,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,IAAA,sCACE,aAAc,EAAA,EAAA,KAAA,EAAM,EACnB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,IAAA,EAAA,2CAEf,CACF,CACA,kBAAA,KAAA,CAAA,aAAA,CAAC,kBAAmB,EAAA,EAAA,UAAA,EAAA,kBACjB,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA,IAAA,sCACE,mBAAoB,CAAA,OAAA,EAApB,IACC,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,IAAA,CAAA,sCACf,cAAe,EAAA,EAAA,aAAA,EAA8B,mBAC7C,KAAA,CAAA,aAAA,CAAA,iBAAA,EAAA,EAAkB,MAAM,eAAiB,EAAA,CAAA,kBACzC,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,IAAgB,CACnB,CAAA,sCACC,mBAAoB,CAAA,OAAA,EAApB,IACC,kBAAA,KAAA,CAAA,aAAA,CAAC,mBAAoB,EAAA,EAAA,OAAA,EAAkB,SAAkB,CAC3D,CACF,CACF,CACF,CACF,CAAA;AAEJ;;;;"}
@@ -1,25 +1,21 @@
1
1
  import React, { useState } from 'react';
2
2
  import useAsync from 'react-use/esm/useAsync';
3
3
  import { makeStyles } from '@material-ui/core/styles';
4
- import { useEntityOwnership, EntityListProvider, catalogApiRef, CATALOG_FILTER_EXISTS } from '@backstage/plugin-catalog-react';
4
+ import { catalogApiRef, CATALOG_FILTER_EXISTS, useEntityOwnership, EntityListProvider } from '@backstage/plugin-catalog-react';
5
5
  import './Tables/EntityListDocsTable.esm.js';
6
6
  import { DocsTable } from './Tables/DocsTable.esm.js';
7
7
  import { DocsCardGrid } from './Grids/DocsCardGrid.esm.js';
8
- import { ContentHeader, SupportButton, Content, Progress, WarningPanel, CodeSnippet, HeaderTabs } from '@backstage/core-components';
8
+ import { Content, Progress, WarningPanel, CodeSnippet, HeaderTabs, ContentHeader, SupportButton } from '@backstage/core-components';
9
9
  import '@material-ui/core/Typography';
10
- import { InfoCardGrid } from './Grids/InfoCardGrid.esm.js';
11
10
  import { TechDocsPageWrapper } from './TechDocsPageWrapper.esm.js';
12
- import { TechDocsIndexPage } from './TechDocsIndexPage.esm.js';
13
11
  import { useApi } from '@backstage/core-plugin-api';
14
12
  import { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common';
15
13
 
16
14
  const panels = {
17
15
  DocsTable,
18
- DocsCardGrid,
19
- TechDocsIndexPage,
20
- InfoCardGrid
16
+ DocsCardGrid
21
17
  };
22
- const CustomDocsPanel = ({
18
+ const CustomPanel = ({
23
19
  config,
24
20
  entities,
25
21
  index
@@ -42,18 +38,10 @@ const CustomDocsPanel = ({
42
38
  }
43
39
  return typeof config.filterPredicate === "function" && config.filterPredicate(entity);
44
40
  });
45
- const Header = config.panelProps?.CustomHeader || (() => /* @__PURE__ */ React.createElement(ContentHeader, { title: config.title, description: config.description }, index === 0 ? /* @__PURE__ */ React.createElement(SupportButton, null, "Discover documentation in your ecosystem.") : null));
46
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Header, null), /* @__PURE__ */ React.createElement("div", { className: classes.panelContainer }, /* @__PURE__ */ React.createElement(EntityListProvider, null, /* @__PURE__ */ React.createElement(
47
- Panel,
48
- {
49
- "data-testid": "techdocs-custom-panel",
50
- entities: shownEntities,
51
- ...config.panelProps
52
- }
53
- ))));
41
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ContentHeader, { title: config.title, description: config.description }, index === 0 ? /* @__PURE__ */ React.createElement(SupportButton, null, "Discover documentation in your ecosystem.") : null), /* @__PURE__ */ React.createElement("div", { className: classes.panelContainer }, /* @__PURE__ */ React.createElement(EntityListProvider, null, /* @__PURE__ */ React.createElement(Panel, { "data-testid": "techdocs-custom-panel", entities: shownEntities }))));
54
42
  };
55
43
  const TechDocsCustomHome = (props) => {
56
- const { tabsConfig, filter, CustomPageWrapper } = props;
44
+ const { tabsConfig } = props;
57
45
  const [selectedTab, setSelectedTab] = useState(0);
58
46
  const catalogApi = useApi(catalogApiRef);
59
47
  const {
@@ -63,7 +51,6 @@ const TechDocsCustomHome = (props) => {
63
51
  } = useAsync(async () => {
64
52
  const response = await catalogApi.getEntities({
65
53
  filter: {
66
- ...filter,
67
54
  [`metadata.annotations.${TECHDOCS_ANNOTATION}`]: CATALOG_FILTER_EXISTS
68
55
  },
69
56
  fields: [
@@ -81,10 +68,10 @@ const TechDocsCustomHome = (props) => {
81
68
  });
82
69
  const currentTabConfig = tabsConfig[selectedTab];
83
70
  if (loading) {
84
- return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, { CustomPageWrapper }, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Progress, null)));
71
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(Progress, null)));
85
72
  }
86
73
  if (error) {
87
- return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, { CustomPageWrapper }, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(
74
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(
88
75
  WarningPanel,
89
76
  {
90
77
  severity: "error",
@@ -93,7 +80,7 @@ const TechDocsCustomHome = (props) => {
93
80
  /* @__PURE__ */ React.createElement(CodeSnippet, { language: "text", text: error.toString() })
94
81
  )));
95
82
  }
96
- return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, { CustomPageWrapper }, /* @__PURE__ */ React.createElement(
83
+ return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(
97
84
  HeaderTabs,
98
85
  {
99
86
  selectedIndex: selectedTab,
@@ -104,7 +91,7 @@ const TechDocsCustomHome = (props) => {
104
91
  }))
105
92
  }
106
93
  ), /* @__PURE__ */ React.createElement(Content, { "data-testid": "techdocs-content" }, currentTabConfig.panels.map((config, index) => /* @__PURE__ */ React.createElement(
107
- CustomDocsPanel,
94
+ CustomPanel,
108
95
  {
109
96
  key: index,
110
97
  config,
@@ -114,5 +101,5 @@ const TechDocsCustomHome = (props) => {
114
101
  ))));
115
102
  };
116
103
 
117
- export { CustomDocsPanel, TechDocsCustomHome };
104
+ export { TechDocsCustomHome };
118
105
  //# sourceMappingURL=TechDocsCustomHome.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TechDocsCustomHome.esm.js","sources":["../../../src/home/components/TechDocsCustomHome.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { CSSProperties } from '@material-ui/styles/withStyles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n useEntityOwnership,\n EntityListProvider,\n} from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { DocsTable, DocsTableRow } from './Tables';\nimport { DocsCardGrid, InfoCardGrid } from './Grids';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\nimport { TechDocsIndexPage } from './TechDocsIndexPage';\n\nimport {\n CodeSnippet,\n Content,\n HeaderTabs,\n Progress,\n WarningPanel,\n SupportButton,\n ContentHeader,\n TableOptions,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common';\nimport { EntityFilterQuery } from '@backstage/catalog-client';\n\nconst panels = {\n DocsTable: DocsTable,\n DocsCardGrid: DocsCardGrid,\n TechDocsIndexPage: TechDocsIndexPage,\n InfoCardGrid: InfoCardGrid,\n};\n\n/**\n * Available panel types\n *\n * @public\n */\nexport type PanelType =\n | 'DocsCardGrid'\n | 'DocsTable'\n | 'TechDocsIndexPage'\n | 'InfoCardGrid';\n\n/**\n * Type representing Panel props\n *\n * @public\n */\nexport interface PanelProps {\n options?: TableOptions<DocsTableRow>;\n linkContent?: string | JSX.Element;\n linkDestination?: (entity: Entity) => string | undefined;\n PageWrapper?: React.FC;\n CustomHeader?: React.FC;\n}\n\n/**\n * Type representing a TechDocsCustomHome panel.\n *\n * @public\n */\nexport interface PanelConfig {\n title: string;\n description: string;\n panelType: PanelType;\n panelCSS?: CSSProperties;\n filterPredicate: ((entity: Entity) => boolean) | string;\n panelProps?: PanelProps;\n}\n\n/**\n * Type representing a TechDocsCustomHome tab.\n *\n * @public\n */\nexport interface TabConfig {\n label: string;\n panels: PanelConfig[];\n}\n\n/**\n * Type representing a list of TechDocsCustomHome tabs.\n *\n * @public\n */\nexport type TabsConfig = TabConfig[];\n\n/**\n * Component which can be used to render entities in a custom way.\n *\n * @public\n */\nexport const CustomDocsPanel = ({\n config,\n entities,\n index,\n}: {\n config: PanelConfig;\n entities: Entity[];\n index: number;\n}) => {\n const useStyles = makeStyles({\n panelContainer: {\n marginBottom: '2rem',\n ...(config.panelCSS ? config.panelCSS : {}),\n },\n });\n const classes = useStyles();\n const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();\n\n const Panel = panels[config.panelType];\n\n const shownEntities = entities.filter(entity => {\n if (config.filterPredicate === 'ownedByUser') {\n if (loadingOwnership) {\n return false;\n }\n return isOwnedEntity(entity);\n }\n\n return (\n typeof config.filterPredicate === 'function' &&\n config.filterPredicate(entity)\n );\n });\n\n const Header: React.FC =\n config.panelProps?.CustomHeader ||\n (() => (\n <ContentHeader title={config.title} description={config.description}>\n {index === 0 ? (\n <SupportButton>\n Discover documentation in your ecosystem.\n </SupportButton>\n ) : null}\n </ContentHeader>\n ));\n\n return (\n <>\n <Header />\n <div className={classes.panelContainer}>\n <EntityListProvider>\n <Panel\n data-testid=\"techdocs-custom-panel\"\n entities={shownEntities}\n {...config.panelProps}\n />\n </EntityListProvider>\n </div>\n </>\n );\n};\n\n/**\n * Props for {@link TechDocsCustomHome}\n *\n * @public\n */\nexport type TechDocsCustomHomeProps = {\n tabsConfig: TabsConfig;\n filter?: EntityFilterQuery;\n CustomPageWrapper?: React.FC;\n};\n\nexport const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {\n const { tabsConfig, filter, CustomPageWrapper } = props;\n const [selectedTab, setSelectedTab] = useState<number>(0);\n const catalogApi: CatalogApi = useApi(catalogApiRef);\n\n const {\n value: entities,\n loading,\n error,\n } = useAsync(async () => {\n const response = await catalogApi.getEntities({\n filter: {\n ...filter,\n [`metadata.annotations.${TECHDOCS_ANNOTATION}`]: CATALOG_FILTER_EXISTS,\n },\n fields: [\n 'apiVersion',\n 'kind',\n 'metadata',\n 'relations',\n 'spec.owner',\n 'spec.type',\n ],\n });\n return response.items.filter((entity: Entity) => {\n return !!entity.metadata.annotations?.[TECHDOCS_ANNOTATION];\n });\n });\n\n const currentTabConfig = tabsConfig[selectedTab];\n\n if (loading) {\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <Content>\n <Progress />\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n if (error) {\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <Content>\n <WarningPanel\n severity=\"error\"\n title=\"Could not load available documentation.\"\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n return (\n <TechDocsPageWrapper CustomPageWrapper={CustomPageWrapper}>\n <HeaderTabs\n selectedIndex={selectedTab}\n onChange={index => setSelectedTab(index)}\n tabs={tabsConfig.map(({ label }, index) => ({\n id: index.toString(),\n label,\n }))}\n />\n <Content data-testid=\"techdocs-content\">\n {currentTabConfig.panels.map((config, index) => (\n <CustomDocsPanel\n key={index}\n config={config}\n entities={!!entities ? entities : []}\n index={index}\n />\n ))}\n </Content>\n </TechDocsPageWrapper>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA+CA,MAAM,MAAS,GAAA;AAAA,EACb,SAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA;AACF,CAAA;AA8DO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,MAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,YAAY,UAAW,CAAA;AAAA,IAC3B,cAAgB,EAAA;AAAA,MACd,YAAc,EAAA,MAAA;AAAA,MACd,GAAI,MAAA,CAAO,QAAW,GAAA,MAAA,CAAO,WAAW;AAAC;AAC3C,GACD,CAAA;AACD,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAkB,EAAA,aAAA,KAAkB,kBAAmB,EA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CAEL,WAAY,EAAA,EAAA,QAAA,EAAS,QAAO,IAAM,EAAA,KAAA,CAAM,UAAY,EAAA;AAAA,KAEzD,CACF,CAAA;AAAA;AAIJ,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,uBAAoB,iBACnB,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,aAAe,EAAA,WAAA;AAAA,MACf,QAAA,EAAU,CAAS,KAAA,KAAA,cAAA,CAAe,KAAK,CAAA;AAAA,MACvC,MAAM,UAAW,CAAA,GAAA,CAAI,CAAC,EAAE,KAAA,IAAS,KAAW,MAAA;AAAA,QAC1C,EAAA,EAAI,MAAM,QAAS,EAAA;AAAA,QACnB;AAAA,OACA,CAAA;AAAA;AAAA,GACJ,kBACC,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,aAAY,EAAA,kBAAA,EAAA,EAClB,iBAAiB,MAAO,CAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,KACpC,qBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,eAAA;AAAA,IAAA;AAAA,MACC,GAAK,EAAA,KAAA;AAAA,MACL,MAAA;AAAA,MACA,QAAU,EAAA,CAAC,CAAC,QAAA,GAAW,WAAW,EAAC;AAAA,MACnC;AAAA;AAAA,GAEH,CACH,CACF,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"TechDocsCustomHome.esm.js","sources":["../../../src/home/components/TechDocsCustomHome.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { CSSProperties } from '@material-ui/styles/withStyles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n useEntityOwnership,\n EntityListProvider,\n} from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { DocsTable } 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';\nimport { TECHDOCS_ANNOTATION } from '@backstage/plugin-techdocs-common';\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 <EntityListProvider>\n <Panel data-testid=\"techdocs-custom-panel\" entities={shownEntities} />\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};\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.${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>\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":";;;;;;;;;;;;;AA4CA,MAAM,MAAS,GAAA;AAAA,EACb,SAAA;AAAA,EACA;AACF,CAAA;AAuCA,MAAM,cAAc,CAAC;AAAA,EACnB,MAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAIM,KAAA;AACJ,EAAA,MAAM,YAAY,UAAW,CAAA;AAAA,IAC3B,cAAgB,EAAA;AAAA,MACd,YAAc,EAAA,MAAA;AAAA,MACd,GAAI,MAAA,CAAO,QAAW,GAAA,MAAA,CAAO,WAAW;AAAC;AAC3C,GACD,CAAA;AACD,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAA,MAAM,EAAE,OAAA,EAAS,gBAAkB,EAAA,aAAA,KAAkB,kBAAmB,EAAA;AAExE,EAAM,MAAA,KAAA,GAAQ,MAAO,CAAA,MAAA,CAAO,SAAS,CAAA;AAErC,EAAM,MAAA,aAAA,GAAgB,QAAS,CAAA,MAAA,CAAO,CAAU,MAAA,KAAA;AAC9C,IAAI,IAAA,MAAA,CAAO,oBAAoB,aAAe,EAAA;AAC5C,MAAA,IAAI,gBAAkB,EAAA;AACpB,QAAO,OAAA,KAAA;AAAA;AAET,MAAA,OAAO,cAAc,MAAM,CAAA;AAAA;AAG7B,IAAA,OACE,OAAO,MAAO,CAAA,eAAA,KAAoB,UAClC,IAAA,MAAA,CAAO,gBAAgB,MAAM,CAAA;AAAA,GAEhC,CAAA;AAED,EAAA,uBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,KAAA,EAAO,OAAO,KAAO,EAAA,WAAA,EAAa,MAAO,CAAA,WAAA,EAAA,EACrD,KAAU,KAAA,CAAA,mBACR,KAAA,CAAA,aAAA,CAAA,aAAA,E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TechDocsIndexPage.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 from 'react';\nimport { useOutlet } from 'react-router-dom';\nimport {\n TableColumn,\n TableProps,\n TableOptions,\n} from '@backstage/core-components';\nimport {\n EntityListPagination,\n EntityOwnerPickerProps,\n UserListFilterKind,\n} from '@backstage/plugin-catalog-react';\nimport { DefaultTechDocsHome } from './DefaultTechDocsHome';\nimport { DocsTableRow } from './Tables';\n\n/**\n * Props for {@link TechDocsIndexPage}\n *\n * @public\n */\nexport type TechDocsIndexPageProps = {\n initialFilter?: UserListFilterKind;\n columns?: TableColumn<DocsTableRow>[];\n actions?: TableProps<DocsTableRow>['actions'];\n ownerPickerMode?: EntityOwnerPickerProps['mode'];\n pagination?: EntityListPagination;\n options?: TableOptions<DocsTableRow>;\n PageWrapper?: React.FC;\n CustomHeader?: React.FC;\n};\n\nexport const TechDocsIndexPage = (props: TechDocsIndexPageProps) => {\n const outlet = useOutlet();\n\n return outlet || <DefaultTechDocsHome {...props} />;\n};\n"],"names":[],"mappings":";;;;AA+Ca,MAAA,iBAAA,GAAoB,CAAC,KAAkC,KAAA;AAClE,EAAA,MAAM,SAAS,SAAU,EAAA;AAEzB,EAAA,OAAO,MAAU,oBAAA,KAAA,CAAA,aAAA,CAAC,mBAAqB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA;AACnD;;;;"}
1
+ {"version":3,"file":"TechDocsIndexPage.esm.js","sources":["../../../src/home/components/TechDocsIndexPage.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 from 'react';\nimport { useOutlet } from 'react-router-dom';\nimport { TableColumn, TableProps } from '@backstage/core-components';\nimport {\n EntityListPagination,\n EntityOwnerPickerProps,\n UserListFilterKind,\n} from '@backstage/plugin-catalog-react';\nimport { DefaultTechDocsHome } from './DefaultTechDocsHome';\nimport { DocsTableRow } from './Tables';\n\n/**\n * Props for {@link TechDocsIndexPage}\n *\n * @public\n */\nexport type TechDocsIndexPageProps = {\n initialFilter?: UserListFilterKind;\n columns?: TableColumn<DocsTableRow>[];\n actions?: TableProps<DocsTableRow>['actions'];\n ownerPickerMode?: EntityOwnerPickerProps['mode'];\n pagination?: EntityListPagination;\n};\n\nexport const TechDocsIndexPage = (props: TechDocsIndexPageProps) => {\n const outlet = useOutlet();\n\n return outlet || <DefaultTechDocsHome {...props} />;\n};\n"],"names":[],"mappings":";;;;AAwCa,MAAA,iBAAA,GAAoB,CAAC,KAAkC,KAAA;AAClE,EAAA,MAAM,SAAS,SAAU,EAAA;AAEzB,EAAA,OAAO,MAAU,oBAAA,KAAA,CAAA,aAAA,CAAC,mBAAqB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA;AACnD;;;;"}
@@ -3,10 +3,10 @@ import { PageWithHeader } from '@backstage/core-components';
3
3
  import { useApi, configApiRef } from '@backstage/core-plugin-api';
4
4
 
5
5
  const TechDocsPageWrapper = (props) => {
6
- const { children, CustomPageWrapper } = props;
6
+ const { children } = props;
7
7
  const configApi = useApi(configApiRef);
8
8
  const generatedSubtitle = `Documentation available in ${configApi.getOptionalString("organization.name") ?? "Backstage"}`;
9
- return /* @__PURE__ */ React.createElement(React.Fragment, null, CustomPageWrapper ? /* @__PURE__ */ React.createElement(CustomPageWrapper, null, children) : /* @__PURE__ */ React.createElement(
9
+ return /* @__PURE__ */ React.createElement(
10
10
  PageWithHeader,
11
11
  {
12
12
  title: "Documentation",
@@ -14,7 +14,7 @@ const TechDocsPageWrapper = (props) => {
14
14
  themeId: "documentation"
15
15
  },
16
16
  children
17
- ));
17
+ );
18
18
  };
19
19
 
20
20
  export { TechDocsPageWrapper };
@@ -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 React 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?: React.ReactNode;\n CustomPageWrapper?: React.FC<{ children?: React.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 generatedSubtitle = `Documentation available in ${\n configApi.getOptionalString('organization.name') ?? 'Backstage'\n }`;\n\n return (\n <>\n {CustomPageWrapper ? (\n <CustomPageWrapper>{children}</CustomPageWrapper>\n ) : (\n <PageWithHeader\n title=\"Documentation\"\n subtitle={generatedSubtitle}\n themeId=\"documentation\"\n >\n {children}\n </PageWithHeader>\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;AAoCa,MAAA,mBAAA,GAAsB,CAAC,KAAoC,KAAA;AACtE,EAAM,MAAA,EAAE,QAAU,EAAA,iBAAA,EAAsB,GAAA,KAAA;AACxC,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAA,MAAM,oBAAoB,CACxB,2BAAA,EAAA,SAAA,CAAU,iBAAkB,CAAA,mBAAmB,KAAK,WACtD,CAAA,CAAA;AAEA,EAAA,uBAEK,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAA,iBAAA,mBACE,KAAA,CAAA,aAAA,CAAA,iBAAA,EAAA,IAAA,EAAmB,QAAS,CAE7B,mBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,KAAM,EAAA,eAAA;AAAA,MACN,QAAU,EAAA,iBAAA;AAAA,MACV,OAAQ,EAAA;AAAA,KAAA;AAAA,IAEP;AAAA,GAGP,CAAA;AAEJ;;;;"}
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 React 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?: React.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 } = props;\n const configApi = useApi(configApiRef);\n const generatedSubtitle = `Documentation available in ${\n configApi.getOptionalString('organization.name') ?? 'Backstage'\n }`;\n\n return (\n <PageWithHeader\n title=\"Documentation\"\n subtitle={generatedSubtitle}\n themeId=\"documentation\"\n >\n {children}\n </PageWithHeader>\n );\n};\n"],"names":[],"mappings":";;;;AAmCa,MAAA,mBAAA,GAAsB,CAAC,KAAoC,KAAA;AACtE,EAAM,MAAA,EAAE,UAAa,GAAA,KAAA;AACrB,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAA,MAAM,oBAAoB,CACxB,2BAAA,EAAA,SAAA,CAAU,iBAAkB,CAAA,mBAAmB,KAAK,WACtD,CAAA,CAAA;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,cAAA;AAAA,IAAA;AAAA,MACC,KAAM,EAAA,eAAA;AAAA,MACN,QAAU,EAAA,iBAAA;AAAA,MACV,OAAQ,EAAA;AAAA,KAAA;AAAA,IAEP;AAAA,GACH;AAEJ;;;;"}
package/dist/index.d.ts CHANGED
@@ -11,11 +11,8 @@ import { ToolbarProps } from '@material-ui/core/Toolbar';
11
11
  import { TableColumn, TableProps, TableOptions } from '@backstage/core-components';
12
12
  import { UserListFilterKind, EntityOwnerPickerProps, EntityListPagination } from '@backstage/plugin-catalog-react';
13
13
  import { CSSProperties } from '@material-ui/styles/withStyles';
14
- import { EntityFilterQuery } from '@backstage/catalog-client';
15
14
  import { SearchResultListItemExtensionProps } from '@backstage/plugin-search-react';
16
15
  import { ResultHighlight } from '@backstage/plugin-search-common';
17
- import { Overrides } from '@material-ui/core/styles/overrides';
18
- import { StyleRules } from '@material-ui/core/styles/withStyles';
19
16
 
20
17
  /**
21
18
  * Helper function that gives the children of {@link TechDocsReaderPage} access to techdocs and entity metadata
@@ -356,25 +353,6 @@ type DocsCardGridProps = {
356
353
  */
357
354
  declare const DocsCardGrid: (props: DocsCardGridProps) => React__default.JSX.Element | null;
358
355
 
359
- /** @public */
360
- type InfoCardGridClassKey = 'linkSpacer' | 'readMoreLink';
361
- /**
362
- * Props for {@link InfoCardGrid}
363
- *
364
- * @public
365
- */
366
- type InfoCardGridProps = {
367
- entities: Entity[] | undefined;
368
- linkContent?: string | JSX.Element;
369
- linkDestination?: (entity: Entity) => string | undefined;
370
- };
371
- /**
372
- * Component which accepts a list of entities and renders a info card for each entity
373
- *
374
- * @public
375
- */
376
- declare const InfoCardGrid: (props: InfoCardGridProps) => React__default.JSX.Element | null;
377
-
378
356
  /**
379
357
  * Generic representing the metadata structure for a docs table row.
380
358
  *
@@ -489,9 +467,6 @@ type TechDocsIndexPageProps = {
489
467
  actions?: TableProps<DocsTableRow>['actions'];
490
468
  ownerPickerMode?: EntityOwnerPickerProps['mode'];
491
469
  pagination?: EntityListPagination;
492
- options?: TableOptions<DocsTableRow>;
493
- PageWrapper?: React__default.FC;
494
- CustomHeader?: React__default.FC;
495
470
  };
496
471
 
497
472
  /**
@@ -513,19 +488,7 @@ declare const DefaultTechDocsHome: (props: TechDocsIndexPageProps) => React__def
513
488
  *
514
489
  * @public
515
490
  */
516
- type PanelType = 'DocsCardGrid' | 'DocsTable' | 'TechDocsIndexPage' | 'InfoCardGrid';
517
- /**
518
- * Type representing Panel props
519
- *
520
- * @public
521
- */
522
- interface PanelProps {
523
- options?: TableOptions<DocsTableRow>;
524
- linkContent?: string | JSX.Element;
525
- linkDestination?: (entity: Entity) => string | undefined;
526
- PageWrapper?: React__default.FC;
527
- CustomHeader?: React__default.FC;
528
- }
491
+ type PanelType = 'DocsCardGrid' | 'DocsTable';
529
492
  /**
530
493
  * Type representing a TechDocsCustomHome panel.
531
494
  *
@@ -537,7 +500,6 @@ interface PanelConfig {
537
500
  panelType: PanelType;
538
501
  panelCSS?: CSSProperties;
539
502
  filterPredicate: ((entity: Entity) => boolean) | string;
540
- panelProps?: PanelProps;
541
503
  }
542
504
  /**
543
505
  * Type representing a TechDocsCustomHome tab.
@@ -554,16 +516,6 @@ interface TabConfig {
554
516
  * @public
555
517
  */
556
518
  type TabsConfig = TabConfig[];
557
- /**
558
- * Component which can be used to render entities in a custom way.
559
- *
560
- * @public
561
- */
562
- declare const CustomDocsPanel: ({ config, entities, index, }: {
563
- config: PanelConfig;
564
- entities: Entity[];
565
- index: number;
566
- }) => React__default.JSX.Element;
567
519
  /**
568
520
  * Props for {@link TechDocsCustomHome}
569
521
  *
@@ -571,8 +523,6 @@ declare const CustomDocsPanel: ({ config, entities, index, }: {
571
523
  */
572
524
  type TechDocsCustomHomeProps = {
573
525
  tabsConfig: TabsConfig;
574
- filter?: EntityFilterQuery;
575
- CustomPageWrapper?: React__default.FC;
576
526
  };
577
527
 
578
528
  /**
@@ -582,9 +532,6 @@ type TechDocsCustomHomeProps = {
582
532
  */
583
533
  type TechDocsPageWrapperProps = {
584
534
  children?: React__default.ReactNode;
585
- CustomPageWrapper?: React__default.FC<{
586
- children?: React__default.ReactNode;
587
- }>;
588
535
  };
589
536
  /**
590
537
  * Component wrapping a TechDocs page with Page and Header components
@@ -690,19 +637,6 @@ declare const LegacyEmbeddedDocsRouter: ({ children, withSearch, }: React__defau
690
637
  withSearch?: boolean | undefined;
691
638
  }>) => React__default.JSX.Element;
692
639
 
693
- /** @public */
694
- type CatalogReactComponentsNameToClassKey = {
695
- BackstageInfoCardGrid: InfoCardGridClassKey;
696
- };
697
- /** @public */
698
- type BackstageOverrides = Overrides & {
699
- [Name in keyof CatalogReactComponentsNameToClassKey]?: Partial<StyleRules<CatalogReactComponentsNameToClassKey[Name]>>;
700
- };
701
- declare module '@backstage/theme' {
702
- interface OverrideComponentNameToClassKeys extends CatalogReactComponentsNameToClassKey {
703
- }
704
- }
705
-
706
640
  /**
707
641
  * The Backstage plugin that renders technical documentation for your components
708
642
  *
@@ -722,4 +656,4 @@ type DeprecatedTechDocsMetadata = TechDocsMetadata;
722
656
  */
723
657
  type DeprecatedTechDocsEntityMetadata = TechDocsEntityMetadata;
724
658
 
725
- export { type BackstageOverrides, type CatalogReactComponentsNameToClassKey, type ContentStateTypes, CustomDocsPanel, DefaultTechDocsHome, type DefaultTechDocsHomeProps, DocsCardGrid, type DocsCardGridProps, type DocsGroupConfig, DocsTable, type DocsTableProps, type DocsTableRow, LegacyEmbeddedDocsRouter as EmbeddedDocsRouter, EntityListDocsGrid, type EntityListDocsGridPageProps, EntityListDocsTable, type EntityListDocsTableProps, EntityTechdocsContent, InfoCardGrid, type InfoCardGridClassKey, type InfoCardGridProps, type PanelConfig, type PanelProps, type PanelType, Reader, type ReaderState, Router, type SyncResult, type TabConfig, type TabsConfig, type TechDocsApi, TechDocsClient, TechDocsCustomHome, type TechDocsCustomHomeProps, type DeprecatedTechDocsEntityMetadata as TechDocsEntityMetadata, TechDocsIndexPage, type TechDocsIndexPageProps, type DeprecatedTechDocsMetadata as TechDocsMetadata, TechDocsPageWrapper, type TechDocsPageWrapperProps, TechDocsPicker, TechDocsReaderLayout, type TechDocsReaderLayoutProps, TechDocsReaderPage, TechDocsReaderPageContent, type TechDocsReaderPageContentProps, TechDocsReaderPageHeader, type TechDocsReaderPageHeaderProps, type TechDocsReaderPageProps, type TechDocsReaderPageRenderFunction, TechDocsReaderPageSubheader, TechDocsReaderProvider, type TechDocsReaderProviderProps, type TechDocsReaderProviderRenderFunction, TechDocsSearch, type TechDocsSearchProps, TechDocsSearchResultListItem, type TechDocsSearchResultListItemProps, type TechDocsStorageApi, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef };
659
+ export { type ContentStateTypes, DefaultTechDocsHome, type DefaultTechDocsHomeProps, DocsCardGrid, type DocsCardGridProps, type DocsGroupConfig, DocsTable, type DocsTableProps, type DocsTableRow, LegacyEmbeddedDocsRouter as EmbeddedDocsRouter, EntityListDocsGrid, type EntityListDocsGridPageProps, EntityListDocsTable, type EntityListDocsTableProps, EntityTechdocsContent, type PanelConfig, type PanelType, Reader, type ReaderState, Router, type SyncResult, type TabConfig, type TabsConfig, type TechDocsApi, TechDocsClient, TechDocsCustomHome, type TechDocsCustomHomeProps, type DeprecatedTechDocsEntityMetadata as TechDocsEntityMetadata, TechDocsIndexPage, type TechDocsIndexPageProps, type DeprecatedTechDocsMetadata as TechDocsMetadata, TechDocsPageWrapper, type TechDocsPageWrapperProps, TechDocsPicker, TechDocsReaderLayout, type TechDocsReaderLayoutProps, TechDocsReaderPage, TechDocsReaderPageContent, type TechDocsReaderPageContentProps, TechDocsReaderPageHeader, type TechDocsReaderPageHeaderProps, type TechDocsReaderPageProps, type TechDocsReaderPageRenderFunction, TechDocsReaderPageSubheader, TechDocsReaderProvider, type TechDocsReaderProviderProps, type TechDocsReaderProviderRenderFunction, TechDocsSearch, type TechDocsSearchProps, TechDocsSearchResultListItem, type TechDocsSearchResultListItemProps, type TechDocsStorageApi, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef };
package/dist/index.esm.js CHANGED
@@ -8,11 +8,9 @@ export { TechDocsReaderPageSubheader } from './reader/components/TechDocsReaderP
8
8
  export { TechDocsSearch } from './search/components/TechDocsSearch.esm.js';
9
9
  export { EntityListDocsGrid } from './home/components/Grids/EntityListDocsGrid.esm.js';
10
10
  export { DocsCardGrid } from './home/components/Grids/DocsCardGrid.esm.js';
11
- export { InfoCardGrid } from './home/components/Grids/InfoCardGrid.esm.js';
12
11
  export { EntityListDocsTable } from './home/components/Tables/EntityListDocsTable.esm.js';
13
12
  export { DocsTable } from './home/components/Tables/DocsTable.esm.js';
14
13
  export { DefaultTechDocsHome } from './home/components/DefaultTechDocsHome.esm.js';
15
- export { CustomDocsPanel } from './home/components/TechDocsCustomHome.esm.js';
16
14
  export { TechDocsPageWrapper } from './home/components/TechDocsPageWrapper.esm.js';
17
15
  export { TechDocsPicker } from './home/components/TechDocsPicker.esm.js';
18
16
  export { EntityTechdocsContent, TechDocsCustomHome, TechDocsIndexPage, TechDocsReaderPage, TechDocsSearchResultListItem, TechdocsPage, techdocsPlugin as plugin, techdocsPlugin } from './plugin.esm.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { useState, useCallback, useEffect } from 'react';
2
2
  import useMediaQuery from '@material-ui/core/useMediaQuery';
3
3
  import { useTheme } from '@material-ui/core/styles';
4
- import { useAnalytics, useApi, configApiRef } from '@backstage/core-plugin-api';
4
+ import { useAnalytics, useApi } from '@backstage/core-plugin-api';
5
5
  import { scmIntegrationsApiRef } from '@backstage/integration-react';
6
6
  import { techdocsStorageApiRef, useShadowDomStylesLoading } from '@backstage/plugin-techdocs-react';
7
7
  import { useTechDocsReader } from '../TechDocsReaderProvider.esm.js';
@@ -32,7 +32,6 @@ const useTechDocsReaderDom = (entityRef) => {
32
32
  const analytics = useAnalytics();
33
33
  const techdocsStorageApi = useApi(techdocsStorageApiRef);
34
34
  const scmIntegrationsApi = useApi(scmIntegrationsApiRef);
35
- const configApi = useApi(configApiRef);
36
35
  const { state, path, content: rawPage } = useTechDocsReader();
37
36
  const { "*": currPath = "" } = useParams();
38
37
  const [dom, setDom] = useState(null);
@@ -127,7 +126,7 @@ const useTechDocsReaderDom = (entityRef) => {
127
126
  scrollIntoNavigation(),
128
127
  copyToClipboard(theme),
129
128
  addLinkClickListener({
130
- baseUrl: configApi.getOptionalString("app.baseUrl") || window.location.origin,
129
+ baseUrl: window.location.origin,
131
130
  onClick: (event, url) => {
132
131
  const modifierActive = event.ctrlKey || event.metaKey;
133
132
  const parsedUrl = new URL(url);
@@ -180,7 +179,7 @@ const useTechDocsReaderDom = (entityRef) => {
180
179
  }
181
180
  })
182
181
  ]),
183
- [theme, navigate, analytics, entityRef.name, configApi]
182
+ [theme, navigate, analytics, entityRef.name]
184
183
  );
185
184
  useEffect(() => {
186
185
  if (!rawPage) return () => {
@@ -1 +1 @@
1
- {"version":3,"file":"dom.esm.js","sources":["../../../../src/reader/components/TechDocsReaderPageContent/dom.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { useCallback, useEffect, useState } from 'react';\n\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport { useTheme } from '@material-ui/core/styles';\n\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { configApiRef, useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport { scmIntegrationsApiRef } from '@backstage/integration-react';\n\nimport {\n techdocsStorageApiRef,\n useShadowDomStylesLoading,\n} from '@backstage/plugin-techdocs-react';\n\nimport { useTechDocsReader } from '../TechDocsReaderProvider';\n\nimport {\n addBaseUrl,\n addGitFeedbackLink,\n addLinkClickListener,\n addSidebarToggle,\n onCssReady,\n removeMkdocsHeader,\n rewriteDocLinks,\n simplifyMkdocsFooter,\n scrollIntoNavigation,\n transform as transformer,\n copyToClipboard,\n useSanitizerTransformer,\n useStylesTransformer,\n handleMetaRedirects,\n} from '../../transformers';\nimport { useNavigateUrl } from './useNavigateUrl';\nimport { useParams } from 'react-router-dom';\n\nconst MOBILE_MEDIA_QUERY = 'screen and (max-width: 76.1875em)';\n\n/**\n * Hook that encapsulates the behavior of getting raw HTML and applying\n * transforms to it in order to make it function at a basic level in the\n * Backstage UI.\n */\nexport const useTechDocsReaderDom = (\n entityRef: CompoundEntityRef,\n): Element | null => {\n const navigate = useNavigateUrl();\n const theme = useTheme();\n const isMobileMedia = useMediaQuery(MOBILE_MEDIA_QUERY);\n const sanitizerTransformer = useSanitizerTransformer();\n const stylesTransformer = useStylesTransformer();\n const analytics = useAnalytics();\n\n const techdocsStorageApi = useApi(techdocsStorageApiRef);\n const scmIntegrationsApi = useApi(scmIntegrationsApiRef);\n const configApi = useApi(configApiRef);\n\n const { state, path, content: rawPage } = useTechDocsReader();\n const { '*': currPath = '' } = useParams();\n\n const [dom, setDom] = useState<HTMLElement | null>(null);\n const isStyleLoading = useShadowDomStylesLoading(dom);\n\n const updateSidebarPositionAndHeight = useCallback(() => {\n if (!dom) return;\n\n const sidebars = dom.querySelectorAll<HTMLElement>('.md-sidebar');\n\n sidebars.forEach(element => {\n // set sidebar position to render in correct position\n if (isMobileMedia) {\n element.style.top = '0px';\n } else {\n const page = document?.querySelector('.techdocs-reader-page');\n const pageTop = page?.getBoundingClientRect().top ?? 0;\n let domTop = dom.getBoundingClientRect().top ?? 0;\n\n const tabs = dom.querySelector('.md-container > .md-tabs');\n const tabsHeight = tabs?.getBoundingClientRect().height ?? 0;\n\n // the sidebars should not scroll beyond the total height of the header and tabs\n if (domTop < pageTop) {\n domTop = pageTop;\n }\n\n const scrollbarTopPx = Math.max(domTop, 0) + tabsHeight;\n\n element.style.top = `${scrollbarTopPx}px`;\n\n // set scrollbar height to ensure all links can be seen when content is small\n const footer = dom.querySelector('.md-container > .md-footer');\n // if no footer, fallback to using the bottom of the window\n const scrollbarEndPx =\n footer?.getBoundingClientRect().top ?? window.innerHeight;\n\n element.style.height = `${scrollbarEndPx - scrollbarTopPx}px`;\n }\n\n // show the sidebar only after updating its position\n element.style.setProperty('opacity', '1');\n });\n }, [dom, isMobileMedia]);\n\n useEffect(() => {\n window.addEventListener('resize', updateSidebarPositionAndHeight);\n window.addEventListener('scroll', updateSidebarPositionAndHeight, true);\n return () => {\n window.removeEventListener('resize', updateSidebarPositionAndHeight);\n window.removeEventListener(\n 'scroll',\n updateSidebarPositionAndHeight,\n true,\n );\n };\n }, [dom, updateSidebarPositionAndHeight]);\n\n // dynamically set width of footer to accommodate for pinning of the sidebar\n const updateFooterWidth = useCallback(() => {\n if (!dom) return;\n const footer = dom.querySelector<HTMLElement>('.md-footer');\n if (footer) {\n footer.style.width = `${dom.getBoundingClientRect().width}px`;\n }\n }, [dom]);\n\n useEffect(() => {\n window.addEventListener('resize', updateFooterWidth);\n return () => {\n window.removeEventListener('resize', updateFooterWidth);\n };\n }, [dom, updateFooterWidth]);\n\n // an update to \"state\" might lead to an updated UI so we include it as a trigger\n useEffect(() => {\n if (!isStyleLoading) {\n updateFooterWidth();\n updateSidebarPositionAndHeight();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n state,\n isStyleLoading,\n updateFooterWidth,\n updateSidebarPositionAndHeight,\n ]);\n\n // a function that performs transformations that are executed prior to adding it to the DOM\n const preRender = useCallback(\n (rawContent: string, contentPath: string) =>\n transformer(rawContent, [\n sanitizerTransformer,\n addBaseUrl({\n techdocsStorageApi,\n entityId: entityRef,\n path: contentPath,\n }),\n rewriteDocLinks(),\n addSidebarToggle(),\n removeMkdocsHeader(),\n simplifyMkdocsFooter(),\n addGitFeedbackLink(scmIntegrationsApi),\n stylesTransformer,\n ]),\n [\n // only add dependencies that are in state or memorized variables to avoid unnecessary calls between re-renders\n entityRef,\n scmIntegrationsApi,\n techdocsStorageApi,\n sanitizerTransformer,\n stylesTransformer,\n ],\n );\n\n // a function that performs transformations that are executed after adding it to the DOM\n const postRender = useCallback(\n async (transformedElement: Element) =>\n transformer(transformedElement, [\n handleMetaRedirects(navigate, entityRef.name),\n scrollIntoNavigation(),\n copyToClipboard(theme),\n addLinkClickListener({\n baseUrl:\n configApi.getOptionalString('app.baseUrl') ||\n window.location.origin,\n onClick: (event: MouseEvent, url: string) => {\n // detect if CTRL or META keys are pressed so that links can be opened in a new tab with `window.open`\n const modifierActive = event.ctrlKey || event.metaKey;\n const parsedUrl = new URL(url);\n\n // capture link clicks within documentation\n const linkText =\n (event.target as HTMLAnchorElement | undefined)?.innerText || url;\n const to = url.replace(window.location.origin, '');\n analytics.captureEvent('click', linkText, { attributes: { to } });\n\n // hash exists when anchor is clicked on secondary sidebar\n if (parsedUrl.hash) {\n if (modifierActive) {\n window.open(url, '_blank');\n } else {\n // If it's in a different page, we navigate to it\n if (window.location.pathname !== parsedUrl.pathname) {\n navigate(url);\n } else {\n // If it's in the same page we avoid using navigate that causes\n // the page to rerender.\n window.history.pushState(\n null,\n document.title,\n parsedUrl.hash,\n );\n }\n // Scroll to hash if it's on the current page\n transformedElement\n ?.querySelector(`[id=\"${parsedUrl.hash.slice(1)}\"]`)\n ?.scrollIntoView();\n }\n } else {\n if (modifierActive) {\n window.open(url, '_blank');\n } else {\n navigate(url);\n }\n }\n },\n }),\n // disable MkDocs drawer toggling ('for' attribute => checkbox mechanism)\n onCssReady({\n onLoading: () => {},\n onLoaded: () => {\n transformedElement\n .querySelector('.md-nav__title')\n ?.removeAttribute('for');\n },\n }),\n // hide sidebars until their positions are updated\n onCssReady({\n onLoading: () => {\n const sidebars = Array.from(\n transformedElement.querySelectorAll<HTMLElement>('.md-sidebar'),\n );\n sidebars.forEach(element => {\n element.style.setProperty('opacity', '0');\n });\n },\n onLoaded: () => {},\n }),\n ]),\n [theme, navigate, analytics, entityRef.name, configApi],\n );\n\n useEffect(() => {\n if (!rawPage) return () => {};\n\n // if false, there is already a newer execution of this effect\n let shouldReplaceContent = true;\n\n // Pre-render\n preRender(rawPage, path).then(async preTransformedDomElement => {\n if (!preTransformedDomElement?.innerHTML) {\n return; // An unexpected error occurred\n }\n\n // don't manipulate the shadow dom if this isn't the latest effect execution\n if (!shouldReplaceContent) {\n return;\n }\n\n // Skip this update if the location's path has changed but the state\n // contains a page that isn't loaded yet.\n if (currPath !== path) {\n return;\n }\n\n // Scroll to top after render\n window.scroll({ top: 0 });\n\n // Post-render\n const postTransformedDomElement = await postRender(\n preTransformedDomElement,\n );\n\n setDom(postTransformedDomElement as HTMLElement);\n });\n\n // cancel this execution\n return () => {\n shouldReplaceContent = false;\n };\n }, [rawPage, currPath, path, preRender, postRender]);\n\n return dom;\n};\n"],"names":["transformer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,kBAAqB,GAAA,mCAAA;AAOd,MAAA,oBAAA,GAAuB,CAClC,SACmB,KAAA;AACnB,EAAA,MAAM,WAAW,cAAe,EAAA;AAChC,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,aAAA,GAAgB,cAAc,kBAAkB,CAAA;AACtD,EAAA,MAAM,uBAAuB,uBAAwB,EAAA;AACrD,EAAA,MAAM,oBAAoB,oBAAqB,EAAA;AAC/C,EAAA,MAAM,YAAY,YAAa,EAAA;AAE/B,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA;AAErC,EAAA,MAAM,EAAE,KAAO,EAAA,IAAA,EAAM,OAAS,EAAA,OAAA,KAAY,iBAAkB,EAAA;AAC5D,EAAA,MAAM,EAAE,GAAA,EAAK,QAAW,GAAA,EAAA,KAAO,SAAU,EAAA;AAEzC,EAAA,MAAM,CAAC,GAAA,EAAK,MAAM,CAAA,GAAI,SAA6B,IAAI,CAAA;AACvD,EAAM,MAAA,cAAA,GAAiB,0BAA0B,GAAG,CAAA;AAEpD,EAAM,MAAA,8BAAA,GAAiC,YAAY,MAAM;AACvD,IAAA,IAAI,CAAC,GAAK,EAAA;AAEV,IAAM,MAAA,QAAA,GAAW,GAAI,CAAA,gBAAA,CAA8B,aAAa,CAAA;AAEhE,IAAA,QAAA,CAAS,QAAQ,CAAW,OAAA,KAAA;AAE1B,MAAA,IAAI,aAAe,EAAA;AACjB,QAAA,OAAA,CAAQ,MAAM,GAAM,GA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AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAI,IAAA,CAAC,OAAS,EAAA,OAAO,MAAM;AAAA,KAAC;AAG5B,IAAA,IAAI,oBAAuB,GAAA,IAAA;AAG3B,IAAA,SAAA,CAAU,OAAS,EAAA,IAAI,CAAE,CAAA,IAAA,CAAK,OAAM,wBAA4B,KAAA;AAC9D,MAAI,IAAA,CAAC,0BAA0B,SAAW,EAAA;AACxC,QAAA;AAAA;AAIF,MAAA,IAAI,CAAC,oBAAsB,EAAA;AACzB,QAAA;AAAA;AAKF,MAAA,IAAI,aAAa,IAAM,EAAA;AACrB,QAAA;AAAA;AAIF,MAAA,MAAA,CAAO,MAAO,CAAA,EAAE,GAAK,EAAA,CAAA,EAAG,CAAA;AAGxB,MAAA,MAAM,4BAA4B,MAAM,UAAA;AAAA,QACtC;AAAA,OACF;AAEA,MAAA,MAAA,CAAO,yBAAwC,CAAA;AAAA,KAChD,CAAA;AAGD,IAAA,OAAO,MAAM;AACX,MAAuB,oBAAA,GAAA,KAAA;AAAA,KACzB;AAAA,KACC,CAAC,OAAA,EAAS,UAAU,IAAM,EAAA,SAAA,EAAW,UAAU,CAAC,CAAA;AAEnD,EAAO,OAAA,GAAA;AACT;;;;"}
1
+ {"version":3,"file":"dom.esm.js","sources":["../../../../src/reader/components/TechDocsReaderPageContent/dom.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { useCallback, useEffect, useState } from 'react';\n\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport { useTheme } from '@material-ui/core/styles';\n\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport { scmIntegrationsApiRef } from '@backstage/integration-react';\n\nimport {\n techdocsStorageApiRef,\n useShadowDomStylesLoading,\n} from '@backstage/plugin-techdocs-react';\n\nimport { useTechDocsReader } from '../TechDocsReaderProvider';\n\nimport {\n addBaseUrl,\n addGitFeedbackLink,\n addLinkClickListener,\n addSidebarToggle,\n onCssReady,\n removeMkdocsHeader,\n rewriteDocLinks,\n simplifyMkdocsFooter,\n scrollIntoNavigation,\n transform as transformer,\n copyToClipboard,\n useSanitizerTransformer,\n useStylesTransformer,\n handleMetaRedirects,\n} from '../../transformers';\nimport { useNavigateUrl } from './useNavigateUrl';\nimport { useParams } from 'react-router-dom';\n\nconst MOBILE_MEDIA_QUERY = 'screen and (max-width: 76.1875em)';\n\n/**\n * Hook that encapsulates the behavior of getting raw HTML and applying\n * transforms to it in order to make it function at a basic level in the\n * Backstage UI.\n */\nexport const useTechDocsReaderDom = (\n entityRef: CompoundEntityRef,\n): Element | null => {\n const navigate = useNavigateUrl();\n const theme = useTheme();\n const isMobileMedia = useMediaQuery(MOBILE_MEDIA_QUERY);\n const sanitizerTransformer = useSanitizerTransformer();\n const stylesTransformer = useStylesTransformer();\n const analytics = useAnalytics();\n\n const techdocsStorageApi = useApi(techdocsStorageApiRef);\n const scmIntegrationsApi = useApi(scmIntegrationsApiRef);\n\n const { state, path, content: rawPage } = useTechDocsReader();\n const { '*': currPath = '' } = useParams();\n\n const [dom, setDom] = useState<HTMLElement | null>(null);\n const isStyleLoading = useShadowDomStylesLoading(dom);\n\n const updateSidebarPositionAndHeight = useCallback(() => {\n if (!dom) return;\n\n const sidebars = dom.querySelectorAll<HTMLElement>('.md-sidebar');\n\n sidebars.forEach(element => {\n // set sidebar position to render in correct position\n if (isMobileMedia) {\n element.style.top = '0px';\n } else {\n const page = document?.querySelector('.techdocs-reader-page');\n const pageTop = page?.getBoundingClientRect().top ?? 0;\n let domTop = dom.getBoundingClientRect().top ?? 0;\n\n const tabs = dom.querySelector('.md-container > .md-tabs');\n const tabsHeight = tabs?.getBoundingClientRect().height ?? 0;\n\n // the sidebars should not scroll beyond the total height of the header and tabs\n if (domTop < pageTop) {\n domTop = pageTop;\n }\n\n const scrollbarTopPx = Math.max(domTop, 0) + tabsHeight;\n\n element.style.top = `${scrollbarTopPx}px`;\n\n // set scrollbar height to ensure all links can be seen when content is small\n const footer = dom.querySelector('.md-container > .md-footer');\n // if no footer, fallback to using the bottom of the window\n const scrollbarEndPx =\n footer?.getBoundingClientRect().top ?? window.innerHeight;\n\n element.style.height = `${scrollbarEndPx - scrollbarTopPx}px`;\n }\n\n // show the sidebar only after updating its position\n element.style.setProperty('opacity', '1');\n });\n }, [dom, isMobileMedia]);\n\n useEffect(() => {\n window.addEventListener('resize', updateSidebarPositionAndHeight);\n window.addEventListener('scroll', updateSidebarPositionAndHeight, true);\n return () => {\n window.removeEventListener('resize', updateSidebarPositionAndHeight);\n window.removeEventListener(\n 'scroll',\n updateSidebarPositionAndHeight,\n true,\n );\n };\n }, [dom, updateSidebarPositionAndHeight]);\n\n // dynamically set width of footer to accommodate for pinning of the sidebar\n const updateFooterWidth = useCallback(() => {\n if (!dom) return;\n const footer = dom.querySelector<HTMLElement>('.md-footer');\n if (footer) {\n footer.style.width = `${dom.getBoundingClientRect().width}px`;\n }\n }, [dom]);\n\n useEffect(() => {\n window.addEventListener('resize', updateFooterWidth);\n return () => {\n window.removeEventListener('resize', updateFooterWidth);\n };\n }, [dom, updateFooterWidth]);\n\n // an update to \"state\" might lead to an updated UI so we include it as a trigger\n useEffect(() => {\n if (!isStyleLoading) {\n updateFooterWidth();\n updateSidebarPositionAndHeight();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n state,\n isStyleLoading,\n updateFooterWidth,\n updateSidebarPositionAndHeight,\n ]);\n\n // a function that performs transformations that are executed prior to adding it to the DOM\n const preRender = useCallback(\n (rawContent: string, contentPath: string) =>\n transformer(rawContent, [\n sanitizerTransformer,\n addBaseUrl({\n techdocsStorageApi,\n entityId: entityRef,\n path: contentPath,\n }),\n rewriteDocLinks(),\n addSidebarToggle(),\n removeMkdocsHeader(),\n simplifyMkdocsFooter(),\n addGitFeedbackLink(scmIntegrationsApi),\n stylesTransformer,\n ]),\n [\n // only add dependencies that are in state or memorized variables to avoid unnecessary calls between re-renders\n entityRef,\n scmIntegrationsApi,\n techdocsStorageApi,\n sanitizerTransformer,\n stylesTransformer,\n ],\n );\n\n // a function that performs transformations that are executed after adding it to the DOM\n const postRender = useCallback(\n async (transformedElement: Element) =>\n transformer(transformedElement, [\n handleMetaRedirects(navigate, entityRef.name),\n scrollIntoNavigation(),\n copyToClipboard(theme),\n addLinkClickListener({\n baseUrl: window.location.origin,\n onClick: (event: MouseEvent, url: string) => {\n // detect if CTRL or META keys are pressed so that links can be opened in a new tab with `window.open`\n const modifierActive = event.ctrlKey || event.metaKey;\n const parsedUrl = new URL(url);\n\n // capture link clicks within documentation\n const linkText =\n (event.target as HTMLAnchorElement | undefined)?.innerText || url;\n const to = url.replace(window.location.origin, '');\n analytics.captureEvent('click', linkText, { attributes: { to } });\n\n // hash exists when anchor is clicked on secondary sidebar\n if (parsedUrl.hash) {\n if (modifierActive) {\n window.open(url, '_blank');\n } else {\n // If it's in a different page, we navigate to it\n if (window.location.pathname !== parsedUrl.pathname) {\n navigate(url);\n } else {\n // If it's in the same page we avoid using navigate that causes\n // the page to rerender.\n window.history.pushState(\n null,\n document.title,\n parsedUrl.hash,\n );\n }\n // Scroll to hash if it's on the current page\n transformedElement\n ?.querySelector(`[id=\"${parsedUrl.hash.slice(1)}\"]`)\n ?.scrollIntoView();\n }\n } else {\n if (modifierActive) {\n window.open(url, '_blank');\n } else {\n navigate(url);\n }\n }\n },\n }),\n // disable MkDocs drawer toggling ('for' attribute => checkbox mechanism)\n onCssReady({\n onLoading: () => {},\n onLoaded: () => {\n transformedElement\n .querySelector('.md-nav__title')\n ?.removeAttribute('for');\n },\n }),\n // hide sidebars until their positions are updated\n onCssReady({\n onLoading: () => {\n const sidebars = Array.from(\n transformedElement.querySelectorAll<HTMLElement>('.md-sidebar'),\n );\n sidebars.forEach(element => {\n element.style.setProperty('opacity', '0');\n });\n },\n onLoaded: () => {},\n }),\n ]),\n [theme, navigate, analytics, entityRef.name],\n );\n\n useEffect(() => {\n if (!rawPage) return () => {};\n\n // if false, there is already a newer execution of this effect\n let shouldReplaceContent = true;\n\n // Pre-render\n preRender(rawPage, path).then(async preTransformedDomElement => {\n if (!preTransformedDomElement?.innerHTML) {\n return; // An unexpected error occurred\n }\n\n // don't manipulate the shadow dom if this isn't the latest effect execution\n if (!shouldReplaceContent) {\n return;\n }\n\n // Skip this update if the location's path has changed but the state\n // contains a page that isn't loaded yet.\n if (currPath !== path) {\n return;\n }\n\n // Scroll to top after render\n window.scroll({ top: 0 });\n\n // Post-render\n const postTransformedDomElement = await postRender(\n preTransformedDomElement,\n );\n\n setDom(postTransformedDomElement as HTMLElement);\n });\n\n // cancel this execution\n return () => {\n shouldReplaceContent = false;\n };\n }, [rawPage, currPath, path, preRender, postRender]);\n\n return dom;\n};\n"],"names":["transformer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,kBAAqB,GAAA,mCAAA;AAOd,MAAA,oBAAA,GAAuB,CAClC,SACmB,KAAA;AACnB,EAAA,MAAM,WAAW,cAAe,EAAA;AAChC,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,aAAA,GAAgB,cAAc,kBAAkB,CAAA;AACtD,EAAA,MAAM,uBAAuB,uBAAwB,EAAA;AACrD,EAAA,MAAM,oBAAoB,oBAAqB,EAAA;AAC/C,EAAA,MAAM,YAAY,YAAa,EAAA;AAE/B,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AAEvD,EAAA,MAAM,EAAE,KAAO,EAAA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;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-techdocs",
3
- "version": "1.12.2-next.1",
3
+ "version": "1.12.2",
4
4
  "description": "The Backstage plugin that renders technical documentation for your components",
5
5
  "backstage": {
6
6
  "role": "frontend-plugin",
@@ -68,23 +68,22 @@
68
68
  "test": "backstage-cli package test"
69
69
  },
70
70
  "dependencies": {
71
- "@backstage/catalog-client": "1.9.1",
72
- "@backstage/catalog-model": "1.7.3",
73
- "@backstage/config": "1.3.2",
74
- "@backstage/core-compat-api": "0.3.6-next.1",
75
- "@backstage/core-components": "0.16.4-next.0",
76
- "@backstage/core-plugin-api": "1.10.4-next.0",
77
- "@backstage/errors": "1.2.7",
78
- "@backstage/frontend-plugin-api": "0.9.5-next.1",
79
- "@backstage/integration": "1.16.1",
80
- "@backstage/integration-react": "1.2.4-next.0",
81
- "@backstage/plugin-auth-react": "0.1.12-next.0",
82
- "@backstage/plugin-catalog-react": "1.15.2-next.1",
83
- "@backstage/plugin-search-common": "1.2.17",
84
- "@backstage/plugin-search-react": "1.8.6-next.1",
85
- "@backstage/plugin-techdocs-common": "0.1.0",
86
- "@backstage/plugin-techdocs-react": "1.2.14-next.0",
87
- "@backstage/theme": "0.6.4-next.0",
71
+ "@backstage/catalog-model": "^1.7.3",
72
+ "@backstage/config": "^1.3.2",
73
+ "@backstage/core-compat-api": "^0.3.5",
74
+ "@backstage/core-components": "^0.16.3",
75
+ "@backstage/core-plugin-api": "^1.10.3",
76
+ "@backstage/errors": "^1.2.7",
77
+ "@backstage/frontend-plugin-api": "^0.9.4",
78
+ "@backstage/integration": "^1.16.1",
79
+ "@backstage/integration-react": "^1.2.3",
80
+ "@backstage/plugin-auth-react": "^0.1.11",
81
+ "@backstage/plugin-catalog-react": "^1.15.1",
82
+ "@backstage/plugin-search-common": "^1.2.17",
83
+ "@backstage/plugin-search-react": "^1.8.5",
84
+ "@backstage/plugin-techdocs-common": "^0.1.0",
85
+ "@backstage/plugin-techdocs-react": "^1.2.13",
86
+ "@backstage/theme": "^0.6.3",
88
87
  "@material-ui/core": "^4.12.2",
89
88
  "@material-ui/icons": "^4.9.1",
90
89
  "@material-ui/lab": "4.0.0-alpha.61",
@@ -98,12 +97,11 @@
98
97
  "react-use": "^17.2.4"
99
98
  },
100
99
  "devDependencies": {
101
- "@backstage/cli": "0.30.0-next.1",
102
- "@backstage/core-app-api": "1.15.5-next.0",
103
- "@backstage/dev-utils": "1.1.7-next.1",
104
- "@backstage/plugin-catalog": "1.26.2-next.1",
105
- "@backstage/plugin-techdocs-module-addons-contrib": "1.1.21-next.0",
106
- "@backstage/test-utils": "1.7.5-next.0",
100
+ "@backstage/cli": "^0.29.6",
101
+ "@backstage/core-app-api": "^1.15.4",
102
+ "@backstage/dev-utils": "^1.1.6",
103
+ "@backstage/plugin-techdocs-module-addons-contrib": "^1.1.20",
104
+ "@backstage/test-utils": "^1.7.4",
107
105
  "@testing-library/dom": "^10.0.0",
108
106
  "@testing-library/jest-dom": "^6.0.0",
109
107
  "@testing-library/react": "^16.0.0",
@@ -115,10 +113,10 @@
115
113
  "react-router-dom": "^6.3.0"
116
114
  },
117
115
  "peerDependencies": {
118
- "@types/react": "^17.0.0 || ^18.0.0",
119
- "react": "^17.0.0 || ^18.0.0",
120
- "react-dom": "^17.0.0 || ^18.0.0",
121
- "react-router-dom": "^6.3.0"
116
+ "@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
117
+ "react": "^16.13.1 || ^17.0.0 || ^18.0.0",
118
+ "react-dom": "^16.13.1 || ^17.0.0 || ^18.0.0",
119
+ "react-router-dom": "6.0.0-beta.0 || ^6.3.0"
122
120
  },
123
121
  "peerDependenciesMeta": {
124
122
  "@types/react": {
@@ -1,75 +0,0 @@
1
- import React from 'react';
2
- import useAsync from 'react-use/esm/useAsync';
3
- import { stringifyEntityRef } from '@backstage/catalog-model';
4
- import { useRouteRef, useApi, configApiRef } from '@backstage/core-plugin-api';
5
- import { Progress, ItemCardGrid, InfoCard, Link } from '@backstage/core-components';
6
- import { entityPresentationApiRef } from '@backstage/plugin-catalog-react';
7
- import { makeStyles } from '@material-ui/core/styles';
8
- import { rootDocsRouteRef } from '../../../routes.esm.js';
9
- import { toLowerMaybe } from '../../../helpers.esm.js';
10
-
11
- const useStyles = makeStyles(
12
- (theme) => ({
13
- linkSpacer: {
14
- paddingTop: theme.spacing(0.2)
15
- },
16
- readMoreLink: {
17
- paddingTop: theme.spacing(0.2)
18
- }
19
- }),
20
- { name: "BackstageInfoCardGrid" }
21
- );
22
- const InfoCardGrid = (props) => {
23
- const { entities, linkContent, linkDestination } = props;
24
- const classes = useStyles();
25
- const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);
26
- const config = useApi(configApiRef);
27
- const linkRoute = (entity) => {
28
- if (linkDestination) {
29
- const destination = linkDestination(entity);
30
- if (destination) {
31
- return destination;
32
- }
33
- }
34
- return getRouteToReaderPageFor({
35
- namespace: toLowerMaybe(entity.metadata.namespace ?? "default", config),
36
- kind: toLowerMaybe(entity.kind, config),
37
- name: toLowerMaybe(entity.metadata.name, config)
38
- });
39
- };
40
- const entityPresentationApi = useApi(entityPresentationApiRef);
41
- const { value: entityRefToPresentation, loading } = useAsync(async () => {
42
- return new Map(
43
- await Promise.all(
44
- entities?.map(async (entity) => {
45
- const presentation = await entityPresentationApi.forEntity(entity).promise;
46
- return [stringifyEntityRef(entity), presentation];
47
- }) || []
48
- )
49
- );
50
- });
51
- if (loading) return /* @__PURE__ */ React.createElement(Progress, null);
52
- if (!entities || !entities?.length) return null;
53
- return /* @__PURE__ */ React.createElement(ItemCardGrid, { "data-testid": "info-card-container" }, entities.map((entity) => /* @__PURE__ */ React.createElement(
54
- InfoCard,
55
- {
56
- key: entity.metadata.name,
57
- "data-testid": entity?.metadata?.title,
58
- title: entityRefToPresentation?.get(stringifyEntityRef(entity))?.primaryTitle
59
- },
60
- /* @__PURE__ */ React.createElement("div", null, entity?.metadata?.description),
61
- /* @__PURE__ */ React.createElement("div", { className: classes.linkSpacer }),
62
- /* @__PURE__ */ React.createElement(
63
- Link,
64
- {
65
- to: linkRoute(entity),
66
- className: classes.readMoreLink,
67
- "data-testid": "read-docs-link"
68
- },
69
- linkContent || "Read Docs"
70
- )
71
- )));
72
- };
73
-
74
- export { InfoCardGrid };
75
- //# sourceMappingURL=InfoCardGrid.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InfoCardGrid.esm.js","sources":["../../../../src/home/components/Grids/InfoCardGrid.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useApi, useRouteRef, configApiRef } from '@backstage/core-plugin-api';\nimport {\n ItemCardGrid,\n InfoCard,\n Link,\n Progress,\n} from '@backstage/core-components';\nimport {\n EntityRefPresentationSnapshot,\n entityPresentationApiRef,\n} from '@backstage/plugin-catalog-react';\nimport { makeStyles } from '@material-ui/core/styles';\nimport { rootDocsRouteRef } from '../../../routes';\nimport { toLowerMaybe } from '../../../helpers';\n\n/** @public */\nexport type InfoCardGridClassKey = 'linkSpacer' | 'readMoreLink';\n\nconst useStyles = makeStyles(\n theme => ({\n linkSpacer: {\n paddingTop: theme.spacing(0.2),\n },\n readMoreLink: {\n paddingTop: theme.spacing(0.2),\n },\n }),\n { name: 'BackstageInfoCardGrid' },\n);\n\n/**\n * Props for {@link InfoCardGrid}\n *\n * @public\n */\nexport type InfoCardGridProps = {\n entities: Entity[] | undefined;\n linkContent?: string | JSX.Element;\n linkDestination?: (entity: Entity) => string | undefined;\n};\n\n/**\n * Component which accepts a list of entities and renders a info card for each entity\n *\n * @public\n */\nexport const InfoCardGrid = (props: InfoCardGridProps) => {\n const { entities, linkContent, linkDestination } = props;\n const classes = useStyles();\n const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);\n const config = useApi(configApiRef);\n const linkRoute = (entity: Entity) => {\n if (linkDestination) {\n const destination = linkDestination(entity);\n if (destination) {\n return destination;\n }\n }\n return getRouteToReaderPageFor({\n namespace: toLowerMaybe(entity.metadata.namespace ?? 'default', config),\n kind: toLowerMaybe(entity.kind, config),\n name: toLowerMaybe(entity.metadata.name, config),\n });\n };\n const entityPresentationApi = useApi(entityPresentationApiRef);\n const { value: entityRefToPresentation, loading } = useAsync(async () => {\n return new Map<string, EntityRefPresentationSnapshot>(\n await Promise.all(\n entities?.map(async entity => {\n const presentation = await entityPresentationApi.forEntity(entity)\n .promise;\n return [stringifyEntityRef(entity), presentation] as [\n string,\n EntityRefPresentationSnapshot,\n ];\n }) || [],\n ),\n );\n });\n if (loading) return <Progress />;\n if (!entities || !entities?.length) return null;\n return (\n <ItemCardGrid data-testid=\"info-card-container\">\n {entities.map(entity => (\n <InfoCard\n key={entity.metadata.name}\n data-testid={entity?.metadata?.title}\n title={\n entityRefToPresentation?.get(stringifyEntityRef(entity))\n ?.primaryTitle\n }\n >\n <div>{entity?.metadata?.description}</div>\n <div className={classes.linkSpacer} />\n <Link\n to={linkRoute(entity)}\n className={classes.readMoreLink}\n data-testid=\"read-docs-link\"\n >\n {linkContent || 'Read Docs'}\n </Link>\n </InfoCard>\n ))}\n </ItemCardGrid>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AAqCA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAU,KAAA,MAAA;AAAA,IACR,UAAY,EAAA;AAAA,MACV,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,GAAG;AAAA,KAC/B;AAAA,IACA,YAAc,E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