@stoplight/elements-dev-portal 2.3.2 → 2.3.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/components/NodeContent/NodeContent.d.ts +2 -2
- package/containers/StoplightProject.d.ts +2 -0
- package/index.esm.js +379 -370
- package/index.js +400 -398
- package/index.mjs +379 -370
- package/package.json +3 -3
- package/version.d.ts +1 -1
- package/web-components.min.js +1 -1
package/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var mosaic = require('@stoplight/mosaic');
|
|
6
4
|
var React = require('react');
|
|
7
5
|
var elementsCore = require('@stoplight/elements-core');
|
|
@@ -11,60 +9,55 @@ var flow = require('lodash/flow.js');
|
|
|
11
9
|
var reactRouterDom = require('react-router-dom');
|
|
12
10
|
var reactQuery = require('react-query');
|
|
13
11
|
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
get: function () { return e[k]; }
|
|
12
|
+
function _interopNamespaceDefault(e) {
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
26
23
|
});
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
n["default"] = e;
|
|
31
|
-
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
32
27
|
}
|
|
33
28
|
|
|
34
|
-
var React__namespace = /*#__PURE__*/
|
|
35
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
36
|
-
var flow__default = /*#__PURE__*/_interopDefaultLegacy(flow);
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
37
30
|
|
|
38
|
-
const BranchSelector = ({ branchSlug, branches, onChange }) => {
|
|
39
|
-
const currentBranch = branches.find(branch => (!branchSlug ? branch.is_default : branch.slug === branchSlug));
|
|
40
|
-
const handleChange = React__namespace.useCallback((selectedSlug) => {
|
|
41
|
-
const selectedBranch = branches.find(branch => branch.slug === selectedSlug);
|
|
42
|
-
if (selectedBranch) {
|
|
43
|
-
onChange(selectedBranch);
|
|
44
|
-
}
|
|
45
|
-
}, [onChange, branches]);
|
|
46
|
-
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Versions", placement: "bottom left", closeOnPress: true, matchTriggerWidth: true, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.FieldButton, { w: "full", icon: "layer-group", px: 4, h: "md", active: isOpen, borderR: 0, roundedR: "none" }, (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.name) || (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.slug) || 'Choose a version')), items: [
|
|
47
|
-
{
|
|
48
|
-
type: 'option_group',
|
|
49
|
-
title: 'Versions',
|
|
50
|
-
onChange: handleChange,
|
|
51
|
-
value: (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.slug) || '',
|
|
52
|
-
children: branches.map(branch => ({
|
|
53
|
-
title: branch.name || branch.slug,
|
|
54
|
-
value: branch.slug,
|
|
55
|
-
meta: branch.is_default ? 'Default' : undefined,
|
|
56
|
-
})),
|
|
57
|
-
},
|
|
58
|
-
] }));
|
|
31
|
+
const BranchSelector = ({ branchSlug, branches, onChange }) => {
|
|
32
|
+
const currentBranch = branches.find(branch => (!branchSlug ? branch.is_default : branch.slug === branchSlug));
|
|
33
|
+
const handleChange = React__namespace.useCallback((selectedSlug) => {
|
|
34
|
+
const selectedBranch = branches.find(branch => branch.slug === selectedSlug);
|
|
35
|
+
if (selectedBranch) {
|
|
36
|
+
onChange(selectedBranch);
|
|
37
|
+
}
|
|
38
|
+
}, [onChange, branches]);
|
|
39
|
+
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Versions", placement: "bottom left", closeOnPress: true, matchTriggerWidth: true, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.FieldButton, { w: "full", icon: "layer-group", px: 4, h: "md", active: isOpen, borderR: 0, roundedR: "none" }, (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.name) || (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.slug) || 'Choose a version')), items: [
|
|
40
|
+
{
|
|
41
|
+
type: 'option_group',
|
|
42
|
+
title: 'Versions',
|
|
43
|
+
onChange: handleChange,
|
|
44
|
+
value: (currentBranch === null || currentBranch === void 0 ? void 0 : currentBranch.slug) || '',
|
|
45
|
+
children: branches.map(branch => ({
|
|
46
|
+
title: branch.name || branch.slug,
|
|
47
|
+
value: branch.slug,
|
|
48
|
+
meta: branch.is_default ? 'Default' : undefined,
|
|
49
|
+
})),
|
|
50
|
+
},
|
|
51
|
+
] }));
|
|
59
52
|
};
|
|
60
53
|
|
|
61
|
-
const PlatformContext = React__namespace.createContext({ platformUrl: 'https://stoplight.io' });
|
|
62
|
-
const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthToken, isLoggedIn, children, }) => {
|
|
63
|
-
return (React__namespace.createElement(PlatformContext.Provider, { value: { platformUrl, platformAuthToken, isLoggedIn } }, children));
|
|
64
|
-
};
|
|
54
|
+
const PlatformContext = React__namespace.createContext({ platformUrl: 'https://stoplight.io' });
|
|
55
|
+
const PlatformProvider = ({ platformUrl = 'https://stoplight.io', platformAuthToken, isLoggedIn, children, }) => {
|
|
56
|
+
return (React__namespace.createElement(PlatformContext.Provider, { value: { platformUrl, platformAuthToken, isLoggedIn } }, children));
|
|
57
|
+
};
|
|
65
58
|
const DevPortalProvider = elementsCore.withPersistenceBoundary(elementsCore.withQueryClientProvider(elementsCore.withMosaicProvider(PlatformProvider)));
|
|
66
59
|
|
|
67
|
-
|
|
60
|
+
/******************************************************************************
|
|
68
61
|
Copyright (c) Microsoft Corporation.
|
|
69
62
|
|
|
70
63
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -78,6 +71,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
78
71
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
79
72
|
PERFORMANCE OF THIS SOFTWARE.
|
|
80
73
|
***************************************************************************** */
|
|
74
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
75
|
+
|
|
81
76
|
|
|
82
77
|
function __rest(s, e) {
|
|
83
78
|
var t = {};
|
|
@@ -99,89 +94,96 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
99
94
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
100
95
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
101
96
|
});
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const NodeContent = ({ node, Link, hideMocking, refResolver, maxRefDepth, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideExport, onExportRequest, }) => {
|
|
105
|
-
var _a, _b, _c, _d;
|
|
106
|
-
return (React__namespace.createElement(NodeLinkContext.Provider, { value: [node, Link] },
|
|
107
|
-
React__namespace.createElement(elementsCore.MarkdownComponentsProvider, { value: {
|
|
108
|
-
a: LinkComponent,
|
|
109
|
-
h2: (_a) => {
|
|
110
|
-
var props = __rest(_a, ["color"]);
|
|
111
|
-
return React__namespace.createElement(elementsCore.LinkHeading, Object.assign({ size: 2 }, props));
|
|
112
|
-
},
|
|
113
|
-
h3: (_a) => {
|
|
114
|
-
var props = __rest(_a, ["color"]);
|
|
115
|
-
return React__namespace.createElement(elementsCore.LinkHeading, Object.assign({ size: 3 }, props));
|
|
116
|
-
},
|
|
117
|
-
h4: (_a) => {
|
|
118
|
-
var props = __rest(_a, ["color"]);
|
|
119
|
-
return React__namespace.createElement(elementsCore.LinkHeading, Object.assign({ size: 4 }, props));
|
|
120
|
-
},
|
|
121
|
-
} },
|
|
122
|
-
React__namespace.createElement(elementsCore.MockingProvider, { mockUrl: node.links.mock_url, hideMocking: hideMocking },
|
|
123
|
-
React__namespace.createElement(elementsCore.Docs, { nodeType: node.type, nodeData: node.data, nodeTitle: node.title, layoutOptions: {
|
|
124
|
-
compact,
|
|
125
|
-
hideTryIt: hideTryIt,
|
|
126
|
-
hideTryItPanel: hideTryItPanel,
|
|
127
|
-
hideExport: hideExport ||
|
|
128
|
-
((_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) ===
|
|
129
|
-
undefined,
|
|
130
|
-
}, useNodeForRefResolving: true, refResolver: refResolver, maxRefDepth: maxRefDepth, tryItCorsProxy: tryItCorsProxy, exportProps: [types.NodeType.HttpService, types.NodeType.Model].includes(node.type)
|
|
131
|
-
? {
|
|
132
|
-
original: onExportRequest
|
|
133
|
-
? { onPress: () => onExportRequest('original') }
|
|
134
|
-
: { href: (_c = node.links.export_original_file_url) !== null && _c !== void 0 ? _c : node.links.export_url },
|
|
135
|
-
bundled: onExportRequest
|
|
136
|
-
? { onPress: () => onExportRequest('bundled') }
|
|
137
|
-
: { href: (_d = node.links.export_bundled_file_url) !== null && _d !== void 0 ? _d : getBundledUrl(node.links.export_url) },
|
|
138
|
-
}
|
|
139
|
-
: undefined, tryItCredentialsPolicy: tryItCredentialsPolicy, nodeHasChanged: nodeHasChanged, nodeUnsupported: nodeUnsupported })))));
|
|
140
|
-
};
|
|
141
|
-
const NodeLinkContext = React__namespace.createContext(undefined);
|
|
142
|
-
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
143
|
-
const LinkComponent = ({ children, href, title }) => {
|
|
144
|
-
const ctx = React__namespace.useContext(NodeLinkContext);
|
|
145
|
-
if (href && externalRegex.test(href)) {
|
|
146
|
-
return (React__namespace.createElement("a", { href: href, target: "_blank", rel: "noreferrer", title: title ? title : undefined }, children));
|
|
147
|
-
}
|
|
148
|
-
if (href && ctx) {
|
|
149
|
-
const [node, Link] = ctx;
|
|
150
|
-
const { fileUri } = getNodeUriParts(node.uri);
|
|
151
|
-
const { fileUri: hrefFileUri } = getNodeUriParts(href);
|
|
152
|
-
let resolvedUri;
|
|
153
|
-
if (hrefFileUri) {
|
|
154
|
-
resolvedUri = path.resolve(path.dirname(fileUri), href);
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
resolvedUri = path.resolve(fileUri, href);
|
|
158
|
-
}
|
|
159
|
-
const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
|
|
160
|
-
const decodedUrl = decodeURIComponent(href);
|
|
161
|
-
const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
|
|
162
|
-
const edge = node.outbound_edges.find(edge => edge.uri === decodedUrl || edge.uri === decodedResolvedUriWithoutAnchor);
|
|
163
|
-
if (edge) {
|
|
164
|
-
return React__namespace.createElement(Link, { to: `${edge.slug}${hash ? `#${hash}` : ''}` }, children);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return React__namespace.createElement("a", { href: href }, children);
|
|
168
|
-
};
|
|
169
|
-
function getBundledUrl(url) {
|
|
170
|
-
if (url === undefined)
|
|
171
|
-
return undefined;
|
|
172
|
-
const bundledUrl = new URL(url);
|
|
173
|
-
const searchParams = new URLSearchParams(bundledUrl.search);
|
|
174
|
-
searchParams.append('deref', 'optimizedBundle');
|
|
175
|
-
bundledUrl.search = searchParams.toString();
|
|
176
|
-
return bundledUrl.toString();
|
|
177
97
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
98
|
+
|
|
99
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
100
|
+
var e = new Error(message);
|
|
101
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const NodeContent = ({ node, Link, hideMocking, refResolver, maxRefDepth, tryItCorsProxy, tryItCredentialsPolicy, nodeHasChanged, nodeUnsupported, compact, hideTryIt, hideTryItPanel, hideSecurityInfo, hideServerInfo, hideExport, onExportRequest, }) => {
|
|
105
|
+
var _a, _b, _c, _d;
|
|
106
|
+
return (React__namespace.createElement(NodeLinkContext.Provider, { value: [node, Link] },
|
|
107
|
+
React__namespace.createElement(elementsCore.MarkdownComponentsProvider, { value: {
|
|
108
|
+
a: LinkComponent,
|
|
109
|
+
h2: (_a) => {
|
|
110
|
+
var props = __rest(_a, ["color"]);
|
|
111
|
+
return React__namespace.createElement(elementsCore.LinkHeading, Object.assign({ size: 2 }, props));
|
|
112
|
+
},
|
|
113
|
+
h3: (_a) => {
|
|
114
|
+
var props = __rest(_a, ["color"]);
|
|
115
|
+
return React__namespace.createElement(elementsCore.LinkHeading, Object.assign({ size: 3 }, props));
|
|
116
|
+
},
|
|
117
|
+
h4: (_a) => {
|
|
118
|
+
var props = __rest(_a, ["color"]);
|
|
119
|
+
return React__namespace.createElement(elementsCore.LinkHeading, Object.assign({ size: 4 }, props));
|
|
120
|
+
},
|
|
121
|
+
} },
|
|
122
|
+
React__namespace.createElement(elementsCore.MockingProvider, { mockUrl: node.links.mock_url, hideMocking: hideMocking },
|
|
123
|
+
React__namespace.createElement(elementsCore.Docs, { nodeType: node.type, nodeData: node.data, nodeTitle: node.title, layoutOptions: {
|
|
124
|
+
compact,
|
|
125
|
+
hideTryIt: hideTryIt,
|
|
126
|
+
hideTryItPanel: hideTryItPanel,
|
|
127
|
+
hideSecurityInfo: hideSecurityInfo,
|
|
128
|
+
hideServerInfo: hideServerInfo,
|
|
129
|
+
hideExport: hideExport ||
|
|
130
|
+
((_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) ===
|
|
131
|
+
undefined,
|
|
132
|
+
}, useNodeForRefResolving: true, refResolver: refResolver, maxRefDepth: maxRefDepth, tryItCorsProxy: tryItCorsProxy, exportProps: [types.NodeType.HttpService, types.NodeType.Model].includes(node.type)
|
|
133
|
+
? {
|
|
134
|
+
original: onExportRequest
|
|
135
|
+
? { onPress: () => onExportRequest('original') }
|
|
136
|
+
: { href: (_c = node.links.export_original_file_url) !== null && _c !== void 0 ? _c : node.links.export_url },
|
|
137
|
+
bundled: onExportRequest
|
|
138
|
+
? { onPress: () => onExportRequest('bundled') }
|
|
139
|
+
: { href: (_d = node.links.export_bundled_file_url) !== null && _d !== void 0 ? _d : getBundledUrl(node.links.export_url) },
|
|
140
|
+
}
|
|
141
|
+
: undefined, tryItCredentialsPolicy: tryItCredentialsPolicy, nodeHasChanged: nodeHasChanged, nodeUnsupported: nodeUnsupported })))));
|
|
142
|
+
};
|
|
143
|
+
const NodeLinkContext = React__namespace.createContext(undefined);
|
|
144
|
+
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
145
|
+
const LinkComponent = ({ children, href, title }) => {
|
|
146
|
+
const ctx = React__namespace.useContext(NodeLinkContext);
|
|
147
|
+
if (href && externalRegex.test(href)) {
|
|
148
|
+
return (React__namespace.createElement("a", { href: href, target: "_blank", rel: "noreferrer", title: title ? title : undefined }, children));
|
|
149
|
+
}
|
|
150
|
+
if (href && ctx) {
|
|
151
|
+
const [node, Link] = ctx;
|
|
152
|
+
const { fileUri } = getNodeUriParts(node.uri);
|
|
153
|
+
const { fileUri: hrefFileUri } = getNodeUriParts(href);
|
|
154
|
+
let resolvedUri;
|
|
155
|
+
if (hrefFileUri) {
|
|
156
|
+
resolvedUri = path.resolve(path.dirname(fileUri), href);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
resolvedUri = path.resolve(fileUri, href);
|
|
160
|
+
}
|
|
161
|
+
const [resolvedUriWithoutAnchor, hash] = resolvedUri.split('#');
|
|
162
|
+
const decodedUrl = decodeURIComponent(href);
|
|
163
|
+
const decodedResolvedUriWithoutAnchor = decodeURIComponent(resolvedUriWithoutAnchor);
|
|
164
|
+
const edge = node.outbound_edges.find(edge => edge.uri === decodedUrl || edge.uri === decodedResolvedUriWithoutAnchor);
|
|
165
|
+
if (edge) {
|
|
166
|
+
return React__namespace.createElement(Link, { to: `${edge.slug}${hash ? `#${hash}` : ''}` }, children);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return React__namespace.createElement("a", { href: href }, children);
|
|
170
|
+
};
|
|
171
|
+
function getBundledUrl(url) {
|
|
172
|
+
if (url === undefined)
|
|
173
|
+
return undefined;
|
|
174
|
+
const bundledUrl = new URL(url);
|
|
175
|
+
const searchParams = new URLSearchParams(bundledUrl.search);
|
|
176
|
+
searchParams.append('deref', 'optimizedBundle');
|
|
177
|
+
bundledUrl.search = searchParams.toString();
|
|
178
|
+
return bundledUrl.toString();
|
|
179
|
+
}
|
|
180
|
+
const getNodeUriParts = (uri) => {
|
|
181
|
+
const parts = uri.split(/(\.yaml|\.yml|\.json|\.md)/);
|
|
182
|
+
if (parts.length === 1) {
|
|
183
|
+
return { fileUri: '', pointer: parts[0] || '' };
|
|
184
|
+
}
|
|
185
|
+
const fileUri = `${parts[0] || ''}${parts[1] || ''}`;
|
|
186
|
+
return { fileUri, pointer: parts[2] || '' };
|
|
185
187
|
};
|
|
186
188
|
|
|
187
189
|
/*!
|
|
@@ -206,287 +208,287 @@ var faSpinner = {
|
|
|
206
208
|
icon: [512, 512, [], "f110", "M304 48C304 74.51 282.5 96 256 96C229.5 96 208 74.51 208 48C208 21.49 229.5 0 256 0C282.5 0 304 21.49 304 48zM304 464C304 490.5 282.5 512 256 512C229.5 512 208 490.5 208 464C208 437.5 229.5 416 256 416C282.5 416 304 437.5 304 464zM0 256C0 229.5 21.49 208 48 208C74.51 208 96 229.5 96 256C96 282.5 74.51 304 48 304C21.49 304 0 282.5 0 256zM512 256C512 282.5 490.5 304 464 304C437.5 304 416 282.5 416 256C416 229.5 437.5 208 464 208C490.5 208 512 229.5 512 256zM74.98 437C56.23 418.3 56.23 387.9 74.98 369.1C93.73 350.4 124.1 350.4 142.9 369.1C161.6 387.9 161.6 418.3 142.9 437C124.1 455.8 93.73 455.8 74.98 437V437zM142.9 142.9C124.1 161.6 93.73 161.6 74.98 142.9C56.24 124.1 56.24 93.73 74.98 74.98C93.73 56.23 124.1 56.23 142.9 74.98C161.6 93.73 161.6 124.1 142.9 142.9zM369.1 369.1C387.9 350.4 418.3 350.4 437 369.1C455.8 387.9 455.8 418.3 437 437C418.3 455.8 387.9 455.8 369.1 437C350.4 418.3 350.4 387.9 369.1 369.1V369.1z"]
|
|
207
209
|
};
|
|
208
210
|
|
|
209
|
-
const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
|
|
210
|
-
const listBoxRef = React__namespace.useRef(null);
|
|
211
|
-
const onChange = React__namespace.useCallback(e => onSearch(e.currentTarget.value), [onSearch]);
|
|
212
|
-
const onKeyDown = React__namespace.useCallback(e => {
|
|
213
|
-
var _a;
|
|
214
|
-
if (e.key === 'ArrowDown') {
|
|
215
|
-
e.preventDefault();
|
|
216
|
-
(_a = listBoxRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
217
|
-
}
|
|
218
|
-
}, []);
|
|
219
|
-
return (React__namespace.createElement(mosaic.Modal, { renderHeader: () => (React__namespace.createElement(mosaic.Input, { appearance: "minimal", borderB: true, size: "lg", icon: React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, ml: 1, icon: isLoading ? faSpinner : faSearch, spin: isLoading }), autoFocus: true, placeholder: "Search...", value: search, onChange: onChange, onKeyDown: onKeyDown })), isOpen: !!isOpen, onClose: onClose },
|
|
220
|
-
React__namespace.createElement(SearchResultsList, { searchResults: searchResults, onClick: onClick })));
|
|
221
|
-
};
|
|
222
|
-
const SearchResultsList = ({ searchResults, onClick, isEmbedded, showDivider = true, }) => {
|
|
223
|
-
const listBoxRef = React__namespace.useRef(null);
|
|
224
|
-
const onSelectionChange = React__namespace.useCallback(keys => {
|
|
225
|
-
const selectedId = keys.values().next().value;
|
|
226
|
-
const selectedResult = searchResults === null || searchResults === void 0 ? void 0 : searchResults.find(searchResult => `${searchResult.id}-${searchResult.project_id}` === selectedId);
|
|
227
|
-
if (selectedResult) {
|
|
228
|
-
onClick(selectedResult);
|
|
229
|
-
}
|
|
230
|
-
}, [searchResults, onClick]);
|
|
231
|
-
return (React__namespace.createElement(React__namespace.Fragment, null, searchResults && searchResults.length > 0 ? (React__namespace.createElement(mosaic.ListBox, { ref: listBoxRef, "aria-label": "Search", overflowY: "auto", h: isEmbedded ? undefined : 80, m: -5, items: searchResults, selectionMode: "single", onSelectionChange: onSelectionChange }, (searchResult) => {
|
|
232
|
-
var _a, _b;
|
|
233
|
-
return (React__namespace.createElement(mosaic.ListBoxItem, { key: `${searchResult.id}-${searchResult.project_id}`, textValue: searchResult.title },
|
|
234
|
-
React__namespace.createElement(mosaic.Box, { p: 3, borderB: !showDivider ? undefined : true },
|
|
235
|
-
React__namespace.createElement(mosaic.Flex, { align: "center" },
|
|
236
|
-
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, w: 4, icon: elementsCore.NodeTypeIconDefs[searchResult.type], style: { color: elementsCore.NodeTypeColors[searchResult.type] } }),
|
|
237
|
-
React__namespace.createElement(mosaic.Box, { flex: 1, fontSize: "lg", dangerouslySetInnerHTML: { __html: (_a = searchResult.highlighted.name) !== null && _a !== void 0 ? _a : '' }, fontWeight: "medium", textOverflow: "overflow-ellipsis", mx: 2 }),
|
|
238
|
-
React__namespace.createElement(mosaic.Box, { fontSize: "sm", color: "muted" }, searchResult.project_name)),
|
|
239
|
-
React__namespace.createElement(mosaic.Box, { dangerouslySetInnerHTML: { __html: (_b = searchResult.highlighted.summary) !== null && _b !== void 0 ? _b : '' }, color: "muted", fontSize: "sm", mt: 1, ml: 6 }))));
|
|
240
|
-
})) : (React__namespace.createElement(mosaic.Flex, { w: "full", h: 80, align: "center", justify: "center", m: -5 }, "No search results"))));
|
|
241
|
-
};
|
|
242
|
-
const SearchResults =
|
|
243
|
-
const Search =
|
|
244
|
-
|
|
245
|
-
const TableOfContents = (_a) => {
|
|
246
|
-
var { tableOfContents, activeId, Link, collapseTableOfContents = false, externalScrollbar, isInResponsiveMode = false, onLinkClick } = _a, boxProps = __rest(_a, ["tableOfContents", "activeId", "Link", "collapseTableOfContents", "externalScrollbar", "isInResponsiveMode", "onLinkClick"]);
|
|
247
|
-
return (React__namespace.createElement(mosaic.Flex, Object.assign({ bg: isInResponsiveMode ? 'canvas' : 'canvas-100' }, boxProps, { flexDirection: "col", maxH: "full" }),
|
|
248
|
-
React__namespace.createElement(mosaic.Flex, { flexGrow: true, flexShrink: true, overflowY: "auto" },
|
|
249
|
-
React__namespace.createElement(elementsCore.TableOfContents, { tree: tableOfContents.items, activeId: activeId, Link: Link, maxDepthOpenByDefault: collapseTableOfContents ? 0 : 1, externalScrollbar: externalScrollbar, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode })),
|
|
250
|
-
tableOfContents.hide_powered_by ? null : (React__namespace.createElement(elementsCore.PoweredByLink, { source: activeId, pathname: typeof window !== 'undefined' ? window.location.pathname : '', packageType: "elements-dev-portal" }))));
|
|
211
|
+
const SearchImpl = ({ isLoading, search, searchResults, isOpen, onClose, onClick, onSearch }) => {
|
|
212
|
+
const listBoxRef = React__namespace.useRef(null);
|
|
213
|
+
const onChange = React__namespace.useCallback(e => onSearch(e.currentTarget.value), [onSearch]);
|
|
214
|
+
const onKeyDown = React__namespace.useCallback(e => {
|
|
215
|
+
var _a;
|
|
216
|
+
if (e.key === 'ArrowDown') {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
(_a = listBoxRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
219
|
+
}
|
|
220
|
+
}, []);
|
|
221
|
+
return (React__namespace.createElement(mosaic.Modal, { renderHeader: () => (React__namespace.createElement(mosaic.Input, { appearance: "minimal", borderB: true, size: "lg", icon: React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, ml: 1, icon: isLoading ? faSpinner : faSearch, spin: isLoading }), autoFocus: true, placeholder: "Search...", value: search, onChange: onChange, onKeyDown: onKeyDown })), isOpen: !!isOpen, onClose: onClose },
|
|
222
|
+
React__namespace.createElement(SearchResultsList, { searchResults: searchResults, onClick: onClick })));
|
|
223
|
+
};
|
|
224
|
+
const SearchResultsList = ({ searchResults, onClick, isEmbedded, showDivider = true, }) => {
|
|
225
|
+
const listBoxRef = React__namespace.useRef(null);
|
|
226
|
+
const onSelectionChange = React__namespace.useCallback(keys => {
|
|
227
|
+
const selectedId = keys.values().next().value;
|
|
228
|
+
const selectedResult = searchResults === null || searchResults === void 0 ? void 0 : searchResults.find(searchResult => `${searchResult.id}-${searchResult.project_id}` === selectedId);
|
|
229
|
+
if (selectedResult) {
|
|
230
|
+
onClick(selectedResult);
|
|
231
|
+
}
|
|
232
|
+
}, [searchResults, onClick]);
|
|
233
|
+
return (React__namespace.createElement(React__namespace.Fragment, null, searchResults && searchResults.length > 0 ? (React__namespace.createElement(mosaic.ListBox, { ref: listBoxRef, "aria-label": "Search", overflowY: "auto", h: isEmbedded ? undefined : 80, m: -5, items: searchResults, selectionMode: "single", onSelectionChange: onSelectionChange }, (searchResult) => {
|
|
234
|
+
var _a, _b;
|
|
235
|
+
return (React__namespace.createElement(mosaic.ListBoxItem, { key: `${searchResult.id}-${searchResult.project_id}`, textValue: searchResult.title },
|
|
236
|
+
React__namespace.createElement(mosaic.Box, { p: 3, borderB: !showDivider ? undefined : true },
|
|
237
|
+
React__namespace.createElement(mosaic.Flex, { align: "center" },
|
|
238
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, w: 4, icon: elementsCore.NodeTypeIconDefs[searchResult.type], style: { color: elementsCore.NodeTypeColors[searchResult.type] } }),
|
|
239
|
+
React__namespace.createElement(mosaic.Box, { flex: 1, fontSize: "lg", dangerouslySetInnerHTML: { __html: (_a = searchResult.highlighted.name) !== null && _a !== void 0 ? _a : '' }, fontWeight: "medium", textOverflow: "overflow-ellipsis", mx: 2 }),
|
|
240
|
+
React__namespace.createElement(mosaic.Box, { fontSize: "sm", color: "muted" }, searchResult.project_name)),
|
|
241
|
+
React__namespace.createElement(mosaic.Box, { dangerouslySetInnerHTML: { __html: (_b = searchResult.highlighted.summary) !== null && _b !== void 0 ? _b : '' }, color: "muted", fontSize: "sm", mt: 1, ml: 6 }))));
|
|
242
|
+
})) : (React__namespace.createElement(mosaic.Flex, { w: "full", h: 80, align: "center", justify: "center", m: -5 }, "No search results"))));
|
|
243
|
+
};
|
|
244
|
+
const SearchResults = flow(elementsCore.withStyles, elementsCore.withPersistenceBoundary, elementsCore.withMosaicProvider, elementsCore.withQueryClientProvider)(SearchResultsList);
|
|
245
|
+
const Search = flow(elementsCore.withStyles, elementsCore.withPersistenceBoundary, elementsCore.withMosaicProvider, elementsCore.withQueryClientProvider)(SearchImpl);
|
|
246
|
+
|
|
247
|
+
const TableOfContents = (_a) => {
|
|
248
|
+
var { tableOfContents, activeId, Link, collapseTableOfContents = false, externalScrollbar, isInResponsiveMode = false, onLinkClick } = _a, boxProps = __rest(_a, ["tableOfContents", "activeId", "Link", "collapseTableOfContents", "externalScrollbar", "isInResponsiveMode", "onLinkClick"]);
|
|
249
|
+
return (React__namespace.createElement(mosaic.Flex, Object.assign({ bg: isInResponsiveMode ? 'canvas' : 'canvas-100' }, boxProps, { flexDirection: "col", maxH: "full" }),
|
|
250
|
+
React__namespace.createElement(mosaic.Flex, { flexGrow: true, flexShrink: true, overflowY: "auto" },
|
|
251
|
+
React__namespace.createElement(elementsCore.TableOfContents, { tree: tableOfContents.items, activeId: activeId, Link: Link, maxDepthOpenByDefault: collapseTableOfContents ? 0 : 1, externalScrollbar: externalScrollbar, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode })),
|
|
252
|
+
tableOfContents.hide_powered_by ? null : (React__namespace.createElement(elementsCore.PoweredByLink, { source: activeId, pathname: typeof window !== 'undefined' ? window.location.pathname : '', packageType: "elements-dev-portal" }))));
|
|
251
253
|
};
|
|
252
254
|
|
|
253
|
-
const ROOT_CACHE_KEY = '@stoplight/elements-dev-portal/client-query';
|
|
254
|
-
const devPortalCacheKeys = {
|
|
255
|
-
all: [ROOT_CACHE_KEY],
|
|
256
|
-
projects: () => [ROOT_CACHE_KEY, 'projects'],
|
|
257
|
-
project: (projectId) => [...devPortalCacheKeys.projects(), projectId],
|
|
258
|
-
projectsList: () => [...devPortalCacheKeys.projects(), 'list'],
|
|
259
|
-
projectDetails: (projectId) => [...devPortalCacheKeys.project(projectId), 'details'],
|
|
260
|
-
branches: (projectId) => [...devPortalCacheKeys.project(projectId), 'branches'],
|
|
261
|
-
branch: (projectId, branch) => [...devPortalCacheKeys.branches(projectId), branch],
|
|
262
|
-
branchesList: (projectId) => [...devPortalCacheKeys.branches(projectId), 'list'],
|
|
263
|
-
branchDetails: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'details'],
|
|
264
|
-
branchTOC: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'toc'],
|
|
265
|
-
branchNodes: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'nodes'],
|
|
266
|
-
branchNode: (projectId, branch, node) => [...devPortalCacheKeys.branchNodes(projectId, branch), node],
|
|
267
|
-
branchNodesList: (projectId, branch) => [...devPortalCacheKeys.branchNodes(projectId, branch), 'list'],
|
|
268
|
-
branchNodeDetails: (projectId, branch, node) => [...devPortalCacheKeys.branchNode(projectId, branch, node), 'details'],
|
|
269
|
-
search: () => [...devPortalCacheKeys.all, 'search'],
|
|
270
|
-
searchNodes: (filters) => [
|
|
271
|
-
...devPortalCacheKeys.search(),
|
|
272
|
-
filters,
|
|
273
|
-
],
|
|
255
|
+
const ROOT_CACHE_KEY = '@stoplight/elements-dev-portal/client-query';
|
|
256
|
+
const devPortalCacheKeys = {
|
|
257
|
+
all: [ROOT_CACHE_KEY],
|
|
258
|
+
projects: () => [ROOT_CACHE_KEY, 'projects'],
|
|
259
|
+
project: (projectId) => [...devPortalCacheKeys.projects(), projectId],
|
|
260
|
+
projectsList: () => [...devPortalCacheKeys.projects(), 'list'],
|
|
261
|
+
projectDetails: (projectId) => [...devPortalCacheKeys.project(projectId), 'details'],
|
|
262
|
+
branches: (projectId) => [...devPortalCacheKeys.project(projectId), 'branches'],
|
|
263
|
+
branch: (projectId, branch) => [...devPortalCacheKeys.branches(projectId), branch],
|
|
264
|
+
branchesList: (projectId) => [...devPortalCacheKeys.branches(projectId), 'list'],
|
|
265
|
+
branchDetails: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'details'],
|
|
266
|
+
branchTOC: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'toc'],
|
|
267
|
+
branchNodes: (projectId, branch) => [...devPortalCacheKeys.branch(projectId, branch), 'nodes'],
|
|
268
|
+
branchNode: (projectId, branch, node) => [...devPortalCacheKeys.branchNodes(projectId, branch), node],
|
|
269
|
+
branchNodesList: (projectId, branch) => [...devPortalCacheKeys.branchNodes(projectId, branch), 'list'],
|
|
270
|
+
branchNodeDetails: (projectId, branch, node) => [...devPortalCacheKeys.branchNode(projectId, branch, node), 'details'],
|
|
271
|
+
search: () => [...devPortalCacheKeys.all, 'search'],
|
|
272
|
+
searchNodes: (filters) => [
|
|
273
|
+
...devPortalCacheKeys.search(),
|
|
274
|
+
filters,
|
|
275
|
+
],
|
|
274
276
|
};
|
|
275
277
|
|
|
276
|
-
const Forbidden = () => (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
const Forbidden = () => (React.createElement(mosaic.Flex, { align: "center", justify: "center", flexGrow: true },
|
|
279
|
+
React.createElement(mosaic.VStack, { spacing: 4, align: "center" },
|
|
280
|
+
React.createElement(mosaic.Heading, { size: 1 }, "Forbidden"),
|
|
281
|
+
React.createElement(mosaic.Box, { as: "p" }, "You don't have permission to access this resource"))));
|
|
280
282
|
|
|
281
|
-
const Loading = () => (
|
|
282
|
-
|
|
283
|
+
const Loading = () => (React.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen", color: "muted" },
|
|
284
|
+
React.createElement(mosaic.Icon, { icon: faCircleNotch, size: "3x", spin: true })));
|
|
283
285
|
|
|
284
|
-
const NotFound = () => (
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
const NotFound = () => (React.createElement(mosaic.Flex, { align: "center", justify: "center", flexGrow: true },
|
|
287
|
+
React.createElement(mosaic.VStack, { spacing: 4, align: "center" },
|
|
288
|
+
React.createElement(mosaic.Heading, { size: 1 }, "Not Found"),
|
|
289
|
+
React.createElement(mosaic.Box, { as: "p" }, "Could not find what you are looking for"))));
|
|
288
290
|
|
|
289
|
-
const UpgradeToStarter = () => (
|
|
290
|
-
|
|
291
|
-
|
|
291
|
+
const UpgradeToStarter = () => (React.createElement(mosaic.Flex, { as: "a", href: "https://stoplight.io/pricing/", target: "_blank", rel: "noreferrer noopener", justify: "center", alignItems: "center", w: "full", minH: "screen", color: "muted", flexDirection: "col" },
|
|
292
|
+
React.createElement(mosaic.Icon, { icon: ['fas', 'exclamation-triangle'], size: "4x" }),
|
|
293
|
+
React.createElement(mosaic.Box, { pt: 3 }, "Please upgrade your Stoplight Workspace to the Starter Plan to use Elements Dev Portal in production.")));
|
|
292
294
|
|
|
293
|
-
const appVersion = '2.3.
|
|
295
|
+
const appVersion = '2.3.4';
|
|
294
296
|
|
|
295
|
-
class ResponseError extends Error {
|
|
296
|
-
constructor(message, responseCode) {
|
|
297
|
-
super(message);
|
|
298
|
-
this.name = 'ResponseError';
|
|
299
|
-
this.code = responseCode;
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
const getNodeContent = ({ nodeSlug, projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
303
|
-
const encodedNodeSlug = encodeURIComponent(nodeSlug);
|
|
304
|
-
const encodedProjectId = encodeURIComponent(projectId);
|
|
305
|
-
const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
|
|
306
|
-
const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
|
|
307
|
-
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/nodes/${encodedNodeSlug}${branchQuery}`, {
|
|
308
|
-
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
309
|
-
});
|
|
310
|
-
const data = yield response.json();
|
|
311
|
-
if (!response.ok) {
|
|
312
|
-
if (response.status === 402) {
|
|
313
|
-
throw new ResponseError('Payment Required', response.status);
|
|
314
|
-
}
|
|
315
|
-
else if (response.status === 403) {
|
|
316
|
-
throw new ResponseError('Forbidden', response.status);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
throw new ResponseError('Something went wrong', response.status);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
return data;
|
|
297
|
+
class ResponseError extends Error {
|
|
298
|
+
constructor(message, responseCode) {
|
|
299
|
+
super(message);
|
|
300
|
+
this.name = 'ResponseError';
|
|
301
|
+
this.code = responseCode;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const getNodeContent = ({ nodeSlug, projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
305
|
+
const encodedNodeSlug = encodeURIComponent(nodeSlug);
|
|
306
|
+
const encodedProjectId = encodeURIComponent(projectId);
|
|
307
|
+
const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
|
|
308
|
+
const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
|
|
309
|
+
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/nodes/${encodedNodeSlug}${branchQuery}`, {
|
|
310
|
+
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
311
|
+
});
|
|
312
|
+
const data = yield response.json();
|
|
313
|
+
if (!response.ok) {
|
|
314
|
+
if (response.status === 402) {
|
|
315
|
+
throw new ResponseError('Payment Required', response.status);
|
|
316
|
+
}
|
|
317
|
+
else if (response.status === 403) {
|
|
318
|
+
throw new ResponseError('Forbidden', response.status);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
throw new ResponseError('Something went wrong', response.status);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return data;
|
|
323
325
|
});
|
|
324
326
|
|
|
325
|
-
const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
326
|
-
const encodedProjectId = encodeURIComponent(projectId);
|
|
327
|
-
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/branches`, {
|
|
328
|
-
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
329
|
-
});
|
|
330
|
-
const data = yield response.json();
|
|
331
|
-
if (!response.ok) {
|
|
332
|
-
throw new Error(data);
|
|
333
|
-
}
|
|
334
|
-
return data;
|
|
327
|
+
const getBranches = ({ projectId, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
328
|
+
const encodedProjectId = encodeURIComponent(projectId);
|
|
329
|
+
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/branches`, {
|
|
330
|
+
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
331
|
+
});
|
|
332
|
+
const data = yield response.json();
|
|
333
|
+
if (!response.ok) {
|
|
334
|
+
throw new Error(data);
|
|
335
|
+
}
|
|
336
|
+
return data;
|
|
335
337
|
});
|
|
336
338
|
|
|
337
|
-
function useGetBranches({ projectId }) {
|
|
338
|
-
const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
|
|
339
|
-
return reactQuery.useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, isLoggedIn], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
|
|
340
|
-
enabled: projectId ? true : false,
|
|
341
|
-
});
|
|
339
|
+
function useGetBranches({ projectId }) {
|
|
340
|
+
const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
|
|
341
|
+
return reactQuery.useQuery([...devPortalCacheKeys.branchesList(projectId), platformUrl, isLoggedIn], () => getBranches({ projectId, platformUrl, platformAuthToken }), {
|
|
342
|
+
enabled: projectId ? true : false,
|
|
343
|
+
});
|
|
342
344
|
}
|
|
343
345
|
|
|
344
|
-
function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
|
|
345
|
-
const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
|
|
346
|
-
return reactQuery.useQuery([...devPortalCacheKeys.branchNodeDetails(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : '', nodeSlug), platformUrl, isLoggedIn], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
|
|
346
|
+
function useGetNodeContent({ nodeSlug, projectId, branchSlug, }) {
|
|
347
|
+
const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
|
|
348
|
+
return reactQuery.useQuery([...devPortalCacheKeys.branchNodeDetails(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : '', nodeSlug), platformUrl, isLoggedIn], () => getNodeContent({ nodeSlug, projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: nodeSlug && projectId ? true : false });
|
|
347
349
|
}
|
|
348
350
|
|
|
349
|
-
const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
350
|
-
const encodedProjectId = encodeURIComponent(projectId);
|
|
351
|
-
const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
|
|
352
|
-
const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
|
|
353
|
-
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/table-of-contents${branchQuery}`, {
|
|
354
|
-
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
355
|
-
});
|
|
356
|
-
const data = yield response.json();
|
|
357
|
-
if (!response.ok) {
|
|
358
|
-
throw new Error(data);
|
|
359
|
-
}
|
|
360
|
-
return data;
|
|
351
|
+
const getTableOfContents = ({ projectId, branchSlug, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
352
|
+
const encodedProjectId = encodeURIComponent(projectId);
|
|
353
|
+
const encodedBranchSlug = branchSlug ? encodeURIComponent(branchSlug) : '';
|
|
354
|
+
const branchQuery = encodedBranchSlug ? `?branch=${encodedBranchSlug}` : '';
|
|
355
|
+
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}/table-of-contents${branchQuery}`, {
|
|
356
|
+
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
357
|
+
});
|
|
358
|
+
const data = yield response.json();
|
|
359
|
+
if (!response.ok) {
|
|
360
|
+
throw new Error(data);
|
|
361
|
+
}
|
|
362
|
+
return data;
|
|
361
363
|
});
|
|
362
364
|
|
|
363
|
-
function useGetTableOfContents({ projectId, branchSlug }) {
|
|
364
|
-
const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
|
|
365
|
-
return reactQuery.useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, isLoggedIn], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
|
|
365
|
+
function useGetTableOfContents({ projectId, branchSlug }) {
|
|
366
|
+
const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
|
|
367
|
+
return reactQuery.useQuery([...devPortalCacheKeys.branchTOC(projectId, branchSlug !== null && branchSlug !== void 0 ? branchSlug : ''), platformUrl, isLoggedIn], () => getTableOfContents({ projectId, branchSlug, platformUrl, platformAuthToken }), { enabled: projectId ? true : false });
|
|
366
368
|
}
|
|
367
369
|
|
|
368
|
-
const StoplightProjectImpl = ({ projectId, hideTryIt, hideMocking, hideExport, collapseTableOfContents = false, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
369
|
-
const { branchSlug: encodedBranchSlug = '', nodeSlug = '' } = reactRouterDom.useParams();
|
|
370
|
-
const branchSlug = decodeURIComponent(encodedBranchSlug);
|
|
371
|
-
const history = reactRouterDom.useHistory();
|
|
372
|
-
const { data: tableOfContents, isFetched: isTocFetched } = useGetTableOfContents({ projectId, branchSlug });
|
|
373
|
-
const { data: branches } = useGetBranches({ projectId });
|
|
374
|
-
const { data: node, isLoading: isLoadingNode, isError, error: nodeError, } = useGetNodeContent({
|
|
375
|
-
nodeSlug,
|
|
376
|
-
projectId,
|
|
377
|
-
branchSlug,
|
|
378
|
-
});
|
|
379
|
-
const container = React__namespace.useRef(null);
|
|
380
|
-
if (!nodeSlug && isTocFetched && (tableOfContents === null || tableOfContents === void 0 ? void 0 : tableOfContents.items)) {
|
|
381
|
-
const firstNode = elementsCore.findFirstNode(tableOfContents.items);
|
|
382
|
-
if (firstNode) {
|
|
383
|
-
return React__namespace.createElement(reactRouterDom.Redirect, { to: branchSlug ? `/branches/${branchSlug}/${firstNode.slug}` : `/${firstNode.slug}` });
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
let elem;
|
|
387
|
-
if (isLoadingNode || !isTocFetched) {
|
|
388
|
-
elem = React__namespace.createElement(Loading, null);
|
|
389
|
-
}
|
|
390
|
-
else if (isError) {
|
|
391
|
-
if (nodeError instanceof ResponseError) {
|
|
392
|
-
if (nodeError.code === 402) {
|
|
393
|
-
elem = React__namespace.createElement(UpgradeToStarter, null);
|
|
394
|
-
}
|
|
395
|
-
else if (nodeError.code === 403) {
|
|
396
|
-
elem = React__namespace.createElement(Forbidden, null);
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
elem = React__namespace.createElement(NotFound, null);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
elem = React__namespace.createElement(NotFound, null);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
else if (!node) {
|
|
407
|
-
elem = React__namespace.createElement(NotFound, null);
|
|
408
|
-
}
|
|
409
|
-
else if ((node === null || node === void 0 ? void 0 : node.slug) && nodeSlug !== node.slug) {
|
|
410
|
-
return React__namespace.createElement(reactRouterDom.Redirect, { to: branchSlug ? `/branches/${branchSlug}/${node.slug}` : `/${node.slug}` });
|
|
411
|
-
}
|
|
412
|
-
else {
|
|
413
|
-
elem = (React__namespace.createElement(NodeContent, { node: node, Link: elementsCore.ReactRouterMarkdownLink, hideTryIt: hideTryIt, hideMocking: hideMocking, hideExport: hideExport, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }));
|
|
414
|
-
}
|
|
415
|
-
const handleTocClick = () => {
|
|
416
|
-
if (container.current) {
|
|
417
|
-
container.current.scrollIntoView();
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
return (React__namespace.createElement(elementsCore.SidebarLayout, { ref: container, sidebar: React__namespace.createElement(React__namespace.Fragment, null,
|
|
421
|
-
branches && branches.items.length > 1 ? (React__namespace.createElement(BranchSelector, { branchSlug: branchSlug, branches: branches.items, onChange: branch => {
|
|
422
|
-
const encodedBranchSlug = encodeURIComponent(branch.slug);
|
|
423
|
-
history.push(branch.is_default ? `/${nodeSlug}` : `/branches/${encodedBranchSlug}/${nodeSlug}`);
|
|
424
|
-
} })) : null,
|
|
425
|
-
tableOfContents ? (React__namespace.createElement(TableOfContents, { activeId: (node === null || node === void 0 ? void 0 : node.id) || (nodeSlug === null || nodeSlug === void 0 ? void 0 : nodeSlug.split('-')[0]) || '', tableOfContents: tableOfContents, Link: reactRouterDom.Link, collapseTableOfContents: collapseTableOfContents, onLinkClick: handleTocClick })) : null) }, elem));
|
|
426
|
-
};
|
|
427
|
-
const StoplightProjectRouter = (_a) => {
|
|
428
|
-
var { platformUrl, basePath = '/', staticRouterPath = '', router = 'history' } = _a, props = __rest(_a, ["platformUrl", "basePath", "staticRouterPath", "router"]);
|
|
429
|
-
const { Router, routerProps } = elementsCore.useRouter(router, basePath, staticRouterPath);
|
|
430
|
-
return (React__namespace.createElement(DevPortalProvider, { platformUrl: platformUrl },
|
|
431
|
-
React__namespace.createElement(elementsCore.RouterTypeContext.Provider, { value: router },
|
|
432
|
-
React__namespace.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
|
433
|
-
React__namespace.createElement(reactRouterDom.Switch, null,
|
|
434
|
-
React__namespace.createElement(reactRouterDom.Route, { path: "/branches/:branchSlug/:nodeSlug+", exact: true },
|
|
435
|
-
React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))),
|
|
436
|
-
React__namespace.createElement(reactRouterDom.Route, { path: "/:nodeSlug+", exact: true },
|
|
437
|
-
React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))),
|
|
438
|
-
React__namespace.createElement(reactRouterDom.Route, { path: "/", exact: true },
|
|
439
|
-
React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))))))));
|
|
440
|
-
};
|
|
370
|
+
const StoplightProjectImpl = ({ projectId, hideTryIt, hideSecurityInfo, hideServerInfo, hideMocking, hideExport, collapseTableOfContents = false, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
371
|
+
const { branchSlug: encodedBranchSlug = '', nodeSlug = '' } = reactRouterDom.useParams();
|
|
372
|
+
const branchSlug = decodeURIComponent(encodedBranchSlug);
|
|
373
|
+
const history = reactRouterDom.useHistory();
|
|
374
|
+
const { data: tableOfContents, isFetched: isTocFetched } = useGetTableOfContents({ projectId, branchSlug });
|
|
375
|
+
const { data: branches } = useGetBranches({ projectId });
|
|
376
|
+
const { data: node, isLoading: isLoadingNode, isError, error: nodeError, } = useGetNodeContent({
|
|
377
|
+
nodeSlug,
|
|
378
|
+
projectId,
|
|
379
|
+
branchSlug,
|
|
380
|
+
});
|
|
381
|
+
const container = React__namespace.useRef(null);
|
|
382
|
+
if (!nodeSlug && isTocFetched && (tableOfContents === null || tableOfContents === void 0 ? void 0 : tableOfContents.items)) {
|
|
383
|
+
const firstNode = elementsCore.findFirstNode(tableOfContents.items);
|
|
384
|
+
if (firstNode) {
|
|
385
|
+
return React__namespace.createElement(reactRouterDom.Redirect, { to: branchSlug ? `/branches/${branchSlug}/${firstNode.slug}` : `/${firstNode.slug}` });
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
let elem;
|
|
389
|
+
if (isLoadingNode || !isTocFetched) {
|
|
390
|
+
elem = React__namespace.createElement(Loading, null);
|
|
391
|
+
}
|
|
392
|
+
else if (isError) {
|
|
393
|
+
if (nodeError instanceof ResponseError) {
|
|
394
|
+
if (nodeError.code === 402) {
|
|
395
|
+
elem = React__namespace.createElement(UpgradeToStarter, null);
|
|
396
|
+
}
|
|
397
|
+
else if (nodeError.code === 403) {
|
|
398
|
+
elem = React__namespace.createElement(Forbidden, null);
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
elem = React__namespace.createElement(NotFound, null);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
elem = React__namespace.createElement(NotFound, null);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
else if (!node) {
|
|
409
|
+
elem = React__namespace.createElement(NotFound, null);
|
|
410
|
+
}
|
|
411
|
+
else if ((node === null || node === void 0 ? void 0 : node.slug) && nodeSlug !== node.slug) {
|
|
412
|
+
return React__namespace.createElement(reactRouterDom.Redirect, { to: branchSlug ? `/branches/${branchSlug}/${node.slug}` : `/${node.slug}` });
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
elem = (React__namespace.createElement(NodeContent, { node: node, Link: elementsCore.ReactRouterMarkdownLink, hideTryIt: hideTryIt, hideMocking: hideMocking, hideExport: hideExport, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }));
|
|
416
|
+
}
|
|
417
|
+
const handleTocClick = () => {
|
|
418
|
+
if (container.current) {
|
|
419
|
+
container.current.scrollIntoView();
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
return (React__namespace.createElement(elementsCore.SidebarLayout, { ref: container, sidebar: React__namespace.createElement(React__namespace.Fragment, null,
|
|
423
|
+
branches && branches.items.length > 1 ? (React__namespace.createElement(BranchSelector, { branchSlug: branchSlug, branches: branches.items, onChange: branch => {
|
|
424
|
+
const encodedBranchSlug = encodeURIComponent(branch.slug);
|
|
425
|
+
history.push(branch.is_default ? `/${nodeSlug}` : `/branches/${encodedBranchSlug}/${nodeSlug}`);
|
|
426
|
+
} })) : null,
|
|
427
|
+
tableOfContents ? (React__namespace.createElement(TableOfContents, { activeId: (node === null || node === void 0 ? void 0 : node.id) || (nodeSlug === null || nodeSlug === void 0 ? void 0 : nodeSlug.split('-')[0]) || '', tableOfContents: tableOfContents, Link: reactRouterDom.Link, collapseTableOfContents: collapseTableOfContents, onLinkClick: handleTocClick })) : null) }, elem));
|
|
428
|
+
};
|
|
429
|
+
const StoplightProjectRouter = (_a) => {
|
|
430
|
+
var { platformUrl, basePath = '/', staticRouterPath = '', router = 'history' } = _a, props = __rest(_a, ["platformUrl", "basePath", "staticRouterPath", "router"]);
|
|
431
|
+
const { Router, routerProps } = elementsCore.useRouter(router, basePath, staticRouterPath);
|
|
432
|
+
return (React__namespace.createElement(DevPortalProvider, { platformUrl: platformUrl },
|
|
433
|
+
React__namespace.createElement(elementsCore.RouterTypeContext.Provider, { value: router },
|
|
434
|
+
React__namespace.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
|
435
|
+
React__namespace.createElement(reactRouterDom.Switch, null,
|
|
436
|
+
React__namespace.createElement(reactRouterDom.Route, { path: "/branches/:branchSlug/:nodeSlug+", exact: true },
|
|
437
|
+
React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))),
|
|
438
|
+
React__namespace.createElement(reactRouterDom.Route, { path: "/:nodeSlug+", exact: true },
|
|
439
|
+
React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))),
|
|
440
|
+
React__namespace.createElement(reactRouterDom.Route, { path: "/", exact: true },
|
|
441
|
+
React__namespace.createElement(StoplightProjectImpl, Object.assign({}, props))))))));
|
|
442
|
+
};
|
|
441
443
|
const StoplightProject = elementsCore.withStyles(StoplightProjectRouter);
|
|
442
444
|
|
|
443
|
-
const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
444
|
-
const queryParams = [];
|
|
445
|
-
let fetchedWorkspaceId = workspaceId || '';
|
|
446
|
-
if (!workspaceId && (projectIds === null || projectIds === void 0 ? void 0 : projectIds.length)) {
|
|
447
|
-
const encodedProjectId = encodeURIComponent(projectIds[0]);
|
|
448
|
-
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
|
|
449
|
-
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
450
|
-
});
|
|
451
|
-
const data = yield response.json();
|
|
452
|
-
fetchedWorkspaceId = data.workspace.id;
|
|
453
|
-
}
|
|
454
|
-
if (projectIds && projectIds.length) {
|
|
455
|
-
queryParams.push(...projectIds.map((projectId, index) => {
|
|
456
|
-
const encodedProjectId = encodeURIComponent(projectId);
|
|
457
|
-
return `project_ids[${index}]=${encodedProjectId}`;
|
|
458
|
-
}));
|
|
459
|
-
}
|
|
460
|
-
if (search) {
|
|
461
|
-
const encodedSearch = encodeURIComponent(search);
|
|
462
|
-
queryParams.push(`search=${encodedSearch}`);
|
|
463
|
-
}
|
|
464
|
-
if (branchSlug) {
|
|
465
|
-
const encodedBranchSlug = encodeURIComponent(branchSlug);
|
|
466
|
-
queryParams.push(`branch=${encodedBranchSlug}`);
|
|
467
|
-
}
|
|
468
|
-
const query = queryParams.length ? `?${queryParams.join('&')}` : '';
|
|
469
|
-
const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
|
|
470
|
-
const response = yield fetch(`${platformUrl}/api/v1/workspaces/${encodedWorkspaceId}/nodes${query}`, {
|
|
471
|
-
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
472
|
-
});
|
|
473
|
-
const data = yield response.json();
|
|
474
|
-
if (!response.ok) {
|
|
475
|
-
throw new Error(data);
|
|
476
|
-
}
|
|
477
|
-
return data;
|
|
445
|
+
const getNodes = ({ workspaceId, branchSlug, projectIds, search, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
446
|
+
const queryParams = [];
|
|
447
|
+
let fetchedWorkspaceId = workspaceId || '';
|
|
448
|
+
if (!workspaceId && (projectIds === null || projectIds === void 0 ? void 0 : projectIds.length)) {
|
|
449
|
+
const encodedProjectId = encodeURIComponent(projectIds[0]);
|
|
450
|
+
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
|
|
451
|
+
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
452
|
+
});
|
|
453
|
+
const data = yield response.json();
|
|
454
|
+
fetchedWorkspaceId = data.workspace.id;
|
|
455
|
+
}
|
|
456
|
+
if (projectIds && projectIds.length) {
|
|
457
|
+
queryParams.push(...projectIds.map((projectId, index) => {
|
|
458
|
+
const encodedProjectId = encodeURIComponent(projectId);
|
|
459
|
+
return `project_ids[${index}]=${encodedProjectId}`;
|
|
460
|
+
}));
|
|
461
|
+
}
|
|
462
|
+
if (search) {
|
|
463
|
+
const encodedSearch = encodeURIComponent(search);
|
|
464
|
+
queryParams.push(`search=${encodedSearch}`);
|
|
465
|
+
}
|
|
466
|
+
if (branchSlug) {
|
|
467
|
+
const encodedBranchSlug = encodeURIComponent(branchSlug);
|
|
468
|
+
queryParams.push(`branch=${encodedBranchSlug}`);
|
|
469
|
+
}
|
|
470
|
+
const query = queryParams.length ? `?${queryParams.join('&')}` : '';
|
|
471
|
+
const encodedWorkspaceId = encodeURIComponent(fetchedWorkspaceId);
|
|
472
|
+
const response = yield fetch(`${platformUrl}/api/v1/workspaces/${encodedWorkspaceId}/nodes${query}`, {
|
|
473
|
+
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
474
|
+
});
|
|
475
|
+
const data = yield response.json();
|
|
476
|
+
if (!response.ok) {
|
|
477
|
+
throw new Error(data);
|
|
478
|
+
}
|
|
479
|
+
return data;
|
|
478
480
|
});
|
|
479
481
|
|
|
480
|
-
const getWorkspace = ({ projectIds, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
481
|
-
const encodedProjectId = encodeURIComponent(projectIds[0]);
|
|
482
|
-
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
|
|
483
|
-
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
484
|
-
});
|
|
485
|
-
const data = yield response.json();
|
|
486
|
-
if (!response.ok) {
|
|
487
|
-
throw new Error(data);
|
|
488
|
-
}
|
|
489
|
-
return data;
|
|
482
|
+
const getWorkspace = ({ projectIds, platformUrl = 'https://stoplight.io', platformAuthToken, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
483
|
+
const encodedProjectId = encodeURIComponent(projectIds[0]);
|
|
484
|
+
const response = yield fetch(`${platformUrl}/api/v1/projects/${encodedProjectId}`, {
|
|
485
|
+
headers: Object.assign({ 'Stoplight-Elements-Version': appVersion }, (platformAuthToken && { Authorization: `Bearer ${platformAuthToken}` })),
|
|
486
|
+
});
|
|
487
|
+
const data = yield response.json();
|
|
488
|
+
if (!response.ok) {
|
|
489
|
+
throw new Error(data);
|
|
490
|
+
}
|
|
491
|
+
return data;
|
|
490
492
|
});
|
|
491
493
|
|
|
492
494
|
/**
|
|
@@ -702,7 +704,7 @@ function useStateIgnoreCallback(initialState) {
|
|
|
702
704
|
return [state, setStateIgnoreCallback];
|
|
703
705
|
}
|
|
704
706
|
function useDebounce(value, delay, options) {
|
|
705
|
-
var eq =
|
|
707
|
+
var eq = valueEquality;
|
|
706
708
|
var _a = useStateIgnoreCallback(value), state = _a[0], dispatch = _a[1];
|
|
707
709
|
var debounced = useDebouncedCallback(React.useCallback(function (value) { return dispatch(value); }, [dispatch]), delay, options);
|
|
708
710
|
var previousValue = React.useRef(value);
|
|
@@ -716,19 +718,19 @@ function useDebounce(value, delay, options) {
|
|
|
716
718
|
return [state, { cancel: debounced.cancel, isPending: debounced.isPending, flush: debounced.flush }];
|
|
717
719
|
}
|
|
718
720
|
|
|
719
|
-
function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
|
|
720
|
-
const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
|
|
721
|
-
const [debounceSearch] = useDebounce(search, 500);
|
|
722
|
-
return reactQuery.useQuery([
|
|
723
|
-
...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
|
|
724
|
-
platformUrl,
|
|
725
|
-
isLoggedIn,
|
|
726
|
-
], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
|
721
|
+
function useGetNodes({ search, workspaceId, projectIds, branch, pause, }) {
|
|
722
|
+
const { platformUrl, platformAuthToken, isLoggedIn } = React__namespace.useContext(PlatformContext);
|
|
723
|
+
const [debounceSearch] = useDebounce(search, 500);
|
|
724
|
+
return reactQuery.useQuery([
|
|
725
|
+
...devPortalCacheKeys.searchNodes({ projectIds, branchSlug: branch, workspaceId, search: debounceSearch }),
|
|
726
|
+
platformUrl,
|
|
727
|
+
isLoggedIn,
|
|
728
|
+
], () => getNodes({ workspaceId, projectIds, branchSlug: branch, search: debounceSearch, platformUrl, platformAuthToken }), { enabled: !pause, keepPreviousData: true });
|
|
727
729
|
}
|
|
728
730
|
|
|
729
|
-
function useGetWorkspace({ projectIds }) {
|
|
730
|
-
const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
|
|
731
|
-
return reactQuery.useQuery([...devPortalCacheKeys.searchNodes({ projectIds }), platformUrl, platformAuthToken], () => getWorkspace({ projectIds, platformUrl, platformAuthToken }));
|
|
731
|
+
function useGetWorkspace({ projectIds }) {
|
|
732
|
+
const { platformUrl, platformAuthToken } = React__namespace.useContext(PlatformContext);
|
|
733
|
+
return reactQuery.useQuery([...devPortalCacheKeys.searchNodes({ projectIds }), platformUrl, platformAuthToken], () => getWorkspace({ projectIds, platformUrl, platformAuthToken }));
|
|
732
734
|
}
|
|
733
735
|
|
|
734
736
|
exports.BranchSelector = BranchSelector;
|