@backstage/plugin-techdocs 0.0.0-nightly-20220510022953 → 0.0.0-nightly-20220513024945

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,25 +1,55 @@
1
1
  # @backstage/plugin-techdocs
2
2
 
3
- ## 0.0.0-nightly-20220510022953
3
+ ## 0.0.0-nightly-20220513024945
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 1af133f779: Updated dependency `event-source-polyfill` to `1.0.26`.
7
+ - 52419be116: Create a menu in the sub header of documentation pages, it is responsible for rendering TechDocs addons that allow users to customize their reading experience.
8
8
  - a307a14be0: Removed dependency on `@backstage/core-app-api`.
9
9
  - bed0d64ce9: Fixed bugs that prevented a 404 error from being shown when it should have been.
10
10
  - 2dcb2c9678: Loading SVGs correctly with `bota` with extended characters
11
11
  - 52fddad92d: The `TechDocsStorageApi` and its associated ref are now exported by `@backstage/plugin-techdocs-react`. The API interface, ref, and types are now deprecated in `@backstage/plugin-techdocs` and will be removed in a future release.
12
+ - 0ad901569f: Hidden exports related to experimental TechDocs reader functionality have been removed and can no longer be imported. In the unlikely event you were using these exports, you can now take advantage of the officially supported and generally available TechDocs Addon framework instead.
13
+ - 3a74e203a8: Updated search result components to support rendering content with highlighted matched terms
14
+ - Updated dependencies
15
+ - @backstage/core-components@0.0.0-nightly-20220513024945
16
+ - @backstage/integration@0.0.0-nightly-20220513024945
17
+ - @backstage/core-plugin-api@0.0.0-nightly-20220513024945
18
+ - @backstage/plugin-catalog-react@0.0.0-nightly-20220513024945
19
+ - @backstage/integration-react@0.0.0-nightly-20220513024945
20
+ - @backstage/plugin-techdocs-react@0.0.0-nightly-20220513024945
21
+ - @backstage/config@0.0.0-nightly-20220513024945
22
+ - @backstage/plugin-search-react@0.0.0-nightly-20220513024945
23
+ - @backstage/plugin-search-common@0.0.0-nightly-20220513024945
24
+ - @backstage/catalog-model@0.0.0-nightly-20220513024945
25
+
26
+ ## 1.1.1-next.3
27
+
28
+ ### Patch Changes
29
+
30
+ - cc8ddd0979: revert dependency `event-source-polyfill` to `1.0.25`
31
+ - Updated dependencies
32
+ - @backstage/core-components@0.9.4-next.2
33
+
34
+ ## 1.1.1-next.2
35
+
36
+ ### Patch Changes
37
+
38
+ - 52419be116: Create a menu in the sub header of documentation pages, it is responsible for rendering TechDocs addons that allow users to customize their reading experience.
39
+ - 1af133f779: Updated dependency `event-source-polyfill` to `1.0.26`.
40
+ - 2dcb2c9678: Loading SVGs correctly with `bota` with extended characters
12
41
  - 3a74e203a8: Updated search result components to support rendering content with highlighted matched terms
13
42
  - Updated dependencies
14
- - @backstage/core-components@0.0.0-nightly-20220510022953
15
- - @backstage/core-plugin-api@0.0.0-nightly-20220510022953
16
- - @backstage/integration@0.0.0-nightly-20220510022953
17
- - @backstage/plugin-catalog-react@0.0.0-nightly-20220510022953
18
- - @backstage/integration-react@0.0.0-nightly-20220510022953
19
- - @backstage/config@0.0.0-nightly-20220510022953
20
- - @backstage/plugin-search-react@0.0.0-nightly-20220510022953
21
- - @backstage/plugin-techdocs-react@0.0.0-nightly-20220510022953
22
- - @backstage/plugin-search-common@0.0.0-nightly-20220510022953
43
+ - @backstage/core-components@0.9.4-next.1
44
+ - @backstage/plugin-techdocs-react@0.1.1-next.2
45
+ - @backstage/config@1.0.1-next.0
46
+ - @backstage/plugin-search-react@0.2.0-next.2
47
+ - @backstage/plugin-search-common@0.3.4-next.0
48
+ - @backstage/plugin-catalog-react@1.1.0-next.2
49
+ - @backstage/catalog-model@1.0.2-next.0
50
+ - @backstage/core-plugin-api@1.0.2-next.1
51
+ - @backstage/integration@1.2.0-next.1
52
+ - @backstage/integration-react@1.1.0-next.2
23
53
 
