@backstage/plugin-techdocs 0.0.0-nightly-202111222339 → 0.0.0-nightly-202111822629
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 +22 -0
- package/dist/index.esm.js +91 -86
- package/dist/index.esm.js.map +1 -1
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs
|
|
2
2
|
|
|
3
|
+
## 0.0.0-nightly-202111822629
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3421826ca8: The problem of lowercase entity triplets which causes docs to not load on entity page is fixed.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-components@0.0.0-nightly-202111822629
|
|
10
|
+
- @backstage/plugin-catalog@0.0.0-nightly-202111822629
|
|
11
|
+
- @backstage/plugin-search@0.0.0-nightly-202111822629
|
|
12
|
+
- @backstage/plugin-catalog-react@0.0.0-nightly-202111822629
|
|
13
|
+
|
|
14
|
+
## 0.12.8
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/integration@0.6.10
|
|
20
|
+
- @backstage/core-components@0.7.6
|
|
21
|
+
- @backstage/theme@0.2.14
|
|
22
|
+
- @backstage/core-plugin-api@0.2.2
|
|
23
|
+
- @backstage/plugin-search@0.5.0
|
|
24
|
+
|
|
3
25
|
## 0.12.7
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createApiRef, createRouteRef, useRouteRef, useApi, configApiRef, createPlugin, createApiFactory, discoveryApiRef, identityApiRef, createRoutableExtension, createComponentExtension } from '@backstage/core-plugin-api';
|
|
2
2
|
import { ResponseError, NotFoundError } from '@backstage/errors';
|
|
3
3
|
import { EventSourcePolyfill } from 'event-source-polyfill';
|
|
4
|
-
import React, { useEffect, useState, Suspense, useReducer, useRef, useMemo,
|
|
4
|
+
import React, { useEffect, useState, Suspense, useReducer, useRef, useMemo, createContext, useContext, useCallback } from 'react';
|
|
5
5
|
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';
|
|
6
6
|
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';
|
|
7
7
|
import TextTruncate from 'react-text-truncate';
|
|
@@ -50,12 +50,12 @@ class TechDocsClient {
|
|
|
50
50
|
return (_a = this.configApi.getOptionalString("techdocs.requestUrl")) != null ? _a : await this.discoveryApi.getBaseUrl("techdocs");
|
|
51
51
|
}
|
|
52
52
|
async getTechDocsMetadata(entityId) {
|
|
53
|
-
const {kind, namespace, name} = entityId;
|
|
53
|
+
const { kind, namespace, name } = entityId;
|
|
54
54
|
const apiOrigin = await this.getApiOrigin();
|
|
55
55
|
const requestUrl = `${apiOrigin}/metadata/techdocs/${namespace}/${kind}/${name}`;
|
|
56
56
|
const token = await this.identityApi.getIdToken();
|
|
57
57
|
const request = await fetch(`${requestUrl}`, {
|
|
58
|
-
headers: token ? {Authorization: `Bearer ${token}`} : {}
|
|
58
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
|
59
59
|
});
|
|
60
60
|
if (!request.ok) {
|
|
61
61
|
throw await ResponseError.fromResponse(request);
|
|
@@ -63,12 +63,12 @@ class TechDocsClient {
|
|
|
63
63
|
return await request.json();
|
|
64
64
|
}
|
|
65
65
|
async getEntityMetadata(entityId) {
|
|
66
|
-
const {kind, namespace, name} = entityId;
|
|
66
|
+
const { kind, namespace, name } = entityId;
|
|
67
67
|
const apiOrigin = await this.getApiOrigin();
|
|
68
68
|
const requestUrl = `${apiOrigin}/metadata/entity/${namespace}/${kind}/${name}`;
|
|
69
69
|
const token = await this.identityApi.getIdToken();
|
|
70
70
|
const request = await fetch(`${requestUrl}`, {
|
|
71
|
-
headers: token ? {Authorization: `Bearer ${token}`} : {}
|
|
71
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
|
72
72
|
});
|
|
73
73
|
if (!request.ok) {
|
|
74
74
|
throw await ResponseError.fromResponse(request);
|
|
@@ -98,12 +98,12 @@ class TechDocsStorageClient {
|
|
|
98
98
|
return this.configApi.getString("techdocs.builder");
|
|
99
99
|
}
|
|
100
100
|
async getEntityDocs(entityId, path) {
|
|
101
|
-
const {kind, namespace, name} = entityId;
|
|
101
|
+
const { kind, namespace, name } = entityId;
|
|
102
102
|
const storageUrl = await this.getStorageUrl();
|
|
103
103
|
const url = `${storageUrl}/${namespace}/${kind}/${name}/${path}`;
|
|
104
104
|
const token = await this.identityApi.getIdToken();
|
|
105
105
|
const request = await fetch(`${url.endsWith("/") ? url : `${url}/`}index.html`, {
|
|
106
|
-
headers: token ? {Authorization: `Bearer ${token}`} : {}
|
|
106
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
|
107
107
|
});
|
|
108
108
|
let errorMessage = "";
|
|
109
109
|
switch (request.status) {
|
|
@@ -121,14 +121,14 @@ class TechDocsStorageClient {
|
|
|
121
121
|
}
|
|
122
122
|
async syncEntityDocs(entityId, logHandler = () => {
|
|
123
123
|
}) {
|
|
124
|
-
const {kind, namespace, name} = entityId;
|
|
124
|
+
const { kind, namespace, name } = entityId;
|
|
125
125
|
const apiOrigin = await this.getApiOrigin();
|
|
126
126
|
const url = `${apiOrigin}/sync/${namespace}/${kind}/${name}`;
|
|
127
127
|
const token = await this.identityApi.getIdToken();
|
|
128
128
|
return new Promise((resolve, reject) => {
|
|
129
129
|
const source = new EventSourcePolyfill(url, {
|
|
130
130
|
withCredentials: true,
|
|
131
|
-
headers: token ? {Authorization: `Bearer ${token}`} : {}
|
|
131
|
+
headers: token ? { Authorization: `Bearer ${token}` } : {}
|
|
132
132
|
});
|
|
133
133
|
source.addEventListener("log", (e) => {
|
|
134
134
|
if (e.data) {
|
|
@@ -138,7 +138,7 @@ class TechDocsStorageClient {
|
|
|
138
138
|
source.addEventListener("finish", (e) => {
|
|
139
139
|
let updated = false;
|
|
140
140
|
if (e.data) {
|
|
141
|
-
({updated} = JSON.parse(e.data));
|
|
141
|
+
({ updated } = JSON.parse(e.data));
|
|
142
142
|
}
|
|
143
143
|
resolve(updated ? "updated" : "cached");
|
|
144
144
|
});
|
|
@@ -156,7 +156,7 @@ class TechDocsStorageClient {
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
async getBaseUrl(oldBaseUrl, entityId, path) {
|
|
159
|
-
const {kind, namespace, name} = entityId;
|
|
159
|
+
const { kind, namespace, name } = entityId;
|
|
160
160
|
const apiOrigin = await this.getApiOrigin();
|
|
161
161
|
return new URL(oldBaseUrl, `${apiOrigin}/static/docs/${namespace}/${kind}/${name}/${path}`).toString();
|
|
162
162
|
}
|
|
@@ -183,7 +183,7 @@ const DocsResultListItem = ({
|
|
|
183
183
|
var _a;
|
|
184
184
|
return /* @__PURE__ */ React.createElement(ListItemText, {
|
|
185
185
|
className: classes.itemText,
|
|
186
|
-
primaryTypographyProps: {variant: "h6"},
|
|
186
|
+
primaryTypographyProps: { variant: "h6" },
|
|
187
187
|
primary: title ? title : `${result.title} | ${(_a = result.entityTitle) != null ? _a : result.name} docs`,
|
|
188
188
|
secondary: /* @__PURE__ */ React.createElement(TextTruncate, {
|
|
189
189
|
line: lineClamp,
|
|
@@ -193,10 +193,10 @@ const DocsResultListItem = ({
|
|
|
193
193
|
})
|
|
194
194
|
});
|
|
195
195
|
};
|
|
196
|
-
const LinkWrapper = ({children}) => asLink ? /* @__PURE__ */ React.createElement(Link, {
|
|
196
|
+
const LinkWrapper = ({ children }) => asLink ? /* @__PURE__ */ React.createElement(Link, {
|
|
197
197
|
to: result.location
|
|
198
198
|
}, children) : /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
199
|
-
const ListItemWrapper = ({children}) => asListItem ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ListItem, {
|
|
199
|
+
const ListItemWrapper = ({ children }) => asListItem ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ListItem, {
|
|
200
200
|
alignItems: "flex-start",
|
|
201
201
|
className: classes.flexContainer
|
|
202
202
|
}, children), /* @__PURE__ */ React.createElement(Divider, {
|
|
@@ -228,10 +228,10 @@ function createCopyDocsUrlAction(copyToClipboard) {
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
function createStarEntityAction(isStarredEntity, toggleStarredEntity) {
|
|
231
|
-
return ({entity}) => {
|
|
231
|
+
return ({ entity }) => {
|
|
232
232
|
const isStarred = isStarredEntity(entity);
|
|
233
233
|
return {
|
|
234
|
-
cellStyle: {paddingLeft: "1em"},
|
|
234
|
+
cellStyle: { paddingLeft: "1em" },
|
|
235
235
|
icon: () => favoriteEntityIcon(isStarred),
|
|
236
236
|
tooltip: favoriteEntityTooltip(isStarred),
|
|
237
237
|
onClick: () => toggleStarredEntity(entity)
|
|
@@ -265,7 +265,7 @@ function createOwnerColumn() {
|
|
|
265
265
|
return {
|
|
266
266
|
title: "Owner",
|
|
267
267
|
field: "resolved.ownedByRelationsTitle",
|
|
268
|
-
render: ({resolved}) => /* @__PURE__ */ React.createElement(EntityRefLinks, {
|
|
268
|
+
render: ({ resolved }) => /* @__PURE__ */ React.createElement(EntityRefLinks, {
|
|
269
269
|
entityRefs: resolved.ownedByRelations,
|
|
270
270
|
defaultKind: "group"
|
|
271
271
|
})
|
|
@@ -285,6 +285,10 @@ var columnFactories = /*#__PURE__*/Object.freeze({
|
|
|
285
285
|
createTypeColumn: createTypeColumn
|
|
286
286
|
});
|
|
287
287
|
|
|
288
|
+
function toLowerMaybe(str, config) {
|
|
289
|
+
return config.getOptionalBoolean("techdocs.legacyUseCaseSensitiveTripletPaths") ? str : str.toLocaleLowerCase("en-US");
|
|
290
|
+
}
|
|
291
|
+
|
|
288
292
|
const DocsTable$1 = ({
|
|
289
293
|
entities,
|
|
290
294
|
title,
|
|
@@ -294,7 +298,7 @@ const DocsTable$1 = ({
|
|
|
294
298
|
}) => {
|
|
295
299
|
const [, copyToClipboard] = useCopyToClipboard();
|
|
296
300
|
const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);
|
|
297
|
-
const
|
|
301
|
+
const config = useApi(configApiRef);
|
|
298
302
|
if (!entities)
|
|
299
303
|
return null;
|
|
300
304
|
const documents = entities.map((entity) => {
|
|
@@ -304,12 +308,12 @@ const DocsTable$1 = ({
|
|
|
304
308
|
entity,
|
|
305
309
|
resolved: {
|
|
306
310
|
docsUrl: getRouteToReaderPageFor({
|
|
307
|
-
namespace: toLowerMaybe((_a = entity.metadata.namespace) != null ? _a : "default"),
|
|
308
|
-
kind: toLowerMaybe(entity.kind),
|
|
309
|
-
name: toLowerMaybe(entity.metadata.name)
|
|
311
|
+
namespace: toLowerMaybe((_a = entity.metadata.namespace) != null ? _a : "default", config),
|
|
312
|
+
kind: toLowerMaybe(entity.kind, config),
|
|
313
|
+
name: toLowerMaybe(entity.metadata.name, config)
|
|
310
314
|
}),
|
|
311
315
|
ownedByRelations,
|
|
312
|
-
ownedByRelationsTitle: ownedByRelations.map((r) => formatEntityRefTitle(r, {defaultKind: "group"})).join(", ")
|
|
316
|
+
ownedByRelationsTitle: ownedByRelations.map((r) => formatEntityRefTitle(r, { defaultKind: "group" })).join(", ")
|
|
313
317
|
}
|
|
314
318
|
};
|
|
315
319
|
});
|
|
@@ -355,8 +359,8 @@ const EntityListDocsTable = ({
|
|
|
355
359
|
actions
|
|
356
360
|
}) => {
|
|
357
361
|
var _a, _b;
|
|
358
|
-
const {loading, error, entities, filters} = useEntityListProvider();
|
|
359
|
-
const {isStarredEntity, toggleStarredEntity} = useStarredEntities();
|
|
362
|
+
const { loading, error, entities, filters } = useEntityListProvider();
|
|
363
|
+
const { isStarredEntity, toggleStarredEntity } = useStarredEntities();
|
|
360
364
|
const [, copyToClipboard] = useCopyToClipboard();
|
|
361
365
|
const title = capitalize((_b = (_a = filters.user) == null ? void 0 : _a.value) != null ? _b : "all");
|
|
362
366
|
const defaultActions = [
|
|
@@ -383,7 +387,7 @@ const EntityListDocsTable = ({
|
|
|
383
387
|
EntityListDocsTable.columns = columnFactories;
|
|
384
388
|
EntityListDocsTable.actions = actionFactories;
|
|
385
389
|
|
|
386
|
-
const TechDocsPageWrapper = ({children}) => {
|
|
390
|
+
const TechDocsPageWrapper = ({ children }) => {
|
|
387
391
|
var _a;
|
|
388
392
|
const configApi = useApi(configApiRef);
|
|
389
393
|
const generatedSubtitle = `Documentation available in ${(_a = configApi.getOptionalString("organization.name")) != null ? _a : "Backstage"}`;
|
|
@@ -402,7 +406,7 @@ class TechDocsFilter {
|
|
|
402
406
|
}
|
|
403
407
|
}
|
|
404
408
|
const TechDocsPicker = () => {
|
|
405
|
-
const {updateFilters} = useEntityListProvider();
|
|
409
|
+
const { updateFilters } = useEntityListProvider();
|
|
406
410
|
useEffect(() => {
|
|
407
411
|
updateFilters({
|
|
408
412
|
techdocs: new TechDocsFilter()
|
|
@@ -430,7 +434,7 @@ const DocsCardGrid$1 = ({
|
|
|
430
434
|
entities
|
|
431
435
|
}) => {
|
|
432
436
|
const getRouteToReaderPageFor = useRouteRef(rootDocsRouteRef);
|
|
433
|
-
const
|
|
437
|
+
const config = useApi(configApiRef);
|
|
434
438
|
if (!entities)
|
|
435
439
|
return null;
|
|
436
440
|
return /* @__PURE__ */ React.createElement(ItemCardGrid, {
|
|
@@ -443,9 +447,9 @@ const DocsCardGrid$1 = ({
|
|
|
443
447
|
title: (_a = entity.metadata.title) != null ? _a : entity.metadata.name
|
|
444
448
|
})), /* @__PURE__ */ React.createElement(CardContent, null, entity.metadata.description), /* @__PURE__ */ React.createElement(CardActions, null, /* @__PURE__ */ React.createElement(Button, {
|
|
445
449
|
to: getRouteToReaderPageFor({
|
|
446
|
-
namespace: toLowerMaybe((_b = entity.metadata.namespace) != null ? _b : "default"),
|
|
447
|
-
kind: toLowerMaybe(entity.kind),
|
|
448
|
-
name: toLowerMaybe(entity.metadata.name)
|
|
450
|
+
namespace: toLowerMaybe((_b = entity.metadata.namespace) != null ? _b : "default", config),
|
|
451
|
+
kind: toLowerMaybe(entity.kind, config),
|
|
452
|
+
name: toLowerMaybe(entity.metadata.name, config)
|
|
449
453
|
}),
|
|
450
454
|
color: "primary",
|
|
451
455
|
"data-testid": "read_docs"
|
|
@@ -459,7 +463,7 @@ var DocsCardGrid$2 = /*#__PURE__*/Object.freeze({
|
|
|
459
463
|
});
|
|
460
464
|
|
|
461
465
|
const EntityListDocsGrid = () => {
|
|
462
|
-
const {loading, error, entities} = useEntityListProvider();
|
|
466
|
+
const { loading, error, entities } = useEntityListProvider();
|
|
463
467
|
if (error) {
|
|
464
468
|
return /* @__PURE__ */ React.createElement(WarningPanel, {
|
|
465
469
|
severity: "error",
|
|
@@ -491,7 +495,7 @@ const techdocsPlugin = createPlugin({
|
|
|
491
495
|
discoveryApi: discoveryApiRef,
|
|
492
496
|
identityApi: identityApiRef
|
|
493
497
|
},
|
|
494
|
-
factory: ({configApi, discoveryApi, identityApi}) => new TechDocsStorageClient({
|
|
498
|
+
factory: ({ configApi, discoveryApi, identityApi }) => new TechDocsStorageClient({
|
|
495
499
|
configApi,
|
|
496
500
|
discoveryApi,
|
|
497
501
|
identityApi
|
|
@@ -504,7 +508,7 @@ const techdocsPlugin = createPlugin({
|
|
|
504
508
|
discoveryApi: discoveryApiRef,
|
|
505
509
|
identityApi: identityApiRef
|
|
506
510
|
},
|
|
507
|
-
factory: ({configApi, discoveryApi, identityApi}) => new TechDocsClient({
|
|
511
|
+
factory: ({ configApi, discoveryApi, identityApi }) => new TechDocsClient({
|
|
508
512
|
configApi,
|
|
509
513
|
discoveryApi,
|
|
510
514
|
identityApi
|
|
@@ -577,7 +581,7 @@ const addBaseUrl = ({
|
|
|
577
581
|
const newValue = await techdocsStorageApi.getBaseUrl(elemAttribute, entityId, path);
|
|
578
582
|
if (isSvgNeedingInlining(attributeName, elemAttribute, apiOrigin)) {
|
|
579
583
|
try {
|
|
580
|
-
const svg = await fetch(newValue, {credentials: "include"});
|
|
584
|
+
const svg = await fetch(newValue, { credentials: "include" });
|
|
581
585
|
const svgContent = await svg.text();
|
|
582
586
|
elem.setAttribute(attributeName, `data:image/svg+xml;base64,${btoa(svgContent)}`);
|
|
583
587
|
} catch (e) {
|
|
@@ -760,7 +764,7 @@ const sanitizeDOM = () => {
|
|
|
760
764
|
};
|
|
761
765
|
};
|
|
762
766
|
|
|
763
|
-
const injectCss = ({css}) => {
|
|
767
|
+
const injectCss = ({ css }) => {
|
|
764
768
|
return (dom) => {
|
|
765
769
|
dom.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", `<style>${css}</style>`);
|
|
766
770
|
return dom;
|
|
@@ -804,7 +808,7 @@ const TechDocsSearchBar = ({
|
|
|
804
808
|
const {
|
|
805
809
|
term,
|
|
806
810
|
setTerm,
|
|
807
|
-
result: {loading, value: searchVal}
|
|
811
|
+
result: { loading, value: searchVal }
|
|
808
812
|
} = useSearch();
|
|
809
813
|
const [options, setOptions] = useState([]);
|
|
810
814
|
useEffect(() => {
|
|
@@ -827,7 +831,7 @@ const TechDocsSearchBar = ({
|
|
|
827
831
|
};
|
|
828
832
|
const handleSelection = (_, selection) => {
|
|
829
833
|
if (selection == null ? void 0 : selection.document) {
|
|
830
|
-
const {location} = selection.document;
|
|
834
|
+
const { location } = selection.document;
|
|
831
835
|
navigate(location);
|
|
832
836
|
}
|
|
833
837
|
};
|
|
@@ -853,7 +857,7 @@ const TechDocsSearchBar = ({
|
|
|
853
857
|
noOptionsText: "No results found",
|
|
854
858
|
value: null,
|
|
855
859
|
options,
|
|
856
|
-
renderOption: ({document}) => /* @__PURE__ */ React.createElement(DocsResultListItem, {
|
|
860
|
+
renderOption: ({ document }) => /* @__PURE__ */ React.createElement(DocsResultListItem, {
|
|
857
861
|
result: document,
|
|
858
862
|
lineClamp: 3,
|
|
859
863
|
asListItem: false,
|
|
@@ -951,14 +955,14 @@ const TechDocsBuildLogsDrawerContent = ({
|
|
|
951
955
|
enableSearch: true
|
|
952
956
|
})));
|
|
953
957
|
};
|
|
954
|
-
const TechDocsBuildLogs = ({buildLog}) => {
|
|
958
|
+
const TechDocsBuildLogs = ({ buildLog }) => {
|
|
955
959
|
const classes = useDrawerStyles();
|
|
956
960
|
const [open, setOpen] = useState(false);
|
|
957
961
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Button$1, {
|
|
958
962
|
color: "inherit",
|
|
959
963
|
onClick: () => setOpen(true)
|
|
960
964
|
}, "Show Build Logs"), /* @__PURE__ */ React.createElement(Drawer, {
|
|
961
|
-
classes: {paper: classes.paper},
|
|
965
|
+
classes: { paper: classes.paper },
|
|
962
966
|
anchor: "right",
|
|
963
967
|
open,
|
|
964
968
|
onClose: () => setOpen(false)
|
|
@@ -968,7 +972,7 @@ const TechDocsBuildLogs = ({buildLog}) => {
|
|
|
968
972
|
})));
|
|
969
973
|
};
|
|
970
974
|
|
|
971
|
-
const TechDocsNotFound = ({errorMessage}) => {
|
|
975
|
+
const TechDocsNotFound = ({ errorMessage }) => {
|
|
972
976
|
const techdocsBuilder = useApi(configApiRef).getOptionalString("techdocs.builder");
|
|
973
977
|
let additionalInfo = "";
|
|
974
978
|
if (techdocsBuilder !== "local") {
|
|
@@ -1039,7 +1043,7 @@ const TechDocsStateIndicator = () => {
|
|
|
1039
1043
|
action: /* @__PURE__ */ React.createElement(TechDocsBuildLogs, {
|
|
1040
1044
|
buildLog
|
|
1041
1045
|
}),
|
|
1042
|
-
classes: {message: classes.message}
|
|
1046
|
+
classes: { message: classes.message }
|
|
1043
1047
|
}, "Building a newer version of this documentation failed.", " ", syncErrorMessage);
|
|
1044
1048
|
}
|
|
1045
1049
|
if (state === "CONTENT_NOT_FOUND") {
|
|
@@ -1049,7 +1053,7 @@ const TechDocsStateIndicator = () => {
|
|
|
1049
1053
|
action: /* @__PURE__ */ React.createElement(TechDocsBuildLogs, {
|
|
1050
1054
|
buildLog
|
|
1051
1055
|
}),
|
|
1052
|
-
classes: {message: classes.message}
|
|
1056
|
+
classes: { message: classes.message }
|
|
1053
1057
|
}, "Building a newer version of this documentation failed.", " ", syncErrorMessage), /* @__PURE__ */ React.createElement(TechDocsNotFound, {
|
|
1054
1058
|
errorMessage: contentErrorMessage
|
|
1055
1059
|
}));
|
|
@@ -1089,7 +1093,7 @@ function calculateDisplayState({
|
|
|
1089
1093
|
return "CONTENT_FRESH";
|
|
1090
1094
|
}
|
|
1091
1095
|
function reducer(oldState, action) {
|
|
1092
|
-
const newState = {...oldState};
|
|
1096
|
+
const newState = { ...oldState };
|
|
1093
1097
|
switch (action.type) {
|
|
1094
1098
|
case "sync":
|
|
1095
1099
|
if (action.state === "CHECKING") {
|
|
@@ -1131,14 +1135,14 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
1131
1135
|
buildLog: []
|
|
1132
1136
|
});
|
|
1133
1137
|
const techdocsStorageApi = useApi(techdocsStorageApiRef);
|
|
1134
|
-
const {retry: contentReload} = useAsyncRetry(async () => {
|
|
1135
|
-
dispatch({type: "contentLoading"});
|
|
1138
|
+
const { retry: contentReload } = useAsyncRetry(async () => {
|
|
1139
|
+
dispatch({ type: "contentLoading" });
|
|
1136
1140
|
try {
|
|
1137
|
-
const entityDocs = await techdocsStorageApi.getEntityDocs({kind, namespace, name}, path);
|
|
1138
|
-
dispatch({type: "content", content: entityDocs, path});
|
|
1141
|
+
const entityDocs = await techdocsStorageApi.getEntityDocs({ kind, namespace, name }, path);
|
|
1142
|
+
dispatch({ type: "content", content: entityDocs, path });
|
|
1139
1143
|
return entityDocs;
|
|
1140
1144
|
} catch (e) {
|
|
1141
|
-
dispatch({type: "content", contentError: e, path});
|
|
1145
|
+
dispatch({ type: "content", contentError: e, path });
|
|
1142
1146
|
}
|
|
1143
1147
|
return void 0;
|
|
1144
1148
|
}, [techdocsStorageApi, kind, namespace, name, path]);
|
|
@@ -1147,11 +1151,11 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
1147
1151
|
reload: () => {
|
|
1148
1152
|
}
|
|
1149
1153
|
});
|
|
1150
|
-
contentRef.current = {content: state.content, reload: contentReload};
|
|
1154
|
+
contentRef.current = { content: state.content, reload: contentReload };
|
|
1151
1155
|
useAsync(async () => {
|
|
1152
|
-
dispatch({type: "sync", state: "CHECKING"});
|
|
1156
|
+
dispatch({ type: "sync", state: "CHECKING" });
|
|
1153
1157
|
const buildingTimeout = setTimeout(() => {
|
|
1154
|
-
dispatch({type: "sync", state: "BUILDING"});
|
|
1158
|
+
dispatch({ type: "sync", state: "BUILDING" });
|
|
1155
1159
|
}, 1e3);
|
|
1156
1160
|
try {
|
|
1157
1161
|
const result = await techdocsStorageApi.syncEntityDocs({
|
|
@@ -1159,19 +1163,19 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
1159
1163
|
namespace,
|
|
1160
1164
|
name
|
|
1161
1165
|
}, (log) => {
|
|
1162
|
-
dispatch({type: "buildLog", log});
|
|
1166
|
+
dispatch({ type: "buildLog", log });
|
|
1163
1167
|
});
|
|
1164
1168
|
switch (result) {
|
|
1165
1169
|
case "updated":
|
|
1166
1170
|
if (!contentRef.current.content) {
|
|
1167
1171
|
contentRef.current.reload();
|
|
1168
|
-
dispatch({type: "sync", state: "BUILD_READY_RELOAD"});
|
|
1172
|
+
dispatch({ type: "sync", state: "BUILD_READY_RELOAD" });
|
|
1169
1173
|
} else {
|
|
1170
|
-
dispatch({type: "sync", state: "BUILD_READY"});
|
|
1174
|
+
dispatch({ type: "sync", state: "BUILD_READY" });
|
|
1171
1175
|
}
|
|
1172
1176
|
break;
|
|
1173
1177
|
case "cached":
|
|
1174
|
-
dispatch({type: "sync", state: "UP_TO_DATE"});
|
|
1178
|
+
dispatch({ type: "sync", state: "UP_TO_DATE" });
|
|
1175
1179
|
break;
|
|
1176
1180
|
default:
|
|
1177
1181
|
dispatch({
|
|
@@ -1182,7 +1186,7 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
1182
1186
|
break;
|
|
1183
1187
|
}
|
|
1184
1188
|
} catch (e) {
|
|
1185
|
-
dispatch({type: "sync", state: "ERROR", syncError: e});
|
|
1189
|
+
dispatch({ type: "sync", state: "ERROR", syncError: e });
|
|
1186
1190
|
} finally {
|
|
1187
1191
|
clearTimeout(buildingTimeout);
|
|
1188
1192
|
}
|
|
@@ -1219,8 +1223,8 @@ const TechDocsReaderProvider = ({
|
|
|
1219
1223
|
children,
|
|
1220
1224
|
entityRef
|
|
1221
1225
|
}) => {
|
|
1222
|
-
const {"*": path} = useParams();
|
|
1223
|
-
const {kind, namespace, name} = entityRef;
|
|
1226
|
+
const { "*": path } = useParams();
|
|
1227
|
+
const { kind, namespace, name } = entityRef;
|
|
1224
1228
|
const value = useReaderState(kind, namespace, name, path);
|
|
1225
1229
|
return /* @__PURE__ */ React.createElement(TechDocsReaderContext.Provider, {
|
|
1226
1230
|
value
|
|
@@ -1237,8 +1241,8 @@ const useTechDocsReaderDom = (entityRef) => {
|
|
|
1237
1241
|
const theme = useTheme();
|
|
1238
1242
|
const techdocsStorageApi = useApi(techdocsStorageApiRef);
|
|
1239
1243
|
const scmIntegrationsApi = useApi(scmIntegrationsApiRef);
|
|
1240
|
-
const {namespace = "", kind = "", name = ""} = entityRef;
|
|
1241
|
-
const {state, path, content: rawPage} = useTechDocsReader();
|
|
1244
|
+
const { namespace = "", kind = "", name = "" } = entityRef;
|
|
1245
|
+
const { state, path, content: rawPage } = useTechDocsReader();
|
|
1242
1246
|
const [sidebars, setSidebars] = useState();
|
|
1243
1247
|
const [dom, setDom] = useState(null);
|
|
1244
1248
|
const updateSidebarPosition = useCallback(() => {
|
|
@@ -1444,7 +1448,7 @@ const useTechDocsReaderDom = (entityRef) => {
|
|
|
1444
1448
|
if (!shouldReplaceContent) {
|
|
1445
1449
|
return;
|
|
1446
1450
|
}
|
|
1447
|
-
window.scroll({top: 0});
|
|
1451
|
+
window.scroll({ top: 0 });
|
|
1448
1452
|
const postTransformedDomElement = await postRender(preTransformedDomElement);
|
|
1449
1453
|
setDom(postTransformedDomElement);
|
|
1450
1454
|
});
|
|
@@ -1472,7 +1476,7 @@ const TheReader = ({
|
|
|
1472
1476
|
if (!dom || !shadowDomRef.current)
|
|
1473
1477
|
return;
|
|
1474
1478
|
const shadowDiv = shadowDomRef.current;
|
|
1475
|
-
const shadowRoot = shadowDiv.shadowRoot || shadowDiv.attachShadow({mode: "open"});
|
|
1479
|
+
const shadowRoot = shadowDiv.shadowRoot || shadowDiv.attachShadow({ mode: "open" });
|
|
1476
1480
|
Array.from(shadowRoot.children).forEach((child) => shadowRoot.removeChild(child));
|
|
1477
1481
|
shadowRoot.appendChild(dom);
|
|
1478
1482
|
onReadyRef.current();
|
|
@@ -1505,9 +1509,9 @@ const TechDocsPageHeader = ({
|
|
|
1505
1509
|
entityMetadata,
|
|
1506
1510
|
techDocsMetadata
|
|
1507
1511
|
}) => {
|
|
1508
|
-
const {name} = entityRef;
|
|
1509
|
-
const {site_name: siteName, site_description: siteDescription} = techDocsMetadata || {};
|
|
1510
|
-
const {locationMetadata, spec} = entityMetadata || {};
|
|
1512
|
+
const { name } = entityRef;
|
|
1513
|
+
const { site_name: siteName, site_description: siteDescription } = techDocsMetadata || {};
|
|
1514
|
+
const { locationMetadata, spec } = entityMetadata || {};
|
|
1511
1515
|
const lifecycle = spec == null ? void 0 : spec.lifecycle;
|
|
1512
1516
|
const ownedByRelations = entityMetadata ? getEntityRelations(entityMetadata, RELATION_OWNED_BY) : [];
|
|
1513
1517
|
const docsRootLink = useRouteRef(rootRouteRef)();
|
|
@@ -1535,7 +1539,7 @@ const TechDocsPageHeader = ({
|
|
|
1535
1539
|
target: "_blank",
|
|
1536
1540
|
rel: "noopener noreferrer"
|
|
1537
1541
|
}, /* @__PURE__ */ React.createElement(CodeIcon, {
|
|
1538
|
-
style: {marginTop: "-25px", fill: "#fff"}
|
|
1542
|
+
style: { marginTop: "-25px", fill: "#fff" }
|
|
1539
1543
|
}))
|
|
1540
1544
|
}) : null);
|
|
1541
1545
|
return /* @__PURE__ */ React.createElement(Header, {
|
|
@@ -1549,16 +1553,16 @@ const TechDocsPageHeader = ({
|
|
|
1549
1553
|
|
|
1550
1554
|
const LegacyTechDocsPage = () => {
|
|
1551
1555
|
const [documentReady, setDocumentReady] = useState(false);
|
|
1552
|
-
const {namespace, kind, name} = useParams();
|
|
1556
|
+
const { namespace, kind, name } = useParams();
|
|
1553
1557
|
const techdocsApi = useApi(techdocsApiRef);
|
|
1554
|
-
const {value: techdocsMetadataValue} = useAsync(() => {
|
|
1558
|
+
const { value: techdocsMetadataValue } = useAsync(() => {
|
|
1555
1559
|
if (documentReady) {
|
|
1556
|
-
return techdocsApi.getTechDocsMetadata({kind, namespace, name});
|
|
1560
|
+
return techdocsApi.getTechDocsMetadata({ kind, namespace, name });
|
|
1557
1561
|
}
|
|
1558
1562
|
return Promise.resolve(void 0);
|
|
1559
1563
|
}, [kind, namespace, name, techdocsApi, documentReady]);
|
|
1560
|
-
const {value: entityMetadataValue, error: entityMetadataError} = useAsync(() => {
|
|
1561
|
-
return techdocsApi.getEntityMetadata({kind, namespace, name});
|
|
1564
|
+
const { value: entityMetadataValue, error: entityMetadataError } = useAsync(() => {
|
|
1565
|
+
return techdocsApi.getEntityMetadata({ kind, namespace, name });
|
|
1562
1566
|
}, [kind, namespace, name, techdocsApi]);
|
|
1563
1567
|
const onReady = useCallback(() => {
|
|
1564
1568
|
setDocumentReady(true);
|
|
@@ -1590,19 +1594,19 @@ const LegacyTechDocsPage = () => {
|
|
|
1590
1594
|
})));
|
|
1591
1595
|
};
|
|
1592
1596
|
|
|
1593
|
-
const TechDocsPage = ({children}) => {
|
|
1597
|
+
const TechDocsPage = ({ children }) => {
|
|
1594
1598
|
const outlet = useOutlet();
|
|
1595
1599
|
const [documentReady, setDocumentReady] = useState(false);
|
|
1596
|
-
const {namespace, kind, name} = useParams();
|
|
1600
|
+
const { namespace, kind, name } = useParams();
|
|
1597
1601
|
const techdocsApi = useApi(techdocsApiRef);
|
|
1598
|
-
const {value: techdocsMetadataValue} = useAsync(() => {
|
|
1602
|
+
const { value: techdocsMetadataValue } = useAsync(() => {
|
|
1599
1603
|
if (documentReady) {
|
|
1600
|
-
return techdocsApi.getTechDocsMetadata({kind, namespace, name});
|
|
1604
|
+
return techdocsApi.getTechDocsMetadata({ kind, namespace, name });
|
|
1601
1605
|
}
|
|
1602
1606
|
return Promise.resolve(void 0);
|
|
1603
1607
|
}, [kind, namespace, name, techdocsApi, documentReady]);
|
|
1604
|
-
const {value: entityMetadataValue, error: entityMetadataError} = useAsync(() => {
|
|
1605
|
-
return techdocsApi.getEntityMetadata({kind, namespace, name});
|
|
1608
|
+
const { value: entityMetadataValue, error: entityMetadataError } = useAsync(() => {
|
|
1609
|
+
return techdocsApi.getEntityMetadata({ kind, namespace, name });
|
|
1606
1610
|
}, [kind, namespace, name, techdocsApi]);
|
|
1607
1611
|
const onReady = useCallback(() => {
|
|
1608
1612
|
setDocumentReady(true);
|
|
@@ -1619,7 +1623,7 @@ const TechDocsPage = ({children}) => {
|
|
|
1619
1623
|
}, children instanceof Function ? children({
|
|
1620
1624
|
techdocsMetadataValue,
|
|
1621
1625
|
entityMetadataValue,
|
|
1622
|
-
entityRef: {kind, namespace, name},
|
|
1626
|
+
entityRef: { kind, namespace, name },
|
|
1623
1627
|
onReady
|
|
1624
1628
|
}) : children);
|
|
1625
1629
|
};
|
|
@@ -1645,7 +1649,7 @@ const CustomPanel = ({
|
|
|
1645
1649
|
}
|
|
1646
1650
|
});
|
|
1647
1651
|
const classes = useStyles();
|
|
1648
|
-
const {value: user} = useOwnUser();
|
|
1652
|
+
const { value: user } = useOwnUser();
|
|
1649
1653
|
const Panel = panels[config.panelType];
|
|
1650
1654
|
const shownEntities = entities.filter((entity) => {
|
|
1651
1655
|
if (config.filterPredicate === "ownedByUser") {
|
|
@@ -1710,7 +1714,7 @@ const TechDocsCustomHome = ({
|
|
|
1710
1714
|
return /* @__PURE__ */ React.createElement(TechDocsPageWrapper, null, /* @__PURE__ */ React.createElement(HeaderTabs, {
|
|
1711
1715
|
selectedIndex: selectedTab,
|
|
1712
1716
|
onChange: (index) => setSelectedTab(index),
|
|
1713
|
-
tabs: tabsConfig.map(({label}, index) => ({
|
|
1717
|
+
tabs: tabsConfig.map(({ label }, index) => ({
|
|
1714
1718
|
id: index.toString(),
|
|
1715
1719
|
label
|
|
1716
1720
|
}))
|
|
@@ -1769,14 +1773,15 @@ var TechDocsIndexPage$1 = /*#__PURE__*/Object.freeze({
|
|
|
1769
1773
|
TechDocsIndexPage: TechDocsIndexPage
|
|
1770
1774
|
});
|
|
1771
1775
|
|
|
1772
|
-
const EntityPageDocs = ({entity}) => {
|
|
1776
|
+
const EntityPageDocs = ({ entity }) => {
|
|
1773
1777
|
var _a;
|
|
1778
|
+
const config = useApi(configApiRef);
|
|
1774
1779
|
return /* @__PURE__ */ React.createElement(Reader, {
|
|
1775
1780
|
withSearch: false,
|
|
1776
1781
|
entityRef: {
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
name: entity.metadata.name
|
|
1782
|
+
namespace: toLowerMaybe((_a = entity.metadata.namespace) != null ? _a : "default", config),
|
|
1783
|
+
kind: toLowerMaybe(entity.kind, config),
|
|
1784
|
+
name: toLowerMaybe(entity.metadata.name, config)
|
|
1780
1785
|
}
|
|
1781
1786
|
});
|
|
1782
1787
|
};
|
|
@@ -1797,7 +1802,7 @@ const Router = () => {
|
|
|
1797
1802
|
};
|
|
1798
1803
|
const EmbeddedDocsRouter = (_props) => {
|
|
1799
1804
|
var _a;
|
|
1800
|
-
const {entity} = useEntity();
|
|
1805
|
+
const { entity } = useEntity();
|
|
1801
1806
|
const projectId = (_a = entity.metadata.annotations) == null ? void 0 : _a[TECHDOCS_ANNOTATION];
|
|
1802
1807
|
if (!projectId) {
|
|
1803
1808
|
return /* @__PURE__ */ React.createElement(MissingAnnotationEmptyState, {
|