@jpmorganchase/elemental-dev-portal 2.9.1 → 2.10.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/components/BranchSelector/BranchSelector.spec.d.ts +2 -15
- package/components/DevPortalProvider/index.d.ts +1 -0
- package/components/NodeContent/NodeContent.d.ts +2 -1
- package/components/Search/SearchOverlay.d.ts +16 -0
- package/handlers/getBranches.d.ts +2 -2
- package/hooks/useGetBranches.d.ts +1 -1
- package/index.esm.js +76 -61
- package/index.js +74 -59
- package/index.mjs +76 -61
- package/package.json +5 -5
- package/styles.min.css +1 -1
- package/types.d.ts +3 -1
- package/version.d.ts +1 -1
- package/web-components.min.js +1 -1
package/index.mjs
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { Menu, FieldButton, Modal, Input, Box, Icon, ListBox, ListBoxItem, Flex, VStack, Heading } from '@stoplight/mosaic';
|
2
2
|
import * as React from 'react';
|
3
3
|
import React__default, { useRef, useEffect, useMemo, useCallback, useState } from 'react';
|
4
|
-
import { withPersistenceBoundary, withQueryClientProvider, withMosaicProvider, MarkdownComponentsProvider, MockingProvider, Docs, withStyles, NodeTypeIconDefs, NodeTypeColors, TableOfContents as TableOfContents$1, PoweredByLink, useRouter, RouterTypeContext, findFirstNode, ReactRouterMarkdownLink, SidebarLayout } from '@jpmorganchase/elemental-core';
|
4
|
+
import { withPersistenceBoundary, withQueryClientProvider, withMosaicProvider, MarkdownComponentsProvider, LinkHeading, MockingProvider, Docs, withStyles, NodeTypeIconDefs, NodeTypeColors, TableOfContents as TableOfContents$1, PoweredByLink, useRouter, RouterTypeContext, findFirstNode, ReactRouterMarkdownLink, SidebarLayout } from '@jpmorganchase/elemental-core';
|
5
5
|
import { resolve, dirname } from '@stoplight/path';
|
6
6
|
import { NodeType } from '@stoplight/types';
|
7
7
|
import flow from 'lodash/flow.js';
|
8
|
-
import { Route, useParams, useHistory, Redirect, Link } from 'react-router-dom';
|
8
|
+
import { Switch, Route, useParams, useHistory, Redirect, Link } from 'react-router-dom';
|
9
9
|
import { useQuery } from 'react-query';
|
10
10
|
|
11
11
|
const BranchSelector = ({ branchSlug, branches, onChange }) => {
|
@@ -23,7 +23,7 @@ const BranchSelector = ({ branchSlug, branches, onChange }) => {
|
|
23
23
|
onChange: handleChange,
|
24
24
|
value: (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.slug) || '',
|
25
25
|
children: branches.map(branch => ({
|
26
|
-
|
26
|
+
title: branch.name || branch.slug,
|
27
27
|
value: branch.slug,
|
28
28
|
meta: branch.is_default ? 'Default' : undefined,
|
29
29
|
})),
|
@@ -32,15 +32,66 @@ const BranchSelector = ({ branchSlug, branches, onChange }) => {
|
|
32
32
|
};
|
33
33
|
|
34
34
|
const PlatformContext = React.createContext({ platformUrl: 'https://stoplight.io' });
|
35
|
-
const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthToken, children, }) => {
|
36
|
-
return React.createElement(PlatformContext.Provider, { value: { platformUrl, platformAuthToken } }, children);
|
35
|
+
const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthToken, isLoggedIn, children, }) => {
|
36
|
+
return (React.createElement(PlatformContext.Provider, { value: { platformUrl, platformAuthToken, isLoggedIn } }, children));
|
37
37
|
};
|
38
38
|
const DevPortalProvider = withPersistenceBoundary(withQueryClientProvider(withMosaicProvider(PlatformProvider)));
|
39
39
|
|
40
|
-
|
40
|
+
/*! *****************************************************************************
|
41
|
+
Copyright (c) Microsoft Corporation.
|
42
|
+
|
43
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
44
|
+
purpose with or without fee is hereby granted.
|
45
|
+
|
46
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
47
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
48
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
49
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
50
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
51
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
52
|
+
PERFORMANCE OF THIS SOFTWARE.
|
53
|
+
***************************************************************************** */
|
54
|
+
|
55
|
+
function __rest(s, e) {
|
56
|
+
var t = {};
|
57
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
58
|
+
t[p] = s[p];
|
59
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
60
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
61
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
62
|
+
t[p[i]] = s[p[i]];
|
63
|
+
}
|
64
|
+
return t;
|
65
|
+
}
|
66
|
+
|
67
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
68
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
69
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
70
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
71
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
72
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
73
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
77
|
+
const NodeContent = ({ node, Link, hideMocking, refResolver, maxRefDepth, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideExport, onExportRequest, }) => {
|
41
78
|
var _a, _b, _c, _d;
|
42
79
|
return (React.createElement(NodeLinkContext.Provider, { value: [node, Link] },
|
43
|
-
React.createElement(MarkdownComponentsProvider, { value: {
|
80
|
+
React.createElement(MarkdownComponentsProvider, { value: {
|
81
|
+
a: LinkComponent,
|
82
|
+
h2: (_a) => {
|
83
|
+
var props = __rest(_a, ["color"]);
|
84
|
+
return React.createElement(LinkHeading, Object.assign({ size: 2 }, props));
|
85
|
+
},
|
86
|
+
h3: (_a) => {
|
87
|
+
var props = __rest(_a, ["color"]);
|
88
|
+
return React.createElement(LinkHeading, Object.assign({ size: 3 }, props));
|
89
|
+
},
|
90
|
+
h4: (_a) => {
|
91
|
+
var props = __rest(_a, ["color"]);
|
92
|
+
return React.createElement(LinkHeading, Object.assign({ size: 4 }, props));
|
93
|
+
},
|
94
|
+
} },
|
44
95
|
React.createElement(MockingProvider, { mockUrl: node.links.mock_url, hideMocking: hideMocking },
|
45
96
|
React.createElement(Docs, { nodeType: node.type, nodeData: node.data, nodeTitle: node.title, layoutOptions: {
|
46
97
|
compact,
|
@@ -49,7 +100,7 @@ const NodeContent = ({ node, Link, hideMocking, refResolver, tryItCorsProxy, try
|
|
49
100
|
hideExport: hideExport ||
|
50
101
|
((_b = (_a = node.links.export_url) !== null && _a !== void 0 ? _a : node.links.export_original_file_url) !== null && _b !== void 0 ? _b : node.links.export_bundled_file_url) ===
|
51
102
|
undefined,
|
52
|
-
}, useNodeForRefResolving: true, refResolver: refResolver, tryItCorsProxy: tryItCorsProxy, exportProps: [NodeType.HttpService, NodeType.Model].includes(node.type)
|
103
|
+
}, useNodeForRefResolving: true, refResolver: refResolver, maxRefDepth: maxRefDepth, tryItCorsProxy: tryItCorsProxy, exportProps: [NodeType.HttpService, NodeType.Model].includes(node.type)
|
53
104
|
? {
|
54
105
|
original: onExportRequest
|
55
106
|
? { onPress: () => onExportRequest('original') }
|
@@ -164,43 +215,6 @@ const SearchResultsList = ({ searchResults, onClick, isEmbedded, showDivider = t
|
|
164
215
|
const SearchResults = flow(withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(SearchResultsList);
|
165
216
|
const Search = flow(withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(SearchImpl);
|
166
217
|
|
167
|
-
/*! *****************************************************************************
|
168
|
-
Copyright (c) Microsoft Corporation.
|
169
|
-
|
170
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
171
|
-
purpose with or without fee is hereby granted.
|
172
|
-
|
173
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
174
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
175
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
176
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
177
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
178
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
179
|
-
PERFORMANCE OF THIS SOFTWARE.
|
180
|
-
***************************************************************************** */
|
181
|
-
|
182
|
-
function __rest(s, e) {
|
183
|
-
var t = {};
|
184
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
185
|
-
t[p] = s[p];
|
186
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
187
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
188
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
189
|
-
t[p[i]] = s[p[i]];
|
190
|
-
}
|
191
|
-
return t;
|
192
|
-
}
|
193
|
-
|
194
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
195
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
196
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
197
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
198
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
199
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
200
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
201
|
-
});
|
202
|
-
}
|
203
|
-
|
204
218
|
const TableOfContents = (_a) => {
|
205
219
|
var { tableOfContents, activeId, Link, collapseTableOfContents = false, externalScrollbar, isInResponsiveMode = false, onLinkClick } = _a, boxProps = __rest(_a, ["tableOfContents", "activeId", "Link", "collapseTableOfContents", "externalScrollbar", "isInResponsiveMode", "onLinkClick"]);
|
206
220
|
return (React.createElement(Flex, Object.assign({ bg: isInResponsiveMode ? 'canvas' : 'canvas-100' }, boxProps, { flexDirection: "col", maxH: "full" }),
|
@@ -249,7 +263,7 @@ const UpgradeToStarter = () => (React__default.createElement(Flex, { as: "a", hr
|
|
249
263
|
React__default.createElement(Icon, { icon: ['fas', 'exclamation-triangle'], size: "4x" }),
|
250
264
|
React__default.createElement(Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
|
251
265
|
|
252
|
-
const appVersion = '2.
|
266
|
+
const appVersion = '2.10.1';
|
253
267
|
|
254
268
|
class ResponseError extends Error {
|
255
269
|
constructor(message, responseCode) {
|
@@ -294,15 +308,15 @@ const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platform
|
|
294
308
|
});
|
295
309
|
|
296
310
|
function useGetBranches({ projectId }) {
|
297
|
-
const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
|
298
|
-
return useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl,
|
311
|
+
const { platformUrl, platformAuthToken, isLoggedIn } = React.useContext(PlatformContext);
|
312
|
+
return useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, isLoggedIn], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
|
299
313
|
enabled: projectId ? true : false,
|
300
314
|
});
|
301
315
|
}
|
302
316
|
|
303
317
|
function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
|
304
|
-
const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
|
305
|
-
return useQuery([...devPortalCacheKeys.branchNodeDetails(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : '', nodeSlug), platformUrl,
|
318
|
+
const { platformUrl, platformAuthToken, isLoggedIn } = React.useContext(PlatformContext);
|
319
|
+
return useQuery([...devPortalCacheKeys.branchNodeDetails(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : '', nodeSlug), platformUrl, isLoggedIn], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
|
306
320
|
}
|
307
321
|
|
308
322
|
const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
@@ -320,8 +334,8 @@ const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stop
|
|
320
334
|
});
|
321
335
|
|
322
336
|
function useGetTableOfContents({ projectId, branchSlug }) {
|
323
|
-
const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
|
324
|
-
return useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl,
|
337
|
+
const { platformUrl, platformAuthToken, isLoggedIn } = React.useContext(PlatformContext);
|
338
|
+
return useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, isLoggedIn], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
|
325
339
|
}
|
326
340
|
|
327
341
|
const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, collapseTableOfContents = false, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
@@ -377,7 +391,7 @@ const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, c
|
|
377
391
|
}
|
378
392
|
};
|
379
393
|
return (React.createElement(SidebarLayout, { ref: container, sidebar: React.createElement(React.Fragment, null,
|
380
|
-
branches && branches.length > 1 ? (React.createElement(BranchSelector, { branchSlug: branchSlug, branches: branches, onChange: branch => {
|
394
|
+
branches && branches.items.length > 1 ? (React.createElement(BranchSelector, { branchSlug: branchSlug, branches: branches.items, onChange: branch => {
|
381
395
|
const encodedBranchSlug = encodeURIComponent(branch.slug);
|
382
396
|
history.push(branch.is_default ? `/${nodeSlug}` : `/branches/${encodedBranchSlug}/${nodeSlug}`);
|
383
397
|
} })) : null,
|
@@ -389,12 +403,13 @@ const StoplightProjectRouter = (_a) => {
|
|
389
403
|
return (React.createElement(DevPortalProvider, { platformUrl: platformUrl },
|
390
404
|
React.createElement(RouterTypeContext.Provider, { value: router },
|
391
405
|
React.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
392
|
-
React.createElement(
|
393
|
-
React.createElement(
|
394
|
-
|
395
|
-
React.createElement(
|
396
|
-
|
397
|
-
React.createElement(
|
406
|
+
React.createElement(Switch, null,
|
407
|
+
React.createElement(Route, { path: "/branches/:branchSlug/:nodeSlug+", exact: true },
|
408
|
+
React.createElement(StoplightProjectImpl, Object.assign({}, props))),
|
409
|
+
React.createElement(Route, { path: "/:nodeSlug+", exact: true },
|
410
|
+
React.createElement(StoplightProjectImpl, Object.assign({}, props))),
|
411
|
+
React.createElement(Route, { path: "/", exact: true },
|
412
|
+
React.createElement(StoplightProjectImpl, Object.assign({}, props))))))));
|
398
413
|
};
|
399
414
|
const StoplightProject = withStyles(StoplightProjectRouter);
|
400
415
|
|
@@ -675,12 +690,12 @@ function useDebounce(value, delay, options) {
|
|
675
690
|
}
|
676
691
|
|
677
692
|
function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
|
678
|
-
const { platformUrl, platformAuthToken } = React.useContext(PlatformContext);
|
693
|
+
const { platformUrl, platformAuthToken, isLoggedIn } = React.useContext(PlatformContext);
|
679
694
|
const [debounceSearch] = useDebounce(search, 500);
|
680
695
|
return useQuery([
|
681
696
|
...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
|
682
697
|
platformUrl,
|
683
|
-
|
698
|
+
isLoggedIn,
|
684
699
|
], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
685
700
|
}
|
686
701
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jpmorganchase/elemental-dev-portal",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.10.1",
|
4
4
|
"description": "UI components for composing beautiful developer documentation.",
|
5
5
|
"keywords": [],
|
6
6
|
"main": "./index.js",
|
@@ -27,13 +27,13 @@
|
|
27
27
|
"react-dom": ">=16.8"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
|
-
"@jpmorganchase/elemental-core": "^1.
|
31
|
-
"@stoplight/markdown-viewer": "^5.
|
32
|
-
"@stoplight/mosaic": "^
|
30
|
+
"@jpmorganchase/elemental-core": "^1.17.1",
|
31
|
+
"@stoplight/markdown-viewer": "^5.7.0",
|
32
|
+
"@stoplight/mosaic": "^1.53.4",
|
33
33
|
"@stoplight/path": "^1.3.2",
|
34
34
|
"@stoplight/types": "^14.0.0",
|
35
35
|
"classnames": "^2.2.6",
|
36
|
-
"lodash": "^4.17.
|
36
|
+
"lodash": "^4.17.21",
|
37
37
|
"react-query": "^3.34.19",
|
38
38
|
"react-router-dom": "^5.2.0",
|
39
39
|
"use-debounce": "^6.0.1"
|