24
54
  ## 1.1.1-next.1
25
55
 
@@ -2,13 +2,14 @@ import React, { useState } from 'react';
2
2
  import useAsync from 'react-use/lib/useAsync';
3
3
  import { makeStyles } from '@material-ui/core';
4
4
  import { catalogApiRef, CATALOG_FILTER_EXISTS, useEntityOwnership } from '@backstage/plugin-catalog-react';
5
- import { T as TechDocsPageWrapper, D as DocsTable, a as DocsCardGrid } from './index-913b47d9.esm.js';
5
+ import { T as TechDocsPageWrapper, D as DocsTable, a as DocsCardGrid } from './index-6c048069.esm.js';
6
6
  import { Content, Progress, WarningPanel, CodeSnippet, HeaderTabs, ContentHeader, SupportButton } from '@backstage/core-components';
7
7
  import { useApi } from '@backstage/core-plugin-api';
8
8
  import '@backstage/errors';
9
9
  import 'event-source-polyfill';
10
10
  import 'react-router-dom';
11
11
  import '@backstage/plugin-techdocs-react';
12
+ import 'react-use/lib/useAsyncRetry';
12
13
  import 'jss';
13
14
  import '@material-ui/styles';
14
15
  import '@backstage/plugin-search-react';
@@ -18,7 +19,6 @@ import 'react-router';
18
19
  import 'react-use/lib/useDebounce';
19
20
  import '@material-ui/lab';
20
21
  import '@material-ui/icons/Close';
21
- import 'react-use/lib/useAsyncRetry';
22
22
  import '@material-ui/core/styles';
23
23
  import '@backstage/integration-react';
24
24
  import '@backstage/integration';
@@ -30,6 +30,7 @@ import 'dompurify';
30
30
  import 'react-helmet';
31
31
  import '@material-ui/icons/Code';
32
32
  import '@backstage/catalog-model';
33
+ import '@material-ui/icons/Settings';
33
34
  import 'react-use/lib/useCopyToClipboard';
34
35
  import 'lodash';
35
36
  import '@material-ui/icons/Share';
@@ -131,4 +132,4 @@ const TechDocsCustomHome = (props) => {
131
132
  };
132
133
 
133
134
  export { TechDocsCustomHome };
134
- //# sourceMappingURL=TechDocsCustomHome-968d179e.esm.js.map
135
+ //# sourceMappingURL=TechDocsCustomHome-2bf696bf.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TechDocsCustomHome-968d179e.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,MAAM,GAAG;AACf,EAAE,SAAS;AACX,EAAE,YAAY;AACd,CAAC,CAAC;AACF,MAAM,WAAW,GAAG,CAAC;AACrB,EAAE,MAAM;AACR,EAAE,QAAQ;AACV,EAAE,KAAK;AACP,CAAC,KAAK;AACN,EAAE,MAAM,SAAS,GAAG,UAAU,CAAC;AAC/B,IAAI,cAAc,EAAE;AACpB,MAAM,YAAY,EAAE,MAAM;AAC1B,MAAM,GAAG,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,GAAG,EAAE;AAC/C,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;AAC9B,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,GAAG,kBAAkB,EAAE,CAAC;AAC5E,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACzC,EAAE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK;AACpD,IAAI,IAAI,MAAM,CAAC,eAAe,KAAK,aAAa,EAAE;AAClD,MAAM,IAAI,gBAAgB,EAAE;AAC5B,QAAQ,OAAO,KAAK,CAAC;AACrB,OAAO;AACP,MAAM,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AACnC,KAAK;AACL,IAAI,OAAO,OAAO,MAAM,CAAC,eAAe,KAAK,UAAU,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC1F,GAAG,CAAC,CAAC;AACL,EAAE,uBAA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,KAAK,cAAc,CAAC,KAAK,CAAC;AAC9C,IAAI,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,MAAM;AAChD,MAAM,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAE;AAC1B,MAAM,KAAK;AACX,KAAK,CAAC,CAAC;AACP,GAAG,CAAC,kBAAkB,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE;AACnD,IAAI,aAAa,EAAE,kBAAkB;AACrC,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,qBAAqB,KAAK,CAAC,aAAa,CAAC,WAAW,EAAE;AACrG,IAAI,GAAG,EAAE,KAAK;AACd,IAAI,MAAM;AACV,IAAI,QAAQ,EAAE,CAAC,CAAC,QAAQ,GAAG,QAAQ,GAAG,EAAE;AACxC,IAAI,KAAK;AACT,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACR;;;;"}
1
+ {"version":3,"file":"TechDocsCustomHome-2bf696bf.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAM,MAAM,GAAG;AACf,EAAE,SAAS;AACX,EAAE,YAAY;AACd,CAAC,CAAC;AACF,MAAM,WAAW,GAAG,CAAC;AACrB,EAAE,MAAM;AACR,EAAE,QAAQ;AACV,EAAE,KAAK;AACP,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,KAAK,CAAC,aAAa,CAAC,WAAW,EAAE;AACrG,IAAI,GAAG,EAAE,KAAK;AACd,IAAI,MAAM;AACV,IAAI,QAAQ,EAAE,CAAC,CAAC,QAAQ,GAAG,QAAQ,GAAG,EAAE;AACxC,IAAI,KAAK;AACT,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACR;;;;"}
@@ -1,12 +1,14 @@
1
1
  import { createApiRef, useApi, configApiRef, createRouteRef, useRouteRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, fetchApiRef, createRoutableExtension } from '@backstage/core-plugin-api';
