@backstage/plugin-techdocs 0.15.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,65 @@
1
1
  # @backstage/plugin-techdocs
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - b58c70c223: This package has been promoted to v1.0! To understand how this change affects the package, please check out our [versioning policy](https://backstage.io/docs/overview/versioning-policy).
8
+
9
+ ### Minor Changes
10
+
11
+ - 700d93ff41: Removed deprecated exports, including:
12
+
13
+ - deprecated `DocsResultListItem` is now deleted and fully replaced with `TechDocsSearchResultListItem`
14
+ - deprecated `TechDocsPage` is now deleted and fully replaced with `TechDocsReaderPage`
15
+ - deprecated `TechDocsPageHeader` is now deleted and fully replaced with `TechDocsReaderPageHeader`
16
+ - deprecated `TechDocsPageHeaderProps` is now deleted and fully replaced with `TechDocsReaderPageHeaderProps`
17
+ - deprecated `TechDocsPageRenderFunction` is now deleted and fully replaced with `TechDocsReaderPageRenderFunction`
18
+ - deprecated config `techdocs.requestUrl` is now deleted and fully replaced with the discoveryApi
19
+
20
+ ### Patch Changes
21
+
22
+ - a422d7ce5e: chore(deps): bump `@testing-library/react` from 11.2.6 to 12.1.3
23
+ - c689d7a94c: Switched to using `CatalogFilterLayout` from `@backstage/plugin-catalog-react`.
24
+ - f24ef7864e: Minor typo fixes
25
+ - 06af9e8d17: Long sidebars will no longer overflow the footer and will properly show a scrollbar when needed.
26
+ - Updated dependencies
27
+ - @backstage/core-components@0.9.2
28
+ - @backstage/core-plugin-api@1.0.0
29
+ - @backstage/integration-react@1.0.0
30
+ - @backstage/plugin-catalog-react@1.0.0
31
+ - @backstage/plugin-search@0.7.4
32
+ - @backstage/catalog-model@1.0.0
33
+ - @backstage/integration@1.0.0
34
+ - @backstage/config@1.0.0
35
+ - @backstage/errors@1.0.0
36
+
37
+ ## 0.15.1
38
+
39
+ ### Patch Changes
40
+
41
+ - 7a1dbe6ce9: The panels of `TechDocsCustomHome` now use the `useEntityOwnership` hook to resolve ownership when the `'ownedByUser'` filter predicate is used.
42
+ - Updated dependencies
43
+ - @backstage/plugin-catalog@0.10.0
44
+ - @backstage/plugin-catalog-react@0.9.0
45
+ - @backstage/core-components@0.9.1
46
+ - @backstage/catalog-model@0.13.0
47
+ - @backstage/plugin-search@0.7.3
48
+ - @backstage/integration-react@0.1.25
49
+
50
+ ## 0.15.1-next.0
51
+
52
+ ### Patch Changes
53
+
54
+ - 7a1dbe6ce9: The panels of `TechDocsCustomHome` now use the `useEntityOwnership` hook to resolve ownership when the `'ownedByUser'` filter predicate is used.
55
+ - Updated dependencies
56
+ - @backstage/plugin-catalog@0.10.0-next.0
57
+ - @backstage/plugin-catalog-react@0.9.0-next.0
58
+ - @backstage/core-components@0.9.1-next.0
59
+ - @backstage/catalog-model@0.13.0-next.0
60
+ - @backstage/plugin-search@0.7.3-next.0
61
+ - @backstage/integration-react@0.1.25-next.0
62
+
3
63
  ## 0.15.0
4
64
 
5
65
  ### Minor Changes
package/config.d.ts CHANGED
@@ -33,13 +33,6 @@ export interface Config {
33
33
  */
34
34
  legacyUseCaseSensitiveTripletPaths?: boolean;
35
35
 
36
- /**
37
- * @example http://localhost:7007/api/techdocs
38
- * @visibility frontend
39
- * @deprecated
40
- */
41
- requestUrl?: string;
42
-
43
36
  sanitizer?: {
44
37
  /**
45
38
  * Allows iframe tag only for listed hosts
@@ -1,11 +1,10 @@
1
1
  import React, { useState } from 'react';
2
2
  import useAsync from 'react-use/lib/useAsync';
3
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';
4
+ import { catalogApiRef, CATALOG_FILTER_EXISTS, useEntityOwnership } from '@backstage/plugin-catalog-react';
6
5
  import { TechDocsPageWrapper, DocsTable, DocsCardGrid } from '../index.esm.js';
7
6
  import { Content, Progress, WarningPanel, CodeSnippet, HeaderTabs, ContentHeader, SupportButton } from '@backstage/core-components';
8
- import { useApi, identityApiRef } from '@backstage/core-plugin-api';
7
+ import { useApi } from '@backstage/core-plugin-api';
9
8
  import '@backstage/errors';
10
9
  import 'event-source-polyfill';
11
10
  import 'react-router-dom';
@@ -26,13 +25,13 @@ import '@material-ui/lab';
26
25
  import '@material-ui/icons/Close';
27
26
  import 'react-use/lib/useAsyncRetry';
28
27
  import '@material-ui/icons/Code';
28
+ import '@backstage/catalog-model';
29
29
  import 'react-use/lib/useCopyToClipboard';
30
30
  import 'lodash';
31
31
  import '@material-ui/icons/Share';
32
32
  import '@material-ui/styles';
33
33
  import '@material-ui/icons/Star';
34
34
  import '@material-ui/icons/StarBorder';
35
- import '@backstage/plugin-catalog';
36
35
 
37
36
  const panels = {
38
37
  DocsTable,
@@ -50,14 +49,14 @@ const CustomPanel = ({
50
49
  }
51
50
  });
52
51
  const classes = useStyles();
53
- const { value: user } = useOwnUser();
52
+ const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();
54
53
  const Panel = panels[config.panelType];
55
54
  const shownEntities = entities.filter((entity) => {
56
55
  if (config.filterPredicate === "ownedByUser") {
57
- if (!user) {
56
+ if (loadingOwnership) {
58
57
  return false;
59
58
  }
60
- return isOwnerOf(user, entity);
59
+ return isOwnedEntity(entity);
61
60
  }
62
61
  return typeof config.filterPredicate === "function" && config.filterPredicate(entity);
63
62
  });
@@ -127,17 +126,6 @@ const TechDocsCustomHome = (props) => {
127
126
  index
128
127
  }))));
129
128
  };
130
- function useOwnUser() {
131
- const catalogApi = useApi(catalogApiRef);
132
- const identityApi = useApi(identityApiRef);
133
- return useAsync(async () => {
134
- const identity = await identityApi.getBackstageIdentity();
135
- return catalogApi.getEntityByRef(parseEntityRef(identity.userEntityRef, {
136
- defaultKind: "User",
137
- defaultNamespace: DEFAULT_NAMESPACE
138
- }));
139
- }, [catalogApi, identityApi]);
140
- }
141
129
 
142
130
  export { TechDocsCustomHome };
143
- //# sourceMappingURL=TechDocsCustomHome-4e5e8594.esm.js.map
131
+ //# sourceMappingURL=TechDocsCustomHome-174c6f0d.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TechDocsCustomHome-174c6f0d.esm.js","sources":["../../src/home/components/TechDocsCustomHome.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState } from 'react';\nimport useAsync from 'react-use/lib/useAsync';\nimport { makeStyles } from '@material-ui/core';\nimport { CSSProperties } from '@material-ui/styles';\nimport {\n CATALOG_FILTER_EXISTS,\n catalogApiRef,\n CatalogApi,\n useEntityOwnership,\n} from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { DocsTable } from './Tables';\nimport { DocsCardGrid } from './Grids';\nimport { TechDocsPageWrapper } from './TechDocsPageWrapper';\n\nimport {\n CodeSnippet,\n Content,\n HeaderTabs,\n Progress,\n WarningPanel,\n SupportButton,\n ContentHeader,\n} from '@backstage/core-components';\nimport { useApi } from '@backstage/core-plugin-api';\n\nconst panels = {\n DocsTable: DocsTable,\n DocsCardGrid: DocsCardGrid,\n};\n\n/**\n * Available panel types\n *\n * @public\n */\nexport type PanelType = 'DocsCardGrid' | 'DocsTable';\n\n/**\n * Type representing a TechDocsCustomHome panel.\n *\n * @public\n */\nexport interface PanelConfig {\n title: string;\n description: string;\n panelType: PanelType;\n panelCSS?: CSSProperties;\n filterPredicate: ((entity: Entity) => boolean) | string;\n}\n\n/**\n * Type representing a TechDocsCustomHome tab.\n *\n * @public\n */\nexport interface TabConfig {\n label: string;\n panels: PanelConfig[];\n}\n\n/**\n * Type representing a list of TechDocsCustomHome tabs.\n *\n * @public\n */\nexport type TabsConfig = TabConfig[];\n\nconst CustomPanel = ({\n config,\n entities,\n index,\n}: {\n config: PanelConfig;\n entities: Entity[];\n index: number;\n}) => {\n const useStyles = makeStyles({\n panelContainer: {\n marginBottom: '2rem',\n ...(config.panelCSS ? config.panelCSS : {}),\n },\n });\n const classes = useStyles();\n const { loading: loadingOwnership, isOwnedEntity } = useEntityOwnership();\n\n const Panel = panels[config.panelType];\n\n const shownEntities = entities.filter(entity => {\n if (config.filterPredicate === 'ownedByUser') {\n if (loadingOwnership) {\n return false;\n }\n return isOwnedEntity(entity);\n }\n\n return (\n typeof config.filterPredicate === 'function' &&\n config.filterPredicate(entity)\n );\n });\n\n return (\n <>\n <ContentHeader title={config.title} description={config.description}>\n {index === 0 ? (\n <SupportButton>\n Discover documentation in your ecosystem.\n </SupportButton>\n ) : null}\n </ContentHeader>\n <div className={classes.panelContainer}>\n <Panel data-testid=\"techdocs-custom-panel\" entities={shownEntities} />\n </div>\n </>\n );\n};\n\n/**\n * Props for {@link TechDocsCustomHome}\n *\n * @public\n */\nexport type TechDocsCustomHomeProps = {\n tabsConfig: TabsConfig;\n};\n\nexport const TechDocsCustomHome = (props: TechDocsCustomHomeProps) => {\n const { tabsConfig } = props;\n const [selectedTab, setSelectedTab] = useState<number>(0);\n const catalogApi: CatalogApi = useApi(catalogApiRef);\n\n const {\n value: entities,\n loading,\n error,\n } = useAsync(async () => {\n const response = await catalogApi.getEntities({\n filter: {\n 'metadata.annotations.backstage.io/techdocs-ref': CATALOG_FILTER_EXISTS,\n },\n fields: [\n 'apiVersion',\n 'kind',\n 'metadata',\n 'relations',\n 'spec.owner',\n 'spec.type',\n ],\n });\n return response.items.filter((entity: Entity) => {\n return !!entity.metadata.annotations?.['backstage.io/techdocs-ref'];\n });\n });\n\n const currentTabConfig = tabsConfig[selectedTab];\n\n if (loading) {\n return (\n <TechDocsPageWrapper>\n <Content>\n <Progress />\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n if (error) {\n return (\n <TechDocsPageWrapper>\n <Content>\n <WarningPanel\n severity=\"error\"\n title=\"Could not load available documentation.\"\n >\n <CodeSnippet language=\"text\" text={error.toString()} />\n </WarningPanel>\n </Content>\n </TechDocsPageWrapper>\n );\n }\n\n return (\n <TechDocsPageWrapper>\n <HeaderTabs\n selectedIndex={selectedTab}\n onChange={index => setSelectedTab(index)}\n tabs={tabsConfig.map(({ label }, index) => ({\n id: index.toString(),\n label,\n }))}\n />\n <Content data-testid=\"techdocs-content\">\n {currentTabConfig.panels.map((config, index) => (\n <CustomPanel\n key={index}\n config={config}\n entities={!!entities ? entities : []}\n index={index}\n />\n ))}\n </Content>\n </TechDocsPageWrapper>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,MAAS,GAAA;AAAA,EACb,SAAA;AAAA,EACA,YAAA;AAAA,CAAA,CAAA;AAwCF,MAAM,cAAc,CAAC;AAAA,EACnB,MAAA;AAAA,EACA,QAAA;AAAA,EACA,KAAA;AAAA,CAKI,KAAA;AACJ,EAAA,MAAM,YAAY,UAAW,CAAA;AAAA,IAC3B,cAAgB,EAAA;AAAA,MACd,YAAc,EAAA,MAAA;AAAA,MACV,GAAA,MAAA,CAAO,QAAW,GAAA,MAAA,CAAO,QAAW,GAAA,EAAA;AAAA,KAAA;AAAA,GAAA,CAAA,CAAA;AAG5C,EAAA,MAAM,OAAU,GAAA,SAAA,EAAA,CAAA;AAChB,EAAM,MAAA,EAAE,OAAS,EAAA,gBAAA,EAAkB,aAAkB,EAAA,GAAA,kBAAA,EAAA,CAAA;AAErD,EAAM,MAAA,KAAA,GAAQ,OAAO,MAAO,CAAA,SAAA,CAAA,CAAA;AAE5B,EAAM,MAAA,aAAA,GAAgB,QAAS,CAAA,MAAA,CAAO,CAAU,M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AA,CAAA;AAAA,IAClC,MAAM,UAAW,CAAA,GAAA,CAAI,CAAC,EAAE,SAAS,KAAW,MAAA;AAAA,MAC1C,IAAI,KAAM,CAAA,QAAA,EAAA;AAAA,MACV,KAAA;AAAA,KAAA,CAAA,CAAA;AAAA,GAAA,CAAA,sCAGH,OAAD,EAAA;AAAA,IAAS,aAAY,EAAA,kBAAA;AAAA,GAAA,EAClB,iBAAiB,MAAO,CAAA,GAAA,CAAI,CAAC,MAAQ,EAAA,KAAA,yCACnC,WAAD,EAAA;AAAA,IACE,GAAK,EAAA,KAAA;AAAA,IACL,MAAA;AAAA,IACA,QAAU,EAAA,CAAC,CAAC,QAAA,GAAW,QAAW,GAAA,EAAA;AAAA,IAClC,KAAA;AAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA;;;;"}
package/dist/index.d.ts CHANGED
@@ -53,9 +53,6 @@ declare type SyncResult = 'cached' | 'updated';
53
53
  * @public
54
54
  */
55
55
  interface TechDocsStorageApi {
56
- /**
57
- * Set to techdocs.requestUrl as the URL for techdocs-backend API.
58
- */
59
56
  getApiOrigin(): Promise<string>;
60
57
  getStorageUrl(): Promise<string>;
61
58
  getBuilder(): Promise<string>;
@@ -69,9 +66,6 @@ interface TechDocsStorageApi {
69
66
  * @public
70
67
  */
71
68
  interface TechDocsApi {
72
- /**
73
- * Set to techdocs.requestUrl as the URL for techdocs-backend API.
74
- */
75
69
  getApiOrigin(): Promise<string>;
76
70
  getTechDocsMetadata(entityId: CompoundEntityRef): Promise<TechDocsMetadata>;
77
71
  getEntityMetadata(entityId: CompoundEntityRef): Promise<TechDocsEntityMetadata>;
@@ -188,16 +182,6 @@ declare type TechDocsReaderPageRenderFunction = ({ techdocsMetadataValue, entity
188
182
  declare type TechDocsReaderPageProps = {
189
183
  children?: TechDocsReaderPageRenderFunction | React.ReactNode;
190
184
  };
191
- /**
192
- * @public
193
- * @deprecated use {@link TechDocsReaderPage} instead
194
- */
195
- declare const TechDocsPage: (props: TechDocsReaderPageProps) => JSX.Element;
196
- /**
197
- * @public
198
- * @deprecated use {@link TechDocsReaderPageRenderFunction} instead
199
- */
200
- declare type TechDocsPageRenderFunction = TechDocsReaderPageRenderFunction;
201
185
 
202
186
  /**
203
187
  * Props for {@link TechDocsReaderPageHeader}
@@ -215,16 +199,6 @@ declare type TechDocsReaderPageHeaderProps = PropsWithChildren<{
215
199
  * @public
216
200
  */
217
201
  declare const TechDocsReaderPageHeader: (props: TechDocsReaderPageHeaderProps) => JSX.Element;
218
- /**
219
- * @public
220
- * @deprecated use {@link TechDocsReaderPageHeader} instead
221
- */
222
- declare const TechDocsPageHeader: (props: TechDocsReaderPageHeaderProps) => JSX.Element;
223
- /**
224
- * @public
225
- * @deprecated use {@link TechDocsReaderPageHeader} instead
226
- */
227
- declare type TechDocsPageHeaderProps = TechDocsReaderPageHeaderProps;
228
202
 
229
203
  /**
230
204
  * Props for {@link TechDocsSearchResultListItem}.
@@ -244,11 +218,6 @@ declare type TechDocsSearchResultListItemProps = {
244
218
  * @public
245
219
  */
246
220
  declare const TechDocsSearchResultListItem: (props: TechDocsSearchResultListItemProps) => JSX.Element;
247
- /**
248
- * @public
249
- * @deprecated use {@link TechDocsSearchResultListItem} instead
250
- */
251
- declare const DocsResultListItem: (props: TechDocsSearchResultListItemProps) => JSX.Element;
252
221
 
253
222
  /**
254
223
  * Props for {@link TechDocsSearch}
@@ -526,4 +495,4 @@ declare const Router: () => JSX.Element;
526
495
  */
527
496
  declare const EmbeddedDocsRouter: () => JSX.Element;
528
497
 
529
- export { DefaultTechDocsHome, DefaultTechDocsHomeProps, DocsCardGrid, DocsCardGridProps, DocsResultListItem, DocsTable, DocsTableProps, DocsTableRow, EmbeddedDocsRouter, EntityListDocsGrid, EntityListDocsTable, EntityListDocsTableProps, EntityTechdocsContent, PanelConfig, PanelType, Reader, ReaderProps, Router, SyncResult, TabConfig, TabsConfig, TechDocsApi, TechDocsClient, TechDocsCustomHome, TechDocsCustomHomeProps, TechDocsEntityMetadata, TechDocsIndexPage, TechDocsMetadata, TechDocsPage, TechDocsPageHeader, TechDocsPageHeaderProps, TechDocsPageRenderFunction, TechDocsPageWrapper, TechDocsPageWrapperProps, TechDocsPicker, TechDocsReaderPage, TechDocsReaderPageHeader, TechDocsReaderPageHeaderProps, TechDocsReaderPageProps, TechDocsReaderPageRenderFunction, TechDocsSearch, TechDocsSearchProps, TechDocsSearchResultListItem, TechDocsSearchResultListItemProps, TechDocsStorageApi, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef };
498
+ export { DefaultTechDocsHome, DefaultTechDocsHomeProps, DocsCardGrid, DocsCardGridProps, DocsTable, DocsTableProps, DocsTableRow, EmbeddedDocsRouter, EntityListDocsGrid, EntityListDocsTable, EntityListDocsTableProps, EntityTechdocsContent, PanelConfig, PanelType, Reader, ReaderProps, Router, SyncResult, TabConfig, TabsConfig, TechDocsApi, TechDocsClient, TechDocsCustomHome, TechDocsCustomHomeProps, TechDocsEntityMetadata, TechDocsIndexPage, TechDocsMetadata, TechDocsPageWrapper, TechDocsPageWrapperProps, TechDocsPicker, TechDocsReaderPage, TechDocsReaderPageHeader, TechDocsReaderPageHeaderProps, TechDocsReaderPageProps, TechDocsReaderPageRenderFunction, TechDocsSearch, TechDocsSearchProps, TechDocsSearchResultListItem, TechDocsSearchResultListItemProps, TechDocsStorageApi, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef };
package/dist/index.esm.js CHANGED
@@ -1,11 +1,11 @@
1
- import { createApiRef, useApi, configApiRef, createRouteRef, useRouteRef, useApp, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, fetchApiRef, createRoutableExtension } from '@backstage/core-plugin-api';
1
+ import { createApiRef, useApi, configApiRef, createRouteRef, useRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, fetchApiRef, createRoutableExtension, useApp } from '@backstage/core-plugin-api';
2
2
  import { ResponseError, NotFoundError } from '@backstage/errors';
3
3
  import { EventSourcePolyfill } from 'event-source-polyfill';
4
4
  import React, { useState, useCallback, useEffect, useReducer, useRef, useMemo, createContext, useContext } from 'react';
5
5
  import { useNavigate as useNavigate$1, useParams, Routes, Route } from 'react-router-dom';
6
6
  import { withStyles, Tooltip, ThemeProvider, SvgIcon, makeStyles, ListItemText, ListItem, Divider, TextField, InputAdornment, IconButton, CircularProgress, createStyles, Button, Drawer, Grid, Typography, useTheme, lighten, alpha, Card, CardMedia, CardContent, CardActions } from '@material-ui/core';
7
7
  import { scmIntegrationsApiRef } from '@backstage/integration-react';
8
- import { Link, LogViewer, ErrorPage, Progress, SidebarPinStateContext, HeaderLabel, Header, Page, Content, ItemCardGrid, ItemCardHeader, Button as Button$1, WarningPanel, CodeSnippet, SubvalueCell, Table, EmptyState, PageWithHeader, ContentHeader, SupportButton, MissingAnnotationEmptyState } from '@backstage/core-components';
8
+ import { Link, LogViewer, ErrorPage, Progress, SidebarPinStateContext, HeaderLabel, Header, ItemCardGrid, ItemCardHeader, Button as Button$1, WarningPanel, CodeSnippet, SubvalueCell, Table, EmptyState, PageWithHeader, Content, ContentHeader, SupportButton, Page, MissingAnnotationEmptyState } from '@backstage/core-components';
9
9
  import { replaceGitHubUrlType } from '@backstage/integration';
10
10
  import FeedbackOutlinedIcon from '@material-ui/icons/FeedbackOutlined';
11
11
  import ReactDOM from 'react-dom';
@@ -24,14 +24,13 @@ import useAsync from 'react-use/lib/useAsync';
24
24
  import useAsyncRetry from 'react-use/lib/useAsyncRetry';
25
25
  import CodeIcon from '@material-ui/icons/Code';
26
26
  import { RELATION_OWNED_BY } from '@backstage/catalog-model';
27
- import { getEntityRelations, EntityRefLink, EntityRefLinks, useEntityList, humanizeEntityRef, useStarredEntities, CATALOG_FILTER_EXISTS, EntityListProvider, UserListPicker, EntityOwnerPicker, EntityTagPicker, useEntity } from '@backstage/plugin-catalog-react';
27
+ import { getEntityRelations, EntityRefLink, EntityRefLinks, useEntityList, humanizeEntityRef, useStarredEntities, CATALOG_FILTER_EXISTS, EntityListProvider, CatalogFilterLayout, UserListPicker, EntityOwnerPicker, EntityTagPicker, useEntity } from '@backstage/plugin-catalog-react';
28
28
  import useCopyToClipboard from 'react-use/lib/useCopyToClipboard';
29
29
  import { capitalize } from 'lodash';
30
30
  import ShareIcon from '@material-ui/icons/Share';
31
31
  import { withStyles as withStyles$1 } from '@material-ui/styles';
32
32
  import Star from '@material-ui/icons/Star';
33
33
  import StarBorder from '@material-ui/icons/StarBorder';
34
- import { FilteredEntityLayout, FilterContainer, EntityListContainer } from '@backstage/plugin-catalog';
35
34
 
36
35
  const techdocsStorageApiRef = createApiRef({
37
36
  id: "plugin.techdocs.storageservice"
@@ -47,8 +46,7 @@ class TechDocsClient {
47
46
  this.fetchApi = options.fetchApi;
48
47
  }
49
48
  async getApiOrigin() {
50
- var _a;
51
- return (_a = this.configApi.getOptionalString("techdocs.requestUrl")) != null ? _a : await this.discoveryApi.getBaseUrl("techdocs");
49
+ return await this.discoveryApi.getBaseUrl("techdocs");
52
50
  }
53
51
  async getTechDocsMetadata(entityId) {
54
52
  const { kind, namespace, name } = entityId;
@@ -79,8 +77,7 @@ class TechDocsStorageClient {
79
77
  this.fetchApi = options.fetchApi;
80
78
  }
81
79
  async getApiOrigin() {
82
- var _a;
83
- return (_a = this.configApi.getOptionalString("techdocs.requestUrl")) != null ? _a : await this.discoveryApi.getBaseUrl("techdocs");
80
+ return await this.discoveryApi.getBaseUrl("techdocs");
84
81
  }
85
82
  async getStorageUrl() {
86
83
  var _a;
@@ -532,7 +529,6 @@ const TechDocsSearchResultListItem = (props) => {
532
529
  })) : /* @__PURE__ */ React.createElement(React.Fragment, null, children);
533
530
  return /* @__PURE__ */ React.createElement(LinkWrapper, null, /* @__PURE__ */ React.createElement(ListItemWrapper, null, /* @__PURE__ */ React.createElement(TextItem, null)));
534
531
  };
535
- const DocsResultListItem = TechDocsSearchResultListItem;
536
532
 
537
533
  const useStyles$2 = makeStyles({
538
534
  root: {
@@ -1214,16 +1210,42 @@ const useTechDocsReaderDom = (entityRef) => {
1214
1210
  }
1215
1211
 
1216
1212
  .md-sidebar {
1217
- height: calc(100% - 100px);
1213
+ bottom: 75px;
1218
1214
  position: fixed;
1219
1215
  width: 16rem;
1216
+ overflow-y: auto;
1217
+ overflow-x: hidden;
1218
+ scrollbar-color: rgb(193, 193, 193) #eee;
1219
+ scrollbar-width: thin;
1220
1220
  }
1221
1221
  .md-sidebar .md-sidebar__scrollwrap {
1222
- max-height: calc(100% - 100px);
1222
+ width: calc(16rem - 10px);
1223
1223
  }
1224
1224
  .md-sidebar--secondary {
1225
1225
  right: ${theme.spacing(3)}px;
1226
1226
  }
1227
+ .md-sidebar::-webkit-scrollbar {
1228
+ width: 5px;
1229
+ }
1230
+ .md-sidebar::-webkit-scrollbar-button {
1231
+ width: 5px;
1232
+ height: 5px;
1233
+ }
1234
+ .md-sidebar::-webkit-scrollbar-track {
1235
+ background: #eee;
1236
+ border: 1 px solid rgb(250, 250, 250);
1237
+ box-shadow: 0px 0px 3px #dfdfdf inset;
1238
+ border-radius: 3px;
1239
+ }
1240
+ .md-sidebar::-webkit-scrollbar-thumb {
1241
+ width: 5px;
1242
+ background: rgb(193, 193, 193);
1243
+ border: transparent;
1244
+ border-radius: 3px;
1245
+ }
1246
+ .md-sidebar::-webkit-scrollbar-thumb:hover {
1247
+ background: rgb(125, 125, 125);
1248
+ }
1227
1249
 
1228
1250
  .md-content {
1229
1251
  max-width: calc(100% - 16rem * 2);
@@ -1246,6 +1268,12 @@ const useTechDocsReaderDom = (entityRef) => {
1246
1268
  background-color: unset;
1247
1269
  }
1248
1270
 
1271
+ @media screen and (min-width: 76.25em) {
1272
+ .md-sidebar {
1273
+ height: auto;
1274
+ }
1275
+ }
1276
+
1249
1277
  @media screen and (max-width: 76.1875em) {
1250
1278
  .md-nav {
1251
1279
  transition: none !important;
@@ -1669,90 +1697,6 @@ const TechDocsReaderPageHeader = (props) => {
1669
1697
  typeLink: docsRootLink
1670
1698
  }, labels, children);
1671
1699
  };
1672
- const TechDocsPageHeader = TechDocsReaderPageHeader;
1673
-
1674
- const LegacyTechDocsPage = () => {
1675
- const [documentReady, setDocumentReady] = useState(false);
1676
- const { namespace, kind, name } = useParams();
1677
- const techdocsApi = useApi(techdocsApiRef);
1678
- const { value: techdocsMetadataValue } = useAsync(() => {
1679
- if (documentReady) {
1680
- return techdocsApi.getTechDocsMetadata({ kind, namespace, name });
1681
- }
1682
- return Promise.resolve(void 0);
1683
- }, [kind, namespace, name, techdocsApi, documentReady]);
1684
- const { value: entityMetadataValue, error: entityMetadataError } = useAsync(() => {
1685
- return techdocsApi.getEntityMetadata({ kind, namespace, name });
1686
- }, [kind, namespace, name, techdocsApi]);
1687
- const onReady = useCallback(() => {
1688
- setDocumentReady(true);
1689
- }, [setDocumentReady]);
1690
- if (entityMetadataError) {
1691
- return /* @__PURE__ */ React.createElement(TechDocsNotFound, {
1692
- errorMessage: entityMetadataError.message
1693
- });
1694
- }
1695
- return /* @__PURE__ */ React.createElement(Page, {
1696
- themeId: "documentation"
1697
- }, /* @__PURE__ */ React.createElement(TechDocsReaderPageHeader, {
1698
- techDocsMetadata: techdocsMetadataValue,
1699
- entityMetadata: entityMetadataValue,
1700
- entityRef: {
1701
- kind,
1702
- namespace,
1703
- name
1704
- }
1705
- }), /* @__PURE__ */ React.createElement(Content, {
1706
- "data-testid": "techdocs-content"
1707
- }, /* @__PURE__ */ React.createElement(Reader, {
1708
- onReady,
1709
- entityRef: {
1710
- kind,
1711
- namespace,
1712
- name
1713
- }
1714
- })));
1715
- };
1716
-
1717
- const TechDocsReaderPage$1 = (props) => {
1718
- const { children } = props;
1719
- const { NotFoundErrorPage } = useApp().getComponents();
1720
- const outlet = useOutlet();
1721
- const [documentReady, setDocumentReady] = useState(false);
1722
- const { namespace, kind, name } = useParams();
1723
- const techdocsApi = useApi(techdocsApiRef);
1724
- const { value: techdocsMetadataValue } = useAsync(() => {
1725
- if (documentReady) {
1726
- return techdocsApi.getTechDocsMetadata({ kind, namespace, name });
1727
- }
1728
- return Promise.resolve(void 0);
1729
- }, [kind, namespace, name, techdocsApi, documentReady]);
1730
- const { value: entityMetadataValue, error: entityMetadataError } = useAsync(() => {
1731
- return techdocsApi.getEntityMetadata({ kind, namespace, name });
1732
- }, [kind, namespace, name, techdocsApi]);
1733
- const onReady = useCallback(() => {
1734
- setDocumentReady(true);
1735
- }, [setDocumentReady]);
1736
- if (entityMetadataError)
1737
- return /* @__PURE__ */ React.createElement(NotFoundErrorPage, null);
1738
- if (!children)
1739
- return outlet || /* @__PURE__ */ React.createElement(LegacyTechDocsPage, null);
1740
- return /* @__PURE__ */ React.createElement(Page, {
1741
- themeId: "documentation"
1742
- }, children instanceof Function ? children({
1743
- techdocsMetadataValue,
1744
- entityMetadataValue,
1745
- entityRef: { kind, namespace, name },
1746
- onReady
1747
- }) : children);
1748
- };
1749
- const TechDocsPage = TechDocsReaderPage$1;
1750
-
1751
- var TechDocsReaderPage$2 = /*#__PURE__*/Object.freeze({
1752
- __proto__: null,
1753
- TechDocsReaderPage: TechDocsReaderPage$1,
1754
- TechDocsPage: TechDocsPage
1755
- });
1756
1700
 
1757
1701
  function toLowerMaybe(str, config) {
1758
1702
  return config.getOptionalBoolean("techdocs.legacyUseCaseSensitiveTripletPaths") ? str : str.toLocaleLowerCase("en-US");
@@ -1993,9 +1937,9 @@ const DefaultTechDocsHome = (props) => {
1993
1937
  const { initialFilter = "all", columns, actions } = props;
1994
1938
  return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(Content, null, /* @__PURE__ */ React.createElement(ContentHeader, {
1995
1939
  title: ""
1996
- }, /* @__PURE__ */ React.createElement(SupportButton, null, "Discover documentation in your ecosystem.")), /* @__PURE__ */ React.createElement(EntityListProvider, null, /* @__PURE__ */ React.createElement(FilteredEntityLayout, null, /* @__PURE__ */ React.createElement(FilterContainer, null, /* @__PURE__ */ React.createElement(TechDocsPicker, null), /* @__PURE__ */ React.createElement(UserListPicker, {
1940
+ }, /* @__PURE__ */ React.createElement(SupportButton, null, "Discover documentation in your ecosystem.")), /* @__PURE__ */ React.createElement(EntityListProvider, null, /* @__PURE__ */ React.createElement(CatalogFilterLayout, null, /* @__PURE__ */ React.createElement(CatalogFilterLayout.Filters, null, /* @__PURE__ */ React.createElement(TechDocsPicker, null), /* @__PURE__ */ React.createElement(UserListPicker, {
1997
1941
  initialFilter
1998
- }), /* @__PURE__ */ React.createElement(EntityOwnerPicker, null), /* @__PURE__ */ React.createElement(EntityTagPicker, null)), /* @__PURE__ */ React.createElement(EntityListContainer, null, /* @__PURE__ */ React.createElement(EntityListDocsTable, {
1942
+ }), /* @__PURE__ */ React.createElement(EntityOwnerPicker, null), /* @__PURE__ */ React.createElement(EntityTagPicker, null)), /* @__PURE__ */ React.createElement(CatalogFilterLayout.Content, null, /* @__PURE__ */ React.createElement(EntityListDocsTable, {
1999
1943
  actions,
2000
1944
  columns
2001
1945
  }))))));
@@ -2051,7 +1995,7 @@ const EntityTechdocsContent = techdocsPlugin.provide(createRoutableExtension({
2051
1995
  }));
2052
1996
  const TechDocsCustomHome = techdocsPlugin.provide(createRoutableExtension({
2053
1997
  name: "TechDocsCustomHome",
2054
- component: () => import('./esm/TechDocsCustomHome-4e5e8594.esm.js').then((m) => m.TechDocsCustomHome),
1998
+ component: () => import('./esm/TechDocsCustomHome-174c6f0d.esm.js').then((m) => m.TechDocsCustomHome),
2055
1999
  mountPoint: rootRouteRef
2056
2000
  }));
2057
2001
  const TechDocsIndexPage$2 = techdocsPlugin.provide(createRoutableExtension({
@@ -2059,9 +2003,9 @@ const TechDocsIndexPage$2 = techdocsPlugin.provide(createRoutableExtension({
2059
2003
  component: () => Promise.resolve().then(function () { return TechDocsIndexPage$1; }).then((m) => m.TechDocsIndexPage),
2060
2004
  mountPoint: rootRouteRef
2061
2005
  }));
2062
- const TechDocsReaderPage = techdocsPlugin.provide(createRoutableExtension({
2006
+ const TechDocsReaderPage$2 = techdocsPlugin.provide(createRoutableExtension({
2063
2007
  name: "TechDocsReaderPage",
2064
- component: () => Promise.resolve().then(function () { return TechDocsReaderPage$2; }).then((m) => m.TechDocsReaderPage),
2008
+ component: () => Promise.resolve().then(function () { return TechDocsReaderPage$1; }).then((m) => m.TechDocsReaderPage),
2065
2009
  mountPoint: rootDocsRouteRef
2066
2010
  }));
2067
2011
 
@@ -2075,6 +2019,63 @@ var TechDocsIndexPage$1 = /*#__PURE__*/Object.freeze({
2075
2019
  TechDocsIndexPage: TechDocsIndexPage
2076
2020
  });
2077
2021
 
2022
+ const TechDocsReaderPage = (props) => {
2023
+ const { children } = props;
2024
+ const { NotFoundErrorPage } = useApp().getComponents();
2025
+ const outlet = useOutlet();
2026
+ const [documentReady, setDocumentReady] = useState(false);
2027
+ const { namespace, kind, name } = useParams();
2028
+ const techdocsApi = useApi(techdocsApiRef);
2029
+ const { value: techdocsMetadataValue } = useAsync(() => {
2030
+ if (documentReady) {
2031
+ return techdocsApi.getTechDocsMetadata({ kind, namespace, name });
2032
+ }
2033
+ return Promise.resolve(void 0);
2034
+ }, [kind, namespace, name, techdocsApi, documentReady]);
2035
+ const { value: entityMetadataValue, error: entityMetadataError } = useAsync(() => {
2036
+ return techdocsApi.getEntityMetadata({ kind, namespace, name });
2037
+ }, [kind, namespace, name, techdocsApi]);
2038
+ const onReady = useCallback(() => {
2039
+ setDocumentReady(true);
2040
+ }, [setDocumentReady]);
2041
+ if (entityMetadataError)
2042
+ return /* @__PURE__ */ React.createElement(NotFoundErrorPage, null);
2043
+ if (!children)
2044
+ return outlet || /* @__PURE__ */ React.createElement(Page, {
2045
+ themeId: "documentation"
2046
+ }, /* @__PURE__ */ React.createElement(TechDocsReaderPageHeader, {
2047
+ techDocsMetadata: techdocsMetadataValue,
2048
+ entityMetadata: entityMetadataValue,
2049
+ entityRef: {
2050
+ kind,
2051
+ namespace,
2052
+ name
2053
+ }
2054
+ }), /* @__PURE__ */ React.createElement(Content, {
2055
+ "data-testid": "techdocs-content"
2056
+ }, /* @__PURE__ */ React.createElement(Reader, {
2057
+ onReady,
2058
+ entityRef: {
2059
+ kind,
2060
+ namespace,
2061
+ name
2062
+ }
2063
+ })));
2064
+ return /* @__PURE__ */ React.createElement(Page, {
2065
+ themeId: "documentation"
2066
+ }, children instanceof Function ? children({
2067
+ techdocsMetadataValue,
2068
+ entityMetadataValue,
2069
+ entityRef: { kind, namespace, name },
2070
+ onReady
2071
+ }) : children);
2072
+ };
2073
+
2074
+ var TechDocsReaderPage$1 = /*#__PURE__*/Object.freeze({
2075
+ __proto__: null,
2076
+ TechDocsReaderPage: TechDocsReaderPage
2077
+ });
2078
+
2078
2079
  const EntityPageDocs = ({ entity }) => {
2079
2080
  var _a;
2080
2081
  const config = useApi(configApiRef);
@@ -2099,7 +2100,7 @@ const Router = () => {
2099
2100
  element: /* @__PURE__ */ React.createElement(TechDocsIndexPage, null)
2100
2101
  }), /* @__PURE__ */ React.createElement(Route, {
2101
2102
  path: "/:namespace/:kind/:name/*",
2102
- element: /* @__PURE__ */ React.createElement(TechDocsReaderPage$1, null)
2103
+ element: /* @__PURE__ */ React.createElement(TechDocsReaderPage, null)
2103
2104
  }));
2104
2105
  };
2105
2106
  const EmbeddedDocsRouter = () => {
@@ -2126,5 +2127,5 @@ var Router$1 = /*#__PURE__*/Object.freeze({
2126
2127
  EmbeddedDocsRouter: EmbeddedDocsRouter
2127
2128
  });
2128
2129
 
2129
- export { DefaultTechDocsHome, DocsCardGrid, DocsResultListItem, DocsTable, EmbeddedDocsRouter, EntityListDocsGrid, EntityListDocsTable, EntityTechdocsContent, Reader, Router, TechDocsClient, TechDocsCustomHome, TechDocsIndexPage$2 as TechDocsIndexPage, TechDocsPage, TechDocsPageHeader, TechDocsPageWrapper, TechDocsPicker, TechDocsReaderPage, TechDocsReaderPageHeader, TechDocsSearch, TechDocsSearchResultListItem, TechDocsStateIndicator, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef, useTechDocsReader, useTechDocsReaderDom, withTechDocsReaderProvider };
2130
+ export { DefaultTechDocsHome, DocsCardGrid, DocsTable, EmbeddedDocsRouter, EntityListDocsGrid, EntityListDocsTable, EntityTechdocsContent, Reader, Router, TechDocsClient, TechDocsCustomHome, TechDocsIndexPage$2 as TechDocsIndexPage, TechDocsPageWrapper, TechDocsPicker, TechDocsReaderPage$2 as TechDocsReaderPage, TechDocsReaderPageHeader, TechDocsSearch, TechDocsSearchResultListItem, TechDocsStateIndicator, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef, useTechDocsReader, useTechDocsReaderDom, withTechDocsReaderProvider };
2130
2131
  //# sourceMappingURL=index.esm.js.map