@backstage/plugin-techdocs 0.12.0 → 0.12.4
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 +66 -0
- package/dist/index.d.ts +26 -24
- package/dist/index.esm.js +450 -370
- package/dist/index.esm.js.map +1 -1
- package/package.json +18 -18
package/dist/index.esm.js
CHANGED
|
@@ -2,30 +2,30 @@ import { createApiRef, createRouteRef, useRouteRef, useApi, configApiRef, create
|
|
|
2
2
|
import { ResponseError, NotFoundError } from '@backstage/errors';
|
|
3
3
|
import { EventSourcePolyfill } from 'event-source-polyfill';
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import React__default, { useEffect, useState, useReducer, useRef, useMemo, useCallback } from 'react';
|
|
5
|
+
import React__default, { useEffect, useState, useReducer, useRef, useMemo, useContext, createContext, useCallback } from 'react';
|
|
6
|
+
import { makeStyles, ListItemText, ListItem, Divider, Card, CardMedia, CardContent, CardActions, Grid, TextField, InputAdornment, IconButton, CircularProgress, createStyles, Button as Button$1, Drawer, Typography, useTheme } from '@material-ui/core';
|
|
7
|
+
import { Link, SubvalueCell, Table, EmptyState, Button, WarningPanel, CodeSnippet, PageWithHeader, Content, ContentHeader, SupportButton, ItemCardGrid, ItemCardHeader, Progress, ErrorPage, HeaderLabel, Header, Page, HeaderTabs, MissingAnnotationEmptyState } from '@backstage/core-components';
|
|
8
|
+
import TextTruncate from 'react-text-truncate';
|
|
9
|
+
import { FilteredEntityLayout, FilterContainer, EntityListContainer } from '@backstage/plugin-catalog';
|
|
10
|
+
import { favoriteEntityIcon, favoriteEntityTooltip, EntityRefLinks, getEntityRelations, formatEntityRefTitle, useEntityListProvider, useStarredEntities, CATALOG_FILTER_EXISTS, EntityListProvider, UserListPicker, EntityOwnerPicker, EntityTagPicker, EntityRefLink, catalogApiRef, useOwnUser, isOwnerOf, useEntity } from '@backstage/plugin-catalog-react';
|
|
6
11
|
import { useCopyToClipboard, useDebounce, useAsyncRetry, useAsync } from 'react-use';
|
|
7
12
|
import { capitalize } from 'lodash';
|
|
8
|
-
import { SubvalueCell, Link, Table, EmptyState, Button, WarningPanel, CodeSnippet, PageWithHeader, Content, ContentHeader, SupportButton, ErrorPage, Progress, HeaderLabel, Header, Page, ItemCardGrid, ItemCardHeader, HeaderTabs, MissingAnnotationEmptyState } from '@backstage/core-components';
|
|
9
|
-
import { favoriteEntityIcon, favoriteEntityTooltip, EntityRefLinks, getEntityRelations, formatEntityRefTitle, useEntityListProvider, useStarredEntities, CATALOG_FILTER_EXISTS, EntityListProvider, UserListPicker, EntityOwnerPicker, EntityTagPicker, EntityRefLink, catalogApiRef, useOwnUser, isOwnerOf, useEntity } from '@backstage/plugin-catalog-react';
|
|
10
13
|
import { RELATION_OWNED_BY } from '@backstage/catalog-model';
|
|
11
14
|
import ShareIcon from '@material-ui/icons/Share';
|
|
12
|
-
import {
|
|
13
|
-
import { makeStyles, ListItemText, ListItem, Divider, createStyles, Button as Button$1, Drawer, Grid, Typography, IconButton, TextField, InputAdornment, CircularProgress, useTheme, Card, CardMedia, CardContent, CardActions } from '@material-ui/core';
|
|
14
|
-
import TextTruncate from 'react-text-truncate';
|
|
15
|
+
import { useNavigate as useNavigate$1, useParams, Routes, Route } from 'react-router-dom';
|
|
15
16
|
import { scmIntegrationsApiRef } from '@backstage/integration-react';
|
|
16
|
-
import { Alert } from '@material-ui/lab';
|
|
17
|
-
import { useParams, useNavigate as useNavigate$1, Routes, Route } from 'react-router-dom';
|
|
18
17
|
import { replaceGitHubUrlType } from '@backstage/integration';
|
|
19
18
|
import FeedbackOutlinedIcon from '@material-ui/icons/FeedbackOutlined';
|
|
20
19
|
import ReactDOM from 'react-dom';
|
|
21
20
|
import parseGitUrl from 'git-url-parse';
|
|
22
21
|
import DOMPurify from 'dompurify';
|
|
23
|
-
import Close from '@material-ui/icons/Close';
|
|
24
|
-
import { LazyLog } from 'react-lazylog';
|
|
25
|
-
import Autocomplete from '@material-ui/lab/Autocomplete';
|
|
26
22
|
import { SearchContextProvider, useSearch } from '@backstage/plugin-search';
|
|
27
23
|
import SearchIcon from '@material-ui/icons/Search';
|
|
24
|
+
import Autocomplete from '@material-ui/lab/Autocomplete';
|
|
28
25
|
import { useNavigate, useOutlet } from 'react-router';
|
|
26
|
+
import { Alert } from '@material-ui/lab';
|
|
27
|
+
import Close from '@material-ui/icons/Close';
|
|
28
|
+
import { LazyLog } from 'react-lazylog';
|
|
29
29
|
import CodeIcon from '@material-ui/icons/Code';
|
|
30
30
|
|
|
31
31
|
const techdocsStorageApiRef = createApiRef({
|
|
@@ -164,6 +164,49 @@ class TechDocsStorageClient {
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
const useStyles$2 = makeStyles({
|
|
168
|
+
flexContainer: {
|
|
169
|
+
flexWrap: "wrap"
|
|
170
|
+
},
|
|
171
|
+
itemText: {
|
|
172
|
+
width: "100%",
|
|
173
|
+
marginBottom: "1rem"
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
const DocsResultListItem = ({
|
|
177
|
+
result,
|
|
178
|
+
lineClamp = 5,
|
|
179
|
+
asListItem = true,
|
|
180
|
+
asLink = true,
|
|
181
|
+
title
|
|
182
|
+
}) => {
|
|
183
|
+
const classes = useStyles$2();
|
|
184
|
+
const TextItem = () => {
|
|
185
|
+
var _a;
|
|
186
|
+
return /* @__PURE__ */ React__default.createElement(ListItemText, {
|
|
187
|
+
className: classes.itemText,
|
|
188
|
+
primaryTypographyProps: {variant: "h6"},
|
|
189
|
+
primary: title ? title : `${result.title} | ${(_a = result.entityTitle) != null ? _a : result.name} docs`,
|
|
190
|
+
secondary: /* @__PURE__ */ React__default.createElement(TextTruncate, {
|
|
191
|
+
line: lineClamp,
|
|
192
|
+
truncateText: "\u2026",
|
|
193
|
+
text: result.text,
|
|
194
|
+
element: "span"
|
|
195
|
+
})
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
const LinkWrapper = ({children}) => asLink ? /* @__PURE__ */ React__default.createElement(Link, {
|
|
199
|
+
to: result.location
|
|
200
|
+
}, children) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children);
|
|
201
|
+
const ListItemWrapper = ({children}) => asListItem ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(ListItem, {
|
|
202
|
+
alignItems: "flex-start",
|
|
203
|
+
className: classes.flexContainer
|
|
204
|
+
}, children), /* @__PURE__ */ React__default.createElement(Divider, {
|
|
205
|
+
component: "li"
|
|
206
|
+
})) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children);
|
|
207
|
+
return /* @__PURE__ */ React__default.createElement(LinkWrapper, null, /* @__PURE__ */ React__default.createElement(ListItemWrapper, null, /* @__PURE__ */ React__default.createElement(TextItem, null)));
|
|
208
|
+
};
|
|
209
|
+
|
|
167
210
|
const rootRouteRef = createRouteRef({
|
|
168
211
|
id: "techdocs-index-page",
|
|
169
212
|
title: "TechDocs Landing Page"
|
|
@@ -388,44 +431,59 @@ const DefaultTechDocsHome = ({
|
|
|
388
431
|
}))))));
|
|
389
432
|
};
|
|
390
433
|
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
flexWrap: "wrap"
|
|
394
|
-
},
|
|
395
|
-
itemText: {
|
|
396
|
-
width: "100%",
|
|
397
|
-
marginBottom: "1rem"
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
const DocsResultListItem = ({
|
|
401
|
-
result,
|
|
402
|
-
lineClamp = 5,
|
|
403
|
-
asListItem = true,
|
|
404
|
-
asLink = true,
|
|
405
|
-
title
|
|
434
|
+
const DocsCardGrid$1 = ({
|
|
435
|
+
entities
|
|
406
436
|
}) => {
|
|
407
|
-
const
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}
|
|
437
|
+
const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);
|
|
438
|
+
const toLowerMaybe = useApi(configApiRef).getOptionalBoolean("techdocs.legacyUseCaseSensitiveTripletPaths") ? (str) => str : (str) => str.toLocaleLowerCase();
|
|
439
|
+
if (!entities)
|
|
440
|
+
return null;
|
|
441
|
+
return /* @__PURE__ */ React__default.createElement(ItemCardGrid, {
|
|
442
|
+
"data-testid": "docs-explore"
|
|
443
|
+
}, !(entities == null ? void 0 : entities.length) ? null : entities.map((entity, index) => {
|
|
444
|
+
var _a, _b;
|
|
445
|
+
return /* @__PURE__ */ React__default.createElement(Card, {
|
|
446
|
+
key: index
|
|
447
|
+
}, /* @__PURE__ */ React__default.createElement(CardMedia, null, /* @__PURE__ */ React__default.createElement(ItemCardHeader, {
|
|
448
|
+
title: (_a = entity.metadata.title) != null ? _a : entity.metadata.name
|
|
449
|
+
})), /* @__PURE__ */ React__default.createElement(CardContent, null, entity.metadata.description), /* @__PURE__ */ React__default.createElement(CardActions, null, /* @__PURE__ */ React__default.createElement(Button, {
|
|
450
|
+
to: getRouteToReaderPageFor({
|
|
451
|
+
namespace: toLowerMaybe((_b = entity.metadata.namespace) != null ? _b : "default"),
|
|
452
|
+
kind: toLowerMaybe(entity.kind),
|
|
453
|
+
name: toLowerMaybe(entity.metadata.name)
|
|
454
|
+
}),
|
|
455
|
+
color: "primary",
|
|
456
|
+
"data-testid": "read_docs"
|
|
457
|
+
}, "Read Docs")));
|
|
458
|
+
}));
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
var DocsCardGrid$2 = /*#__PURE__*/Object.freeze({
|
|
462
|
+
__proto__: null,
|
|
463
|
+
DocsCardGrid: DocsCardGrid$1
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
const EntityListDocsGrid = () => {
|
|
467
|
+
const {loading, error, entities} = useEntityListProvider();
|
|
468
|
+
if (error) {
|
|
469
|
+
return /* @__PURE__ */ React__default.createElement(WarningPanel, {
|
|
470
|
+
severity: "error",
|
|
471
|
+
title: "Could not load available documentation."
|
|
472
|
+
}, /* @__PURE__ */ React__default.createElement(CodeSnippet, {
|
|
473
|
+
language: "text",
|
|
474
|
+
text: error.toString()
|
|
475
|
+
}));
|
|
476
|
+
}
|
|
477
|
+
if (loading || !entities) {
|
|
478
|
+
return /* @__PURE__ */ React__default.createElement(Progress, null);
|
|
479
|
+
}
|
|
480
|
+
entities.sort((a, b) => {
|
|
481
|
+
var _a, _b;
|
|
482
|
+
return ((_a = a.metadata.title) != null ? _a : a.metadata.name).localeCompare((_b = b.metadata.title) != null ? _b : b.metadata.name);
|
|
483
|
+
});
|
|
484
|
+
return /* @__PURE__ */ React__default.createElement(DocsCardGrid$1, {
|
|
485
|
+
entities
|
|
418
486
|
});
|
|
419
|
-
const LinkWrapper = ({children}) => asLink ? /* @__PURE__ */ React__default.createElement(Link, {
|
|
420
|
-
to: result.location
|
|
421
|
-
}, children) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children);
|
|
422
|
-
const ListItemWrapper = ({children}) => asListItem ? /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(ListItem, {
|
|
423
|
-
alignItems: "flex-start",
|
|
424
|
-
className: classes.flexContainer
|
|
425
|
-
}, children), /* @__PURE__ */ React__default.createElement(Divider, {
|
|
426
|
-
component: "li"
|
|
427
|
-
})) : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, children);
|
|
428
|
-
return /* @__PURE__ */ React__default.createElement(LinkWrapper, null, /* @__PURE__ */ React__default.createElement(ListItemWrapper, null, /* @__PURE__ */ React__default.createElement(TextItem, null)));
|
|
429
487
|
};
|
|
430
488
|
|
|
431
489
|
const techdocsPlugin = createPlugin({
|
|
@@ -465,32 +523,39 @@ const techdocsPlugin = createPlugin({
|
|
|
465
523
|
}
|
|
466
524
|
});
|
|
467
525
|
const TechdocsPage = techdocsPlugin.provide(createRoutableExtension({
|
|
526
|
+
name: "TechdocsPage",
|
|
468
527
|
component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.Router),
|
|
469
528
|
mountPoint: rootRouteRef
|
|
470
529
|
}));
|
|
471
530
|
const EntityTechdocsContent = techdocsPlugin.provide(createRoutableExtension({
|
|
531
|
+
name: "EntityTechdocsContent",
|
|
472
532
|
component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.EmbeddedDocsRouter),
|
|
473
533
|
mountPoint: rootCatalogDocsRouteRef
|
|
474
534
|
}));
|
|
475
|
-
const DocsCardGrid
|
|
535
|
+
const DocsCardGrid = techdocsPlugin.provide(createComponentExtension({
|
|
536
|
+
name: "DocsCardGrid",
|
|
476
537
|
component: {
|
|
477
|
-
lazy: () => Promise.resolve().then(function () { return DocsCardGrid$
|
|
538
|
+
lazy: () => Promise.resolve().then(function () { return DocsCardGrid$2; }).then((m) => m.DocsCardGrid)
|
|
478
539
|
}
|
|
479
540
|
}));
|
|
480
541
|
const DocsTable = techdocsPlugin.provide(createComponentExtension({
|
|
542
|
+
name: "DocsTable",
|
|
481
543
|
component: {
|
|
482
544
|
lazy: () => Promise.resolve().then(function () { return DocsTable$2; }).then((m) => m.DocsTable)
|
|
483
545
|
}
|
|
484
546
|
}));
|
|
485
547
|
const TechDocsCustomHome$2 = techdocsPlugin.provide(createRoutableExtension({
|
|
548
|
+
name: "TechDocsCustomHome",
|
|
486
549
|
component: () => Promise.resolve().then(function () { return TechDocsCustomHome$1; }).then((m) => m.TechDocsCustomHome),
|
|
487
550
|
mountPoint: rootRouteRef
|
|
488
551
|
}));
|
|
489
552
|
const TechDocsIndexPage$2 = techdocsPlugin.provide(createRoutableExtension({
|
|
553
|
+
name: "TechDocsIndexPage",
|
|
490
554
|
component: () => Promise.resolve().then(function () { return TechDocsIndexPage$1; }).then((m) => m.TechDocsIndexPage),
|
|
491
555
|
mountPoint: rootRouteRef
|
|
492
556
|
}));
|
|
493
557
|
const TechDocsReaderPage = techdocsPlugin.provide(createRoutableExtension({
|
|
558
|
+
name: "TechDocsReaderPage",
|
|
494
559
|
component: () => Promise.resolve().then(function () { return TechDocsPage$1; }).then((m) => m.TechDocsPage),
|
|
495
560
|
mountPoint: rootDocsRouteRef
|
|
496
561
|
}));
|
|
@@ -707,6 +772,19 @@ const injectCss = ({css}) => {
|
|
|
707
772
|
};
|
|
708
773
|
};
|
|
709
774
|
|
|
775
|
+
const scrollIntoAnchor = () => {
|
|
776
|
+
return (dom) => {
|
|
777
|
+
setTimeout(() => {
|
|
778
|
+
var _a;
|
|
779
|
+
if (window.location.hash) {
|
|
780
|
+
const hash = window.location.hash.slice(1);
|
|
781
|
+
(_a = dom == null ? void 0 : dom.querySelector(`#${hash}`)) == null ? void 0 : _a.scrollIntoView();
|
|
782
|
+
}
|
|
783
|
+
}, 200);
|
|
784
|
+
return dom;
|
|
785
|
+
};
|
|
786
|
+
};
|
|
787
|
+
|
|
710
788
|
const transform = async (html, transformers) => {
|
|
711
789
|
let dom;
|
|
712
790
|
if (typeof html === "string") {
|
|
@@ -722,90 +800,6 @@ const transform = async (html, transformers) => {
|
|
|
722
800
|
return dom;
|
|
723
801
|
};
|
|
724
802
|
|
|
725
|
-
const useDrawerStyles = makeStyles((theme) => createStyles({
|
|
726
|
-
paper: {
|
|
727
|
-
width: "100%",
|
|
728
|
-
[theme.breakpoints.up("sm")]: {
|
|
729
|
-
width: "75%"
|
|
730
|
-
},
|
|
731
|
-
[theme.breakpoints.up("md")]: {
|
|
732
|
-
width: "50%"
|
|
733
|
-
},
|
|
734
|
-
padding: theme.spacing(2.5)
|
|
735
|
-
},
|
|
736
|
-
root: {
|
|
737
|
-
height: "100%",
|
|
738
|
-
overflow: "hidden"
|
|
739
|
-
}
|
|
740
|
-
}));
|
|
741
|
-
const TechDocsBuildLogsDrawerContent = ({
|
|
742
|
-
buildLog,
|
|
743
|
-
onClose
|
|
744
|
-
}) => {
|
|
745
|
-
const classes = useDrawerStyles();
|
|
746
|
-
return /* @__PURE__ */ React.createElement(Grid, {
|
|
747
|
-
container: true,
|
|
748
|
-
direction: "column",
|
|
749
|
-
className: classes.root,
|
|
750
|
-
spacing: 0,
|
|
751
|
-
wrap: "nowrap"
|
|
752
|
-
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
753
|
-
item: true,
|
|
754
|
-
container: true,
|
|
755
|
-
justifyContent: "space-between",
|
|
756
|
-
alignItems: "center",
|
|
757
|
-
spacing: 0,
|
|
758
|
-
wrap: "nowrap"
|
|
759
|
-
}, /* @__PURE__ */ React.createElement(Typography, {
|
|
760
|
-
variant: "h5"
|
|
761
|
-
}, "Build Details"), /* @__PURE__ */ React.createElement(IconButton, {
|
|
762
|
-
key: "dismiss",
|
|
763
|
-
title: "Close the drawer",
|
|
764
|
-
onClick: onClose,
|
|
765
|
-
color: "inherit"
|
|
766
|
-
}, /* @__PURE__ */ React.createElement(Close, null))), /* @__PURE__ */ React.createElement(LazyLog, {
|
|
767
|
-
text: buildLog.length === 0 ? "Waiting for logs..." : buildLog.join("\n"),
|
|
768
|
-
extraLines: 1,
|
|
769
|
-
follow: true,
|
|
770
|
-
selectableLines: true,
|
|
771
|
-
enableSearch: true
|
|
772
|
-
}));
|
|
773
|
-
};
|
|
774
|
-
const TechDocsBuildLogs = ({buildLog}) => {
|
|
775
|
-
const classes = useDrawerStyles();
|
|
776
|
-
const [open, setOpen] = useState(false);
|
|
777
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Button$1, {
|
|
778
|
-
color: "inherit",
|
|
779
|
-
onClick: () => setOpen(true)
|
|
780
|
-
}, "Show Build Logs"), /* @__PURE__ */ React.createElement(Drawer, {
|
|
781
|
-
classes: {paper: classes.paper},
|
|
782
|
-
anchor: "right",
|
|
783
|
-
open,
|
|
784
|
-
onClose: () => setOpen(false)
|
|
785
|
-
}, /* @__PURE__ */ React.createElement(TechDocsBuildLogsDrawerContent, {
|
|
786
|
-
buildLog,
|
|
787
|
-
onClose: () => setOpen(false)
|
|
788
|
-
})));
|
|
789
|
-
};
|
|
790
|
-
|
|
791
|
-
const TechDocsNotFound = ({errorMessage}) => {
|
|
792
|
-
const techdocsBuilder = useApi(configApiRef).getOptionalString("techdocs.builder");
|
|
793
|
-
let additionalInfo = "";
|
|
794
|
-
if (techdocsBuilder !== "local") {
|
|
795
|
-
additionalInfo = "Note that techdocs.builder is not set to 'local' in your config, which means this Backstage app will not generate docs if they are not found. Make sure the project's docs are generated and published by some external process (e.g. CI/CD pipeline). Or change techdocs.builder to 'local' to generate docs from this Backstage instance.";
|
|
796
|
-
}
|
|
797
|
-
return /* @__PURE__ */ React__default.createElement(ErrorPage, {
|
|
798
|
-
status: "404",
|
|
799
|
-
statusMessage: errorMessage || "Documentation not found",
|
|
800
|
-
additionalInfo
|
|
801
|
-
});
|
|
802
|
-
};
|
|
803
|
-
|
|
804
|
-
const buildInitialFilters = (legacyPaths, entityId) => {
|
|
805
|
-
return legacyPaths ? entityId : Object.entries(entityId).reduce((acc, [key, value]) => {
|
|
806
|
-
return {...acc, [key]: value.toLocaleLowerCase("en-US")};
|
|
807
|
-
}, {});
|
|
808
|
-
};
|
|
809
803
|
const TechDocsSearchBar = ({
|
|
810
804
|
entityId,
|
|
811
805
|
debounceTime = 150
|
|
@@ -897,13 +891,11 @@ const TechDocsSearchBar = ({
|
|
|
897
891
|
}));
|
|
898
892
|
};
|
|
899
893
|
const TechDocsSearch = (props) => {
|
|
900
|
-
const configApi = useApi(configApiRef);
|
|
901
|
-
const legacyPaths = configApi.getOptionalBoolean("techdocs.legacyUseCaseSensitiveTripletPaths");
|
|
902
894
|
const initialState = {
|
|
903
895
|
term: "",
|
|
904
896
|
types: ["techdocs"],
|
|
905
897
|
pageCursor: "",
|
|
906
|
-
filters:
|
|
898
|
+
filters: props.entityId
|
|
907
899
|
};
|
|
908
900
|
return /* @__PURE__ */ React__default.createElement(SearchContextProvider, {
|
|
909
901
|
initialState
|
|
@@ -912,6 +904,161 @@ const TechDocsSearch = (props) => {
|
|
|
912
904
|
}));
|
|
913
905
|
};
|
|
914
906
|
|
|
907
|
+
const useDrawerStyles = makeStyles((theme) => createStyles({
|
|
908
|
+
paper: {
|
|
909
|
+
width: "100%",
|
|
910
|
+
[theme.breakpoints.up("sm")]: {
|
|
911
|
+
width: "75%"
|
|
912
|
+
},
|
|
913
|
+
[theme.breakpoints.up("md")]: {
|
|
914
|
+
width: "50%"
|
|
915
|
+
},
|
|
916
|
+
padding: theme.spacing(2.5)
|
|
917
|
+
},
|
|
918
|
+
root: {
|
|
919
|
+
height: "100%",
|
|
920
|
+
overflow: "hidden"
|
|
921
|
+
}
|
|
922
|
+
}));
|
|
923
|
+
const TechDocsBuildLogsDrawerContent = ({
|
|
924
|
+
buildLog,
|
|
925
|
+
onClose
|
|
926
|
+
}) => {
|
|
927
|
+
const classes = useDrawerStyles();
|
|
928
|
+
return /* @__PURE__ */ React.createElement(Grid, {
|
|
929
|
+
container: true,
|
|
930
|
+
direction: "column",
|
|
931
|
+
className: classes.root,
|
|
932
|
+
spacing: 0,
|
|
933
|
+
wrap: "nowrap"
|
|
934
|
+
}, /* @__PURE__ */ React.createElement(Grid, {
|
|
935
|
+
item: true,
|
|
936
|
+
container: true,
|
|
937
|
+
justifyContent: "space-between",
|
|
938
|
+
alignItems: "center",
|
|
939
|
+
spacing: 0,
|
|
940
|
+
wrap: "nowrap"
|
|
941
|
+
}, /* @__PURE__ */ React.createElement(Typography, {
|
|
942
|
+
variant: "h5"
|
|
943
|
+
}, "Build Details"), /* @__PURE__ */ React.createElement(IconButton, {
|
|
944
|
+
key: "dismiss",
|
|
945
|
+
title: "Close the drawer",
|
|
946
|
+
onClick: onClose,
|
|
947
|
+
color: "inherit"
|
|
948
|
+
}, /* @__PURE__ */ React.createElement(Close, null))), /* @__PURE__ */ React.createElement(LazyLog, {
|
|
949
|
+
text: buildLog.length === 0 ? "Waiting for logs..." : buildLog.join("\n"),
|
|
950
|
+
extraLines: 1,
|
|
951
|
+
follow: true,
|
|
952
|
+
selectableLines: true,
|
|
953
|
+
enableSearch: true
|
|
954
|
+
}));
|
|
955
|
+
};
|
|
956
|
+
const TechDocsBuildLogs = ({buildLog}) => {
|
|
957
|
+
const classes = useDrawerStyles();
|
|
958
|
+
const [open, setOpen] = useState(false);
|
|
959
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Button$1, {
|
|
960
|
+
color: "inherit",
|
|
961
|
+
onClick: () => setOpen(true)
|
|
962
|
+
}, "Show Build Logs"), /* @__PURE__ */ React.createElement(Drawer, {
|
|
963
|
+
classes: {paper: classes.paper},
|
|
964
|
+
anchor: "right",
|
|
965
|
+
open,
|
|
966
|
+
onClose: () => setOpen(false)
|
|
967
|
+
}, /* @__PURE__ */ React.createElement(TechDocsBuildLogsDrawerContent, {
|
|
968
|
+
buildLog,
|
|
969
|
+
onClose: () => setOpen(false)
|
|
970
|
+
})));
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
const TechDocsNotFound = ({errorMessage}) => {
|
|
974
|
+
const techdocsBuilder = useApi(configApiRef).getOptionalString("techdocs.builder");
|
|
975
|
+
let additionalInfo = "";
|
|
976
|
+
if (techdocsBuilder !== "local") {
|
|
977
|
+
additionalInfo = "Note that techdocs.builder is not set to 'local' in your config, which means this Backstage app will not generate docs if they are not found. Make sure the project's docs are generated and published by some external process (e.g. CI/CD pipeline). Or change techdocs.builder to 'local' to generate docs from this Backstage instance.";
|
|
978
|
+
}
|
|
979
|
+
return /* @__PURE__ */ React__default.createElement(ErrorPage, {
|
|
980
|
+
status: "404",
|
|
981
|
+
statusMessage: errorMessage || "Documentation not found",
|
|
982
|
+
additionalInfo
|
|
983
|
+
});
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
const useStyles$1 = makeStyles(() => ({
|
|
987
|
+
message: {
|
|
988
|
+
wordBreak: "break-word",
|
|
989
|
+
overflowWrap: "anywhere"
|
|
990
|
+
}
|
|
991
|
+
}));
|
|
992
|
+
const TechDocsStateIndicator = () => {
|
|
993
|
+
let StateAlert = null;
|
|
994
|
+
const classes = useStyles$1();
|
|
995
|
+
const {
|
|
996
|
+
state,
|
|
997
|
+
contentReload,
|
|
998
|
+
contentErrorMessage,
|
|
999
|
+
syncErrorMessage,
|
|
1000
|
+
buildLog
|
|
1001
|
+
} = useTechDocsReader();
|
|
1002
|
+
const ReaderProgress = state === "CHECKING" ? /* @__PURE__ */ React__default.createElement(Progress, null) : null;
|
|
1003
|
+
if (state === "INITIAL_BUILD") {
|
|
1004
|
+
StateAlert = /* @__PURE__ */ React__default.createElement(Alert, {
|
|
1005
|
+
variant: "outlined",
|
|
1006
|
+
severity: "info",
|
|
1007
|
+
icon: /* @__PURE__ */ React__default.createElement(CircularProgress, {
|
|
1008
|
+
size: "24px"
|
|
1009
|
+
}),
|
|
1010
|
+
action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
|
|
1011
|
+
buildLog
|
|
1012
|
+
})
|
|
1013
|
+
}, "Documentation is accessed for the first time and is being prepared. The subsequent loads are much faster.");
|
|
1014
|
+
}
|
|
1015
|
+
if (state === "CONTENT_STALE_REFRESHING") {
|
|
1016
|
+
StateAlert = /* @__PURE__ */ React__default.createElement(Alert, {
|
|
1017
|
+
variant: "outlined",
|
|
1018
|
+
severity: "info",
|
|
1019
|
+
icon: /* @__PURE__ */ React__default.createElement(CircularProgress, {
|
|
1020
|
+
size: "24px"
|
|
1021
|
+
}),
|
|
1022
|
+
action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
|
|
1023
|
+
buildLog
|
|
1024
|
+
})
|
|
1025
|
+
}, "A newer version of this documentation is being prepared and will be available shortly.");
|
|
1026
|
+
}
|
|
1027
|
+
if (state === "CONTENT_STALE_READY") {
|
|
1028
|
+
StateAlert = /* @__PURE__ */ React__default.createElement(Alert, {
|
|
1029
|
+
variant: "outlined",
|
|
1030
|
+
severity: "success",
|
|
1031
|
+
action: /* @__PURE__ */ React__default.createElement(Button$1, {
|
|
1032
|
+
color: "inherit",
|
|
1033
|
+
onClick: () => contentReload()
|
|
1034
|
+
}, "Refresh")
|
|
1035
|
+
}, "A newer version of this documentation is now available, please refresh to view.");
|
|
1036
|
+
}
|
|
1037
|
+
if (state === "CONTENT_STALE_ERROR") {
|
|
1038
|
+
StateAlert = /* @__PURE__ */ React__default.createElement(Alert, {
|
|
1039
|
+
variant: "outlined",
|
|
1040
|
+
severity: "error",
|
|
1041
|
+
action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
|
|
1042
|
+
buildLog
|
|
1043
|
+
}),
|
|
1044
|
+
classes: {message: classes.message}
|
|
1045
|
+
}, "Building a newer version of this documentation failed.", " ", syncErrorMessage);
|
|
1046
|
+
}
|
|
1047
|
+
if (state === "CONTENT_NOT_FOUND") {
|
|
1048
|
+
StateAlert = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, syncErrorMessage && /* @__PURE__ */ React__default.createElement(Alert, {
|
|
1049
|
+
variant: "outlined",
|
|
1050
|
+
severity: "error",
|
|
1051
|
+
action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
|
|
1052
|
+
buildLog
|
|
1053
|
+
}),
|
|
1054
|
+
classes: {message: classes.message}
|
|
1055
|
+
}, "Building a newer version of this documentation failed.", " ", syncErrorMessage), /* @__PURE__ */ React__default.createElement(TechDocsNotFound, {
|
|
1056
|
+
errorMessage: contentErrorMessage
|
|
1057
|
+
}));
|
|
1058
|
+
}
|
|
1059
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, ReaderProgress, StateAlert);
|
|
1060
|
+
};
|
|
1061
|
+
|
|
915
1062
|
function calculateDisplayState({
|
|
916
1063
|
contentLoading,
|
|
917
1064
|
content,
|
|
@@ -1059,10 +1206,6 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
1059
1206
|
}
|
|
1060
1207
|
|
|
1061
1208
|
const useStyles = makeStyles((theme) => ({
|
|
1062
|
-
message: {
|
|
1063
|
-
wordBreak: "break-word",
|
|
1064
|
-
overflowWrap: "anywhere"
|
|
1065
|
-
},
|
|
1066
1209
|
searchBar: {
|
|
1067
1210
|
marginLeft: "20rem",
|
|
1068
1211
|
maxWidth: "calc(100% - 20rem * 2 - 3rem)",
|
|
@@ -1073,36 +1216,36 @@ const useStyles = makeStyles((theme) => ({
|
|
|
1073
1216
|
}
|
|
1074
1217
|
}
|
|
1075
1218
|
}));
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1078
|
-
const {kind,
|
|
1219
|
+
const TechDocsReaderContext = createContext({});
|
|
1220
|
+
const TechDocsReaderProvider = ({children}) => {
|
|
1221
|
+
const {namespace = "", kind = "", name = "", "*": path} = useParams();
|
|
1222
|
+
const value = useReaderState(kind, namespace, name, path);
|
|
1223
|
+
return /* @__PURE__ */ React__default.createElement(TechDocsReaderContext.Provider, {
|
|
1224
|
+
value
|
|
1225
|
+
}, children);
|
|
1226
|
+
};
|
|
1227
|
+
const withTechDocsReaderProvider = (Component) => (props) => /* @__PURE__ */ React__default.createElement(TechDocsReaderProvider, null, /* @__PURE__ */ React__default.createElement(Component, {
|
|
1228
|
+
...props
|
|
1229
|
+
}));
|
|
1230
|
+
const useTechDocsReader = () => useContext(TechDocsReaderContext);
|
|
1231
|
+
const useTechDocsReaderDom = () => {
|
|
1232
|
+
const navigate = useNavigate$1();
|
|
1079
1233
|
const theme = useTheme();
|
|
1080
|
-
const classes = useStyles();
|
|
1081
|
-
const {
|
|
1082
|
-
state,
|
|
1083
|
-
path,
|
|
1084
|
-
contentReload,
|
|
1085
|
-
content: rawPage,
|
|
1086
|
-
contentErrorMessage,
|
|
1087
|
-
syncErrorMessage,
|
|
1088
|
-
buildLog
|
|
1089
|
-
} = useReaderState(kind, namespace, name, useParams()["*"]);
|
|
1090
1234
|
const techdocsStorageApi = useApi(techdocsStorageApiRef);
|
|
1091
|
-
const [sidebars, setSidebars] = useState();
|
|
1092
|
-
const navigate = useNavigate$1();
|
|
1093
|
-
const shadowDomRef = useRef(null);
|
|
1094
1235
|
const scmIntegrationsApi = useApi(scmIntegrationsApiRef);
|
|
1236
|
+
const {namespace = "", kind = "", name = ""} = useParams();
|
|
1237
|
+
const {state, path, content: rawPage} = useTechDocsReader();
|
|
1238
|
+
const [sidebars, setSidebars] = useState();
|
|
1239
|
+
const [dom, setDom] = useState(null);
|
|
1095
1240
|
const updateSidebarPosition = useCallback(() => {
|
|
1096
|
-
if (
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
}
|
|
1105
|
-
}, [shadowDomRef, sidebars]);
|
|
1241
|
+
if (!dom || !sidebars)
|
|
1242
|
+
return;
|
|
1243
|
+
const mdTabs = dom.querySelector(".md-container > .md-tabs");
|
|
1244
|
+
sidebars.forEach((sidebar) => {
|
|
1245
|
+
const newTop = Math.max(dom.getBoundingClientRect().top, 0);
|
|
1246
|
+
sidebar.style.top = mdTabs ? `${newTop + mdTabs.getBoundingClientRect().height}px` : `${newTop}px`;
|
|
1247
|
+
});
|
|
1248
|
+
}, [dom, sidebars]);
|
|
1106
1249
|
useEffect(() => {
|
|
1107
1250
|
updateSidebarPosition();
|
|
1108
1251
|
window.addEventListener("scroll", updateSidebarPosition, true);
|
|
@@ -1129,106 +1272,106 @@ const Reader = ({entityRef, onReady, withSearch = true}) => {
|
|
|
1129
1272
|
addGitFeedbackLink(scmIntegrationsApi),
|
|
1130
1273
|
injectCss({
|
|
1131
1274
|
css: `
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1275
|
+
body {
|
|
1276
|
+
font-family: ${theme.typography.fontFamily};
|
|
1277
|
+
--md-text-color: ${theme.palette.text.primary};
|
|
1278
|
+
--md-text-link-color: ${theme.palette.primary.main};
|
|
1136
1279
|
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
}
|
|
1140
|
-
.md-main__inner { margin-top: 0; }
|
|
1141
|
-
.md-sidebar { position: fixed; bottom: 100px; width: 20rem; }
|
|
1142
|
-
.md-sidebar--secondary { right: 2rem; }
|
|
1143
|
-
.md-content { margin-bottom: 50px }
|
|
1144
|
-
.md-footer { position: fixed; bottom: 0px; width: 100vw; }
|
|
1145
|
-
.md-footer-nav__link { width: 20rem;}
|
|
1146
|
-
.md-content { margin-left: 20rem; max-width: calc(100% - 20rem * 2 - 3rem); }
|
|
1147
|
-
.md-typeset { font-size: 1rem; }
|
|
1148
|
-
.md-nav { font-size: 1rem; }
|
|
1149
|
-
.md-grid { max-width: 90vw; margin: 0 }
|
|
1150
|
-
.md-typeset table:not([class]) {
|
|
1151
|
-
font-size: 1rem;
|
|
1152
|
-
border: 1px solid ${theme.palette.text.primary};
|
|
1153
|
-
border-bottom: none;
|
|
1154
|
-
border-collapse: collapse;
|
|
1155
|
-
}
|
|
1156
|
-
.md-typeset table:not([class]) td, .md-typeset table:not([class]) th {
|
|
1157
|
-
border-bottom: 1px solid ${theme.palette.text.primary};
|
|
1158
|
-
}
|
|
1159
|
-
.md-typeset table:not([class]) th { font-weight: bold; }
|
|
1160
|
-
.md-typeset .admonition, .md-typeset details {
|
|
1161
|
-
font-size: 1rem;
|
|
1162
|
-
}
|
|
1163
|
-
@media screen and (max-width: 76.1875em) {
|
|
1164
|
-
.md-nav {
|
|
1165
|
-
background-color: ${theme.palette.background.default};
|
|
1166
|
-
transition: none !important
|
|
1280
|
+
--md-code-fg-color: ${theme.palette.text.primary};
|
|
1281
|
+
--md-code-bg-color: ${theme.palette.background.paper};
|
|
1167
1282
|
}
|
|
1168
|
-
.md-
|
|
1169
|
-
.md-sidebar
|
|
1170
|
-
.md-
|
|
1171
|
-
.md-
|
|
1172
|
-
.md-footer {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1283
|
+
.md-main__inner { margin-top: 0; }
|
|
1284
|
+
.md-sidebar { position: fixed; bottom: 100px; width: 20rem; }
|
|
1285
|
+
.md-sidebar--secondary { right: 2rem; }
|
|
1286
|
+
.md-content { margin-bottom: 50px }
|
|
1287
|
+
.md-footer { position: fixed; bottom: 0px; width: 100vw; }
|
|
1288
|
+
.md-footer-nav__link { width: 20rem;}
|
|
1289
|
+
.md-content { margin-left: 20rem; max-width: calc(100% - 20rem * 2 - 3rem); }
|
|
1290
|
+
.md-typeset { font-size: 1rem; }
|
|
1291
|
+
.md-nav { font-size: 1rem; }
|
|
1292
|
+
.md-grid { max-width: 90vw; margin: 0 }
|
|
1293
|
+
.md-typeset table:not([class]) {
|
|
1294
|
+
font-size: 1rem;
|
|
1295
|
+
border: 1px solid ${theme.palette.text.primary};
|
|
1296
|
+
border-bottom: none;
|
|
1297
|
+
border-collapse: collapse;
|
|
1176
1298
|
}
|
|
1177
|
-
.md-
|
|
1178
|
-
|
|
1179
|
-
height: auto;
|
|
1180
|
-
line-height: 1rem;
|
|
1181
|
-
cursor: auto;
|
|
1299
|
+
.md-typeset table:not([class]) td, .md-typeset table:not([class]) th {
|
|
1300
|
+
border-bottom: 1px solid ${theme.palette.text.primary};
|
|
1182
1301
|
}
|
|
1183
|
-
.md-
|
|
1184
|
-
|
|
1302
|
+
.md-typeset table:not([class]) th { font-weight: bold; }
|
|
1303
|
+
.md-typeset .admonition, .md-typeset details {
|
|
1304
|
+
font-size: 1rem;
|
|
1185
1305
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1306
|
+
@media screen and (max-width: 76.1875em) {
|
|
1307
|
+
.md-nav {
|
|
1308
|
+
background-color: ${theme.palette.background.default};
|
|
1309
|
+
transition: none !important
|
|
1310
|
+
}
|
|
1311
|
+
.md-sidebar--secondary { display: none; }
|
|
1312
|
+
.md-sidebar--primary { left: 72px; width: 10rem }
|
|
1313
|
+
.md-content { margin-left: 10rem; max-width: calc(100% - 10rem); }
|
|
1314
|
+
.md-content__inner { font-size: 0.9rem }
|
|
1315
|
+
.md-footer {
|
|
1316
|
+
position: static;
|
|
1317
|
+
margin-left: 10rem;
|
|
1318
|
+
width: calc(100% - 10rem);
|
|
1319
|
+
}
|
|
1320
|
+
.md-nav--primary .md-nav__title {
|
|
1321
|
+
white-space: normal;
|
|
1322
|
+
height: auto;
|
|
1323
|
+
line-height: 1rem;
|
|
1324
|
+
cursor: auto;
|
|
1325
|
+
}
|
|
1326
|
+
.md-nav--primary > .md-nav__title [for="none"] {
|
|
1327
|
+
padding-top: 0;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
`
|
|
1188
1331
|
}),
|
|
1189
1332
|
injectCss({
|
|
1190
1333
|
css: `
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1334
|
+
.md-nav__link, .md-typeset a, .md-typeset a::before, .md-typeset .headerlink {
|
|
1335
|
+
transition: none;
|
|
1336
|
+
}
|
|
1337
|
+
`
|
|
1195
1338
|
}),
|
|
1196
1339
|
injectCss({
|
|
1197
1340
|
css: `
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1341
|
+
.md-typeset pre > code::-webkit-scrollbar-thumb {
|
|
1342
|
+
background-color: hsla(0, 0%, 0%, 0.32);
|
|
1343
|
+
}
|
|
1344
|
+
.md-typeset pre > code::-webkit-scrollbar-thumb:hover {
|
|
1345
|
+
background-color: hsla(0, 0%, 0%, 0.87);
|
|
1346
|
+
}
|
|
1204
1347
|
`
|
|
1205
1348
|
}),
|
|
1206
1349
|
injectCss({
|
|
1207
1350
|
css: `
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1351
|
+
:host {
|
|
1352
|
+
--md-admonition-icon--note: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"/></svg>');
|
|
1353
|
+
--md-admonition-icon--abstract: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 5h16v2H4V5m0 4h16v2H4V9m0 4h16v2H4v-2m0 4h10v2H4v-2z"/></svg>');
|
|
1354
|
+
--md-admonition-icon--info: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10A10 10 0 0012 2z"/></svg>');
|
|
1355
|
+
--md-admonition-icon--tip: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17.55 11.2c-.23-.3-.5-.56-.76-.82-.65-.6-1.4-1.03-2.03-1.66C13.3 7.26 13 4.85 13.91 3c-.91.23-1.75.75-2.45 1.32-2.54 2.08-3.54 5.75-2.34 8.9.04.1.08.2.08.33 0 .22-.15.42-.35.5-.22.1-.46.04-.64-.12a.83.83 0 01-.15-.17c-1.1-1.43-1.28-3.48-.53-5.12C5.89 10 5 12.3 5.14 14.47c.04.5.1 1 .27 1.5.14.6.4 1.2.72 1.73 1.04 1.73 2.87 2.97 4.84 3.22 2.1.27 4.35-.12 5.96-1.6 1.8-1.66 2.45-4.32 1.5-6.6l-.13-.26c-.2-.46-.47-.87-.8-1.25l.05-.01m-3.1 6.3c-.28.24-.73.5-1.08.6-1.1.4-2.2-.16-2.87-.82 1.19-.28 1.89-1.16 2.09-2.05.17-.8-.14-1.46-.27-2.23-.12-.74-.1-1.37.18-2.06.17.38.37.76.6 1.06.76 1 1.95 1.44 2.2 2.8.04.14.06.28.06.43.03.82-.32 1.72-.92 2.27h.01z"/></svg>');
|
|
1356
|
+
--md-admonition-icon--success: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2m-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>');
|
|
1357
|
+
--md-admonition-icon--question: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.07 11.25l-.9.92C13.45 12.89 13 13.5 13 15h-2v-.5c0-1.11.45-2.11 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41a2 2 0 00-2-2 2 2 0 00-2 2H8a4 4 0 014-4 4 4 0 014 4 3.2 3.2 0 01-.93 2.25M13 19h-2v-2h2M12 2A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10c0-5.53-4.5-10-10-10z"/></svg>');
|
|
1358
|
+
--md-admonition-icon--warning: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 14h-2v-4h2m0 8h-2v-2h2M1 21h22L12 2 1 21z"/></svg>');
|
|
1359
|
+
--md-admonition-icon--failure: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2c5.53 0 10 4.47 10 10s-4.47 10-10 10S2 17.53 2 12 6.47 2 12 2m3.59 5L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41 15.59 7z"/></svg>');
|
|
1360
|
+
--md-admonition-icon--danger: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11.5 20l4.86-9.73H13V4l-5 9.73h3.5V20M12 2c2.75 0 5.1 1 7.05 2.95C21 6.9 22 9.25 22 12s-1 5.1-2.95 7.05C17.1 21 14.75 22 12 22s-5.1-1-7.05-2.95C3 17.1 2 14.75 2 12s1-5.1 2.95-7.05C6.9 3 9.25 2 12 2z"/></svg>');
|
|
1361
|
+
--md-admonition-icon--bug: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 12h-4v-2h4m0 6h-4v-2h4m6-6h-2.81a5.985 5.985 0 00-1.82-1.96L17 4.41 15.59 3l-2.17 2.17a6.002 6.002 0 00-2.83 0L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8z"/></svg>');
|
|
1362
|
+
--md-admonition-icon--example: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.25-7a.75.75 0 01.75.75c0 .2-.08.39-.21.52L3.12 13H5v1H2v-.92L4 11H2v-1h2.25z"/></svg>');
|
|
1363
|
+
--md-admonition-icon--quote: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 17h3l2-4V7h-6v6h3M6 17h3l2-4V7H5v6h3l-2 4z"/></svg>');
|
|
1364
|
+
}
|
|
1365
|
+
:host {
|
|
1366
|
+
--md-footnotes-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.42L5.83 13H21V7h-2z"/></svg>');
|
|
1367
|
+
}
|
|
1368
|
+
:host {
|
|
1369
|
+
--md-details-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.59 16.58L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.42z"/></svg>');
|
|
1370
|
+
}
|
|
1371
|
+
:host {
|
|
1372
|
+
--md-tasklist-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10A10 10 0 0012 2z"/></svg>');
|
|
1373
|
+
--md-tasklist-icon--checked: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2m-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>');
|
|
1374
|
+
}
|
|
1232
1375
|
`
|
|
1233
1376
|
})
|
|
1234
1377
|
]), [
|
|
@@ -1243,122 +1386,81 @@ const Reader = ({entityRef, onReady, withSearch = true}) => {
|
|
|
1243
1386
|
theme.palette.text.primary,
|
|
1244
1387
|
theme.typography.fontFamily
|
|
1245
1388
|
]);
|
|
1246
|
-
const postRender = useCallback(async (
|
|
1247
|
-
(
|
|
1248
|
-
setTimeout(() => {
|
|
1249
|
-
var _a2;
|
|
1250
|
-
if (window.location.hash) {
|
|
1251
|
-
const hash = window.location.hash.slice(1);
|
|
1252
|
-
(_a2 = shadowRoot == null ? void 0 : shadowRoot.getElementById(hash)) == null ? void 0 : _a2.scrollIntoView();
|
|
1253
|
-
}
|
|
1254
|
-
}, 200);
|
|
1255
|
-
return dom;
|
|
1256
|
-
},
|
|
1389
|
+
const postRender = useCallback(async (transformedElement) => transform(transformedElement, [
|
|
1390
|
+
scrollIntoAnchor(),
|
|
1257
1391
|
addLinkClickListener({
|
|
1258
1392
|
baseUrl: window.location.origin,
|
|
1259
1393
|
onClick: (_, url) => {
|
|
1260
|
-
var
|
|
1394
|
+
var _a, _b;
|
|
1261
1395
|
const parsedUrl = new URL(url);
|
|
1262
1396
|
if (parsedUrl.hash) {
|
|
1263
1397
|
navigate(`${parsedUrl.pathname}${parsedUrl.hash}`);
|
|
1264
|
-
(
|
|
1398
|
+
(_a = transformedElement == null ? void 0 : transformedElement.querySelector(`#${parsedUrl.hash.slice(1)}`)) == null ? void 0 : _a.scrollIntoView();
|
|
1265
1399
|
} else {
|
|
1266
1400
|
navigate(parsedUrl.pathname);
|
|
1401
|
+
(_b = transformedElement == null ? void 0 : transformedElement.querySelector(".md-content__inner")) == null ? void 0 : _b.scrollIntoView();
|
|
1267
1402
|
}
|
|
1268
1403
|
}
|
|
1269
1404
|
}),
|
|
1270
1405
|
onCssReady({
|
|
1271
1406
|
docStorageUrl: await techdocsStorageApi.getApiOrigin(),
|
|
1272
|
-
onLoading: (
|
|
1273
|
-
|
|
1407
|
+
onLoading: (renderedElement) => {
|
|
1408
|
+
renderedElement.style.setProperty("opacity", "0");
|
|
1274
1409
|
},
|
|
1275
|
-
onLoaded: (
|
|
1276
|
-
var
|
|
1277
|
-
|
|
1278
|
-
(
|
|
1279
|
-
|
|
1280
|
-
setSidebars(sideDivs);
|
|
1281
|
-
const docTopPosition = dom.getBoundingClientRect().top;
|
|
1282
|
-
const mdTabs = dom.querySelector(".md-container > .md-tabs");
|
|
1283
|
-
sideDivs.forEach((sidebar) => {
|
|
1284
|
-
sidebar.style.top = mdTabs ? `${docTopPosition + mdTabs.getBoundingClientRect().height}px` : `${docTopPosition}px`;
|
|
1285
|
-
});
|
|
1410
|
+
onLoaded: (renderedElement) => {
|
|
1411
|
+
var _a;
|
|
1412
|
+
renderedElement.style.removeProperty("opacity");
|
|
1413
|
+
(_a = renderedElement.querySelector(".md-nav__title")) == null ? void 0 : _a.removeAttribute("for");
|
|
1414
|
+
setSidebars(Array.from(renderedElement.querySelectorAll(".md-sidebar")));
|
|
1286
1415
|
}
|
|
1287
1416
|
})
|
|
1288
1417
|
]), [navigate, techdocsStorageApi]);
|
|
1289
1418
|
useEffect(() => {
|
|
1290
|
-
|
|
1291
|
-
if (!rawPage || !shadowDomRef.current) {
|
|
1292
|
-
if ((_a2 = shadowDomRef.current) == null ? void 0 : _a2.shadowRoot) {
|
|
1293
|
-
shadowDomRef.current.shadowRoot.innerHTML = "";
|
|
1294
|
-
}
|
|
1419
|
+
if (!rawPage)
|
|
1295
1420
|
return () => {
|
|
1296
1421
|
};
|
|
1297
|
-
}
|
|
1298
|
-
if (onReady) {
|
|
1299
|
-
onReady();
|
|
1300
|
-
}
|
|
1301
1422
|
let shouldReplaceContent = true;
|
|
1302
|
-
preRender(rawPage, path).then(async (
|
|
1303
|
-
if (!(
|
|
1423
|
+
preRender(rawPage, path).then(async (preTransformedDomElement) => {
|
|
1424
|
+
if (!(preTransformedDomElement == null ? void 0 : preTransformedDomElement.innerHTML)) {
|
|
1304
1425
|
return;
|
|
1305
1426
|
}
|
|
1306
1427
|
if (!shouldReplaceContent) {
|
|
1307
1428
|
return;
|
|
1308
1429
|
}
|
|
1309
|
-
const shadowDiv = shadowDomRef.current;
|
|
1310
|
-
const shadowRoot = shadowDiv.shadowRoot || shadowDiv.attachShadow({mode: "open"});
|
|
1311
|
-
Array.from(shadowRoot.children).forEach((child) => shadowRoot.removeChild(child));
|
|
1312
|
-
shadowRoot.appendChild(transformedElement);
|
|
1313
1430
|
window.scroll({top: 0});
|
|
1314
|
-
await postRender(
|
|
1431
|
+
const postTransformedDomElement = await postRender(preTransformedDomElement);
|
|
1432
|
+
setDom(postTransformedDomElement);
|
|
1315
1433
|
});
|
|
1316
1434
|
return () => {
|
|
1317
1435
|
shouldReplaceContent = false;
|
|
1318
1436
|
};
|
|
1319
|
-
}, [
|
|
1320
|
-
return
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
variant: "outlined",
|
|
1347
|
-
severity: "error",
|
|
1348
|
-
action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
|
|
1349
|
-
buildLog
|
|
1350
|
-
}),
|
|
1351
|
-
classes: {message: classes.message}
|
|
1352
|
-
}, "Building a newer version of this documentation failed.", " ", syncErrorMessage), state === "CONTENT_NOT_FOUND" && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, syncErrorMessage && /* @__PURE__ */ React__default.createElement(Alert, {
|
|
1353
|
-
variant: "outlined",
|
|
1354
|
-
severity: "error",
|
|
1355
|
-
action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
|
|
1356
|
-
buildLog
|
|
1357
|
-
}),
|
|
1358
|
-
classes: {message: classes.message}
|
|
1359
|
-
}, "Building a newer version of this documentation failed.", " ", syncErrorMessage), /* @__PURE__ */ React__default.createElement(TechDocsNotFound, {
|
|
1360
|
-
errorMessage: contentErrorMessage
|
|
1361
|
-
})), withSearch && ((_b = (_a = shadowDomRef == null ? void 0 : shadowDomRef.current) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.innerHTML) && /* @__PURE__ */ React__default.createElement(Grid, {
|
|
1437
|
+
}, [rawPage, path, preRender, postRender]);
|
|
1438
|
+
return dom;
|
|
1439
|
+
};
|
|
1440
|
+
const TheReader = ({
|
|
1441
|
+
entityRef,
|
|
1442
|
+
onReady = () => {
|
|
1443
|
+
},
|
|
1444
|
+
withSearch = true
|
|
1445
|
+
}) => {
|
|
1446
|
+
var _a, _b;
|
|
1447
|
+
const classes = useStyles();
|
|
1448
|
+
const dom = useTechDocsReaderDom();
|
|
1449
|
+
const shadowDomRef = useRef(null);
|
|
1450
|
+
const onReadyRef = useRef(onReady);
|
|
1451
|
+
useEffect(() => {
|
|
1452
|
+
onReadyRef.current = onReady;
|
|
1453
|
+
}, [onReady]);
|
|
1454
|
+
useEffect(() => {
|
|
1455
|
+
if (!dom || !shadowDomRef.current)
|
|
1456
|
+
return;
|
|
1457
|
+
const shadowDiv = shadowDomRef.current;
|
|
1458
|
+
const shadowRoot = shadowDiv.shadowRoot || shadowDiv.attachShadow({mode: "open"});
|
|
1459
|
+
Array.from(shadowRoot.children).forEach((child) => shadowRoot.removeChild(child));
|
|
1460
|
+
shadowRoot.appendChild(dom);
|
|
1461
|
+
onReadyRef.current();
|
|
1462
|
+
}, [dom]);
|
|
1463
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(TechDocsStateIndicator, null), withSearch && ((_b = (_a = shadowDomRef == null ? void 0 : shadowDomRef.current) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.innerHTML) && /* @__PURE__ */ React__default.createElement(Grid, {
|
|
1362
1464
|
container: true,
|
|
1363
1465
|
className: classes.searchBar
|
|
1364
1466
|
}, /* @__PURE__ */ React__default.createElement(TechDocsSearch, {
|
|
@@ -1368,6 +1470,16 @@ const Reader = ({entityRef, onReady, withSearch = true}) => {
|
|
|
1368
1470
|
ref: shadowDomRef
|
|
1369
1471
|
}));
|
|
1370
1472
|
};
|
|
1473
|
+
const Reader = ({
|
|
1474
|
+
entityRef,
|
|
1475
|
+
onReady = () => {
|
|
1476
|
+
},
|
|
1477
|
+
withSearch = true
|
|
1478
|
+
}) => /* @__PURE__ */ React__default.createElement(TechDocsReaderProvider, null, /* @__PURE__ */ React__default.createElement(TheReader, {
|
|
1479
|
+
entityRef,
|
|
1480
|
+
onReady,
|
|
1481
|
+
withSearch
|
|
1482
|
+
}));
|
|
1371
1483
|
|
|
1372
1484
|
const TechDocsPageHeader = ({
|
|
1373
1485
|
entityRef,
|
|
@@ -1498,41 +1610,9 @@ var TechDocsPage$1 = /*#__PURE__*/Object.freeze({
|
|
|
1498
1610
|
TechDocsPage: TechDocsPage
|
|
1499
1611
|
});
|
|
1500
1612
|
|
|
1501
|
-
const DocsCardGrid = ({
|
|
1502
|
-
entities
|
|
1503
|
-
}) => {
|
|
1504
|
-
const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);
|
|
1505
|
-
const toLowerMaybe = useApi(configApiRef).getOptionalBoolean("techdocs.legacyUseCaseSensitiveTripletPaths") ? (str) => str : (str) => str.toLocaleLowerCase();
|
|
1506
|
-
if (!entities)
|
|
1507
|
-
return null;
|
|
1508
|
-
return /* @__PURE__ */ React__default.createElement(ItemCardGrid, {
|
|
1509
|
-
"data-testid": "docs-explore"
|
|
1510
|
-
}, !(entities == null ? void 0 : entities.length) ? null : entities.map((entity, index) => {
|
|
1511
|
-
var _a;
|
|
1512
|
-
return /* @__PURE__ */ React__default.createElement(Card, {
|
|
1513
|
-
key: index
|
|
1514
|
-
}, /* @__PURE__ */ React__default.createElement(CardMedia, null, /* @__PURE__ */ React__default.createElement(ItemCardHeader, {
|
|
1515
|
-
title: entity.metadata.name
|
|
1516
|
-
})), /* @__PURE__ */ React__default.createElement(CardContent, null, entity.metadata.description), /* @__PURE__ */ React__default.createElement(CardActions, null, /* @__PURE__ */ React__default.createElement(Button, {
|
|
1517
|
-
to: getRouteToReaderPageFor({
|
|
1518
|
-
namespace: toLowerMaybe((_a = entity.metadata.namespace) != null ? _a : "default"),
|
|
1519
|
-
kind: toLowerMaybe(entity.kind),
|
|
1520
|
-
name: toLowerMaybe(entity.metadata.name)
|
|
1521
|
-
}),
|
|
1522
|
-
color: "primary",
|
|
1523
|
-
"data-testid": "read_docs"
|
|
1524
|
-
}, "Read Docs")));
|
|
1525
|
-
}));
|
|
1526
|
-
};
|
|
1527
|
-
|
|
1528
|
-
var DocsCardGrid$1 = /*#__PURE__*/Object.freeze({
|
|
1529
|
-
__proto__: null,
|
|
1530
|
-
DocsCardGrid: DocsCardGrid
|
|
1531
|
-
});
|
|
1532
|
-
|
|
1533
1613
|
const panels = {
|
|
1534
1614
|
DocsTable: DocsTable$1,
|
|
1535
|
-
DocsCardGrid
|
|
1615
|
+
DocsCardGrid: DocsCardGrid$1
|
|
1536
1616
|
};
|
|
1537
1617
|
const CustomPanel = ({
|
|
1538
1618
|
config,
|
|
@@ -1720,5 +1800,5 @@ var Router$1 = /*#__PURE__*/Object.freeze({
|
|
|
1720
1800
|
EmbeddedDocsRouter: EmbeddedDocsRouter
|
|
1721
1801
|
});
|
|
1722
1802
|
|
|
1723
|
-
export { DefaultTechDocsHome, DocsCardGrid
|
|
1803
|
+
export { DefaultTechDocsHome, DocsCardGrid, DocsResultListItem, DocsTable, EmbeddedDocsRouter, EntityListDocsGrid, EntityListDocsTable, EntityTechdocsContent, Reader, Router, TechDocsClient, TechDocsCustomHome$2 as TechDocsCustomHome, TechDocsIndexPage$2 as TechDocsIndexPage, TechDocsPage, TechDocsPageHeader, TechDocsPageWrapper, TechDocsPicker, TechDocsReaderPage, TechDocsSearch, TechDocsStateIndicator, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef, useTechDocsReader, useTechDocsReaderDom, withTechDocsReaderProvider };
|
|
1724
1804
|
//# sourceMappingURL=index.esm.js.map
|