2
2
  import { ResponseError, NotFoundError } from '@backstage/errors';
3
3
  import { EventSourcePolyfill } from 'event-source-polyfill';
4
- import React, { useState, useEffect, useReducer, useRef, useMemo, createContext, useContext, useCallback, Children } from 'react';
4
+ import React, { useReducer, useRef, useMemo, createContext, useContext, useState, useEffect, useCallback, Children } from 'react';
5
5
  import { useParams, useNavigate as useNavigate$1, useOutlet, Routes, Route } from 'react-router-dom';
6
- import { Link, LogViewer, ErrorPage, Progress, SidebarPinStateContext, Content, HeaderLabel, Header, Page, ItemCardGrid, ItemCardHeader, Button as Button$1, WarningPanel, CodeSnippet, SubvalueCell, Table, EmptyState, PageWithHeader, ContentHeader, SupportButton, MissingAnnotationEmptyState } from '@backstage/core-components';
7
6
  import { techdocsStorageApiRef as techdocsStorageApiRef$1, useTechDocsReaderPage, useTechDocsAddons, TechDocsAddonLocations, TECHDOCS_ADDONS_WRAPPER_KEY, TechDocsReaderPageProvider, techdocsApiRef as techdocsApiRef$1 } from '@backstage/plugin-techdocs-react';
7
+ import useAsync from 'react-use/lib/useAsync';
8
+ import useAsyncRetry from 'react-use/lib/useAsyncRetry';
9
+ import { Link, LogViewer, ErrorPage, Progress, SidebarPinStateContext, Content, HeaderLabel, Header, Page, ItemCardGrid, ItemCardHeader, Button as Button$1, WarningPanel, CodeSnippet, SubvalueCell, Table, EmptyState, PageWithHeader, ContentHeader, SupportButton, MissingAnnotationEmptyState } from '@backstage/core-components';
8
10
  import { create } from 'jss';
9
- import { makeStyles, ListItemText, ListItem, Divider, TextField, InputAdornment, IconButton, CircularProgress, createStyles, Button, Drawer, Grid, Typography, withStyles, Tooltip, ThemeProvider, SvgIcon, useTheme, Portal, Toolbar, Box, Card, CardMedia, CardContent, CardActions } from '@material-ui/core';
11
+ import { makeStyles, ListItemText, ListItem, Divider, TextField, InputAdornment, IconButton, CircularProgress, createStyles, Button, Drawer, Grid, Typography, withStyles, Tooltip, ThemeProvider, SvgIcon, useTheme, Portal, Toolbar, Box, Menu, Card, CardMedia, CardContent, CardActions } from '@material-ui/core';
10
12
  import { jssPreset, StylesProvider, withStyles as withStyles$1 } from '@material-ui/styles';
11
13
  import { HighlightedSearchResultText, SearchContextProvider, useSearch } from '@backstage/plugin-search-react';
