@backstage/plugin-techdocs 1.1.1-next.1 → 1.1.1
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 +52 -0
- package/dist/esm/{TechDocsCustomHome-e3ec7aed.esm.js → TechDocsCustomHome-cd82e45b.esm.js} +4 -4
- package/dist/esm/{TechDocsCustomHome-e3ec7aed.esm.js.map → TechDocsCustomHome-cd82e45b.esm.js.map} +1 -1
- package/dist/esm/{index-998ae86b.esm.js → index-aaf89f6d.esm.js} +6 -6
- package/dist/esm/index-aaf89f6d.esm.js.map +1 -0
- package/dist/esm/{index-76cc1cd7.esm.js → index-dd16232a.esm.js} +233 -188
- package/dist/esm/index-dd16232a.esm.js.map +1 -0
- package/dist/index.d.ts +51 -49
- package/dist/index.esm.js +5 -5
- package/package.json +16 -16
- package/dist/esm/index-76cc1cd7.esm.js.map +0 -1
- package/dist/esm/index-998ae86b.esm.js.map +0 -1
|
@@ -1,23 +1,22 @@
|
|
|
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, {
|
|
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
|
-
import
|
|
12
|
-
import { SearchContextProvider, useSearch } from '@backstage/plugin-search-react';
|
|
13
|
+
import { HighlightedSearchResultText, SearchContextProvider, useSearch } from '@backstage/plugin-search-react';
|
|
13
14
|
import SearchIcon from '@material-ui/icons/Search';
|
|
14
15
|
import Autocomplete from '@material-ui/lab/Autocomplete';
|
|
15
16
|
import { useNavigate, useOutlet as useOutlet$1 } from 'react-router';
|
|
16
17
|
import useDebounce from 'react-use/lib/useDebounce';
|
|
17
18
|
import { Alert, Skeleton } from '@material-ui/lab';
|
|
18
19
|
import Close from '@material-ui/icons/Close';
|
|
19
|
-
import useAsync from 'react-use/lib/useAsync';
|
|
20
|
-
import useAsyncRetry from 'react-use/lib/useAsyncRetry';
|
|
21
20
|
import { lighten, alpha } from '@material-ui/core/styles';
|
|
22
21
|
import { scmIntegrationsApiRef } from '@backstage/integration-react';
|
|
23
22
|
import { replaceGitHubUrlType } from '@backstage/integration';
|
|
@@ -30,6 +29,7 @@ import Helmet from 'react-helmet';
|
|
|
30
29
|
import CodeIcon from '@material-ui/icons/Code';
|
|
31
30
|
import { getEntityRelations, EntityRefLink, EntityRefLinks, useEntityList, humanizeEntityRef, useStarredEntities, CATALOG_FILTER_EXISTS, EntityListProvider, CatalogFilterLayout, UserListPicker, EntityOwnerPicker, EntityTagPicker, useEntity } from '@backstage/plugin-catalog-react';
|
|
32
31
|
import { RELATION_OWNED_BY, getCompoundEntityRef } from '@backstage/catalog-model';
|
|
32
|
+
import SettingsIcon from '@material-ui/icons/Settings';
|
|
33
33
|
import useCopyToClipboard from 'react-use/lib/useCopyToClipboard';
|
|
34
34
|
import { capitalize } from 'lodash';
|
|
35
35
|
import ShareIcon from '@material-ui/icons/Share';
|
|
@@ -153,6 +153,169 @@ class TechDocsStorageClient {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
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
|
+
|
|
156
319
|
const useStyles$4 = makeStyles({
|
|
157
320
|
flexContainer: {
|
|
158
321
|
flexWrap: "wrap"
|
|
@@ -165,6 +328,7 @@ const useStyles$4 = makeStyles({
|
|
|
165
328
|
const TechDocsSearchResultListItem = (props) => {
|
|
166
329
|
const {
|
|
167
330
|
result,
|
|
331
|
+
highlight,
|
|
168
332
|
lineClamp = 5,
|
|
169
333
|
asListItem = true,
|
|
170
334
|
asLink = true,
|
|
@@ -172,17 +336,37 @@ const TechDocsSearchResultListItem = (props) => {
|
|
|
172
336
|
} = props;
|
|
173
337
|
const classes = useStyles$4();
|
|
174
338
|
const TextItem = () => {
|
|
175
|
-
|
|
339
|
+
const resultTitle = (highlight == null ? void 0 : highlight.fields.title) ? /* @__PURE__ */ React.createElement(HighlightedSearchResultText, {
|
|
340
|
+
text: highlight.fields.title,
|
|
341
|
+
preTag: highlight.preTag,
|
|
342
|
+
postTag: highlight.postTag
|
|
343
|
+
}) : result.title;
|
|
344
|
+
const entityTitle = (highlight == null ? void 0 : highlight.fields.entityTitle) ? /* @__PURE__ */ React.createElement(HighlightedSearchResultText, {
|
|
345
|
+
text: highlight.fields.entityTitle,
|
|
346
|
+
preTag: highlight.preTag,
|
|
347
|
+
postTag: highlight.postTag
|
|
348
|
+
}) : result.entityTitle;
|
|
349
|
+
const resultName = (highlight == null ? void 0 : highlight.fields.name) ? /* @__PURE__ */ React.createElement(HighlightedSearchResultText, {
|
|
350
|
+
text: highlight.fields.name,
|
|
351
|
+
preTag: highlight.preTag,
|
|
352
|
+
postTag: highlight.postTag
|
|
353
|
+
}) : result.name;
|
|
176
354
|
return /* @__PURE__ */ React.createElement(ListItemText, {
|
|
177
355
|
className: classes.itemText,
|
|
178
356
|
primaryTypographyProps: { variant: "h6" },
|
|
179
|
-
primary: title ? title :
|
|
180
|
-
secondary: /* @__PURE__ */ React.createElement(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
357
|
+
primary: title ? title : /* @__PURE__ */ React.createElement(React.Fragment, null, resultTitle, " | ", entityTitle != null ? entityTitle : resultName, " docs"),
|
|
358
|
+
secondary: /* @__PURE__ */ React.createElement("span", {
|
|
359
|
+
style: {
|
|
360
|
+
display: "-webkit-box",
|
|
361
|
+
WebkitBoxOrient: "vertical",
|
|
362
|
+
WebkitLineClamp: lineClamp,
|
|
363
|
+
overflow: "hidden"
|
|
364
|
+
}
|
|
365
|
+
}, (highlight == null ? void 0 : highlight.fields.text) ? /* @__PURE__ */ React.createElement(HighlightedSearchResultText, {
|
|
366
|
+
text: highlight.fields.text,
|
|
367
|
+
preTag: highlight.preTag,
|
|
368
|
+
postTag: highlight.postTag
|
|
369
|
+
}) : result.text)
|
|
186
370
|
});
|
|
187
371
|
};
|
|
188
372
|
const LinkWrapper = ({ children }) => asLink ? /* @__PURE__ */ React.createElement(Link, {
|
|
@@ -269,12 +453,13 @@ const TechDocsSearchBar = (props) => {
|
|
|
269
453
|
noOptionsText: "No results found",
|
|
270
454
|
value: null,
|
|
271
455
|
options,
|
|
272
|
-
renderOption: ({ document }) => /* @__PURE__ */ React.createElement(TechDocsSearchResultListItem, {
|
|
456
|
+
renderOption: ({ document, highlight }) => /* @__PURE__ */ React.createElement(TechDocsSearchResultListItem, {
|
|
273
457
|
result: document,
|
|
274
458
|
lineClamp: 3,
|
|
275
459
|
asListItem: false,
|
|
276
460
|
asLink: false,
|
|
277
|
-
title: document.title
|
|
461
|
+
title: document.title,
|
|
462
|
+
highlight
|
|
278
463
|
}),
|
|
279
464
|
loading,
|
|
280
465
|
renderInput: (params) => /* @__PURE__ */ React.createElement(TextField, {
|
|
@@ -477,169 +662,6 @@ const TechDocsStateIndicator = () => {
|
|
|
477
662
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, ReaderProgress, StateAlert);
|
|
478
663
|
};
|
|
479
664
|
|
|
480
|
-
function calculateDisplayState({
|
|
481
|
-
contentLoading,
|
|
482
|
-
content,
|
|
483
|
-
activeSyncState
|
|
484
|
-
}) {
|
|
485
|
-
if (contentLoading) {
|
|
486
|
-
return "CHECKING";
|
|
487
|
-
}
|
|
488
|
-
if (activeSyncState === "BUILD_READY_RELOAD") {
|
|
489
|
-
return "CHECKING";
|
|
490
|
-
}
|
|
491
|
-
if (!content && activeSyncState === "CHECKING") {
|
|
492
|
-
return "CHECKING";
|
|
493
|
-
}
|
|
494
|
-
if (!content && activeSyncState === "BUILDING") {
|
|
495
|
-
return "INITIAL_BUILD";
|
|
496
|
-
}
|
|
497
|
-
if (!content) {
|
|
498
|
-
return "CONTENT_NOT_FOUND";
|
|
499
|
-
}
|
|
500
|
-
if (activeSyncState === "BUILDING") {
|
|
501
|
-
return "CONTENT_STALE_REFRESHING";
|
|
502
|
-
}
|
|
503
|
-
if (activeSyncState === "BUILD_READY") {
|
|
504
|
-
return "CONTENT_STALE_READY";
|
|
505
|
-
}
|
|
506
|
-
if (activeSyncState === "ERROR") {
|
|
507
|
-
return "CONTENT_STALE_ERROR";
|
|
508
|
-
}
|
|
509
|
-
return "CONTENT_FRESH";
|
|
510
|
-
}
|
|
511
|
-
function reducer(oldState, action) {
|
|
512
|
-
const newState = { ...oldState };
|
|
513
|
-
switch (action.type) {
|
|
514
|
-
case "sync":
|
|
515
|
-
if (action.state === "CHECKING") {
|
|
516
|
-
newState.buildLog = [];
|
|
517
|
-
}
|
|
518
|
-
newState.activeSyncState = action.state;
|
|
519
|
-
newState.syncError = action.syncError;
|
|
520
|
-
break;
|
|
521
|
-
case "contentLoading":
|
|
522
|
-
newState.contentLoading = true;
|
|
523
|
-
newState.contentError = void 0;
|
|
524
|
-
break;
|
|
525
|
-
case "content":
|
|
526
|
-
if (typeof action.path === "string") {
|
|
527
|
-
newState.path = action.path;
|
|
528
|
-
}
|
|
529
|
-
newState.contentLoading = false;
|
|
530
|
-
newState.content = action.content;
|
|
531
|
-
newState.contentError = action.contentError;
|
|
532
|
-
break;
|
|
533
|
-
case "buildLog":
|
|
534
|
-
newState.buildLog = newState.buildLog.concat(action.log);
|
|
535
|
-
break;
|
|
536
|
-
default:
|
|
537
|
-
throw new Error();
|
|
538
|
-
}
|
|
539
|
-
if (["BUILD_READY", "BUILD_READY_RELOAD"].includes(newState.activeSyncState) && ["contentLoading", "content"].includes(action.type)) {
|
|
540
|
-
newState.activeSyncState = "UP_TO_DATE";
|
|
541
|
-
newState.buildLog = [];
|
|
542
|
-
}
|
|
543
|
-
return newState;
|
|
544
|
-
}
|
|
545
|
-
function useReaderState(kind, namespace, name, path) {
|
|
546
|
-
var _a, _b;
|
|
547
|
-
const [state, dispatch] = useReducer(reducer, {
|
|
548
|
-
activeSyncState: "CHECKING",
|
|
549
|
-
path,
|
|
550
|
-
contentLoading: true,
|
|
551
|
-
buildLog: []
|
|
552
|
-
});
|
|
553
|
-
const techdocsStorageApi = useApi(techdocsStorageApiRef$1);
|
|
554
|
-
const { retry: contentReload } = useAsyncRetry(async () => {
|
|
555
|
-
dispatch({ type: "contentLoading" });
|
|
556
|
-
try {
|
|
557
|
-
const entityDocs = await techdocsStorageApi.getEntityDocs({ kind, namespace, name }, path);
|
|
558
|
-
dispatch({ type: "content", content: entityDocs, path });
|
|
559
|
-
return entityDocs;
|
|
560
|
-
} catch (e) {
|
|
561
|
-
dispatch({ type: "content", contentError: e, path });
|
|
562
|
-
}
|
|
563
|
-
return void 0;
|
|
564
|
-
}, [techdocsStorageApi, kind, namespace, name, path]);
|
|
565
|
-
const contentRef = useRef({
|
|
566
|
-
content: void 0,
|
|
567
|
-
reload: () => {
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
contentRef.current = { content: state.content, reload: contentReload };
|
|
571
|
-
useAsync(async () => {
|
|
572
|
-
dispatch({ type: "sync", state: "CHECKING" });
|
|
573
|
-
const buildingTimeout = setTimeout(() => {
|
|
574
|
-
dispatch({ type: "sync", state: "BUILDING" });
|
|
575
|
-
}, 1e3);
|
|
576
|
-
try {
|
|
577
|
-
const result = await techdocsStorageApi.syncEntityDocs({
|
|
578
|
-
kind,
|
|
579
|
-
namespace,
|
|
580
|
-
name
|
|
581
|
-
}, (log) => {
|
|
582
|
-
dispatch({ type: "buildLog", log });
|
|
583
|
-
});
|
|
584
|
-
switch (result) {
|
|
585
|
-
case "updated":
|
|
586
|
-
if (!contentRef.current.content) {
|
|
587
|
-
contentRef.current.reload();
|
|
588
|
-
dispatch({ type: "sync", state: "BUILD_READY_RELOAD" });
|
|
589
|
-
} else {
|
|
590
|
-
dispatch({ type: "sync", state: "BUILD_READY" });
|
|
591
|
-
}
|
|
592
|
-
break;
|
|
593
|
-
case "cached":
|
|
594
|
-
dispatch({ type: "sync", state: "UP_TO_DATE" });
|
|
595
|
-
break;
|
|
596
|
-
default:
|
|
597
|
-
dispatch({
|
|
598
|
-
type: "sync",
|
|
599
|
-
state: "ERROR",
|
|
600
|
-
syncError: new Error("Unexpected return state")
|
|
601
|
-
});
|
|
602
|
-
break;
|
|
603
|
-
}
|
|
604
|
-
} catch (e) {
|
|
605
|
-
dispatch({ type: "sync", state: "ERROR", syncError: e });
|
|
606
|
-
} finally {
|
|
607
|
-
clearTimeout(buildingTimeout);
|
|
608
|
-
}
|
|
609
|
-
}, [kind, name, namespace, techdocsStorageApi, dispatch, contentRef]);
|
|
610
|
-
const displayState = useMemo(() => calculateDisplayState({
|
|
611
|
-
activeSyncState: state.activeSyncState,
|
|
612
|
-
contentLoading: state.contentLoading,
|
|
613
|
-
content: state.content
|
|
614
|
-
}), [state.activeSyncState, state.content, state.contentLoading]);
|
|
615
|
-
return {
|
|
616
|
-
state: displayState,
|
|
617
|
-
contentReload,
|
|
618
|
-
path: state.path,
|
|
619
|
-
content: state.content,
|
|
620
|
-
contentErrorMessage: (_a = state.contentError) == null ? void 0 : _a.toString(),
|
|
621
|
-
syncErrorMessage: (_b = state.syncError) == null ? void 0 : _b.toString(),
|
|
622
|
-
buildLog: state.buildLog
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
const TechDocsReaderContext = createContext({});
|
|
627
|
-
const useTechDocsReader = () => useContext(TechDocsReaderContext);
|
|
628
|
-
const TechDocsReaderProvider = ({
|
|
629
|
-
children
|
|
630
|
-
}) => {
|
|
631
|
-
const { "*": path = "" } = useParams();
|
|
632
|
-
const { entityRef } = useTechDocsReaderPage();
|
|
633
|
-
const { kind, namespace, name } = entityRef;
|
|
634
|
-
const value = useReaderState(kind, namespace, name, path);
|
|
635
|
-
return /* @__PURE__ */ React.createElement(TechDocsReaderContext.Provider, {
|
|
636
|
-
value
|
|
637
|
-
}, children instanceof Function ? children(value) : children);
|
|
638
|
-
};
|
|
639
|
-
const withTechDocsReaderProvider = (Component) => (props) => /* @__PURE__ */ React.createElement(TechDocsReaderProvider, null, /* @__PURE__ */ React.createElement(Component, {
|
|
640
|
-
...props
|
|
641
|
-
}));
|
|
642
|
-
|
|
643
665
|
const isSvgNeedingInlining = (attrName, attrVal, apiOrigin) => {
|
|
644
666
|
const isSrcToSvg = attrName === "src" && attrVal.endsWith(".svg");
|
|
645
667
|
const isRelativeUrl = !attrVal.match(/^([a-z]*:)?\/\//i);
|
|
@@ -664,7 +686,7 @@ const addBaseUrl = ({
|
|
|
664
686
|
try {
|
|
665
687
|
const svg = await fetch(newValue, { credentials: "include" });
|
|
666
688
|
const svgContent = await svg.text();
|
|
667
|
-
elem.setAttribute(attributeName, `data:image/svg+xml;base64,${btoa(svgContent)}`);
|
|
689
|
+
elem.setAttribute(attributeName, `data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(svgContent)))}`);
|
|
668
690
|
} catch (e) {
|
|
669
691
|
elem.setAttribute("alt", `Error: ${elemAttribute}`);
|
|
670
692
|
}
|
|
@@ -1784,24 +1806,46 @@ const TechDocsReaderPageSubheader = ({
|
|
|
1784
1806
|
toolbarProps
|
|
1785
1807
|
}) => {
|
|
1786
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
|
+
}, []);
|
|
1787
1816
|
const {
|
|
1788
1817
|
entityMetadata: { value: entityMetadata, loading: entityMetadataLoading }
|
|
1789
1818
|
} = useTechDocsReaderPage();
|
|
1790
1819
|
const addons = useTechDocsAddons();
|
|
1791
1820
|
const subheaderAddons = addons.renderComponentsByLocation(TechDocsAddonLocations.Subheader);
|
|
1792
|
-
|
|
1821
|
+
const settingsAddons = addons.renderComponentsByLocation(TechDocsAddonLocations.Settings);
|
|
1822
|
+
if (!subheaderAddons && !settingsAddons)
|
|
1793
1823
|
return null;
|
|
1794
1824
|
if (entityMetadataLoading === false && !entityMetadata)
|
|
1795
1825
|
return null;
|
|
1796
1826
|
return /* @__PURE__ */ React.createElement(Toolbar, {
|
|
1797
1827
|
classes,
|
|
1798
1828
|
...toolbarProps
|
|
1799
|
-
},
|
|
1829
|
+
}, /* @__PURE__ */ React.createElement(Box, {
|
|
1800
1830
|
display: "flex",
|
|
1801
1831
|
justifyContent: "flex-end",
|
|
1802
1832
|
width: "100%",
|
|
1803
1833
|
flexWrap: "wrap"
|
|
1804
|
-
}, 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));
|
|
1805
1849
|
};
|
|
1806
1850
|
|
|
1807
1851
|
const TechDocsReaderLayout = ({
|
|
@@ -2138,7 +2182,7 @@ const EntityTechdocsContent = techdocsPlugin.provide(createRoutableExtension({
|
|
|
2138
2182
|
}));
|
|
2139
2183
|
const TechDocsCustomHome = techdocsPlugin.provide(createRoutableExtension({
|
|
2140
2184
|
name: "TechDocsCustomHome",
|
|
2141
|
-
component: () => import('./TechDocsCustomHome-
|
|
2185
|
+
component: () => import('./TechDocsCustomHome-cd82e45b.esm.js').then((m) => m.TechDocsCustomHome),
|
|
2142
2186
|
mountPoint: rootRouteRef
|
|
2143
2187
|
}));
|
|
2144
2188
|
const TechDocsIndexPage$2 = techdocsPlugin.provide(createRoutableExtension({
|
|
@@ -2148,7 +2192,7 @@ const TechDocsIndexPage$2 = techdocsPlugin.provide(createRoutableExtension({
|
|
|
2148
2192
|
}));
|
|
2149
2193
|
const TechDocsReaderPage = techdocsPlugin.provide(createRoutableExtension({
|
|
2150
2194
|
name: "TechDocsReaderPage",
|
|
2151
|
-
component: () => import('./index-
|
|
2195
|
+
component: () => import('./index-aaf89f6d.esm.js').then((m) => m.TechDocsReaderPage),
|
|
2152
2196
|
mountPoint: rootDocsRouteRef
|
|
2153
2197
|
}));
|
|
2154
2198
|
|
|
@@ -2196,6 +2240,7 @@ const EmbeddedDocsRouter = (props) => {
|
|
|
2196
2240
|
});
|
|
2197
2241
|
}
|
|
2198
2242
|
return /* @__PURE__ */ React.createElement(Routes, null, /* @__PURE__ */ React.createElement(Route, {
|
|
2243
|
+
path: "*",
|
|
2199
2244
|
element: /* @__PURE__ */ React.createElement(EntityPageDocs, {
|
|
2200
2245
|
entity
|
|
2201
2246
|
})
|
|
@@ -2209,5 +2254,5 @@ var Router$1 = /*#__PURE__*/Object.freeze({
|
|
|
2209
2254
|
EmbeddedDocsRouter: EmbeddedDocsRouter
|
|
2210
2255
|
});
|
|
2211
2256
|
|
|
2212
|
-
export {
|
|
2213
|
-
//# sourceMappingURL=index-
|
|
2257
|
+
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 };
|
|
2258
|
+
//# sourceMappingURL=index-dd16232a.esm.js.map
|