12
14
  import SearchIcon from '@material-ui/icons/Search';
@@ -15,8 +17,6 @@ import { useNavigate, useOutlet as useOutlet$1 } from 'react-router';
15
17
  import useDebounce from 'react-use/lib/useDebounce';
16
18
  import { Alert, Skeleton } from '@material-ui/lab';
17
19
  import Close from '@material-ui/icons/Close';
18
- import useAsync from 'react-use/lib/useAsync';
19
- import useAsyncRetry from 'react-use/lib/useAsyncRetry';
20
20
  import { lighten, alpha } from '@material-ui/core/styles';
21
21
  import { scmIntegrationsApiRef } from '@backstage/integration-react';
22
22
  import { replaceGitHubUrlType } from '@backstage/integration';
@@ -29,6 +29,7 @@ import Helmet from 'react-helmet';
29
29
  import CodeIcon from '@material-ui/icons/Code';
30
30
  import { getEntityRelations, EntityRefLink, EntityRefLinks, useEntityList, humanizeEntityRef, useStarredEntities, CATALOG_FILTER_EXISTS, EntityListProvider, CatalogFilterLayout, UserListPicker, EntityOwnerPicker, EntityTagPicker, useEntity } from '@backstage/plugin-catalog-react';
31
31
  import { RELATION_OWNED_BY, getCompoundEntityRef } from '@backstage/catalog-model';
32
+ import SettingsIcon from '@material-ui/icons/Settings';
32
33
  import useCopyToClipboard from 'react-use/lib/useCopyToClipboard';
33
34
  import { capitalize } from 'lodash';
34
35
  import ShareIcon from '@material-ui/icons/Share';
@@ -152,6 +153,169 @@ class TechDocsStorageClient {
152
153
  }
153
154
  }
154
155
 
156
+ function calculateDisplayState({
157
+ contentLoading,
158
+ content,
159
+ activeSyncState
160
+ }) {
161
+ if (contentLoading) {
162
+ return "CHECKING";
163
+ }
164
+ if (activeSyncState === "BUILD_READY_RELOAD") {
165
+ return "CHECKING";
166
+ }
167
+ if (!content && activeSyncState === "CHECKING") {
168
+ return "CHECKING";
169
+ }
170
+ if (!content && activeSyncState === "BUILDING") {
171
+ return "INITIAL_BUILD";
172
+ }
173
+ if (!content) {
174
+ return "CONTENT_NOT_FOUND";
175
+ }
176
+ if (activeSyncState === "BUILDING") {
177
+ return "CONTENT_STALE_REFRESHING";
178
+ }
179
+ if (activeSyncState === "BUILD_READY") {
180
+ return "CONTENT_STALE_READY";
181
+ }
182
+ if (activeSyncState === "ERROR") {
183
+ return "CONTENT_STALE_ERROR";
184
+ }
185
+ return "CONTENT_FRESH";
186
+ }
187
+ function reducer(oldState, action) {
188
+ const newState = { ...oldState };
189
+ switch (action.type) {
190
+ case "sync":
191
+ if (action.state === "CHECKING") {
192
+ newState.buildLog = [];
193
+ }
194
+ newState.activeSyncState = action.state;
195
+ newState.syncError = action.syncError;
196
+ break;
197
+ case "contentLoading":
198
+ newState.contentLoading = true;
199
+ newState.contentError = void 0;
200
+ break;
201
+ case "content":
202
+ if (typeof action.path === "string") {
203
+ newState.path = action.path;
204
+ }
205
+ newState.contentLoading = false;
206
+ newState.content = action.content;
207
+ newState.contentError = action.contentError;
208
+ break;
209
+ case "buildLog":
210
+ newState.buildLog = newState.buildLog.concat(action.log);
211
+ break;
212
+ default:
213
+ throw new Error();
214
+ }
215
+ if (["BUILD_READY", "BUILD_READY_RELOAD"].includes(newState.activeSyncState) && ["contentLoading", "content"].includes(action.type)) {
216
+ newState.activeSyncState = "UP_TO_DATE";
217
+ newState.buildLog = [];
218
+ }
219
+ return newState;
220
+ }
221
+ function useReaderState(kind, namespace, name, path) {
222
+ var _a, _b;
223
+ const [state, dispatch] = useReducer(reducer, {
224
+ activeSyncState: "CHECKING",
225
+ path,
226
+ contentLoading: true,
227
+ buildLog: []
228
+ });
229
+ const techdocsStorageApi = useApi(techdocsStorageApiRef$1);
230
+ const { retry: contentReload } = useAsyncRetry(async () => {
231
+ dispatch({ type: "contentLoading" });
232
+ try {
233
+ const entityDocs = await techdocsStorageApi.getEntityDocs({ kind, namespace, name }, path);
234
+ dispatch({ type: "content", content: entityDocs, path });
235
+ return entityDocs;
236
+ } catch (e) {
237
+ dispatch({ type: "content", contentError: e, path });
238
+ }
239
+ return void 0;
240
+ }, [techdocsStorageApi, kind, namespace, name, path]);
241
+ const contentRef = useRef({
242
+ content: void 0,
243
+ reload: () => {
244
+ }
245
+ });
246
+ contentRef.current = { content: state.content, reload: contentReload };
247
+ useAsync(async () => {
248
+ dispatch({ type: "sync", state: "CHECKING" });
249
+ const buildingTimeout = setTimeout(() => {
250
+ dispatch({ type: "sync", state: "BUILDING" });
251
+ }, 1e3);
252
+ try {
253
+ const result = await techdocsStorageApi.syncEntityDocs({
254
+ kind,
255
+ namespace,
256
+ name
257
+ }, (log) => {
258
+ dispatch({ type: "buildLog", log });
259
+ });
260
+ switch (result) {
261
+ case "updated":
262
+ if (!contentRef.current.content) {
263
+ contentRef.current.reload();
264
+ dispatch({ type: "sync", state: "BUILD_READY_RELOAD" });
265
+ } else {
266
+ dispatch({ type: "sync", state: "BUILD_READY" });
267
+ }
268
+ break;
269
+ case "cached":
270
+ dispatch({ type: "sync", state: "UP_TO_DATE" });
271
+ break;
272
+ default:
273
+ dispatch({
274
+ type: "sync",
275
+ state: "ERROR",
276
+ syncError: new Error("Unexpected return state")
277
+ });
278
+ break;
279
+ }
280
+ } catch (e) {
281
+ dispatch({ type: "sync", state: "ERROR", syncError: e });
282
+ } finally {
283
+ clearTimeout(buildingTimeout);
284
+ }
285
+ }, [kind, name, namespace, techdocsStorageApi, dispatch, contentRef]);
286
+ const displayState = useMemo(() => calculateDisplayState({
287
+ activeSyncState: state.activeSyncState,
288
+ contentLoading: state.contentLoading,
289
+ content: state.content
290
+ }), [state.activeSyncState, state.content, state.contentLoading]);
291
+ return {
292
+ state: displayState,
293
+ contentReload,
294
+ path: state.path,
295
+ content: state.content,
296
+ contentErrorMessage: (_a = state.contentError) == null ? void 0 : _a.toString(),
297
+ syncErrorMessage: (_b = state.syncError) == null ? void 0 : _b.toString(),
298
+ buildLog: state.buildLog
299
+ };
300
+ }
301
+
302
+ const TechDocsReaderContext = createContext({});
303
+ const useTechDocsReader = () => useContext(TechDocsReaderContext);
304
+ const TechDocsReaderProvider = ({
305
+ children
306
+ }) => {
307
+ const { "*": path = "" } = useParams();
308
+ const { entityRef } = useTechDocsReaderPage();
309
+ const { kind, namespace, name } = entityRef;
310
+ const value = useReaderState(kind, namespace, name, path);
311
+ return /* @__PURE__ */ React.createElement(TechDocsReaderContext.Provider, {
312
+ value
313
+ }, children instanceof Function ? children(value) : children);
314
+ };
315
+ const withTechDocsReaderProvider = (Component) => (props) => /* @__PURE__ */ React.createElement(TechDocsReaderProvider, null, /* @__PURE__ */ React.createElement(Component, {
316
+ ...props
317
+ }));
318
+
155
319
  const useStyles$4 = makeStyles({
156
320
  flexContainer: {
157
321
  flexWrap: "wrap"
@@ -498,169 +662,6 @@ const TechDocsStateIndicator = () => {
498
662
  return /* @__PURE__ */ React.createElement(React.Fragment, null, ReaderProgress, StateAlert);
499
663
  };
500
664
 
501
- function calculateDisplayState({
502
- contentLoading,
503
- content,
504
- activeSyncState
505
- }) {
506
- if (contentLoading) {
507
- return "CHECKING";
508
- }
509
- if (activeSyncState === "BUILD_READY_RELOAD") {
510
- return "CHECKING";
511
- }
512
- if (!content && activeSyncState === "CHECKING") {
513
- return "CHECKING";
514
- }
515
- if (!content && activeSyncState === "BUILDING") {
516
- return "INITIAL_BUILD";
517
- }
518
- if (!content) {
519
- return "CONTENT_NOT_FOUND";
520
- }
521
- if (activeSyncState === "BUILDING") {
522
- return "CONTENT_STALE_REFRESHING";
523
- }
524
- if (activeSyncState === "BUILD_READY") {
525
- return "CONTENT_STALE_READY";
526
- }
527
- if (activeSyncState === "ERROR") {
528
- return "CONTENT_STALE_ERROR";
529
- }
530
- return "CONTENT_FRESH";
531
- }
532
- function reducer(oldState, action) {
533
- const newState = { ...oldState };
534
- switch (action.type) {
535
- case "sync":
536
- if (action.state === "CHECKING") {
537
- newState.buildLog = [];
538
- }
539
- newState.activeSyncState = action.state;
540
- newState.syncError = action.syncError;
541
- break;
542
- case "contentLoading":
543
- newState.contentLoading = true;
544
- newState.contentError = void 0;
545
- break;
546
- case "content":
547
- if (typeof action.path === "string") {
548
- newState.path = action.path;
549
- }
550
- newState.contentLoading = false;
551
- newState.content = action.content;
552
- newState.contentError = action.contentError;
553
- break;
554
- case "buildLog":
555
- newState.buildLog = newState.buildLog.concat(action.log);
556
- break;
557
- default:
558
- throw new Error();
559
- }
560
- if (["BUILD_READY", "BUILD_READY_RELOAD"].includes(newState.activeSyncState) && ["contentLoading", "content"].includes(action.type)) {
561
- newState.activeSyncState = "UP_TO_DATE";
562
- newState.buildLog = [];
563
- }
564
- return newState;
565
- }
566
- function useReaderState(kind, namespace, name, path) {
567
- var _a, _b;
568
- const [state, dispatch] = useReducer(reducer, {
569
- activeSyncState: "CHECKING",
570
- path,
571
- contentLoading: true,
572
- buildLog: []
573
- });
574
- const techdocsStorageApi = useApi(techdocsStorageApiRef$1);
575
- const { retry: contentReload } = useAsyncRetry(async () => {
576
- dispatch({ type: "contentLoading" });
577
- try {
578
- const entityDocs = await techdocsStorageApi.getEntityDocs({ kind, namespace, name }, path);
579
- dispatch({ type: "content", content: entityDocs, path });
580
- return entityDocs;
581
- } catch (e) {
582
- dispatch({ type: "content", contentError: e, path });
583
- }
584
- return void 0;
585
- }, [techdocsStorageApi, kind, namespace, name, path]);
586
- const contentRef = useRef({
587
- content: void 0,
588
- reload: () => {
589
- }
590
- });
591
- contentRef.current = { content: state.content, reload: contentReload };
592
- useAsync(async () => {
593
- dispatch({ type: "sync", state: "CHECKING" });
594
- const buildingTimeout = setTimeout(() => {
595
- dispatch({ type: "sync", state: "BUILDING" });
596
- }, 1e3);
597
- try {
598
- const result = await techdocsStorageApi.syncEntityDocs({
599
- kind,
600
- namespace,
601
- name
602
- }, (log) => {
603
- dispatch({ type: "buildLog", log });
604
- });
605
- switch (result) {
606
- case "updated":
607
- if (!contentRef.current.content) {
608
- contentRef.current.reload();
609
- dispatch({ type: "sync", state: "BUILD_READY_RELOAD" });
610
- } else {
611
- dispatch({ type: "sync", state: "BUILD_READY" });
612
- }
613
- break;
614
- case "cached":
615
- dispatch({ type: "sync", state: "UP_TO_DATE" });
616
- break;
617
- default:
618
- dispatch({
619
- type: "sync",
620
- state: "ERROR",
621
- syncError: new Error("Unexpected return state")
622
- });
623
- break;
624
- }
625
- } catch (e) {
626
- dispatch({ type: "sync", state: "ERROR", syncError: e });
627
- } finally {
628
- clearTimeout(buildingTimeout);
629
- }
630
- }, [kind, name, namespace, techdocsStorageApi, dispatch, contentRef]);
631
- const displayState = useMemo(() => calculateDisplayState({
632
- activeSyncState: state.activeSyncState,
633
- contentLoading: state.contentLoading,
634
- content: state.content
635
- }), [state.activeSyncState, state.content, state.contentLoading]);
636
- return {
637
- state: displayState,
638
- contentReload,
639
- path: state.path,
640
- content: state.content,
641
- contentErrorMessage: (_a = state.contentError) == null ? void 0 : _a.toString(),
642
- syncErrorMessage: (_b = state.syncError) == null ? void 0 : _b.toString(),
643
- buildLog: state.buildLog
644
- };
645
- }
646
-
647
- const TechDocsReaderContext = createContext({});
648
- const useTechDocsReader = () => useContext(TechDocsReaderContext);
649
- const TechDocsReaderProvider = ({
650
- children
651
- }) => {
652
- const { "*": path = "" } = useParams();
653
- const { entityRef } = useTechDocsReaderPage();
654
- const { kind, namespace, name } = entityRef;
655
- const value = useReaderState(kind, namespace, name, path);
656
- return /* @__PURE__ */ React.createElement(TechDocsReaderContext.Provider, {
657
- value
658
- }, children instanceof Function ? children(value) : children);
659
- };
660
- const withTechDocsReaderProvider = (Component) => (props) => /* @__PURE__ */ React.createElement(TechDocsReaderProvider, null, /* @__PURE__ */ React.createElement(Component, {
661
- ...props
662
- }));
663
-
664
665
  const isSvgNeedingInlining = (attrName, attrVal, apiOrigin) => {
665
666
  const isSrcToSvg = attrName === "src" && attrVal.endsWith(".svg");
666
667
  const isRelativeUrl = !attrVal.match(/^([a-z]*:)?\/\//i);
@@ -1805,24 +1806,46 @@ const TechDocsReaderPageSubheader = ({
1805
1806
  toolbarProps
1806
1807
  }) => {
1807
1808
  const classes = useStyles();
1809
+ const [anchorEl, setAnchorEl] = useState(null);
1810
+ const handleClick = useCallback((event) => {
1811
+ setAnchorEl(event.currentTarget);
1812
+ }, []);
1813
+ const handleClose = useCallback(() => {
1814
+ setAnchorEl(null);
1815
+ }, []);
1808
1816
  const {
1809
1817
  entityMetadata: { value: entityMetadata, loading: entityMetadataLoading }
1810
1818
  } = useTechDocsReaderPage();
1811
1819
  const addons = useTechDocsAddons();
1812
1820
  const subheaderAddons = addons.renderComponentsByLocation(TechDocsAddonLocations.Subheader);
1813
- if (!subheaderAddons)
1821
+ const settingsAddons = addons.renderComponentsByLocation(TechDocsAddonLocations.Settings);
1822
+ if (!subheaderAddons && !settingsAddons)
1814
1823
  return null;
1815
1824
  if (entityMetadataLoading === false && !entityMetadata)
1816
1825
  return null;
1817
1826
  return /* @__PURE__ */ React.createElement(Toolbar, {
1818
1827
  classes,
1819
1828
  ...toolbarProps
1820
- }, subheaderAddons && /* @__PURE__ */ React.createElement(Box, {
1829
+ }, /* @__PURE__ */ React.createElement(Box, {
1821
1830
  display: "flex",
1822
1831
  justifyContent: "flex-end",
1823
1832
  width: "100%",
1824
1833
  flexWrap: "wrap"
1825
- }, subheaderAddons));
1834
+ }, subheaderAddons, settingsAddons ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Tooltip, {
1835
+ title: "Settings"
1836
+ }, /* @__PURE__ */ React.createElement(IconButton, {
1837
+ "aria-controls": "tech-docs-reader-page-settings",
1838
+ "aria-haspopup": "true",
1839
+ onClick: handleClick
1840
+ }, /* @__PURE__ */ React.createElement(SettingsIcon, null))), /* @__PURE__ */ React.createElement(Menu, {
1841
+ id: "tech-docs-reader-page-settings",
1842
+ getContentAnchorEl: null,
1843
+ anchorEl,
1844
+ anchorOrigin: { vertical: "bottom", horizontal: "right" },
1845
+ open: Boolean(anchorEl),
1846
+ onClose: handleClose,
1847
+ keepMounted: true
1848
+ }, settingsAddons)) : null));
1826
1849
  };
1827
1850
 
1828
1851
  const TechDocsReaderLayout = ({
@@ -2159,7 +2182,7 @@ const EntityTechdocsContent = techdocsPlugin.provide(createRoutableExtension({
2159
2182
  }));
2160
2183
  const TechDocsCustomHome = techdocsPlugin.provide(createRoutableExtension({
2161
2184
  name: "TechDocsCustomHome",
2162
- component: () => import('./TechDocsCustomHome-968d179e.esm.js').then((m) => m.TechDocsCustomHome),
2185
+ component: () => import('./TechDocsCustomHome-2bf696bf.esm.js').then((m) => m.TechDocsCustomHome),
2163
2186
  mountPoint: rootRouteRef
2164
2187
  }));
2165
2188
  const TechDocsIndexPage$2 = techdocsPlugin.provide(createRoutableExtension({
@@ -2169,7 +2192,7 @@ const TechDocsIndexPage$2 = techdocsPlugin.provide(createRoutableExtension({
2169
2192
  }));
2170
2193
  const TechDocsReaderPage = techdocsPlugin.provide(createRoutableExtension({
2171
2194
  name: "TechDocsReaderPage",
2172
- component: () => import('./index-9f90aba8.esm.js').then((m) => m.TechDocsReaderPage),
2195
+ component: () => import('./index-88da5adb.esm.js').then((m) => m.TechDocsReaderPage),
2173
2196
  mountPoint: rootDocsRouteRef
2174
2197
  }));
2175
2198
 
@@ -2230,5 +2253,5 @@ var Router$1 = /*#__PURE__*/Object.freeze({
2230
2253
  EmbeddedDocsRouter: EmbeddedDocsRouter
2231
2254
  });
2232
2255
 
2233
- export { isTechDocsAvailable as A, Router as B, EmbeddedDocsRouter as C, DocsTable as D, EntityTechdocsContent as E, Reader as R, TechDocsPageWrapper as T, DocsCardGrid as a, TechDocsReaderPage$1 as b, TechDocsReaderLayout as c, TechDocsCustomHome as d, TechDocsIndexPage$2 as e, TechdocsPage as f, TechDocsReaderPage as g, techdocsStorageApiRef as h, techdocsApiRef as i, TechDocsClient as j, TechDocsStorageClient as k, TechDocsReaderPageHeader as l, TechDocsReaderPageContent as m, TechDocsReaderProvider as n, useTechDocsReaderDom as o, TechDocsReaderPageSubheader as p, TechDocsStateIndicator as q, TechDocsSearchResultListItem as r, TechDocsSearch as s, techdocsPlugin as t, useTechDocsReader as u, EntityListDocsGrid as v, withTechDocsReaderProvider as w, EntityListDocsTable as x, DefaultTechDocsHome as y, TechDocsPicker as z };
2234
- //# sourceMappingURL=index-913b47d9.esm.js.map
2256
+ export { DocsTable as D, EntityTechdocsContent as E, Reader as R, TechDocsPageWrapper as T, DocsCardGrid as a, TechDocsReaderPage$1 as b, TechDocsReaderLayout as c, TechDocsCustomHome as d, TechDocsIndexPage$2 as e, TechdocsPage as f, TechDocsReaderPage as g, techdocsStorageApiRef as h, techdocsApiRef as i, TechDocsClient as j, TechDocsStorageClient as k, TechDocsReaderProvider as l, TechDocsReaderPageHeader as m, TechDocsReaderPageContent as n, TechDocsReaderPageSubheader as o, TechDocsSearchResultListItem as p, TechDocsSearch as q, EntityListDocsGrid as r, EntityListDocsTable as s, techdocsPlugin as t, DefaultTechDocsHome as u, TechDocsPicker as v, isTechDocsAvailable as w, Router as x, EmbeddedDocsRouter as y };
2257
+ //# sourceMappingURL=index-6c048069.esm.js.map