@patternfly/quickstarts 5.0.0-prerelease.2 → 5.1.0-prerelease.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/dist/ConsoleInternal/components/markdown-view.d.ts +19 -19
- package/dist/ConsoleInternal/components/utils/camel-case-wrap.d.ts +6 -6
- package/dist/ConsoleInternal/components/utils/index.d.ts +3 -3
- package/dist/ConsoleInternal/components/utils/router.d.ts +9 -9
- package/dist/ConsoleInternal/components/utils/status-box.d.ts +20 -20
- package/dist/ConsoleInternal/module/k8s/types.d.ts +42 -42
- package/dist/ConsoleShared/index.d.ts +1 -1
- package/dist/ConsoleShared/src/components/index.d.ts +7 -7
- package/dist/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.d.ts +13 -13
- package/dist/ConsoleShared/src/components/markdown-extensions/accordion-extension.d.ts +7 -7
- package/dist/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.d.ts +6 -6
- package/dist/ConsoleShared/src/components/markdown-extensions/admonition-extension.d.ts +7 -7
- package/dist/ConsoleShared/src/components/markdown-extensions/code-extension.d.ts +7 -7
- package/dist/ConsoleShared/src/components/markdown-extensions/const.d.ts +5 -5
- package/dist/ConsoleShared/src/components/markdown-extensions/index.d.ts +7 -7
- package/dist/ConsoleShared/src/components/markdown-extensions/inline-clipboard-extension.d.ts +7 -7
- package/dist/ConsoleShared/src/components/markdown-extensions/multiline-clipboard-extension.d.ts +7 -7
- package/dist/ConsoleShared/src/components/markdown-extensions/utils.d.ts +1 -1
- package/dist/ConsoleShared/src/components/markdown-highlight-extension/MarkdownHighlightExtension.d.ts +7 -7
- package/dist/ConsoleShared/src/components/markdown-highlight-extension/highlight-consts.d.ts +4 -4
- package/dist/ConsoleShared/src/components/markdown-highlight-extension/index.d.ts +1 -1
- package/dist/ConsoleShared/src/components/modal/Modal.d.ts +9 -9
- package/dist/ConsoleShared/src/components/modal/index.d.ts +1 -1
- package/dist/ConsoleShared/src/components/popper/Portal.d.ts +8 -8
- package/dist/ConsoleShared/src/components/popper/SimplePopper.d.ts +6 -6
- package/dist/ConsoleShared/src/components/popper/index.d.ts +2 -2
- package/dist/ConsoleShared/src/components/spotlight/InteractiveSpotlight.d.ts +7 -7
- package/dist/ConsoleShared/src/components/spotlight/Spotlight.d.ts +7 -7
- package/dist/ConsoleShared/src/components/spotlight/StaticSpotlight.d.ts +7 -7
- package/dist/ConsoleShared/src/components/spotlight/index.d.ts +1 -1
- package/dist/ConsoleShared/src/components/status/GenericStatus.d.ts +12 -12
- package/dist/ConsoleShared/src/components/status/NotStartedIcon.d.ts +3 -3
- package/dist/ConsoleShared/src/components/status/PopoverStatus.d.ts +13 -13
- package/dist/ConsoleShared/src/components/status/Status.d.ts +11 -11
- package/dist/ConsoleShared/src/components/status/StatusIconAndText.d.ts +8 -8
- package/dist/ConsoleShared/src/components/status/icons.d.ts +9 -9
- package/dist/ConsoleShared/src/components/status/index.d.ts +1 -1
- package/dist/ConsoleShared/src/components/status/statuses.d.ts +5 -5
- package/dist/ConsoleShared/src/components/status/types.d.ts +9 -9
- package/dist/ConsoleShared/src/components/utils/FallbackImg.d.ts +9 -9
- package/dist/ConsoleShared/src/components/utils/index.d.ts +1 -1
- package/dist/ConsoleShared/src/constants/index.d.ts +1 -1
- package/dist/ConsoleShared/src/constants/ui.d.ts +1 -1
- package/dist/ConsoleShared/src/hooks/index.d.ts +6 -6
- package/dist/ConsoleShared/src/hooks/scroll.d.ts +8 -8
- package/dist/ConsoleShared/src/hooks/useBoundingClientRect.d.ts +3 -3
- package/dist/ConsoleShared/src/hooks/useEventListener.d.ts +1 -1
- package/dist/ConsoleShared/src/hooks/useForceRender.d.ts +4 -4
- package/dist/ConsoleShared/src/hooks/useResizeObserver.d.ts +1 -1
- package/dist/ConsoleShared/src/hooks/useScrollShadows.d.ts +7 -7
- package/dist/ConsoleShared/src/index.d.ts +4 -4
- package/dist/ConsoleShared/src/utils/index.d.ts +1 -1
- package/dist/ConsoleShared/src/utils/useCombineRefs.d.ts +2 -2
- package/dist/HelpTopicDrawer.d.ts +33 -33
- package/dist/HelpTopicPanelContent.d.ts +11 -11
- package/dist/QuickStartCatalogPage.d.ts +14 -14
- package/dist/QuickStartCloseModal.d.ts +8 -8
- package/dist/QuickStartController.d.ts +10 -10
- package/dist/QuickStartDrawer.d.ts +62 -62
- package/dist/QuickStartMarkdownView.d.ts +9 -9
- package/dist/QuickStartPanelContent.d.ts +15 -15
- package/dist/catalog/Catalog/QuickStartCatalogHeader.d.ts +6 -6
- package/dist/catalog/Catalog/QuickStartCatalogSection.d.ts +5 -5
- package/dist/catalog/Catalog/QuickStartCatalogToolbar.d.ts +5 -5
- package/dist/catalog/Catalog/index.d.ts +3 -3
- package/dist/catalog/QuickStartCatalog.d.ts +8 -8
- package/dist/catalog/QuickStartTile.d.ts +11 -11
- package/dist/catalog/QuickStartTileDescription.d.ts +8 -8
- package/dist/catalog/QuickStartTileFooter.d.ts +8 -8
- package/dist/catalog/QuickStartTileFooterExternal.d.ts +8 -8
- package/dist/catalog/QuickStartTileHeader.d.ts +12 -12
- package/dist/catalog/Toolbar/QuickStartCatalogFilter.d.ts +10 -10
- package/dist/catalog/Toolbar/QuickStartCatalogFilterItems.d.ts +31 -31
- package/dist/catalog/index.d.ts +9 -9
- package/dist/controller/QuickStartConclusion.d.ts +12 -12
- package/dist/controller/QuickStartContent.d.ts +14 -14
- package/dist/controller/QuickStartFooter.d.ts +14 -14
- package/dist/controller/QuickStartIntroduction.d.ts +12 -12
- package/dist/controller/QuickStartTaskHeader.d.ts +15 -15
- package/dist/controller/QuickStartTaskHeaderList.d.ts +10 -10
- package/dist/controller/QuickStartTaskReview.d.ts +10 -10
- package/dist/controller/QuickStartTasks.d.ts +12 -12
- package/dist/data/mocks/json/explore-pipeline-quickstart.d.ts +2 -2
- package/dist/data/mocks/json/explore-serverless-quickstart.d.ts +2 -2
- package/dist/data/mocks/json/monitor-sampleapp-quickstart.d.ts +2 -2
- package/dist/data/mocks/json/tour-icons.d.ts +2 -2
- package/dist/data/quick-start-test-data.d.ts +2 -2
- package/dist/data/test-utils.d.ts +8 -8
- package/dist/index.d.ts +16 -16
- package/dist/index.es.js +2286 -2286
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +2286 -2286
- package/dist/index.js.map +1 -1
- package/dist/quickstarts-base.css +4 -4
- package/dist/quickstarts-full.es.js +3026 -2393
- package/dist/quickstarts-full.es.js.map +1 -1
- package/dist/quickstarts.css +4 -4
- package/dist/quickstarts.min.css +1 -1
- package/dist/styles/patternfly-global-entry.d.ts +1 -1
- package/dist/styles/patternfly-nested-entry.d.ts +1 -1
- package/dist/styles/quickstarts-standalone-entry.d.ts +1 -1
- package/dist/styles/vendor-entry.d.ts +1 -1
- package/dist/utils/PluralResolver.d.ts +16 -16
- package/dist/utils/asciidoc-procedure-parser.d.ts +12 -12
- package/dist/utils/const.d.ts +6 -6
- package/dist/utils/help-topic-context.d.ts +23 -23
- package/dist/utils/help-topic-types.d.ts +13 -13
- package/dist/utils/quick-start-context.d.ts +81 -81
- package/dist/utils/quick-start-types.d.ts +60 -60
- package/dist/utils/quick-start-utils.d.ts +10 -10
- package/dist/utils/useLocalStorage.d.ts +1 -1
- package/package.json +12 -13
- package/src/QuickStartController.tsx +1 -1
package/dist/index.js
CHANGED
|
@@ -96,66 +96,66 @@ m.Pop;a=b();var q=a[0],l=a[1],c=B(),e=B();null==q&&(q=0,f.replaceState(_extends(
|
|
|
96
96
|
y(_extends({pathname:"/",search:"",hash:"",state:null,key:D()},"string"===typeof a?F(a):a));"production"!==process.env.NODE_ENV?z("/"===b.pathname.charAt(0),"Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: "+JSON.stringify(a)+")"):void 0;return b}),f=Math.min(Math.max(null==r?h.length-1:r,0),h.length-1),p=m.Pop,n=h[f],q=B(),l=B();return {get index(){return f},get action(){return p},get location(){return n},createHref:function(a){return "string"===typeof a?
|
|
97
97
|
a:E(a)},push:v,replace:w,go:u,back:function(){u(-1);},forward:function(){u(1);},listen:function(a){return q.push(a)},block:function(a){return l.push(a)}}}
|
|
98
98
|
|
|
99
|
-
exports.QuickStartStatus = void 0;
|
|
100
|
-
(function (QuickStartStatus) {
|
|
101
|
-
QuickStartStatus["COMPLETE"] = "Complete";
|
|
102
|
-
QuickStartStatus["IN_PROGRESS"] = "In Progress";
|
|
103
|
-
QuickStartStatus["NOT_STARTED"] = "Not started";
|
|
104
|
-
})(exports.QuickStartStatus || (exports.QuickStartStatus = {}));
|
|
105
|
-
exports.QuickStartTaskStatus = void 0;
|
|
106
|
-
(function (QuickStartTaskStatus) {
|
|
107
|
-
QuickStartTaskStatus["INIT"] = "Initial";
|
|
108
|
-
QuickStartTaskStatus["VISITED"] = "Visited";
|
|
109
|
-
QuickStartTaskStatus["REVIEW"] = "Review";
|
|
110
|
-
QuickStartTaskStatus["SUCCESS"] = "Success";
|
|
111
|
-
QuickStartTaskStatus["FAILED"] = "Failed";
|
|
99
|
+
exports.QuickStartStatus = void 0;
|
|
100
|
+
(function (QuickStartStatus) {
|
|
101
|
+
QuickStartStatus["COMPLETE"] = "Complete";
|
|
102
|
+
QuickStartStatus["IN_PROGRESS"] = "In Progress";
|
|
103
|
+
QuickStartStatus["NOT_STARTED"] = "Not started";
|
|
104
|
+
})(exports.QuickStartStatus || (exports.QuickStartStatus = {}));
|
|
105
|
+
exports.QuickStartTaskStatus = void 0;
|
|
106
|
+
(function (QuickStartTaskStatus) {
|
|
107
|
+
QuickStartTaskStatus["INIT"] = "Initial";
|
|
108
|
+
QuickStartTaskStatus["VISITED"] = "Visited";
|
|
109
|
+
QuickStartTaskStatus["REVIEW"] = "Review";
|
|
110
|
+
QuickStartTaskStatus["SUCCESS"] = "Success";
|
|
111
|
+
QuickStartTaskStatus["FAILED"] = "Failed";
|
|
112
112
|
})(exports.QuickStartTaskStatus || (exports.QuickStartTaskStatus = {}));
|
|
113
113
|
|
|
114
|
-
const QUICKSTART_SEARCH_FILTER_KEY = 'keyword';
|
|
115
|
-
const QUICKSTART_STATUS_FILTER_KEY = 'status';
|
|
116
|
-
const QUICKSTART_ID_FILTER_KEY = 'quickstart';
|
|
117
|
-
const QUICKSTART_TASKS_INITIAL_STATES = [
|
|
118
|
-
exports.QuickStartTaskStatus.INIT,
|
|
119
|
-
exports.QuickStartTaskStatus.VISITED,
|
|
120
|
-
];
|
|
114
|
+
const QUICKSTART_SEARCH_FILTER_KEY = 'keyword';
|
|
115
|
+
const QUICKSTART_STATUS_FILTER_KEY = 'status';
|
|
116
|
+
const QUICKSTART_ID_FILTER_KEY = 'quickstart';
|
|
117
|
+
const QUICKSTART_TASKS_INITIAL_STATES = [
|
|
118
|
+
exports.QuickStartTaskStatus.INIT,
|
|
119
|
+
exports.QuickStartTaskStatus.VISITED,
|
|
120
|
+
];
|
|
121
121
|
const HELP_TOPIC_NAME_KEY = 'topic';
|
|
122
122
|
|
|
123
|
-
let createHistory;
|
|
124
|
-
try {
|
|
125
|
-
if (process.env.NODE_ENV === 'test') {
|
|
126
|
-
// Running in node. Can't use browser history
|
|
127
|
-
createHistory = createMemoryHistory;
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
createHistory = createBrowserHistory;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
catch (unused) {
|
|
134
|
-
createHistory = createBrowserHistory;
|
|
135
|
-
}
|
|
136
|
-
const history = createHistory();
|
|
137
|
-
const removeQueryArgument = (k) => {
|
|
138
|
-
const params = new URLSearchParams(window.location.search);
|
|
139
|
-
if (params.has(k)) {
|
|
140
|
-
params.delete(k);
|
|
141
|
-
const url = new URL(window.location.href);
|
|
142
|
-
history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const setQueryArgument = (k, v) => {
|
|
146
|
-
if (!v) {
|
|
147
|
-
return removeQueryArgument(k);
|
|
148
|
-
}
|
|
149
|
-
const params = new URLSearchParams(window.location.search);
|
|
150
|
-
if (params.get(k) !== v) {
|
|
151
|
-
params.set(k, v);
|
|
152
|
-
const url = new URL(window.location.href);
|
|
153
|
-
history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
const clearFilterParams = () => {
|
|
157
|
-
removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
|
|
158
|
-
removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
|
|
123
|
+
let createHistory;
|
|
124
|
+
try {
|
|
125
|
+
if (process.env.NODE_ENV === 'test') {
|
|
126
|
+
// Running in node. Can't use browser history
|
|
127
|
+
createHistory = createMemoryHistory;
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
createHistory = createBrowserHistory;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (unused) {
|
|
134
|
+
createHistory = createBrowserHistory;
|
|
135
|
+
}
|
|
136
|
+
const history = createHistory();
|
|
137
|
+
const removeQueryArgument = (k) => {
|
|
138
|
+
const params = new URLSearchParams(window.location.search);
|
|
139
|
+
if (params.has(k)) {
|
|
140
|
+
params.delete(k);
|
|
141
|
+
const url = new URL(window.location.href);
|
|
142
|
+
history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const setQueryArgument = (k, v) => {
|
|
146
|
+
if (!v) {
|
|
147
|
+
return removeQueryArgument(k);
|
|
148
|
+
}
|
|
149
|
+
const params = new URLSearchParams(window.location.search);
|
|
150
|
+
if (params.get(k) !== v) {
|
|
151
|
+
params.set(k, v);
|
|
152
|
+
const url = new URL(window.location.href);
|
|
153
|
+
history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const clearFilterParams = () => {
|
|
157
|
+
removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
|
|
158
|
+
removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
var Status$1 = "Status";
|
|
@@ -219,667 +219,667 @@ var en = {
|
|
|
219
219
|
"{{type}} • {{duration, number}} minutes": "{{type}} • {{duration, number}} minutes"
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
-
/* eslint-disable */
|
|
223
|
-
// https://github.com/i18next/i18next/blob/master/src/PluralResolver.js
|
|
224
|
-
const sets = [
|
|
225
|
-
{
|
|
226
|
-
lngs: [
|
|
227
|
-
'ach',
|
|
228
|
-
'ak',
|
|
229
|
-
'am',
|
|
230
|
-
'arn',
|
|
231
|
-
'br',
|
|
232
|
-
'fil',
|
|
233
|
-
'gun',
|
|
234
|
-
'ln',
|
|
235
|
-
'mfe',
|
|
236
|
-
'mg',
|
|
237
|
-
'mi',
|
|
238
|
-
'oc',
|
|
239
|
-
'pt',
|
|
240
|
-
'pt-BR',
|
|
241
|
-
'tg',
|
|
242
|
-
'tl',
|
|
243
|
-
'ti',
|
|
244
|
-
'tr',
|
|
245
|
-
'uz',
|
|
246
|
-
'wa',
|
|
247
|
-
],
|
|
248
|
-
nr: [1, 2],
|
|
249
|
-
fc: 1,
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
lngs: [
|
|
253
|
-
'af',
|
|
254
|
-
'an',
|
|
255
|
-
'ast',
|
|
256
|
-
'az',
|
|
257
|
-
'bg',
|
|
258
|
-
'bn',
|
|
259
|
-
'ca',
|
|
260
|
-
'da',
|
|
261
|
-
'de',
|
|
262
|
-
'dev',
|
|
263
|
-
'el',
|
|
264
|
-
'en',
|
|
265
|
-
'eo',
|
|
266
|
-
'es',
|
|
267
|
-
'et',
|
|
268
|
-
'eu',
|
|
269
|
-
'fi',
|
|
270
|
-
'fo',
|
|
271
|
-
'fur',
|
|
272
|
-
'fy',
|
|
273
|
-
'gl',
|
|
274
|
-
'gu',
|
|
275
|
-
'ha',
|
|
276
|
-
'hi',
|
|
277
|
-
'hu',
|
|
278
|
-
'hy',
|
|
279
|
-
'ia',
|
|
280
|
-
'it',
|
|
281
|
-
'kk',
|
|
282
|
-
'kn',
|
|
283
|
-
'ku',
|
|
284
|
-
'lb',
|
|
285
|
-
'mai',
|
|
286
|
-
'ml',
|
|
287
|
-
'mn',
|
|
288
|
-
'mr',
|
|
289
|
-
'nah',
|
|
290
|
-
'nap',
|
|
291
|
-
'nb',
|
|
292
|
-
'ne',
|
|
293
|
-
'nl',
|
|
294
|
-
'nn',
|
|
295
|
-
'no',
|
|
296
|
-
'nso',
|
|
297
|
-
'pa',
|
|
298
|
-
'pap',
|
|
299
|
-
'pms',
|
|
300
|
-
'ps',
|
|
301
|
-
'pt-PT',
|
|
302
|
-
'rm',
|
|
303
|
-
'sco',
|
|
304
|
-
'se',
|
|
305
|
-
'si',
|
|
306
|
-
'so',
|
|
307
|
-
'son',
|
|
308
|
-
'sq',
|
|
309
|
-
'sv',
|
|
310
|
-
'sw',
|
|
311
|
-
'ta',
|
|
312
|
-
'te',
|
|
313
|
-
'tk',
|
|
314
|
-
'ur',
|
|
315
|
-
'yo',
|
|
316
|
-
],
|
|
317
|
-
nr: [1, 2],
|
|
318
|
-
fc: 2,
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
lngs: [
|
|
322
|
-
'ay',
|
|
323
|
-
'bo',
|
|
324
|
-
'cgg',
|
|
325
|
-
'fa',
|
|
326
|
-
'ht',
|
|
327
|
-
'id',
|
|
328
|
-
'ja',
|
|
329
|
-
'jbo',
|
|
330
|
-
'ka',
|
|
331
|
-
'km',
|
|
332
|
-
'ko',
|
|
333
|
-
'ky',
|
|
334
|
-
'lo',
|
|
335
|
-
'ms',
|
|
336
|
-
'sah',
|
|
337
|
-
'su',
|
|
338
|
-
'th',
|
|
339
|
-
'tt',
|
|
340
|
-
'ug',
|
|
341
|
-
'vi',
|
|
342
|
-
'wo',
|
|
343
|
-
'zh',
|
|
344
|
-
],
|
|
345
|
-
nr: [1],
|
|
346
|
-
fc: 3,
|
|
347
|
-
},
|
|
348
|
-
{ lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'], nr: [1, 2, 5], fc: 4 },
|
|
349
|
-
{ lngs: ['ar'], nr: [0, 1, 2, 3, 11, 100], fc: 5 },
|
|
350
|
-
{ lngs: ['cs', 'sk'], nr: [1, 2, 5], fc: 6 },
|
|
351
|
-
{ lngs: ['csb', 'pl'], nr: [1, 2, 5], fc: 7 },
|
|
352
|
-
{ lngs: ['cy'], nr: [1, 2, 3, 8], fc: 8 },
|
|
353
|
-
{ lngs: ['fr'], nr: [1, 2], fc: 9 },
|
|
354
|
-
{ lngs: ['ga'], nr: [1, 2, 3, 7, 11], fc: 10 },
|
|
355
|
-
{ lngs: ['gd'], nr: [1, 2, 3, 20], fc: 11 },
|
|
356
|
-
{ lngs: ['is'], nr: [1, 2], fc: 12 },
|
|
357
|
-
{ lngs: ['jv'], nr: [0, 1], fc: 13 },
|
|
358
|
-
{ lngs: ['kw'], nr: [1, 2, 3, 4], fc: 14 },
|
|
359
|
-
{ lngs: ['lt'], nr: [1, 2, 10], fc: 15 },
|
|
360
|
-
{ lngs: ['lv'], nr: [1, 2, 0], fc: 16 },
|
|
361
|
-
{ lngs: ['mk'], nr: [1, 2], fc: 17 },
|
|
362
|
-
{ lngs: ['mnk'], nr: [0, 1, 2], fc: 18 },
|
|
363
|
-
{ lngs: ['mt'], nr: [1, 2, 11, 20], fc: 19 },
|
|
364
|
-
{ lngs: ['or'], nr: [2, 1], fc: 2 },
|
|
365
|
-
{ lngs: ['ro'], nr: [1, 2, 20], fc: 20 },
|
|
366
|
-
{ lngs: ['sl'], nr: [5, 1, 2, 3], fc: 21 },
|
|
367
|
-
{ lngs: ['he', 'iw'], nr: [1, 2, 20, 21], fc: 22 },
|
|
368
|
-
];
|
|
369
|
-
const _rulesPluralsTypes = {
|
|
370
|
-
1: function (n) {
|
|
371
|
-
return Number(n > 1);
|
|
372
|
-
},
|
|
373
|
-
2: function (n) {
|
|
374
|
-
return Number(n != 1);
|
|
375
|
-
},
|
|
376
|
-
3: function (n) {
|
|
377
|
-
return 0;
|
|
378
|
-
},
|
|
379
|
-
4: function (n) {
|
|
380
|
-
return Number(n % 10 == 1 && n % 100 != 11
|
|
381
|
-
? 0
|
|
382
|
-
: n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20)
|
|
383
|
-
? 1
|
|
384
|
-
: 2);
|
|
385
|
-
},
|
|
386
|
-
5: function (n) {
|
|
387
|
-
return Number(n == 0
|
|
388
|
-
? 0
|
|
389
|
-
: n == 1
|
|
390
|
-
? 1
|
|
391
|
-
: n == 2
|
|
392
|
-
? 2
|
|
393
|
-
: n % 100 >= 3 && n % 100 <= 10
|
|
394
|
-
? 3
|
|
395
|
-
: n % 100 >= 11
|
|
396
|
-
? 4
|
|
397
|
-
: 5);
|
|
398
|
-
},
|
|
399
|
-
6: function (n) {
|
|
400
|
-
return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
|
|
401
|
-
},
|
|
402
|
-
7: function (n) {
|
|
403
|
-
return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
404
|
-
},
|
|
405
|
-
8: function (n) {
|
|
406
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
|
|
407
|
-
},
|
|
408
|
-
9: function (n) {
|
|
409
|
-
return Number(n >= 2);
|
|
410
|
-
},
|
|
411
|
-
10: function (n) {
|
|
412
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
|
|
413
|
-
},
|
|
414
|
-
11: function (n) {
|
|
415
|
-
return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
|
|
416
|
-
},
|
|
417
|
-
12: function (n) {
|
|
418
|
-
return Number(n % 10 != 1 || n % 100 == 11);
|
|
419
|
-
},
|
|
420
|
-
13: function (n) {
|
|
421
|
-
return Number(n !== 0);
|
|
422
|
-
},
|
|
423
|
-
14: function (n) {
|
|
424
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
|
|
425
|
-
},
|
|
426
|
-
15: function (n) {
|
|
427
|
-
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
428
|
-
},
|
|
429
|
-
16: function (n) {
|
|
430
|
-
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
|
|
431
|
-
},
|
|
432
|
-
17: function (n) {
|
|
433
|
-
return Number(n == 1 || (n % 10 == 1 && n % 100 != 11) ? 0 : 1);
|
|
434
|
-
},
|
|
435
|
-
18: function (n) {
|
|
436
|
-
return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
|
|
437
|
-
},
|
|
438
|
-
19: function (n) {
|
|
439
|
-
return Number(n == 1
|
|
440
|
-
? 0
|
|
441
|
-
: n == 0 || (n % 100 > 1 && n % 100 < 11)
|
|
442
|
-
? 1
|
|
443
|
-
: n % 100 > 10 && n % 100 < 20
|
|
444
|
-
? 2
|
|
445
|
-
: 3);
|
|
446
|
-
},
|
|
447
|
-
20: function (n) {
|
|
448
|
-
return Number(n == 1 ? 0 : n == 0 || (n % 100 > 0 && n % 100 < 20) ? 1 : 2);
|
|
449
|
-
},
|
|
450
|
-
21: function (n) {
|
|
451
|
-
return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
|
|
452
|
-
},
|
|
453
|
-
22: function (n) {
|
|
454
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
|
|
455
|
-
},
|
|
456
|
-
};
|
|
457
|
-
function createRules() {
|
|
458
|
-
const rules = {};
|
|
459
|
-
sets.forEach((set) => {
|
|
460
|
-
set.lngs.forEach((l) => {
|
|
461
|
-
rules[l] = {
|
|
462
|
-
numbers: set.nr,
|
|
463
|
-
plurals: _rulesPluralsTypes[set.fc],
|
|
464
|
-
};
|
|
465
|
-
});
|
|
466
|
-
});
|
|
467
|
-
return rules;
|
|
468
|
-
}
|
|
469
|
-
class PluralResolver {
|
|
470
|
-
constructor(options = {}) {
|
|
471
|
-
this.options = options;
|
|
472
|
-
this.rules = createRules();
|
|
473
|
-
}
|
|
474
|
-
addRule(lng, obj) {
|
|
475
|
-
this.rules[lng] = obj;
|
|
476
|
-
}
|
|
477
|
-
getRule(code) {
|
|
478
|
-
return this.rules[code];
|
|
479
|
-
}
|
|
480
|
-
needsPlural(code) {
|
|
481
|
-
const rule = this.getRule(code);
|
|
482
|
-
return rule && rule.numbers.length > 1;
|
|
483
|
-
}
|
|
484
|
-
getPluralFormsOfKey(code, key) {
|
|
485
|
-
return this.getSuffixes(code).map((suffix) => key + suffix);
|
|
486
|
-
}
|
|
487
|
-
getSuffixes(code) {
|
|
488
|
-
const rule = this.getRule(code);
|
|
489
|
-
if (!rule) {
|
|
490
|
-
return [];
|
|
491
|
-
}
|
|
492
|
-
return rule.numbers.map((number) => this.getSuffix(code, number));
|
|
493
|
-
}
|
|
494
|
-
getSuffix(code, count) {
|
|
495
|
-
const rule = this.getRule(code);
|
|
496
|
-
if (rule) {
|
|
497
|
-
// if (rule.numbers.length === 1) return ''; // only singular
|
|
498
|
-
const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
|
499
|
-
let suffix = rule.numbers[idx];
|
|
500
|
-
// special treatment for lngs only having singular and plural
|
|
501
|
-
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
502
|
-
if (suffix === 2) {
|
|
503
|
-
suffix = 'plural';
|
|
504
|
-
}
|
|
505
|
-
else if (suffix === 1) {
|
|
506
|
-
suffix = '';
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
const returnSuffix = () => this.options.prepend && suffix.toString()
|
|
510
|
-
? this.options.prepend + suffix.toString()
|
|
511
|
-
: suffix.toString();
|
|
512
|
-
// COMPATIBILITY JSON
|
|
513
|
-
// v1
|
|
514
|
-
if (this.options.compatibilityJSON === 'v1') {
|
|
515
|
-
if (suffix === 1) {
|
|
516
|
-
return '';
|
|
517
|
-
}
|
|
518
|
-
if (typeof suffix === 'number') {
|
|
519
|
-
return `_plural_${suffix.toString()}`;
|
|
520
|
-
}
|
|
521
|
-
return returnSuffix();
|
|
522
|
-
}
|
|
523
|
-
if ( /* v2 */this.options.compatibilityJSON === 'v2') {
|
|
524
|
-
return returnSuffix();
|
|
525
|
-
}
|
|
526
|
-
if (
|
|
527
|
-
/* v3 - gettext index */ this.options.simplifyPluralSuffix &&
|
|
528
|
-
rule.numbers.length === 2 &&
|
|
529
|
-
rule.numbers[0] === 1) {
|
|
530
|
-
return returnSuffix();
|
|
531
|
-
}
|
|
532
|
-
return this.options.prepend && idx.toString()
|
|
533
|
-
? this.options.prepend + idx.toString()
|
|
534
|
-
: idx.toString();
|
|
535
|
-
}
|
|
536
|
-
// this.logger.warn(`no plural rule found for: ${code}`);
|
|
537
|
-
return '';
|
|
538
|
-
}
|
|
222
|
+
/* eslint-disable */
|
|
223
|
+
// https://github.com/i18next/i18next/blob/master/src/PluralResolver.js
|
|
224
|
+
const sets = [
|
|
225
|
+
{
|
|
226
|
+
lngs: [
|
|
227
|
+
'ach',
|
|
228
|
+
'ak',
|
|
229
|
+
'am',
|
|
230
|
+
'arn',
|
|
231
|
+
'br',
|
|
232
|
+
'fil',
|
|
233
|
+
'gun',
|
|
234
|
+
'ln',
|
|
235
|
+
'mfe',
|
|
236
|
+
'mg',
|
|
237
|
+
'mi',
|
|
238
|
+
'oc',
|
|
239
|
+
'pt',
|
|
240
|
+
'pt-BR',
|
|
241
|
+
'tg',
|
|
242
|
+
'tl',
|
|
243
|
+
'ti',
|
|
244
|
+
'tr',
|
|
245
|
+
'uz',
|
|
246
|
+
'wa',
|
|
247
|
+
],
|
|
248
|
+
nr: [1, 2],
|
|
249
|
+
fc: 1,
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
lngs: [
|
|
253
|
+
'af',
|
|
254
|
+
'an',
|
|
255
|
+
'ast',
|
|
256
|
+
'az',
|
|
257
|
+
'bg',
|
|
258
|
+
'bn',
|
|
259
|
+
'ca',
|
|
260
|
+
'da',
|
|
261
|
+
'de',
|
|
262
|
+
'dev',
|
|
263
|
+
'el',
|
|
264
|
+
'en',
|
|
265
|
+
'eo',
|
|
266
|
+
'es',
|
|
267
|
+
'et',
|
|
268
|
+
'eu',
|
|
269
|
+
'fi',
|
|
270
|
+
'fo',
|
|
271
|
+
'fur',
|
|
272
|
+
'fy',
|
|
273
|
+
'gl',
|
|
274
|
+
'gu',
|
|
275
|
+
'ha',
|
|
276
|
+
'hi',
|
|
277
|
+
'hu',
|
|
278
|
+
'hy',
|
|
279
|
+
'ia',
|
|
280
|
+
'it',
|
|
281
|
+
'kk',
|
|
282
|
+
'kn',
|
|
283
|
+
'ku',
|
|
284
|
+
'lb',
|
|
285
|
+
'mai',
|
|
286
|
+
'ml',
|
|
287
|
+
'mn',
|
|
288
|
+
'mr',
|
|
289
|
+
'nah',
|
|
290
|
+
'nap',
|
|
291
|
+
'nb',
|
|
292
|
+
'ne',
|
|
293
|
+
'nl',
|
|
294
|
+
'nn',
|
|
295
|
+
'no',
|
|
296
|
+
'nso',
|
|
297
|
+
'pa',
|
|
298
|
+
'pap',
|
|
299
|
+
'pms',
|
|
300
|
+
'ps',
|
|
301
|
+
'pt-PT',
|
|
302
|
+
'rm',
|
|
303
|
+
'sco',
|
|
304
|
+
'se',
|
|
305
|
+
'si',
|
|
306
|
+
'so',
|
|
307
|
+
'son',
|
|
308
|
+
'sq',
|
|
309
|
+
'sv',
|
|
310
|
+
'sw',
|
|
311
|
+
'ta',
|
|
312
|
+
'te',
|
|
313
|
+
'tk',
|
|
314
|
+
'ur',
|
|
315
|
+
'yo',
|
|
316
|
+
],
|
|
317
|
+
nr: [1, 2],
|
|
318
|
+
fc: 2,
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
lngs: [
|
|
322
|
+
'ay',
|
|
323
|
+
'bo',
|
|
324
|
+
'cgg',
|
|
325
|
+
'fa',
|
|
326
|
+
'ht',
|
|
327
|
+
'id',
|
|
328
|
+
'ja',
|
|
329
|
+
'jbo',
|
|
330
|
+
'ka',
|
|
331
|
+
'km',
|
|
332
|
+
'ko',
|
|
333
|
+
'ky',
|
|
334
|
+
'lo',
|
|
335
|
+
'ms',
|
|
336
|
+
'sah',
|
|
337
|
+
'su',
|
|
338
|
+
'th',
|
|
339
|
+
'tt',
|
|
340
|
+
'ug',
|
|
341
|
+
'vi',
|
|
342
|
+
'wo',
|
|
343
|
+
'zh',
|
|
344
|
+
],
|
|
345
|
+
nr: [1],
|
|
346
|
+
fc: 3,
|
|
347
|
+
},
|
|
348
|
+
{ lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'], nr: [1, 2, 5], fc: 4 },
|
|
349
|
+
{ lngs: ['ar'], nr: [0, 1, 2, 3, 11, 100], fc: 5 },
|
|
350
|
+
{ lngs: ['cs', 'sk'], nr: [1, 2, 5], fc: 6 },
|
|
351
|
+
{ lngs: ['csb', 'pl'], nr: [1, 2, 5], fc: 7 },
|
|
352
|
+
{ lngs: ['cy'], nr: [1, 2, 3, 8], fc: 8 },
|
|
353
|
+
{ lngs: ['fr'], nr: [1, 2], fc: 9 },
|
|
354
|
+
{ lngs: ['ga'], nr: [1, 2, 3, 7, 11], fc: 10 },
|
|
355
|
+
{ lngs: ['gd'], nr: [1, 2, 3, 20], fc: 11 },
|
|
356
|
+
{ lngs: ['is'], nr: [1, 2], fc: 12 },
|
|
357
|
+
{ lngs: ['jv'], nr: [0, 1], fc: 13 },
|
|
358
|
+
{ lngs: ['kw'], nr: [1, 2, 3, 4], fc: 14 },
|
|
359
|
+
{ lngs: ['lt'], nr: [1, 2, 10], fc: 15 },
|
|
360
|
+
{ lngs: ['lv'], nr: [1, 2, 0], fc: 16 },
|
|
361
|
+
{ lngs: ['mk'], nr: [1, 2], fc: 17 },
|
|
362
|
+
{ lngs: ['mnk'], nr: [0, 1, 2], fc: 18 },
|
|
363
|
+
{ lngs: ['mt'], nr: [1, 2, 11, 20], fc: 19 },
|
|
364
|
+
{ lngs: ['or'], nr: [2, 1], fc: 2 },
|
|
365
|
+
{ lngs: ['ro'], nr: [1, 2, 20], fc: 20 },
|
|
366
|
+
{ lngs: ['sl'], nr: [5, 1, 2, 3], fc: 21 },
|
|
367
|
+
{ lngs: ['he', 'iw'], nr: [1, 2, 20, 21], fc: 22 },
|
|
368
|
+
];
|
|
369
|
+
const _rulesPluralsTypes = {
|
|
370
|
+
1: function (n) {
|
|
371
|
+
return Number(n > 1);
|
|
372
|
+
},
|
|
373
|
+
2: function (n) {
|
|
374
|
+
return Number(n != 1);
|
|
375
|
+
},
|
|
376
|
+
3: function (n) {
|
|
377
|
+
return 0;
|
|
378
|
+
},
|
|
379
|
+
4: function (n) {
|
|
380
|
+
return Number(n % 10 == 1 && n % 100 != 11
|
|
381
|
+
? 0
|
|
382
|
+
: n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20)
|
|
383
|
+
? 1
|
|
384
|
+
: 2);
|
|
385
|
+
},
|
|
386
|
+
5: function (n) {
|
|
387
|
+
return Number(n == 0
|
|
388
|
+
? 0
|
|
389
|
+
: n == 1
|
|
390
|
+
? 1
|
|
391
|
+
: n == 2
|
|
392
|
+
? 2
|
|
393
|
+
: n % 100 >= 3 && n % 100 <= 10
|
|
394
|
+
? 3
|
|
395
|
+
: n % 100 >= 11
|
|
396
|
+
? 4
|
|
397
|
+
: 5);
|
|
398
|
+
},
|
|
399
|
+
6: function (n) {
|
|
400
|
+
return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
|
|
401
|
+
},
|
|
402
|
+
7: function (n) {
|
|
403
|
+
return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
404
|
+
},
|
|
405
|
+
8: function (n) {
|
|
406
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
|
|
407
|
+
},
|
|
408
|
+
9: function (n) {
|
|
409
|
+
return Number(n >= 2);
|
|
410
|
+
},
|
|
411
|
+
10: function (n) {
|
|
412
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
|
|
413
|
+
},
|
|
414
|
+
11: function (n) {
|
|
415
|
+
return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
|
|
416
|
+
},
|
|
417
|
+
12: function (n) {
|
|
418
|
+
return Number(n % 10 != 1 || n % 100 == 11);
|
|
419
|
+
},
|
|
420
|
+
13: function (n) {
|
|
421
|
+
return Number(n !== 0);
|
|
422
|
+
},
|
|
423
|
+
14: function (n) {
|
|
424
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
|
|
425
|
+
},
|
|
426
|
+
15: function (n) {
|
|
427
|
+
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
428
|
+
},
|
|
429
|
+
16: function (n) {
|
|
430
|
+
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
|
|
431
|
+
},
|
|
432
|
+
17: function (n) {
|
|
433
|
+
return Number(n == 1 || (n % 10 == 1 && n % 100 != 11) ? 0 : 1);
|
|
434
|
+
},
|
|
435
|
+
18: function (n) {
|
|
436
|
+
return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
|
|
437
|
+
},
|
|
438
|
+
19: function (n) {
|
|
439
|
+
return Number(n == 1
|
|
440
|
+
? 0
|
|
441
|
+
: n == 0 || (n % 100 > 1 && n % 100 < 11)
|
|
442
|
+
? 1
|
|
443
|
+
: n % 100 > 10 && n % 100 < 20
|
|
444
|
+
? 2
|
|
445
|
+
: 3);
|
|
446
|
+
},
|
|
447
|
+
20: function (n) {
|
|
448
|
+
return Number(n == 1 ? 0 : n == 0 || (n % 100 > 0 && n % 100 < 20) ? 1 : 2);
|
|
449
|
+
},
|
|
450
|
+
21: function (n) {
|
|
451
|
+
return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
|
|
452
|
+
},
|
|
453
|
+
22: function (n) {
|
|
454
|
+
return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
|
|
455
|
+
},
|
|
456
|
+
};
|
|
457
|
+
function createRules() {
|
|
458
|
+
const rules = {};
|
|
459
|
+
sets.forEach((set) => {
|
|
460
|
+
set.lngs.forEach((l) => {
|
|
461
|
+
rules[l] = {
|
|
462
|
+
numbers: set.nr,
|
|
463
|
+
plurals: _rulesPluralsTypes[set.fc],
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
});
|
|
467
|
+
return rules;
|
|
468
|
+
}
|
|
469
|
+
class PluralResolver {
|
|
470
|
+
constructor(options = {}) {
|
|
471
|
+
this.options = options;
|
|
472
|
+
this.rules = createRules();
|
|
473
|
+
}
|
|
474
|
+
addRule(lng, obj) {
|
|
475
|
+
this.rules[lng] = obj;
|
|
476
|
+
}
|
|
477
|
+
getRule(code) {
|
|
478
|
+
return this.rules[code];
|
|
479
|
+
}
|
|
480
|
+
needsPlural(code) {
|
|
481
|
+
const rule = this.getRule(code);
|
|
482
|
+
return rule && rule.numbers.length > 1;
|
|
483
|
+
}
|
|
484
|
+
getPluralFormsOfKey(code, key) {
|
|
485
|
+
return this.getSuffixes(code).map((suffix) => key + suffix);
|
|
486
|
+
}
|
|
487
|
+
getSuffixes(code) {
|
|
488
|
+
const rule = this.getRule(code);
|
|
489
|
+
if (!rule) {
|
|
490
|
+
return [];
|
|
491
|
+
}
|
|
492
|
+
return rule.numbers.map((number) => this.getSuffix(code, number));
|
|
493
|
+
}
|
|
494
|
+
getSuffix(code, count) {
|
|
495
|
+
const rule = this.getRule(code);
|
|
496
|
+
if (rule) {
|
|
497
|
+
// if (rule.numbers.length === 1) return ''; // only singular
|
|
498
|
+
const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
|
499
|
+
let suffix = rule.numbers[idx];
|
|
500
|
+
// special treatment for lngs only having singular and plural
|
|
501
|
+
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
502
|
+
if (suffix === 2) {
|
|
503
|
+
suffix = 'plural';
|
|
504
|
+
}
|
|
505
|
+
else if (suffix === 1) {
|
|
506
|
+
suffix = '';
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
const returnSuffix = () => this.options.prepend && suffix.toString()
|
|
510
|
+
? this.options.prepend + suffix.toString()
|
|
511
|
+
: suffix.toString();
|
|
512
|
+
// COMPATIBILITY JSON
|
|
513
|
+
// v1
|
|
514
|
+
if (this.options.compatibilityJSON === 'v1') {
|
|
515
|
+
if (suffix === 1) {
|
|
516
|
+
return '';
|
|
517
|
+
}
|
|
518
|
+
if (typeof suffix === 'number') {
|
|
519
|
+
return `_plural_${suffix.toString()}`;
|
|
520
|
+
}
|
|
521
|
+
return returnSuffix();
|
|
522
|
+
}
|
|
523
|
+
if ( /* v2 */this.options.compatibilityJSON === 'v2') {
|
|
524
|
+
return returnSuffix();
|
|
525
|
+
}
|
|
526
|
+
if (
|
|
527
|
+
/* v3 - gettext index */ this.options.simplifyPluralSuffix &&
|
|
528
|
+
rule.numbers.length === 2 &&
|
|
529
|
+
rule.numbers[0] === 1) {
|
|
530
|
+
return returnSuffix();
|
|
531
|
+
}
|
|
532
|
+
return this.options.prepend && idx.toString()
|
|
533
|
+
? this.options.prepend + idx.toString()
|
|
534
|
+
: idx.toString();
|
|
535
|
+
}
|
|
536
|
+
// this.logger.warn(`no plural rule found for: ${code}`);
|
|
537
|
+
return '';
|
|
538
|
+
}
|
|
539
539
|
}
|
|
540
540
|
|
|
541
|
-
const QUICK_START_NAME = 'console.openshift.io/name';
|
|
542
|
-
const getQuickStartByName = (name, quickStarts) => quickStarts.find((quickStart) => quickStart.metadata.name === name);
|
|
543
|
-
const getQuickStartStatus = (allQuickStartStates, quickStartID) => { var _a, _b; return (_b = (_a = allQuickStartStates === null || allQuickStartStates === void 0 ? void 0 : allQuickStartStates[quickStartID]) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : exports.QuickStartStatus.NOT_STARTED; };
|
|
544
|
-
const getTaskStatusKey = (taskNumber) => `taskStatus${taskNumber}`;
|
|
545
|
-
const getQuickStartStatusCount = (allQuickStartStates, quickStarts) => quickStarts.reduce((totals, item) => {
|
|
546
|
-
totals[getQuickStartStatus(allQuickStartStates, item.metadata.name)]++;
|
|
547
|
-
return totals;
|
|
548
|
-
}, {
|
|
549
|
-
[exports.QuickStartStatus.IN_PROGRESS]: 0,
|
|
550
|
-
[exports.QuickStartStatus.COMPLETE]: 0,
|
|
551
|
-
[exports.QuickStartStatus.NOT_STARTED]: 0,
|
|
552
|
-
});
|
|
553
|
-
const getDisabledQuickStarts = () => {
|
|
554
|
-
var _a, _b;
|
|
555
|
-
let disabledQuickStarts = [];
|
|
556
|
-
const quickStartServerData = (_a = window.SERVER_FLAGS) === null || _a === void 0 ? void 0 : _a.quickStarts;
|
|
557
|
-
try {
|
|
558
|
-
if (quickStartServerData) {
|
|
559
|
-
disabledQuickStarts = (_b = JSON.parse(quickStartServerData).disabled) !== null && _b !== void 0 ? _b : [];
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
catch (e) {
|
|
563
|
-
// eslint-disable-next-line no-console
|
|
564
|
-
console.error('error while parsing SERVER_FLAG.quickStarts', e);
|
|
565
|
-
}
|
|
566
|
-
return disabledQuickStarts;
|
|
567
|
-
};
|
|
568
|
-
const isDisabledQuickStart = (quickstart, disabledQuickStarts) => {
|
|
569
|
-
var _a, _b;
|
|
570
|
-
const quickStartName = (_b = (_a = quickstart.metadata.annotations) === null || _a === void 0 ? void 0 : _a[QUICK_START_NAME]) !== null && _b !== void 0 ? _b : quickstart.metadata.name;
|
|
571
|
-
return disabledQuickStarts.includes(quickStartName);
|
|
572
|
-
};
|
|
573
|
-
const filterQuickStarts = (quickStarts, filterText, statusFilters, allQuickStartStates) => {
|
|
574
|
-
const searchText = filterText.toLowerCase();
|
|
575
|
-
return quickStarts.filter(({ metadata: { name }, spec: { displayName, prerequisites = [], description } }) => {
|
|
576
|
-
const matchesFilter = statusFilters.length > 0
|
|
577
|
-
? statusFilters.includes(getQuickStartStatus(allQuickStartStates, name))
|
|
578
|
-
: true;
|
|
579
|
-
const matchesText = displayName.toLowerCase().includes(searchText) ||
|
|
580
|
-
description.toLowerCase().includes(searchText) ||
|
|
581
|
-
prerequisites.some((text) => text.toLowerCase().includes(searchText));
|
|
582
|
-
return matchesFilter && matchesText;
|
|
583
|
-
});
|
|
584
|
-
};
|
|
585
|
-
const camelize = (str) => str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
|
|
586
|
-
if (+match === 0) {
|
|
587
|
-
return '';
|
|
588
|
-
} // or if (/\s+/.test(match)) for white spaces
|
|
589
|
-
return index === 0 ? match.toLowerCase() : match.toUpperCase();
|
|
541
|
+
const QUICK_START_NAME = 'console.openshift.io/name';
|
|
542
|
+
const getQuickStartByName = (name, quickStarts) => quickStarts.find((quickStart) => quickStart.metadata.name === name);
|
|
543
|
+
const getQuickStartStatus = (allQuickStartStates, quickStartID) => { var _a, _b; return (_b = (_a = allQuickStartStates === null || allQuickStartStates === void 0 ? void 0 : allQuickStartStates[quickStartID]) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : exports.QuickStartStatus.NOT_STARTED; };
|
|
544
|
+
const getTaskStatusKey = (taskNumber) => `taskStatus${taskNumber}`;
|
|
545
|
+
const getQuickStartStatusCount = (allQuickStartStates, quickStarts) => quickStarts.reduce((totals, item) => {
|
|
546
|
+
totals[getQuickStartStatus(allQuickStartStates, item.metadata.name)]++;
|
|
547
|
+
return totals;
|
|
548
|
+
}, {
|
|
549
|
+
[exports.QuickStartStatus.IN_PROGRESS]: 0,
|
|
550
|
+
[exports.QuickStartStatus.COMPLETE]: 0,
|
|
551
|
+
[exports.QuickStartStatus.NOT_STARTED]: 0,
|
|
552
|
+
});
|
|
553
|
+
const getDisabledQuickStarts = () => {
|
|
554
|
+
var _a, _b;
|
|
555
|
+
let disabledQuickStarts = [];
|
|
556
|
+
const quickStartServerData = (_a = window.SERVER_FLAGS) === null || _a === void 0 ? void 0 : _a.quickStarts;
|
|
557
|
+
try {
|
|
558
|
+
if (quickStartServerData) {
|
|
559
|
+
disabledQuickStarts = (_b = JSON.parse(quickStartServerData).disabled) !== null && _b !== void 0 ? _b : [];
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
catch (e) {
|
|
563
|
+
// eslint-disable-next-line no-console
|
|
564
|
+
console.error('error while parsing SERVER_FLAG.quickStarts', e);
|
|
565
|
+
}
|
|
566
|
+
return disabledQuickStarts;
|
|
567
|
+
};
|
|
568
|
+
const isDisabledQuickStart = (quickstart, disabledQuickStarts) => {
|
|
569
|
+
var _a, _b;
|
|
570
|
+
const quickStartName = (_b = (_a = quickstart.metadata.annotations) === null || _a === void 0 ? void 0 : _a[QUICK_START_NAME]) !== null && _b !== void 0 ? _b : quickstart.metadata.name;
|
|
571
|
+
return disabledQuickStarts.includes(quickStartName);
|
|
572
|
+
};
|
|
573
|
+
const filterQuickStarts = (quickStarts, filterText, statusFilters, allQuickStartStates) => {
|
|
574
|
+
const searchText = filterText.toLowerCase();
|
|
575
|
+
return quickStarts.filter(({ metadata: { name }, spec: { displayName, prerequisites = [], description } }) => {
|
|
576
|
+
const matchesFilter = statusFilters.length > 0
|
|
577
|
+
? statusFilters.includes(getQuickStartStatus(allQuickStartStates, name))
|
|
578
|
+
: true;
|
|
579
|
+
const matchesText = displayName.toLowerCase().includes(searchText) ||
|
|
580
|
+
description.toLowerCase().includes(searchText) ||
|
|
581
|
+
prerequisites.some((text) => text.toLowerCase().includes(searchText));
|
|
582
|
+
return matchesFilter && matchesText;
|
|
583
|
+
});
|
|
584
|
+
};
|
|
585
|
+
const camelize = (str) => str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function (match, index) {
|
|
586
|
+
if (+match === 0) {
|
|
587
|
+
return '';
|
|
588
|
+
} // or if (/\s+/.test(match)) for white spaces
|
|
589
|
+
return index === 0 ? match.toLowerCase() : match.toUpperCase();
|
|
590
590
|
});
|
|
591
591
|
|
|
592
|
-
const pluralResolver = new PluralResolver({ simplifyPluralSuffix: true });
|
|
593
|
-
const getDefaultQuickStartState = (totalTasks, initialStatus) => {
|
|
594
|
-
const defaultQuickStartState = {
|
|
595
|
-
status: initialStatus || exports.QuickStartStatus.NOT_STARTED,
|
|
596
|
-
taskNumber: -1,
|
|
597
|
-
};
|
|
598
|
-
if (totalTasks) {
|
|
599
|
-
for (let i = 0; i < totalTasks; i++) {
|
|
600
|
-
defaultQuickStartState[getTaskStatusKey(i)] = exports.QuickStartTaskStatus.INIT;
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
return defaultQuickStartState;
|
|
604
|
-
};
|
|
605
|
-
const QuickStartContextDefaults = {
|
|
606
|
-
allQuickStarts: [],
|
|
607
|
-
activeQuickStartID: '',
|
|
608
|
-
allQuickStartStates: {},
|
|
609
|
-
activeQuickStartState: {},
|
|
610
|
-
setAllQuickStarts: () => { },
|
|
611
|
-
resourceBundle: en,
|
|
612
|
-
getResource: (resource) => resource,
|
|
613
|
-
language: 'en',
|
|
614
|
-
useQueryParams: true,
|
|
615
|
-
filter: {
|
|
616
|
-
keyword: '',
|
|
617
|
-
status: {
|
|
618
|
-
statusTypes: {},
|
|
619
|
-
statusFilters: [],
|
|
620
|
-
},
|
|
621
|
-
},
|
|
622
|
-
setFilter: () => { },
|
|
623
|
-
footer: null,
|
|
624
|
-
useLegacyHeaderColors: false,
|
|
625
|
-
markdown: null,
|
|
626
|
-
loading: false,
|
|
627
|
-
alwaysShowTaskReview: true,
|
|
628
|
-
};
|
|
629
|
-
const QuickStartContext = React.createContext(QuickStartContextDefaults);
|
|
630
|
-
const getResource = (resource, options, resourceBundle, lng) => {
|
|
631
|
-
if (options && !isNaN(options.count)) {
|
|
632
|
-
const suffix = pluralResolver.getSuffix(lng, options.count);
|
|
633
|
-
if (suffix && resourceBundle[`${resource}_${suffix}`]) {
|
|
634
|
-
// needs plural
|
|
635
|
-
return resourceBundle[`${resource}_${suffix}`];
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
return (resourceBundle && resourceBundle[resource]) || resource;
|
|
639
|
-
};
|
|
640
|
-
const useValuesForQuickStartContext = (value = {}) => {
|
|
641
|
-
var _a, _b;
|
|
642
|
-
const combinedValue = Object.assign(Object.assign({}, QuickStartContextDefaults), value);
|
|
643
|
-
const { activeQuickStartID, setActiveQuickStartID, setAllQuickStartStates, useQueryParams, allQuickStartStates, allQuickStarts = [], footer, useLegacyHeaderColors, markdown, } = combinedValue;
|
|
644
|
-
const [quickStarts, setQuickStarts] = React__default['default'].useState(combinedValue.allQuickStarts || []);
|
|
645
|
-
const [resourceBundle, setResourceBundle] = React__default['default'].useState(Object.assign(Object.assign({}, en), combinedValue.resourceBundle));
|
|
646
|
-
const [language, setLanguage] = React__default['default'].useState(combinedValue.language);
|
|
647
|
-
const changeResourceBundle = (bundle, lng) => {
|
|
648
|
-
lng && setLanguage(lng);
|
|
649
|
-
setResourceBundle(Object.assign(Object.assign({}, en), bundle));
|
|
650
|
-
};
|
|
651
|
-
const findResource = React.useCallback((resource, count) => getResource(resource, count !== undefined ? { count } : null, resourceBundle, language), [resourceBundle, language]);
|
|
652
|
-
const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
|
|
653
|
-
const [alwaysShowTaskReview, setAlwaysShowTaskReview] = React__default['default'].useState(combinedValue.alwaysShowTaskReview);
|
|
654
|
-
const initialSearchParams = new URLSearchParams(window.location.search);
|
|
655
|
-
const initialSearchQuery = initialSearchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
|
|
656
|
-
const initialStatusFilters = ((_a = initialSearchParams.get(QUICKSTART_STATUS_FILTER_KEY)) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
|
|
657
|
-
const quickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, allQuickStarts);
|
|
658
|
-
const [statusTypes, setStatusTypes] = React__default['default'].useState({
|
|
659
|
-
[exports.QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.COMPLETE]),
|
|
660
|
-
[exports.QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.IN_PROGRESS]),
|
|
661
|
-
[exports.QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.NOT_STARTED]),
|
|
662
|
-
});
|
|
663
|
-
const [statusFilters, setStatusFilters] = React__default['default'].useState(initialStatusFilters);
|
|
664
|
-
const [filterKeyword, setFilterKeyword] = React__default['default'].useState(initialSearchQuery);
|
|
665
|
-
const setFilter = (type, val) => {
|
|
666
|
-
if (type === 'keyword') {
|
|
667
|
-
setFilterKeyword(val);
|
|
668
|
-
}
|
|
669
|
-
else if (type === 'status') {
|
|
670
|
-
setStatusFilters(val);
|
|
671
|
-
}
|
|
672
|
-
};
|
|
673
|
-
React__default['default'].useEffect(() => {
|
|
674
|
-
const updatedQuickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, quickStarts);
|
|
675
|
-
setStatusTypes({
|
|
676
|
-
[exports.QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.COMPLETE]),
|
|
677
|
-
[exports.QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.IN_PROGRESS]),
|
|
678
|
-
[exports.QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.NOT_STARTED]),
|
|
679
|
-
});
|
|
680
|
-
}, [allQuickStartStates, findResource, quickStarts]);
|
|
681
|
-
const updateAllQuickStarts = (qs) => {
|
|
682
|
-
setQuickStarts(qs);
|
|
683
|
-
};
|
|
684
|
-
const setActiveQuickStart = React.useCallback((quickStartId, totalTasks) => {
|
|
685
|
-
setActiveQuickStartID((id) => {
|
|
686
|
-
if (!quickStartId || id === quickStartId) {
|
|
687
|
-
useQueryParams && removeQueryArgument(QUICKSTART_ID_FILTER_KEY);
|
|
688
|
-
return '';
|
|
689
|
-
}
|
|
690
|
-
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
691
|
-
return quickStartId;
|
|
692
|
-
});
|
|
693
|
-
setAllQuickStartStates((qs) => !quickStartId || qs[quickStartId]
|
|
694
|
-
? qs
|
|
695
|
-
: Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks) }));
|
|
696
|
-
}, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
|
|
697
|
-
const startQuickStart = React.useCallback((quickStartId, totalTasks) => {
|
|
698
|
-
setActiveQuickStartID((id) => {
|
|
699
|
-
if (!id || id !== quickStartId) {
|
|
700
|
-
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
701
|
-
return quickStartId;
|
|
702
|
-
}
|
|
703
|
-
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
|
|
704
|
-
return id;
|
|
705
|
-
});
|
|
706
|
-
setAllQuickStartStates((qs) => {
|
|
707
|
-
if (qs.hasOwnProperty(quickStartId)) {
|
|
708
|
-
return Object.assign(Object.assign({}, qs), { [quickStartId]: Object.assign(Object.assign({}, qs[quickStartId]), { status: exports.QuickStartStatus.IN_PROGRESS }) });
|
|
709
|
-
}
|
|
710
|
-
return Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.IN_PROGRESS) });
|
|
711
|
-
});
|
|
712
|
-
}, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
|
|
713
|
-
const restartQuickStart = React.useCallback((quickStartId, totalTasks) => {
|
|
714
|
-
setActiveQuickStartID((id) => {
|
|
715
|
-
if (!id || id !== quickStartId) {
|
|
716
|
-
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
717
|
-
return quickStartId;
|
|
718
|
-
}
|
|
719
|
-
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
|
|
720
|
-
return id;
|
|
721
|
-
});
|
|
722
|
-
setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.NOT_STARTED) })));
|
|
723
|
-
}, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
|
|
724
|
-
// When alwaysShowTaskReview preference is enabled, skip visited step and go directly to review
|
|
725
|
-
const stepAfterInitial = alwaysShowTaskReview
|
|
726
|
-
? exports.QuickStartTaskStatus.REVIEW
|
|
727
|
-
: exports.QuickStartTaskStatus.VISITED;
|
|
728
|
-
const nextStep = React.useCallback((totalTasks) => {
|
|
729
|
-
if (!activeQuickStartID) {
|
|
730
|
-
return;
|
|
731
|
-
}
|
|
732
|
-
setAllQuickStartStates((qs) => {
|
|
733
|
-
const quickStart = qs[activeQuickStartID];
|
|
734
|
-
const status = quickStart === null || quickStart === void 0 ? void 0 : quickStart.status;
|
|
735
|
-
const taskNumber = quickStart === null || quickStart === void 0 ? void 0 : quickStart.taskNumber;
|
|
736
|
-
const taskStatus = quickStart[getTaskStatusKey(taskNumber)];
|
|
737
|
-
let updatedStatus;
|
|
738
|
-
let updatedTaskNumber;
|
|
739
|
-
let updatedTaskStatus;
|
|
740
|
-
if (status === exports.QuickStartStatus.NOT_STARTED) {
|
|
741
|
-
updatedStatus = exports.QuickStartStatus.IN_PROGRESS;
|
|
742
|
-
}
|
|
743
|
-
else if (status === exports.QuickStartStatus.IN_PROGRESS &&
|
|
744
|
-
!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) &&
|
|
745
|
-
taskNumber === totalTasks - 1) {
|
|
746
|
-
updatedStatus = exports.QuickStartStatus.COMPLETE;
|
|
747
|
-
}
|
|
748
|
-
if (taskStatus === exports.QuickStartTaskStatus.VISITED) {
|
|
749
|
-
updatedTaskStatus = exports.QuickStartTaskStatus.REVIEW;
|
|
750
|
-
}
|
|
751
|
-
if (taskNumber < totalTasks && !updatedTaskStatus) {
|
|
752
|
-
updatedTaskNumber = taskNumber + 1;
|
|
753
|
-
}
|
|
754
|
-
const markInitialStepVisitedOrReview = updatedTaskNumber > -1 &&
|
|
755
|
-
quickStart[getTaskStatusKey(updatedTaskNumber)] === exports.QuickStartTaskStatus.INIT
|
|
756
|
-
? stepAfterInitial
|
|
757
|
-
: quickStart[getTaskStatusKey(updatedTaskNumber)];
|
|
758
|
-
const newState = Object.assign(Object.assign({}, qs), { [activeQuickStartID]: Object.assign(Object.assign(Object.assign(Object.assign({}, quickStart), (updatedStatus ? { status: updatedStatus } : {})), (updatedTaskNumber > -1
|
|
759
|
-
? {
|
|
760
|
-
taskNumber: updatedTaskNumber,
|
|
761
|
-
[getTaskStatusKey(updatedTaskNumber)]: markInitialStepVisitedOrReview,
|
|
762
|
-
}
|
|
763
|
-
: {})), (updatedTaskStatus ? { [getTaskStatusKey(taskNumber)]: updatedTaskStatus } : {})) });
|
|
764
|
-
return newState;
|
|
765
|
-
});
|
|
766
|
-
}, [activeQuickStartID, setAllQuickStartStates, stepAfterInitial]);
|
|
767
|
-
const previousStep = React.useCallback(() => {
|
|
768
|
-
setAllQuickStartStates((qs) => {
|
|
769
|
-
const quickStart = qs[activeQuickStartID];
|
|
770
|
-
const taskNumber = quickStart === null || quickStart === void 0 ? void 0 : quickStart.taskNumber;
|
|
771
|
-
if (taskNumber < 0) {
|
|
772
|
-
return qs;
|
|
773
|
-
}
|
|
774
|
-
return Object.assign(Object.assign({}, qs), { [activeQuickStartID]: Object.assign(Object.assign({}, quickStart), { taskNumber: taskNumber - 1 }) });
|
|
775
|
-
});
|
|
776
|
-
}, [activeQuickStartID, setAllQuickStartStates]);
|
|
777
|
-
const setQuickStartTaskNumber = React.useCallback((quickStartId, taskNumber) => {
|
|
778
|
-
setAllQuickStartStates((qs) => {
|
|
779
|
-
const quickStart = qs[quickStartId];
|
|
780
|
-
const status = quickStart === null || quickStart === void 0 ? void 0 : quickStart.status;
|
|
781
|
-
let updatedStatus;
|
|
782
|
-
if (taskNumber > -1 && status === exports.QuickStartStatus.NOT_STARTED) {
|
|
783
|
-
updatedStatus = exports.QuickStartStatus.IN_PROGRESS;
|
|
784
|
-
}
|
|
785
|
-
let updatedTaskStatus = {};
|
|
786
|
-
for (let taskIndex = 0; taskIndex <= taskNumber; taskIndex++) {
|
|
787
|
-
const taskStatus = quickStart[getTaskStatusKey(taskIndex)];
|
|
788
|
-
const newTaskStatus = taskStatus === exports.QuickStartTaskStatus.INIT ? stepAfterInitial : undefined;
|
|
789
|
-
if (newTaskStatus) {
|
|
790
|
-
updatedTaskStatus = Object.assign(Object.assign({}, updatedTaskStatus), { [getTaskStatusKey(taskIndex)]: newTaskStatus });
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
const updatedQuickStart = Object.assign(Object.assign(Object.assign(Object.assign({}, quickStart), (updatedStatus ? { status: updatedStatus } : {})), { taskNumber }), updatedTaskStatus);
|
|
794
|
-
return Object.assign(Object.assign({}, qs), { [quickStartId]: updatedQuickStart });
|
|
795
|
-
});
|
|
796
|
-
}, [setAllQuickStartStates, stepAfterInitial]);
|
|
797
|
-
const setQuickStartTaskStatus = React.useCallback((taskStatus) => {
|
|
798
|
-
const quickStart = allQuickStartStates[activeQuickStartID];
|
|
799
|
-
const { taskNumber } = quickStart;
|
|
800
|
-
const updatedQuickStart = Object.assign(Object.assign({}, quickStart), { [getTaskStatusKey(taskNumber)]: taskStatus });
|
|
801
|
-
setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [activeQuickStartID]: updatedQuickStart })));
|
|
802
|
-
}, [allQuickStartStates, activeQuickStartID, setAllQuickStartStates]);
|
|
803
|
-
const activeQuickStartState = (_b = allQuickStartStates === null || allQuickStartStates === void 0 ? void 0 : allQuickStartStates[activeQuickStartID]) !== null && _b !== void 0 ? _b : {};
|
|
804
|
-
const getQuickStartForId = React.useCallback((id) => allQuickStartStates[id], [
|
|
805
|
-
allQuickStartStates,
|
|
806
|
-
]);
|
|
807
|
-
return {
|
|
808
|
-
allQuickStarts: quickStarts,
|
|
809
|
-
setAllQuickStarts: updateAllQuickStarts,
|
|
810
|
-
activeQuickStartID,
|
|
811
|
-
setActiveQuickStartID,
|
|
812
|
-
allQuickStartStates,
|
|
813
|
-
setAllQuickStartStates,
|
|
814
|
-
activeQuickStartState,
|
|
815
|
-
setActiveQuickStart: value.setActiveQuickStart || setActiveQuickStart,
|
|
816
|
-
startQuickStart: value.startQuickStart || startQuickStart,
|
|
817
|
-
restartQuickStart: value.restartQuickStart || restartQuickStart,
|
|
818
|
-
nextStep: value.nextStep || nextStep,
|
|
819
|
-
previousStep: value.previousStep || previousStep,
|
|
820
|
-
setQuickStartTaskNumber,
|
|
821
|
-
setQuickStartTaskStatus,
|
|
822
|
-
getQuickStartForId,
|
|
823
|
-
footer,
|
|
824
|
-
useLegacyHeaderColors,
|
|
825
|
-
useQueryParams,
|
|
826
|
-
markdown,
|
|
827
|
-
resourceBundle,
|
|
828
|
-
getResource: findResource,
|
|
829
|
-
setResourceBundle: changeResourceBundle,
|
|
830
|
-
language,
|
|
831
|
-
setLanguage,
|
|
832
|
-
// revisit if this should be in public context API
|
|
833
|
-
filter: {
|
|
834
|
-
keyword: filterKeyword,
|
|
835
|
-
status: {
|
|
836
|
-
statusTypes,
|
|
837
|
-
statusFilters,
|
|
838
|
-
},
|
|
839
|
-
},
|
|
840
|
-
setFilter,
|
|
841
|
-
loading,
|
|
842
|
-
setLoading,
|
|
843
|
-
alwaysShowTaskReview,
|
|
844
|
-
setAlwaysShowTaskReview,
|
|
845
|
-
};
|
|
846
|
-
};
|
|
592
|
+
const pluralResolver = new PluralResolver({ simplifyPluralSuffix: true });
|
|
593
|
+
const getDefaultQuickStartState = (totalTasks, initialStatus) => {
|
|
594
|
+
const defaultQuickStartState = {
|
|
595
|
+
status: initialStatus || exports.QuickStartStatus.NOT_STARTED,
|
|
596
|
+
taskNumber: -1,
|
|
597
|
+
};
|
|
598
|
+
if (totalTasks) {
|
|
599
|
+
for (let i = 0; i < totalTasks; i++) {
|
|
600
|
+
defaultQuickStartState[getTaskStatusKey(i)] = exports.QuickStartTaskStatus.INIT;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return defaultQuickStartState;
|
|
604
|
+
};
|
|
605
|
+
const QuickStartContextDefaults = {
|
|
606
|
+
allQuickStarts: [],
|
|
607
|
+
activeQuickStartID: '',
|
|
608
|
+
allQuickStartStates: {},
|
|
609
|
+
activeQuickStartState: {},
|
|
610
|
+
setAllQuickStarts: () => { },
|
|
611
|
+
resourceBundle: en,
|
|
612
|
+
getResource: (resource) => resource,
|
|
613
|
+
language: 'en',
|
|
614
|
+
useQueryParams: true,
|
|
615
|
+
filter: {
|
|
616
|
+
keyword: '',
|
|
617
|
+
status: {
|
|
618
|
+
statusTypes: {},
|
|
619
|
+
statusFilters: [],
|
|
620
|
+
},
|
|
621
|
+
},
|
|
622
|
+
setFilter: () => { },
|
|
623
|
+
footer: null,
|
|
624
|
+
useLegacyHeaderColors: false,
|
|
625
|
+
markdown: null,
|
|
626
|
+
loading: false,
|
|
627
|
+
alwaysShowTaskReview: true,
|
|
628
|
+
};
|
|
629
|
+
const QuickStartContext = React.createContext(QuickStartContextDefaults);
|
|
630
|
+
const getResource = (resource, options, resourceBundle, lng) => {
|
|
631
|
+
if (options && !isNaN(options.count)) {
|
|
632
|
+
const suffix = pluralResolver.getSuffix(lng, options.count);
|
|
633
|
+
if (suffix && resourceBundle[`${resource}_${suffix}`]) {
|
|
634
|
+
// needs plural
|
|
635
|
+
return resourceBundle[`${resource}_${suffix}`];
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
return (resourceBundle && resourceBundle[resource]) || resource;
|
|
639
|
+
};
|
|
640
|
+
const useValuesForQuickStartContext = (value = {}) => {
|
|
641
|
+
var _a, _b;
|
|
642
|
+
const combinedValue = Object.assign(Object.assign({}, QuickStartContextDefaults), value);
|
|
643
|
+
const { activeQuickStartID, setActiveQuickStartID, setAllQuickStartStates, useQueryParams, allQuickStartStates, allQuickStarts = [], footer, useLegacyHeaderColors, markdown, } = combinedValue;
|
|
644
|
+
const [quickStarts, setQuickStarts] = React__default['default'].useState(combinedValue.allQuickStarts || []);
|
|
645
|
+
const [resourceBundle, setResourceBundle] = React__default['default'].useState(Object.assign(Object.assign({}, en), combinedValue.resourceBundle));
|
|
646
|
+
const [language, setLanguage] = React__default['default'].useState(combinedValue.language);
|
|
647
|
+
const changeResourceBundle = (bundle, lng) => {
|
|
648
|
+
lng && setLanguage(lng);
|
|
649
|
+
setResourceBundle(Object.assign(Object.assign({}, en), bundle));
|
|
650
|
+
};
|
|
651
|
+
const findResource = React.useCallback((resource, count) => getResource(resource, count !== undefined ? { count } : null, resourceBundle, language), [resourceBundle, language]);
|
|
652
|
+
const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
|
|
653
|
+
const [alwaysShowTaskReview, setAlwaysShowTaskReview] = React__default['default'].useState(combinedValue.alwaysShowTaskReview);
|
|
654
|
+
const initialSearchParams = new URLSearchParams(window.location.search);
|
|
655
|
+
const initialSearchQuery = initialSearchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
|
|
656
|
+
const initialStatusFilters = ((_a = initialSearchParams.get(QUICKSTART_STATUS_FILTER_KEY)) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
|
|
657
|
+
const quickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, allQuickStarts);
|
|
658
|
+
const [statusTypes, setStatusTypes] = React__default['default'].useState({
|
|
659
|
+
[exports.QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.COMPLETE]),
|
|
660
|
+
[exports.QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.IN_PROGRESS]),
|
|
661
|
+
[exports.QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace('{{statusCount, number}}', quickStartStatusCount[exports.QuickStartStatus.NOT_STARTED]),
|
|
662
|
+
});
|
|
663
|
+
const [statusFilters, setStatusFilters] = React__default['default'].useState(initialStatusFilters);
|
|
664
|
+
const [filterKeyword, setFilterKeyword] = React__default['default'].useState(initialSearchQuery);
|
|
665
|
+
const setFilter = (type, val) => {
|
|
666
|
+
if (type === 'keyword') {
|
|
667
|
+
setFilterKeyword(val);
|
|
668
|
+
}
|
|
669
|
+
else if (type === 'status') {
|
|
670
|
+
setStatusFilters(val);
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
React__default['default'].useEffect(() => {
|
|
674
|
+
const updatedQuickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, quickStarts);
|
|
675
|
+
setStatusTypes({
|
|
676
|
+
[exports.QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.COMPLETE]),
|
|
677
|
+
[exports.QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.IN_PROGRESS]),
|
|
678
|
+
[exports.QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace('{{statusCount, number}}', updatedQuickStartStatusCount[exports.QuickStartStatus.NOT_STARTED]),
|
|
679
|
+
});
|
|
680
|
+
}, [allQuickStartStates, findResource, quickStarts]);
|
|
681
|
+
const updateAllQuickStarts = (qs) => {
|
|
682
|
+
setQuickStarts(qs);
|
|
683
|
+
};
|
|
684
|
+
const setActiveQuickStart = React.useCallback((quickStartId, totalTasks) => {
|
|
685
|
+
setActiveQuickStartID((id) => {
|
|
686
|
+
if (!quickStartId || id === quickStartId) {
|
|
687
|
+
useQueryParams && removeQueryArgument(QUICKSTART_ID_FILTER_KEY);
|
|
688
|
+
return '';
|
|
689
|
+
}
|
|
690
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
691
|
+
return quickStartId;
|
|
692
|
+
});
|
|
693
|
+
setAllQuickStartStates((qs) => !quickStartId || qs[quickStartId]
|
|
694
|
+
? qs
|
|
695
|
+
: Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks) }));
|
|
696
|
+
}, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
|
|
697
|
+
const startQuickStart = React.useCallback((quickStartId, totalTasks) => {
|
|
698
|
+
setActiveQuickStartID((id) => {
|
|
699
|
+
if (!id || id !== quickStartId) {
|
|
700
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
701
|
+
return quickStartId;
|
|
702
|
+
}
|
|
703
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
|
|
704
|
+
return id;
|
|
705
|
+
});
|
|
706
|
+
setAllQuickStartStates((qs) => {
|
|
707
|
+
if (qs.hasOwnProperty(quickStartId)) {
|
|
708
|
+
return Object.assign(Object.assign({}, qs), { [quickStartId]: Object.assign(Object.assign({}, qs[quickStartId]), { status: exports.QuickStartStatus.IN_PROGRESS }) });
|
|
709
|
+
}
|
|
710
|
+
return Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.IN_PROGRESS) });
|
|
711
|
+
});
|
|
712
|
+
}, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
|
|
713
|
+
const restartQuickStart = React.useCallback((quickStartId, totalTasks) => {
|
|
714
|
+
setActiveQuickStartID((id) => {
|
|
715
|
+
if (!id || id !== quickStartId) {
|
|
716
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
717
|
+
return quickStartId;
|
|
718
|
+
}
|
|
719
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
|
|
720
|
+
return id;
|
|
721
|
+
});
|
|
722
|
+
setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.NOT_STARTED) })));
|
|
723
|
+
}, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
|
|
724
|
+
// When alwaysShowTaskReview preference is enabled, skip visited step and go directly to review
|
|
725
|
+
const stepAfterInitial = alwaysShowTaskReview
|
|
726
|
+
? exports.QuickStartTaskStatus.REVIEW
|
|
727
|
+
: exports.QuickStartTaskStatus.VISITED;
|
|
728
|
+
const nextStep = React.useCallback((totalTasks) => {
|
|
729
|
+
if (!activeQuickStartID) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
setAllQuickStartStates((qs) => {
|
|
733
|
+
const quickStart = qs[activeQuickStartID];
|
|
734
|
+
const status = quickStart === null || quickStart === void 0 ? void 0 : quickStart.status;
|
|
735
|
+
const taskNumber = quickStart === null || quickStart === void 0 ? void 0 : quickStart.taskNumber;
|
|
736
|
+
const taskStatus = quickStart[getTaskStatusKey(taskNumber)];
|
|
737
|
+
let updatedStatus;
|
|
738
|
+
let updatedTaskNumber;
|
|
739
|
+
let updatedTaskStatus;
|
|
740
|
+
if (status === exports.QuickStartStatus.NOT_STARTED) {
|
|
741
|
+
updatedStatus = exports.QuickStartStatus.IN_PROGRESS;
|
|
742
|
+
}
|
|
743
|
+
else if (status === exports.QuickStartStatus.IN_PROGRESS &&
|
|
744
|
+
!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) &&
|
|
745
|
+
taskNumber === totalTasks - 1) {
|
|
746
|
+
updatedStatus = exports.QuickStartStatus.COMPLETE;
|
|
747
|
+
}
|
|
748
|
+
if (taskStatus === exports.QuickStartTaskStatus.VISITED) {
|
|
749
|
+
updatedTaskStatus = exports.QuickStartTaskStatus.REVIEW;
|
|
750
|
+
}
|
|
751
|
+
if (taskNumber < totalTasks && !updatedTaskStatus) {
|
|
752
|
+
updatedTaskNumber = taskNumber + 1;
|
|
753
|
+
}
|
|
754
|
+
const markInitialStepVisitedOrReview = updatedTaskNumber > -1 &&
|
|
755
|
+
quickStart[getTaskStatusKey(updatedTaskNumber)] === exports.QuickStartTaskStatus.INIT
|
|
756
|
+
? stepAfterInitial
|
|
757
|
+
: quickStart[getTaskStatusKey(updatedTaskNumber)];
|
|
758
|
+
const newState = Object.assign(Object.assign({}, qs), { [activeQuickStartID]: Object.assign(Object.assign(Object.assign(Object.assign({}, quickStart), (updatedStatus ? { status: updatedStatus } : {})), (updatedTaskNumber > -1
|
|
759
|
+
? {
|
|
760
|
+
taskNumber: updatedTaskNumber,
|
|
761
|
+
[getTaskStatusKey(updatedTaskNumber)]: markInitialStepVisitedOrReview,
|
|
762
|
+
}
|
|
763
|
+
: {})), (updatedTaskStatus ? { [getTaskStatusKey(taskNumber)]: updatedTaskStatus } : {})) });
|
|
764
|
+
return newState;
|
|
765
|
+
});
|
|
766
|
+
}, [activeQuickStartID, setAllQuickStartStates, stepAfterInitial]);
|
|
767
|
+
const previousStep = React.useCallback(() => {
|
|
768
|
+
setAllQuickStartStates((qs) => {
|
|
769
|
+
const quickStart = qs[activeQuickStartID];
|
|
770
|
+
const taskNumber = quickStart === null || quickStart === void 0 ? void 0 : quickStart.taskNumber;
|
|
771
|
+
if (taskNumber < 0) {
|
|
772
|
+
return qs;
|
|
773
|
+
}
|
|
774
|
+
return Object.assign(Object.assign({}, qs), { [activeQuickStartID]: Object.assign(Object.assign({}, quickStart), { taskNumber: taskNumber - 1 }) });
|
|
775
|
+
});
|
|
776
|
+
}, [activeQuickStartID, setAllQuickStartStates]);
|
|
777
|
+
const setQuickStartTaskNumber = React.useCallback((quickStartId, taskNumber) => {
|
|
778
|
+
setAllQuickStartStates((qs) => {
|
|
779
|
+
const quickStart = qs[quickStartId];
|
|
780
|
+
const status = quickStart === null || quickStart === void 0 ? void 0 : quickStart.status;
|
|
781
|
+
let updatedStatus;
|
|
782
|
+
if (taskNumber > -1 && status === exports.QuickStartStatus.NOT_STARTED) {
|
|
783
|
+
updatedStatus = exports.QuickStartStatus.IN_PROGRESS;
|
|
784
|
+
}
|
|
785
|
+
let updatedTaskStatus = {};
|
|
786
|
+
for (let taskIndex = 0; taskIndex <= taskNumber; taskIndex++) {
|
|
787
|
+
const taskStatus = quickStart[getTaskStatusKey(taskIndex)];
|
|
788
|
+
const newTaskStatus = taskStatus === exports.QuickStartTaskStatus.INIT ? stepAfterInitial : undefined;
|
|
789
|
+
if (newTaskStatus) {
|
|
790
|
+
updatedTaskStatus = Object.assign(Object.assign({}, updatedTaskStatus), { [getTaskStatusKey(taskIndex)]: newTaskStatus });
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
const updatedQuickStart = Object.assign(Object.assign(Object.assign(Object.assign({}, quickStart), (updatedStatus ? { status: updatedStatus } : {})), { taskNumber }), updatedTaskStatus);
|
|
794
|
+
return Object.assign(Object.assign({}, qs), { [quickStartId]: updatedQuickStart });
|
|
795
|
+
});
|
|
796
|
+
}, [setAllQuickStartStates, stepAfterInitial]);
|
|
797
|
+
const setQuickStartTaskStatus = React.useCallback((taskStatus) => {
|
|
798
|
+
const quickStart = allQuickStartStates[activeQuickStartID];
|
|
799
|
+
const { taskNumber } = quickStart;
|
|
800
|
+
const updatedQuickStart = Object.assign(Object.assign({}, quickStart), { [getTaskStatusKey(taskNumber)]: taskStatus });
|
|
801
|
+
setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [activeQuickStartID]: updatedQuickStart })));
|
|
802
|
+
}, [allQuickStartStates, activeQuickStartID, setAllQuickStartStates]);
|
|
803
|
+
const activeQuickStartState = (_b = allQuickStartStates === null || allQuickStartStates === void 0 ? void 0 : allQuickStartStates[activeQuickStartID]) !== null && _b !== void 0 ? _b : {};
|
|
804
|
+
const getQuickStartForId = React.useCallback((id) => allQuickStartStates[id], [
|
|
805
|
+
allQuickStartStates,
|
|
806
|
+
]);
|
|
807
|
+
return {
|
|
808
|
+
allQuickStarts: quickStarts,
|
|
809
|
+
setAllQuickStarts: updateAllQuickStarts,
|
|
810
|
+
activeQuickStartID,
|
|
811
|
+
setActiveQuickStartID,
|
|
812
|
+
allQuickStartStates,
|
|
813
|
+
setAllQuickStartStates,
|
|
814
|
+
activeQuickStartState,
|
|
815
|
+
setActiveQuickStart: value.setActiveQuickStart || setActiveQuickStart,
|
|
816
|
+
startQuickStart: value.startQuickStart || startQuickStart,
|
|
817
|
+
restartQuickStart: value.restartQuickStart || restartQuickStart,
|
|
818
|
+
nextStep: value.nextStep || nextStep,
|
|
819
|
+
previousStep: value.previousStep || previousStep,
|
|
820
|
+
setQuickStartTaskNumber,
|
|
821
|
+
setQuickStartTaskStatus,
|
|
822
|
+
getQuickStartForId,
|
|
823
|
+
footer,
|
|
824
|
+
useLegacyHeaderColors,
|
|
825
|
+
useQueryParams,
|
|
826
|
+
markdown,
|
|
827
|
+
resourceBundle,
|
|
828
|
+
getResource: findResource,
|
|
829
|
+
setResourceBundle: changeResourceBundle,
|
|
830
|
+
language,
|
|
831
|
+
setLanguage,
|
|
832
|
+
// revisit if this should be in public context API
|
|
833
|
+
filter: {
|
|
834
|
+
keyword: filterKeyword,
|
|
835
|
+
status: {
|
|
836
|
+
statusTypes,
|
|
837
|
+
statusFilters,
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
setFilter,
|
|
841
|
+
loading,
|
|
842
|
+
setLoading,
|
|
843
|
+
alwaysShowTaskReview,
|
|
844
|
+
setAlwaysShowTaskReview,
|
|
845
|
+
};
|
|
846
|
+
};
|
|
847
847
|
const QuickStartContextProvider = ({ children, value }) => (React__default['default'].createElement(QuickStartContext.Provider, { value: useValuesForQuickStartContext(value) }, children));
|
|
848
848
|
|
|
849
|
-
const Box = ({ children, className }) => (React__namespace.createElement("div", { className: reactStyles.css('pfext-status-box', className) }, children));
|
|
850
|
-
const Loading = ({ className }) => (React__namespace.createElement("div", { className: reactStyles.css('pfext-m-loader', className) },
|
|
851
|
-
React__namespace.createElement("div", { className: "pfext-m-loader-dot__one" }),
|
|
852
|
-
React__namespace.createElement("div", { className: "pfext-m-loader-dot__two" }),
|
|
853
|
-
React__namespace.createElement("div", { className: "pfext-m-loader-dot__three" })));
|
|
854
|
-
Loading.displayName = 'Loading';
|
|
855
|
-
const LoadingBox = ({ className, message }) => (React__namespace.createElement(Box, { className: reactStyles.css('pfext-status-box--loading', className) },
|
|
856
|
-
React__namespace.createElement(Loading, null),
|
|
857
|
-
message && React__namespace.createElement("div", { className: "pfext-status-box__loading-message" }, message)));
|
|
858
|
-
LoadingBox.displayName = 'LoadingBox';
|
|
859
|
-
const EmptyBox = ({ label }) => {
|
|
860
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
861
|
-
return (React__namespace.createElement(Box, null,
|
|
862
|
-
React__namespace.createElement("div", { "data-test": "empty-message", className: "text-center" }, label
|
|
863
|
-
? getResource('No {{label}} found').replace('{{label}}', label)
|
|
864
|
-
: getResource('Not found'))));
|
|
865
|
-
};
|
|
849
|
+
const Box = ({ children, className }) => (React__namespace.createElement("div", { className: reactStyles.css('pfext-status-box', className) }, children));
|
|
850
|
+
const Loading = ({ className }) => (React__namespace.createElement("div", { className: reactStyles.css('pfext-m-loader', className) },
|
|
851
|
+
React__namespace.createElement("div", { className: "pfext-m-loader-dot__one" }),
|
|
852
|
+
React__namespace.createElement("div", { className: "pfext-m-loader-dot__two" }),
|
|
853
|
+
React__namespace.createElement("div", { className: "pfext-m-loader-dot__three" })));
|
|
854
|
+
Loading.displayName = 'Loading';
|
|
855
|
+
const LoadingBox = ({ className, message }) => (React__namespace.createElement(Box, { className: reactStyles.css('pfext-status-box--loading', className) },
|
|
856
|
+
React__namespace.createElement(Loading, null),
|
|
857
|
+
message && React__namespace.createElement("div", { className: "pfext-status-box__loading-message" }, message)));
|
|
858
|
+
LoadingBox.displayName = 'LoadingBox';
|
|
859
|
+
const EmptyBox = ({ label }) => {
|
|
860
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
861
|
+
return (React__namespace.createElement(Box, null,
|
|
862
|
+
React__namespace.createElement("div", { "data-test": "empty-message", className: "text-center" }, label
|
|
863
|
+
? getResource('No {{label}} found').replace('{{label}}', label)
|
|
864
|
+
: getResource('Not found'))));
|
|
865
|
+
};
|
|
866
866
|
EmptyBox.displayName = 'EmptyBox';
|
|
867
867
|
|
|
868
|
-
const MEMO = {};
|
|
869
|
-
const CamelCaseWrap = ({ value, dataTest }) => {
|
|
870
|
-
if (!value) {
|
|
871
|
-
return '-';
|
|
872
|
-
}
|
|
873
|
-
if (MEMO[value]) {
|
|
874
|
-
return MEMO[value];
|
|
875
|
-
}
|
|
876
|
-
// Add word break points before capital letters (but keep consecutive capital letters together).
|
|
877
|
-
const words = value.match(/[A-Z]+[^A-Z]*|[^A-Z]+/g);
|
|
878
|
-
const rendered = (React__namespace.createElement("span", { "data-test": dataTest }, words.map((word, i) => (React__namespace.createElement(React__namespace.Fragment, { key: i },
|
|
879
|
-
word,
|
|
880
|
-
i !== words.length - 1 && React__namespace.createElement("wbr", null))))));
|
|
881
|
-
MEMO[value] = rendered;
|
|
882
|
-
return rendered;
|
|
868
|
+
const MEMO = {};
|
|
869
|
+
const CamelCaseWrap = ({ value, dataTest }) => {
|
|
870
|
+
if (!value) {
|
|
871
|
+
return '-';
|
|
872
|
+
}
|
|
873
|
+
if (MEMO[value]) {
|
|
874
|
+
return MEMO[value];
|
|
875
|
+
}
|
|
876
|
+
// Add word break points before capital letters (but keep consecutive capital letters together).
|
|
877
|
+
const words = value.match(/[A-Z]+[^A-Z]*|[^A-Z]+/g);
|
|
878
|
+
const rendered = (React__namespace.createElement("span", { "data-test": dataTest }, words.map((word, i) => (React__namespace.createElement(React__namespace.Fragment, { key: i },
|
|
879
|
+
word,
|
|
880
|
+
i !== words.length - 1 && React__namespace.createElement("wbr", null))))));
|
|
881
|
+
MEMO[value] = rendered;
|
|
882
|
+
return rendered;
|
|
883
883
|
};
|
|
884
884
|
|
|
885
885
|
class CatalogTile extends React__namespace.Component {
|
|
@@ -942,335 +942,335 @@ CatalogTile.defaultProps = {
|
|
|
942
942
|
children: null
|
|
943
943
|
};
|
|
944
944
|
|
|
945
|
-
const Modal = (_a) => {
|
|
946
|
-
var { isFullScreen = false, className } = _a, props = tslib.__rest(_a, ["isFullScreen", "className"]);
|
|
947
|
-
return (React__namespace.createElement(reactCore.Modal, Object.assign({}, props, { className: reactStyles.css('pfext-modal', className), appendTo: () => (isFullScreen ? document.body : document.querySelector('#modal-container')) })));
|
|
948
|
-
};
|
|
949
|
-
|
|
950
|
-
const getContainer = (container) => typeof container === 'function' ? container() : container;
|
|
951
|
-
const Portal = ({ children, container }) => {
|
|
952
|
-
const [containerNode, setContainerNode] = React__namespace.useState();
|
|
953
|
-
reactCore.useIsomorphicLayoutEffect(() => {
|
|
954
|
-
setContainerNode(getContainer(container) || document.body);
|
|
955
|
-
}, [container]);
|
|
956
|
-
return containerNode ? ReactDOM__namespace.createPortal(children, containerNode) : null;
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
const SimplePopper = ({ children }) => {
|
|
960
|
-
const openProp = true;
|
|
961
|
-
const nodeRef = React__namespace.useRef();
|
|
962
|
-
const popperRef = React__namespace.useRef(null);
|
|
963
|
-
const [isOpen, setOpenState] = React__namespace.useState(openProp);
|
|
964
|
-
const setOpen = React__namespace.useCallback((newOpen) => {
|
|
965
|
-
setOpenState(newOpen);
|
|
966
|
-
}, []);
|
|
967
|
-
React__namespace.useEffect(() => {
|
|
968
|
-
setOpen(openProp);
|
|
969
|
-
}, [openProp, setOpen]);
|
|
970
|
-
const onKeyDown = React__namespace.useCallback((e) => {
|
|
971
|
-
if (e.keyCode === 27) {
|
|
972
|
-
setOpen(false);
|
|
973
|
-
}
|
|
974
|
-
}, [setOpen]);
|
|
975
|
-
const onClickOutside = React__namespace.useCallback((e) => {
|
|
976
|
-
if (!nodeRef.current || (e.target instanceof Node && !nodeRef.current.contains(e.target))) {
|
|
977
|
-
setOpen(false);
|
|
978
|
-
}
|
|
979
|
-
}, [setOpen]);
|
|
980
|
-
const destroy = React__namespace.useCallback(() => {
|
|
981
|
-
if (popperRef.current) {
|
|
982
|
-
popperRef.current.destroy();
|
|
983
|
-
document.removeEventListener('keydown', onKeyDown, true);
|
|
984
|
-
document.removeEventListener('mousedown', onClickOutside, true);
|
|
985
|
-
document.removeEventListener('touchstart', onClickOutside, true);
|
|
986
|
-
}
|
|
987
|
-
}, [onClickOutside, onKeyDown]);
|
|
988
|
-
const initialize = React__namespace.useCallback(() => {
|
|
989
|
-
if (!nodeRef.current || !isOpen) {
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
992
|
-
destroy();
|
|
993
|
-
}, [isOpen, destroy]);
|
|
994
|
-
const nodeRefCallback = React__namespace.useCallback((node) => {
|
|
995
|
-
nodeRef.current = node;
|
|
996
|
-
initialize();
|
|
997
|
-
}, [initialize]);
|
|
998
|
-
React__namespace.useEffect(() => {
|
|
999
|
-
initialize();
|
|
1000
|
-
}, [initialize]);
|
|
1001
|
-
React__namespace.useEffect(() => () => {
|
|
1002
|
-
destroy();
|
|
1003
|
-
}, [destroy]);
|
|
1004
|
-
React__namespace.useEffect(() => {
|
|
1005
|
-
if (!isOpen) {
|
|
1006
|
-
destroy();
|
|
1007
|
-
}
|
|
1008
|
-
}, [destroy, isOpen]);
|
|
1009
|
-
return isOpen ? (React__namespace.createElement(Portal, null,
|
|
1010
|
-
React__namespace.createElement("div", { ref: nodeRefCallback, style: { zIndex: 9999, position: 'absolute', top: 0, left: 0 }, className: "pfext-quick-start__base" }, children))) : null;
|
|
1011
|
-
};
|
|
1012
|
-
|
|
1013
|
-
const isInViewport = (elementToCheck) => {
|
|
1014
|
-
const rect = elementToCheck.getBoundingClientRect();
|
|
1015
|
-
return (rect.top >= 0 &&
|
|
1016
|
-
rect.left >= 0 &&
|
|
1017
|
-
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
|
|
1018
|
-
rect.right <= (window.innerWidth || document.documentElement.clientWidth));
|
|
1019
|
-
};
|
|
1020
|
-
const InteractiveSpotlight = ({ element }) => {
|
|
1021
|
-
const { top, bottom, left, right, height, width } = element.getBoundingClientRect();
|
|
1022
|
-
const style = {
|
|
1023
|
-
height,
|
|
1024
|
-
width,
|
|
1025
|
-
top,
|
|
1026
|
-
left,
|
|
1027
|
-
bottom,
|
|
1028
|
-
right,
|
|
1029
|
-
};
|
|
1030
|
-
const [clicked, setClicked] = React__namespace.useState(false);
|
|
1031
|
-
React__namespace.useEffect(() => {
|
|
1032
|
-
if (!clicked) {
|
|
1033
|
-
if (!isInViewport(element)) {
|
|
1034
|
-
element.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' });
|
|
1035
|
-
}
|
|
1036
|
-
const handleClick = () => setClicked(true);
|
|
1037
|
-
document.addEventListener('click', handleClick);
|
|
1038
|
-
return () => {
|
|
1039
|
-
document.removeEventListener('click', handleClick);
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
return () => { };
|
|
1043
|
-
}, [element, clicked]);
|
|
1044
|
-
if (clicked) {
|
|
1045
|
-
return null;
|
|
1046
|
-
}
|
|
1047
|
-
return (React__namespace.createElement(Portal, null,
|
|
1048
|
-
React__namespace.createElement(SimplePopper, null,
|
|
1049
|
-
React__namespace.createElement("div", { className: "pfext-spotlight pfext-spotlight__element-highlight-animate", style: style }))));
|
|
1050
|
-
};
|
|
1051
|
-
|
|
1052
|
-
var ScrollDirection;
|
|
1053
|
-
(function (ScrollDirection) {
|
|
1054
|
-
ScrollDirection["scrollingUp"] = "scrolling-up";
|
|
1055
|
-
ScrollDirection["scrollingDown"] = "scrolling-down";
|
|
1056
|
-
ScrollDirection["scrolledToBottom"] = "scrolled-to-bottom";
|
|
1057
|
-
ScrollDirection["scrolledToTop"] = "scrolled-to-top";
|
|
945
|
+
const Modal = (_a) => {
|
|
946
|
+
var { isFullScreen = false, className } = _a, props = tslib.__rest(_a, ["isFullScreen", "className"]);
|
|
947
|
+
return (React__namespace.createElement(reactCore.Modal, Object.assign({}, props, { className: reactStyles.css('pfext-modal', className), appendTo: () => (isFullScreen ? document.body : document.querySelector('#modal-container')) })));
|
|
948
|
+
};
|
|
949
|
+
|
|
950
|
+
const getContainer = (container) => typeof container === 'function' ? container() : container;
|
|
951
|
+
const Portal = ({ children, container }) => {
|
|
952
|
+
const [containerNode, setContainerNode] = React__namespace.useState();
|
|
953
|
+
reactCore.useIsomorphicLayoutEffect(() => {
|
|
954
|
+
setContainerNode(getContainer(container) || document.body);
|
|
955
|
+
}, [container]);
|
|
956
|
+
return containerNode ? ReactDOM__namespace.createPortal(children, containerNode) : null;
|
|
957
|
+
};
|
|
958
|
+
|
|
959
|
+
const SimplePopper = ({ children }) => {
|
|
960
|
+
const openProp = true;
|
|
961
|
+
const nodeRef = React__namespace.useRef();
|
|
962
|
+
const popperRef = React__namespace.useRef(null);
|
|
963
|
+
const [isOpen, setOpenState] = React__namespace.useState(openProp);
|
|
964
|
+
const setOpen = React__namespace.useCallback((newOpen) => {
|
|
965
|
+
setOpenState(newOpen);
|
|
966
|
+
}, []);
|
|
967
|
+
React__namespace.useEffect(() => {
|
|
968
|
+
setOpen(openProp);
|
|
969
|
+
}, [openProp, setOpen]);
|
|
970
|
+
const onKeyDown = React__namespace.useCallback((e) => {
|
|
971
|
+
if (e.keyCode === 27) {
|
|
972
|
+
setOpen(false);
|
|
973
|
+
}
|
|
974
|
+
}, [setOpen]);
|
|
975
|
+
const onClickOutside = React__namespace.useCallback((e) => {
|
|
976
|
+
if (!nodeRef.current || (e.target instanceof Node && !nodeRef.current.contains(e.target))) {
|
|
977
|
+
setOpen(false);
|
|
978
|
+
}
|
|
979
|
+
}, [setOpen]);
|
|
980
|
+
const destroy = React__namespace.useCallback(() => {
|
|
981
|
+
if (popperRef.current) {
|
|
982
|
+
popperRef.current.destroy();
|
|
983
|
+
document.removeEventListener('keydown', onKeyDown, true);
|
|
984
|
+
document.removeEventListener('mousedown', onClickOutside, true);
|
|
985
|
+
document.removeEventListener('touchstart', onClickOutside, true);
|
|
986
|
+
}
|
|
987
|
+
}, [onClickOutside, onKeyDown]);
|
|
988
|
+
const initialize = React__namespace.useCallback(() => {
|
|
989
|
+
if (!nodeRef.current || !isOpen) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
destroy();
|
|
993
|
+
}, [isOpen, destroy]);
|
|
994
|
+
const nodeRefCallback = React__namespace.useCallback((node) => {
|
|
995
|
+
nodeRef.current = node;
|
|
996
|
+
initialize();
|
|
997
|
+
}, [initialize]);
|
|
998
|
+
React__namespace.useEffect(() => {
|
|
999
|
+
initialize();
|
|
1000
|
+
}, [initialize]);
|
|
1001
|
+
React__namespace.useEffect(() => () => {
|
|
1002
|
+
destroy();
|
|
1003
|
+
}, [destroy]);
|
|
1004
|
+
React__namespace.useEffect(() => {
|
|
1005
|
+
if (!isOpen) {
|
|
1006
|
+
destroy();
|
|
1007
|
+
}
|
|
1008
|
+
}, [destroy, isOpen]);
|
|
1009
|
+
return isOpen ? (React__namespace.createElement(Portal, null,
|
|
1010
|
+
React__namespace.createElement("div", { ref: nodeRefCallback, style: { zIndex: 9999, position: 'absolute', top: 0, left: 0 }, className: "pfext-quick-start__base" }, children))) : null;
|
|
1011
|
+
};
|
|
1012
|
+
|
|
1013
|
+
const isInViewport = (elementToCheck) => {
|
|
1014
|
+
const rect = elementToCheck.getBoundingClientRect();
|
|
1015
|
+
return (rect.top >= 0 &&
|
|
1016
|
+
rect.left >= 0 &&
|
|
1017
|
+
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
|
|
1018
|
+
rect.right <= (window.innerWidth || document.documentElement.clientWidth));
|
|
1019
|
+
};
|
|
1020
|
+
const InteractiveSpotlight = ({ element }) => {
|
|
1021
|
+
const { top, bottom, left, right, height, width } = element.getBoundingClientRect();
|
|
1022
|
+
const style = {
|
|
1023
|
+
height,
|
|
1024
|
+
width,
|
|
1025
|
+
top,
|
|
1026
|
+
left,
|
|
1027
|
+
bottom,
|
|
1028
|
+
right,
|
|
1029
|
+
};
|
|
1030
|
+
const [clicked, setClicked] = React__namespace.useState(false);
|
|
1031
|
+
React__namespace.useEffect(() => {
|
|
1032
|
+
if (!clicked) {
|
|
1033
|
+
if (!isInViewport(element)) {
|
|
1034
|
+
element.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest' });
|
|
1035
|
+
}
|
|
1036
|
+
const handleClick = () => setClicked(true);
|
|
1037
|
+
document.addEventListener('click', handleClick);
|
|
1038
|
+
return () => {
|
|
1039
|
+
document.removeEventListener('click', handleClick);
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
return () => { };
|
|
1043
|
+
}, [element, clicked]);
|
|
1044
|
+
if (clicked) {
|
|
1045
|
+
return null;
|
|
1046
|
+
}
|
|
1047
|
+
return (React__namespace.createElement(Portal, null,
|
|
1048
|
+
React__namespace.createElement(SimplePopper, null,
|
|
1049
|
+
React__namespace.createElement("div", { className: "pfext-spotlight pfext-spotlight__element-highlight-animate", style: style }))));
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
var ScrollDirection;
|
|
1053
|
+
(function (ScrollDirection) {
|
|
1054
|
+
ScrollDirection["scrollingUp"] = "scrolling-up";
|
|
1055
|
+
ScrollDirection["scrollingDown"] = "scrolling-down";
|
|
1056
|
+
ScrollDirection["scrolledToBottom"] = "scrolled-to-bottom";
|
|
1057
|
+
ScrollDirection["scrolledToTop"] = "scrolled-to-top";
|
|
1058
1058
|
})(ScrollDirection || (ScrollDirection = {}));
|
|
1059
1059
|
|
|
1060
|
-
const useResizeObserver = (callback, targetElement, observerOptions = undefined) => {
|
|
1061
|
-
const element = React__namespace.useMemo(() => targetElement !== null && targetElement !== void 0 ? targetElement : document.querySelector('body'), [targetElement]);
|
|
1062
|
-
React__namespace.useEffect(() => {
|
|
1063
|
-
const observer = new ResizeObserver(callback);
|
|
1064
|
-
observer.observe(element, observerOptions);
|
|
1065
|
-
return () => {
|
|
1066
|
-
observer.disconnect();
|
|
1067
|
-
};
|
|
1068
|
-
}, [callback, observerOptions, element]);
|
|
1069
|
-
};
|
|
1070
|
-
|
|
1071
|
-
var Shadows;
|
|
1072
|
-
(function (Shadows) {
|
|
1073
|
-
Shadows["none"] = "none";
|
|
1074
|
-
Shadows["both"] = "both";
|
|
1075
|
-
Shadows["top"] = "top";
|
|
1076
|
-
Shadows["bottom"] = "bottom";
|
|
1077
|
-
})(Shadows || (Shadows = {}));
|
|
1078
|
-
const useScrollShadows = (node) => {
|
|
1079
|
-
const [shadows, setShadows] = React__namespace.useState(Shadows.none);
|
|
1080
|
-
const computeShadows = React__namespace.useCallback(() => {
|
|
1081
|
-
if (node) {
|
|
1082
|
-
const { scrollTop, clientHeight, scrollHeight } = node;
|
|
1083
|
-
const top = scrollTop !== 0;
|
|
1084
|
-
const bottom = scrollTop + clientHeight < scrollHeight;
|
|
1085
|
-
if (top && bottom) {
|
|
1086
|
-
setShadows(Shadows.both);
|
|
1087
|
-
}
|
|
1088
|
-
else if (top) {
|
|
1089
|
-
setShadows(Shadows.top);
|
|
1090
|
-
}
|
|
1091
|
-
else if (bottom) {
|
|
1092
|
-
setShadows(Shadows.bottom);
|
|
1093
|
-
}
|
|
1094
|
-
else {
|
|
1095
|
-
setShadows(Shadows.none);
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
}, [node]);
|
|
1099
|
-
// recompute when the scroll container changes in size
|
|
1100
|
-
useResizeObserver(computeShadows, node);
|
|
1101
|
-
React__namespace.useEffect(() => {
|
|
1102
|
-
if (node) {
|
|
1103
|
-
// compute initial shadows
|
|
1104
|
-
computeShadows();
|
|
1105
|
-
// listen for scroll events
|
|
1106
|
-
node.addEventListener('scroll', computeShadows);
|
|
1107
|
-
}
|
|
1108
|
-
return () => {
|
|
1109
|
-
if (node) {
|
|
1110
|
-
node.removeEventListener('scroll', computeShadows);
|
|
1111
|
-
}
|
|
1112
|
-
};
|
|
1113
|
-
}, [node, computeShadows]);
|
|
1114
|
-
return shadows;
|
|
1115
|
-
};
|
|
1116
|
-
|
|
1117
|
-
const useBoundingClientRect = (targetElement) => {
|
|
1118
|
-
const [clientRect, setClientRect] = React__namespace.useState(() => targetElement ? targetElement.getBoundingClientRect() : null);
|
|
1119
|
-
const observerCallback = React__namespace.useCallback(() => {
|
|
1120
|
-
setClientRect(targetElement ? targetElement.getBoundingClientRect() : null);
|
|
1121
|
-
}, [targetElement]);
|
|
1122
|
-
useResizeObserver(observerCallback);
|
|
1123
|
-
return clientRect;
|
|
1124
|
-
};
|
|
1125
|
-
|
|
1126
|
-
/**
|
|
1127
|
-
* React hook that forces component render.
|
|
1128
|
-
*/
|
|
1060
|
+
const useResizeObserver = (callback, targetElement, observerOptions = undefined) => {
|
|
1061
|
+
const element = React__namespace.useMemo(() => targetElement !== null && targetElement !== void 0 ? targetElement : document.querySelector('body'), [targetElement]);
|
|
1062
|
+
React__namespace.useEffect(() => {
|
|
1063
|
+
const observer = new ResizeObserver(callback);
|
|
1064
|
+
observer.observe(element, observerOptions);
|
|
1065
|
+
return () => {
|
|
1066
|
+
observer.disconnect();
|
|
1067
|
+
};
|
|
1068
|
+
}, [callback, observerOptions, element]);
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
var Shadows;
|
|
1072
|
+
(function (Shadows) {
|
|
1073
|
+
Shadows["none"] = "none";
|
|
1074
|
+
Shadows["both"] = "both";
|
|
1075
|
+
Shadows["top"] = "top";
|
|
1076
|
+
Shadows["bottom"] = "bottom";
|
|
1077
|
+
})(Shadows || (Shadows = {}));
|
|
1078
|
+
const useScrollShadows = (node) => {
|
|
1079
|
+
const [shadows, setShadows] = React__namespace.useState(Shadows.none);
|
|
1080
|
+
const computeShadows = React__namespace.useCallback(() => {
|
|
1081
|
+
if (node) {
|
|
1082
|
+
const { scrollTop, clientHeight, scrollHeight } = node;
|
|
1083
|
+
const top = scrollTop !== 0;
|
|
1084
|
+
const bottom = scrollTop + clientHeight < scrollHeight;
|
|
1085
|
+
if (top && bottom) {
|
|
1086
|
+
setShadows(Shadows.both);
|
|
1087
|
+
}
|
|
1088
|
+
else if (top) {
|
|
1089
|
+
setShadows(Shadows.top);
|
|
1090
|
+
}
|
|
1091
|
+
else if (bottom) {
|
|
1092
|
+
setShadows(Shadows.bottom);
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
setShadows(Shadows.none);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}, [node]);
|
|
1099
|
+
// recompute when the scroll container changes in size
|
|
1100
|
+
useResizeObserver(computeShadows, node);
|
|
1101
|
+
React__namespace.useEffect(() => {
|
|
1102
|
+
if (node) {
|
|
1103
|
+
// compute initial shadows
|
|
1104
|
+
computeShadows();
|
|
1105
|
+
// listen for scroll events
|
|
1106
|
+
node.addEventListener('scroll', computeShadows);
|
|
1107
|
+
}
|
|
1108
|
+
return () => {
|
|
1109
|
+
if (node) {
|
|
1110
|
+
node.removeEventListener('scroll', computeShadows);
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
}, [node, computeShadows]);
|
|
1114
|
+
return shadows;
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
const useBoundingClientRect = (targetElement) => {
|
|
1118
|
+
const [clientRect, setClientRect] = React__namespace.useState(() => targetElement ? targetElement.getBoundingClientRect() : null);
|
|
1119
|
+
const observerCallback = React__namespace.useCallback(() => {
|
|
1120
|
+
setClientRect(targetElement ? targetElement.getBoundingClientRect() : null);
|
|
1121
|
+
}, [targetElement]);
|
|
1122
|
+
useResizeObserver(observerCallback);
|
|
1123
|
+
return clientRect;
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* React hook that forces component render.
|
|
1128
|
+
*/
|
|
1129
1129
|
const useForceRender = () => React__namespace.useReducer((s) => !s, false)[1];
|
|
1130
1130
|
|
|
1131
|
-
const useEventListener = (target, event, callback) => {
|
|
1132
|
-
React.useEffect(() => {
|
|
1133
|
-
target.addEventListener(event, callback);
|
|
1134
|
-
return () => {
|
|
1135
|
-
target.removeEventListener(event, callback);
|
|
1136
|
-
};
|
|
1137
|
-
}, [target, event, callback]);
|
|
1138
|
-
};
|
|
1139
|
-
|
|
1140
|
-
const StaticSpotlight = ({ element }) => {
|
|
1141
|
-
const clientRect = useBoundingClientRect(element);
|
|
1142
|
-
const style = clientRect
|
|
1143
|
-
? {
|
|
1144
|
-
top: clientRect.top,
|
|
1145
|
-
left: clientRect.left,
|
|
1146
|
-
height: clientRect.height,
|
|
1147
|
-
width: clientRect.width,
|
|
1148
|
-
}
|
|
1149
|
-
: {};
|
|
1150
|
-
return clientRect ? (React__namespace.createElement(Portal, null,
|
|
1151
|
-
React__namespace.createElement("div", { className: "pf-v5-c-backdrop pfext-spotlight__with-backdrop" },
|
|
1152
|
-
React__namespace.createElement("div", { className: "pfext-spotlight pfext-spotlight__element-highlight-noanimate", style: style })))) : null;
|
|
1153
|
-
};
|
|
1154
|
-
|
|
1155
|
-
const Spotlight = ({ selector, interactive }) => {
|
|
1156
|
-
// if target element is a hidden one return null
|
|
1157
|
-
const element = React__namespace.useMemo(() => {
|
|
1158
|
-
const highlightElement = document.querySelector(selector);
|
|
1159
|
-
let hiddenElement = highlightElement;
|
|
1160
|
-
while (hiddenElement) {
|
|
1161
|
-
const ariaHidden = hiddenElement.getAttribute('aria-hidden');
|
|
1162
|
-
if (ariaHidden === 'true') {
|
|
1163
|
-
return null;
|
|
1164
|
-
}
|
|
1165
|
-
hiddenElement = hiddenElement.parentElement;
|
|
1166
|
-
}
|
|
1167
|
-
return highlightElement;
|
|
1168
|
-
}, [selector]);
|
|
1169
|
-
if (!element) {
|
|
1170
|
-
return null;
|
|
1171
|
-
}
|
|
1172
|
-
return interactive ? (React__namespace.createElement(InteractiveSpotlight, { element: element })) : (React__namespace.createElement(StaticSpotlight, { element: element }));
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
|
-
const MarkdownHighlightExtension = ({ docContext, rootSelector, }) => {
|
|
1176
|
-
const [selector, setSelector] = React__namespace.useState(null);
|
|
1177
|
-
React__namespace.useEffect(() => {
|
|
1178
|
-
const elements = docContext.querySelectorAll(`${rootSelector} [data-highlight]`);
|
|
1179
|
-
let timeoutId;
|
|
1180
|
-
function startHighlight(e) {
|
|
1181
|
-
const highlightId = e.target.getAttribute('data-highlight');
|
|
1182
|
-
if (!highlightId) {
|
|
1183
|
-
return;
|
|
1184
|
-
}
|
|
1185
|
-
setSelector(null);
|
|
1186
|
-
timeoutId = setTimeout(() => {
|
|
1187
|
-
setSelector(`[data-quickstart-id="${highlightId}"]`);
|
|
1188
|
-
}, 0);
|
|
1189
|
-
}
|
|
1190
|
-
elements && elements.forEach((elm) => elm.addEventListener('click', startHighlight));
|
|
1191
|
-
return () => {
|
|
1192
|
-
clearTimeout(timeoutId);
|
|
1193
|
-
elements && elements.forEach((elm) => elm.removeEventListener('click', startHighlight));
|
|
1194
|
-
};
|
|
1195
|
-
}, [docContext, rootSelector]);
|
|
1196
|
-
React__namespace.useEffect(() => {
|
|
1197
|
-
const elements = docContext.querySelectorAll(`${rootSelector} [class^=data-highlight__]`);
|
|
1198
|
-
let timeoutId;
|
|
1199
|
-
function startHighlight(e) {
|
|
1200
|
-
e.preventDefault();
|
|
1201
|
-
const classes = e.target.getAttribute('class').split(' ');
|
|
1202
|
-
let highlightId;
|
|
1203
|
-
for (const className of classes) {
|
|
1204
|
-
if (className.startsWith('data-highlight__')) {
|
|
1205
|
-
highlightId = className.split('__')[1];
|
|
1206
|
-
break;
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
if (!highlightId) {
|
|
1210
|
-
return;
|
|
1211
|
-
}
|
|
1212
|
-
setSelector(null);
|
|
1213
|
-
timeoutId = setTimeout(() => {
|
|
1214
|
-
setSelector(`[data-quickstart-id="${highlightId}"]`);
|
|
1215
|
-
}, 0);
|
|
1216
|
-
}
|
|
1217
|
-
elements && elements.forEach((elm) => elm.addEventListener('click', startHighlight));
|
|
1218
|
-
return () => {
|
|
1219
|
-
clearTimeout(timeoutId);
|
|
1220
|
-
elements && elements.forEach((elm) => elm.removeEventListener('click', startHighlight));
|
|
1221
|
-
};
|
|
1222
|
-
}, [docContext, rootSelector]);
|
|
1223
|
-
if (!selector) {
|
|
1224
|
-
return null;
|
|
1225
|
-
}
|
|
1226
|
-
return React__namespace.createElement(Spotlight, { selector: selector, interactive: true });
|
|
1227
|
-
};
|
|
1228
|
-
|
|
1229
|
-
const MARKDOWN_COPY_BUTTON_ID = 'data-copy-for';
|
|
1230
|
-
const MARKDOWN_SNIPPET_ID = 'data-snippet-id';
|
|
1231
|
-
const ACCORDION_MARKDOWN_BUTTON_ID = `accordion-markdown-button-id`;
|
|
1131
|
+
const useEventListener = (target, event, callback) => {
|
|
1132
|
+
React.useEffect(() => {
|
|
1133
|
+
target.addEventListener(event, callback);
|
|
1134
|
+
return () => {
|
|
1135
|
+
target.removeEventListener(event, callback);
|
|
1136
|
+
};
|
|
1137
|
+
}, [target, event, callback]);
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1140
|
+
const StaticSpotlight = ({ element }) => {
|
|
1141
|
+
const clientRect = useBoundingClientRect(element);
|
|
1142
|
+
const style = clientRect
|
|
1143
|
+
? {
|
|
1144
|
+
top: clientRect.top,
|
|
1145
|
+
left: clientRect.left,
|
|
1146
|
+
height: clientRect.height,
|
|
1147
|
+
width: clientRect.width,
|
|
1148
|
+
}
|
|
1149
|
+
: {};
|
|
1150
|
+
return clientRect ? (React__namespace.createElement(Portal, null,
|
|
1151
|
+
React__namespace.createElement("div", { className: "pf-v5-c-backdrop pfext-spotlight__with-backdrop" },
|
|
1152
|
+
React__namespace.createElement("div", { className: "pfext-spotlight pfext-spotlight__element-highlight-noanimate", style: style })))) : null;
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
const Spotlight = ({ selector, interactive }) => {
|
|
1156
|
+
// if target element is a hidden one return null
|
|
1157
|
+
const element = React__namespace.useMemo(() => {
|
|
1158
|
+
const highlightElement = document.querySelector(selector);
|
|
1159
|
+
let hiddenElement = highlightElement;
|
|
1160
|
+
while (hiddenElement) {
|
|
1161
|
+
const ariaHidden = hiddenElement.getAttribute('aria-hidden');
|
|
1162
|
+
if (ariaHidden === 'true') {
|
|
1163
|
+
return null;
|
|
1164
|
+
}
|
|
1165
|
+
hiddenElement = hiddenElement.parentElement;
|
|
1166
|
+
}
|
|
1167
|
+
return highlightElement;
|
|
1168
|
+
}, [selector]);
|
|
1169
|
+
if (!element) {
|
|
1170
|
+
return null;
|
|
1171
|
+
}
|
|
1172
|
+
return interactive ? (React__namespace.createElement(InteractiveSpotlight, { element: element })) : (React__namespace.createElement(StaticSpotlight, { element: element }));
|
|
1173
|
+
};
|
|
1174
|
+
|
|
1175
|
+
const MarkdownHighlightExtension = ({ docContext, rootSelector, }) => {
|
|
1176
|
+
const [selector, setSelector] = React__namespace.useState(null);
|
|
1177
|
+
React__namespace.useEffect(() => {
|
|
1178
|
+
const elements = docContext.querySelectorAll(`${rootSelector} [data-highlight]`);
|
|
1179
|
+
let timeoutId;
|
|
1180
|
+
function startHighlight(e) {
|
|
1181
|
+
const highlightId = e.target.getAttribute('data-highlight');
|
|
1182
|
+
if (!highlightId) {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
setSelector(null);
|
|
1186
|
+
timeoutId = setTimeout(() => {
|
|
1187
|
+
setSelector(`[data-quickstart-id="${highlightId}"]`);
|
|
1188
|
+
}, 0);
|
|
1189
|
+
}
|
|
1190
|
+
elements && elements.forEach((elm) => elm.addEventListener('click', startHighlight));
|
|
1191
|
+
return () => {
|
|
1192
|
+
clearTimeout(timeoutId);
|
|
1193
|
+
elements && elements.forEach((elm) => elm.removeEventListener('click', startHighlight));
|
|
1194
|
+
};
|
|
1195
|
+
}, [docContext, rootSelector]);
|
|
1196
|
+
React__namespace.useEffect(() => {
|
|
1197
|
+
const elements = docContext.querySelectorAll(`${rootSelector} [class^=data-highlight__]`);
|
|
1198
|
+
let timeoutId;
|
|
1199
|
+
function startHighlight(e) {
|
|
1200
|
+
e.preventDefault();
|
|
1201
|
+
const classes = e.target.getAttribute('class').split(' ');
|
|
1202
|
+
let highlightId;
|
|
1203
|
+
for (const className of classes) {
|
|
1204
|
+
if (className.startsWith('data-highlight__')) {
|
|
1205
|
+
highlightId = className.split('__')[1];
|
|
1206
|
+
break;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
if (!highlightId) {
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
setSelector(null);
|
|
1213
|
+
timeoutId = setTimeout(() => {
|
|
1214
|
+
setSelector(`[data-quickstart-id="${highlightId}"]`);
|
|
1215
|
+
}, 0);
|
|
1216
|
+
}
|
|
1217
|
+
elements && elements.forEach((elm) => elm.addEventListener('click', startHighlight));
|
|
1218
|
+
return () => {
|
|
1219
|
+
clearTimeout(timeoutId);
|
|
1220
|
+
elements && elements.forEach((elm) => elm.removeEventListener('click', startHighlight));
|
|
1221
|
+
};
|
|
1222
|
+
}, [docContext, rootSelector]);
|
|
1223
|
+
if (!selector) {
|
|
1224
|
+
return null;
|
|
1225
|
+
}
|
|
1226
|
+
return React__namespace.createElement(Spotlight, { selector: selector, interactive: true });
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
const MARKDOWN_COPY_BUTTON_ID = 'data-copy-for';
|
|
1230
|
+
const MARKDOWN_SNIPPET_ID = 'data-snippet-id';
|
|
1231
|
+
const ACCORDION_MARKDOWN_BUTTON_ID = `accordion-markdown-button-id`;
|
|
1232
1232
|
const ACCORDION_MARKDOWN_CONTENT_ID = `accordion-markdown-content-id`;
|
|
1233
1233
|
|
|
1234
|
-
const CopyClipboard = ({ element, rootSelector, docContext, }) => {
|
|
1235
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1236
|
-
const [showSuccessContent, setShowSuccessContent] = React__namespace.useState(false);
|
|
1237
|
-
const textToCopy = React__namespace.useMemo(() => {
|
|
1238
|
-
var _a;
|
|
1239
|
-
const copyTextId = element.getAttribute(MARKDOWN_COPY_BUTTON_ID);
|
|
1240
|
-
return (_a = docContext.querySelector(`${rootSelector} [${MARKDOWN_SNIPPET_ID}="${copyTextId}"]`)) === null || _a === void 0 ? void 0 : _a.innerText;
|
|
1241
|
-
}, [element, docContext, rootSelector]);
|
|
1242
|
-
useEventListener(element, 'click', React__namespace.useCallback(() => {
|
|
1243
|
-
navigator.clipboard
|
|
1244
|
-
.writeText(textToCopy.trim())
|
|
1245
|
-
.then(() => {
|
|
1246
|
-
setShowSuccessContent(true);
|
|
1247
|
-
})
|
|
1248
|
-
.catch(() => { });
|
|
1249
|
-
}, [textToCopy]));
|
|
1250
|
-
useEventListener(element, 'mouseleave', React__namespace.useCallback(() => {
|
|
1251
|
-
setShowSuccessContent(false);
|
|
1252
|
-
}, []));
|
|
1253
|
-
return showSuccessContent ? (React__namespace.createElement(reactCore.Tooltip, { key: "after-copy", isVisible: true, triggerRef: () => element, content: getResource('Successfully copied to clipboard!'), className: "pfext-quick-start__base" })) : (React__namespace.createElement(reactCore.Tooltip, { key: "before-copy", triggerRef: () => element, content: getResource('Copy to clipboard'), className: "pfext-quick-start__base" }));
|
|
1254
|
-
};
|
|
1255
|
-
const MarkdownCopyClipboard = ({ docContext, rootSelector, }) => {
|
|
1256
|
-
const elements = docContext.querySelectorAll(`${rootSelector} [${MARKDOWN_COPY_BUTTON_ID}]`);
|
|
1257
|
-
return elements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(elements).map((elm) => {
|
|
1258
|
-
const attributeValue = elm.getAttribute(MARKDOWN_COPY_BUTTON_ID);
|
|
1259
|
-
return (React__namespace.createElement(CopyClipboard, { key: attributeValue, element: elm, rootSelector: rootSelector, docContext: docContext }));
|
|
1260
|
-
}))) : null;
|
|
1234
|
+
const CopyClipboard = ({ element, rootSelector, docContext, }) => {
|
|
1235
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1236
|
+
const [showSuccessContent, setShowSuccessContent] = React__namespace.useState(false);
|
|
1237
|
+
const textToCopy = React__namespace.useMemo(() => {
|
|
1238
|
+
var _a;
|
|
1239
|
+
const copyTextId = element.getAttribute(MARKDOWN_COPY_BUTTON_ID);
|
|
1240
|
+
return (_a = docContext.querySelector(`${rootSelector} [${MARKDOWN_SNIPPET_ID}="${copyTextId}"]`)) === null || _a === void 0 ? void 0 : _a.innerText;
|
|
1241
|
+
}, [element, docContext, rootSelector]);
|
|
1242
|
+
useEventListener(element, 'click', React__namespace.useCallback(() => {
|
|
1243
|
+
navigator.clipboard
|
|
1244
|
+
.writeText(textToCopy.trim())
|
|
1245
|
+
.then(() => {
|
|
1246
|
+
setShowSuccessContent(true);
|
|
1247
|
+
})
|
|
1248
|
+
.catch(() => { });
|
|
1249
|
+
}, [textToCopy]));
|
|
1250
|
+
useEventListener(element, 'mouseleave', React__namespace.useCallback(() => {
|
|
1251
|
+
setShowSuccessContent(false);
|
|
1252
|
+
}, []));
|
|
1253
|
+
return showSuccessContent ? (React__namespace.createElement(reactCore.Tooltip, { key: "after-copy", isVisible: true, triggerRef: () => element, content: getResource('Successfully copied to clipboard!'), className: "pfext-quick-start__base" })) : (React__namespace.createElement(reactCore.Tooltip, { key: "before-copy", triggerRef: () => element, content: getResource('Copy to clipboard'), className: "pfext-quick-start__base" }));
|
|
1254
|
+
};
|
|
1255
|
+
const MarkdownCopyClipboard = ({ docContext, rootSelector, }) => {
|
|
1256
|
+
const elements = docContext.querySelectorAll(`${rootSelector} [${MARKDOWN_COPY_BUTTON_ID}]`);
|
|
1257
|
+
return elements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(elements).map((elm) => {
|
|
1258
|
+
const attributeValue = elm.getAttribute(MARKDOWN_COPY_BUTTON_ID);
|
|
1259
|
+
return (React__namespace.createElement(CopyClipboard, { key: attributeValue, element: elm, rootSelector: rootSelector, docContext: docContext }));
|
|
1260
|
+
}))) : null;
|
|
1261
1261
|
};
|
|
1262
1262
|
|
|
1263
1263
|
const removeTemplateWhitespace = (template) => template.replace(/>(?:\s|\n)+</g, '><');
|
|
1264
1264
|
|
|
1265
|
-
const useInlineCopyClipboardShowdownExtension = () => {
|
|
1266
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1267
|
-
return React__namespace.useMemo(() => ({
|
|
1268
|
-
type: 'lang',
|
|
1269
|
-
regex: /`([^`](.*?)[^`])`{{copy}}/g,
|
|
1270
|
-
replace: (text, group, _, groupId) => {
|
|
1271
|
-
if (!group || isNaN(groupId)) {
|
|
1272
|
-
return text;
|
|
1273
|
-
}
|
|
1265
|
+
const useInlineCopyClipboardShowdownExtension = () => {
|
|
1266
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1267
|
+
return React__namespace.useMemo(() => ({
|
|
1268
|
+
type: 'lang',
|
|
1269
|
+
regex: /`([^`](.*?)[^`])`{{copy}}/g,
|
|
1270
|
+
replace: (text, group, _, groupId) => {
|
|
1271
|
+
if (!group || isNaN(groupId)) {
|
|
1272
|
+
return text;
|
|
1273
|
+
}
|
|
1274
1274
|
return removeTemplateWhitespace(`<span class="pf-v5-c-clipboard-copy pf-m-inline">
|
|
1275
1275
|
<span class="pf-v5-c-clipboard-copy__text" ${MARKDOWN_SNIPPET_ID}="${groupId}">${group}</span>
|
|
1276
1276
|
<span class="pf-v5-c-clipboard-copy__actions">
|
|
@@ -1280,20 +1280,20 @@ const useInlineCopyClipboardShowdownExtension = () => {
|
|
|
1280
1280
|
</button>
|
|
1281
1281
|
</span>
|
|
1282
1282
|
</span>
|
|
1283
|
-
</span>`);
|
|
1284
|
-
},
|
|
1285
|
-
}), [getResource]);
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1288
|
-
const useMultilineCopyClipboardShowdownExtension = () => {
|
|
1289
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1290
|
-
return React__namespace.useMemo(() => ({
|
|
1291
|
-
type: 'lang',
|
|
1292
|
-
regex: /```[\n]\s*((((?!```).)*?\n)+)\s*```{{copy}}/g,
|
|
1293
|
-
replace: (text, group, _1, _2, groupId) => {
|
|
1294
|
-
if (!group || isNaN(groupId)) {
|
|
1295
|
-
return text;
|
|
1296
|
-
}
|
|
1283
|
+
</span>`);
|
|
1284
|
+
},
|
|
1285
|
+
}), [getResource]);
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1288
|
+
const useMultilineCopyClipboardShowdownExtension = () => {
|
|
1289
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1290
|
+
return React__namespace.useMemo(() => ({
|
|
1291
|
+
type: 'lang',
|
|
1292
|
+
regex: /```[\n]\s*((((?!```).)*?\n)+)\s*```{{copy}}/g,
|
|
1293
|
+
replace: (text, group, _1, _2, groupId) => {
|
|
1294
|
+
if (!group || isNaN(groupId)) {
|
|
1295
|
+
return text;
|
|
1296
|
+
}
|
|
1297
1297
|
return `<div class="pf-v5-c-code-block">
|
|
1298
1298
|
<div class="pf-v5-c-code-block__header">
|
|
1299
1299
|
<div class="pf-v5-c-code-block__actions">
|
|
@@ -1310,138 +1310,138 @@ const useMultilineCopyClipboardShowdownExtension = () => {
|
|
|
1310
1310
|
${MARKDOWN_SNIPPET_ID}="${groupId}">${group.trim()}</code>
|
|
1311
1311
|
</pre>
|
|
1312
1312
|
</div>
|
|
1313
|
-
</div>`;
|
|
1314
|
-
},
|
|
1315
|
-
}), [getResource]);
|
|
1316
|
-
};
|
|
1317
|
-
|
|
1318
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1319
|
-
const DOMPurify = require('dompurify');
|
|
1320
|
-
const markdownConvert = (markdown, extensions) => {
|
|
1321
|
-
const converter = new showdown.Converter({
|
|
1322
|
-
tables: true,
|
|
1323
|
-
openLinksInNewWindow: true,
|
|
1324
|
-
strikethrough: true,
|
|
1325
|
-
emoji: false,
|
|
1326
|
-
});
|
|
1327
|
-
if (extensions) {
|
|
1328
|
-
converter.addExtension(extensions);
|
|
1329
|
-
}
|
|
1330
|
-
DOMPurify.addHook('beforeSanitizeElements', function (node) {
|
|
1331
|
-
// nodeType 1 = element type
|
|
1332
|
-
// transform anchor tags
|
|
1333
|
-
if (node.nodeType === 1 && node.nodeName.toLowerCase() === 'a') {
|
|
1334
|
-
node.setAttribute('rel', 'noopener noreferrer');
|
|
1335
|
-
return node;
|
|
1336
|
-
}
|
|
1337
|
-
// add PF class to ul and ol lists
|
|
1338
|
-
if (node.nodeType === 1 &&
|
|
1339
|
-
(node.nodeName.toLowerCase() === 'ul' || node.nodeName.toLowerCase() === 'ol')) {
|
|
1340
|
-
node.setAttribute('class', 'pf-v5-c-list');
|
|
1341
|
-
return node;
|
|
1342
|
-
}
|
|
1343
|
-
});
|
|
1344
|
-
// Add a hook to make all links open a new window
|
|
1345
|
-
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
|
|
1346
|
-
// set all elements owning target to target=_blank
|
|
1347
|
-
if ('target' in node) {
|
|
1348
|
-
node.setAttribute('target', '_blank');
|
|
1349
|
-
}
|
|
1350
|
-
// set non-HTML/MathML links to xlink:show=new
|
|
1351
|
-
if (!node.hasAttribute('target') &&
|
|
1352
|
-
(node.hasAttribute('xlink:href') || node.hasAttribute('href'))) {
|
|
1353
|
-
node.setAttribute('xlink:show', 'new');
|
|
1354
|
-
}
|
|
1355
|
-
});
|
|
1356
|
-
return DOMPurify.sanitize(converter.makeHtml(markdown), {
|
|
1357
|
-
USE_PROFILES: {
|
|
1358
|
-
html: true,
|
|
1359
|
-
svg: true,
|
|
1360
|
-
},
|
|
1361
|
-
});
|
|
1362
|
-
};
|
|
1363
|
-
const SyncMarkdownView = ({ content, emptyMsg, extensions, renderExtension, exactHeight, inline, className, }) => {
|
|
1364
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1365
|
-
const markup = React__namespace.useMemo(() => markdownConvert(content || emptyMsg || getResource('Not available'), extensions), [content, emptyMsg, extensions, getResource]);
|
|
1366
|
-
const innerProps = {
|
|
1367
|
-
renderExtension: (extensions === null || extensions === void 0 ? void 0 : extensions.length) > 0 ? renderExtension : undefined,
|
|
1368
|
-
exactHeight,
|
|
1369
|
-
markup,
|
|
1370
|
-
isEmpty: !content,
|
|
1371
|
-
className,
|
|
1372
|
-
};
|
|
1373
|
-
return inline ? React__namespace.createElement(InlineMarkdownView, Object.assign({}, innerProps)) : React__namespace.createElement(IFrameMarkdownView, Object.assign({}, innerProps));
|
|
1374
|
-
};
|
|
1375
|
-
const uniqueId = (function () {
|
|
1376
|
-
let num = 0;
|
|
1377
|
-
return function (prefix) {
|
|
1378
|
-
const prefixStr = String(prefix) || '';
|
|
1379
|
-
num += 1;
|
|
1380
|
-
return prefixStr + num;
|
|
1381
|
-
};
|
|
1382
|
-
})();
|
|
1383
|
-
const RenderExtension = ({ renderExtension, selector, markup, docContext, }) => {
|
|
1384
|
-
const forceRender = useForceRender();
|
|
1385
|
-
const markupRef = React__namespace.useRef(null);
|
|
1386
|
-
const shouldRenderExtension = React__namespace.useCallback(() => {
|
|
1387
|
-
if (markupRef.current === markup) {
|
|
1388
|
-
return true;
|
|
1389
|
-
}
|
|
1390
|
-
markupRef.current = markup;
|
|
1391
|
-
return false;
|
|
1392
|
-
}, [markup]);
|
|
1393
|
-
/**
|
|
1394
|
-
* During a render cycle in which markup changes, renderExtension receives an old copy of document
|
|
1395
|
-
* because react is still updating the dom using `dangerouslySetInnerHTML` with latest markdown markup
|
|
1396
|
-
* which causes the component rendered by renderExtension to receive old copy of document
|
|
1397
|
-
* use forceRender to delay the rendering of extension by one render cycle
|
|
1398
|
-
*/
|
|
1399
|
-
React__namespace.useEffect(() => {
|
|
1400
|
-
if (renderExtension) {
|
|
1401
|
-
forceRender();
|
|
1402
|
-
}
|
|
1403
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1404
|
-
}, [markup]);
|
|
1405
|
-
return (React__namespace.createElement(React__namespace.Fragment, null, shouldRenderExtension() ? renderExtension === null || renderExtension === void 0 ? void 0 : renderExtension(docContext !== null && docContext !== void 0 ? docContext : document, selector) : null));
|
|
1406
|
-
};
|
|
1407
|
-
const InlineMarkdownView = ({ markup, isEmpty, renderExtension, className, }) => {
|
|
1408
|
-
const id = React__namespace.useMemo(() => uniqueId('markdown'), []);
|
|
1409
|
-
return (React__namespace.createElement("div", { className: reactStyles.css('pfext-markdown-view', { 'is-empty': isEmpty }, className), id: id },
|
|
1410
|
-
React__namespace.createElement("div", { dangerouslySetInnerHTML: { __html: markup } }),
|
|
1411
|
-
renderExtension && (React__namespace.createElement(RenderExtension, { renderExtension: renderExtension, selector: `#${id}`, markup: markup }))));
|
|
1412
|
-
};
|
|
1413
|
-
const IFrameMarkdownView = ({ exactHeight, markup, isEmpty, renderExtension, className, }) => {
|
|
1414
|
-
const [frame, setFrame] = React__namespace.useState();
|
|
1415
|
-
const [loaded, setLoaded] = React__namespace.useState(false);
|
|
1416
|
-
const updateTimeoutHandle = React__namespace.useRef();
|
|
1417
|
-
const updateDimensions = React__namespace.useCallback(() => {
|
|
1418
|
-
var _a;
|
|
1419
|
-
if (!((_a = frame === null || frame === void 0 ? void 0 : frame.contentWindow) === null || _a === void 0 ? void 0 : _a.document.body.firstChild)) {
|
|
1420
|
-
return;
|
|
1421
|
-
}
|
|
1422
|
-
frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight}px`;
|
|
1423
|
-
// Let the new height take effect, then reset again once we recompute
|
|
1424
|
-
updateTimeoutHandle.current = setTimeout(() => {
|
|
1425
|
-
if (exactHeight) {
|
|
1426
|
-
frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight}px`;
|
|
1427
|
-
}
|
|
1428
|
-
else {
|
|
1429
|
-
// Increase by 15px for the case where a horizontal scrollbar might appear
|
|
1430
|
-
frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight + 15}px`;
|
|
1431
|
-
}
|
|
1432
|
-
});
|
|
1433
|
-
}, [frame, exactHeight]);
|
|
1434
|
-
React__namespace.useEffect(() => () => {
|
|
1435
|
-
clearTimeout(updateTimeoutHandle.current);
|
|
1436
|
-
}, []);
|
|
1437
|
-
const onLoad = React__namespace.useCallback(() => {
|
|
1438
|
-
updateDimensions();
|
|
1439
|
-
setLoaded(true);
|
|
1440
|
-
}, [updateDimensions]);
|
|
1441
|
-
// Find the app's stylesheets and inject them into the frame to ensure consistent styling.
|
|
1442
|
-
const filteredLinks = Array.from(document.getElementsByTagName('link')).filter((l) => l.href.includes('app-bundle'));
|
|
1313
|
+
</div>`;
|
|
1314
|
+
},
|
|
1315
|
+
}), [getResource]);
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
1319
|
+
const DOMPurify = require('dompurify');
|
|
1320
|
+
const markdownConvert = (markdown, extensions) => {
|
|
1321
|
+
const converter = new showdown.Converter({
|
|
1322
|
+
tables: true,
|
|
1323
|
+
openLinksInNewWindow: true,
|
|
1324
|
+
strikethrough: true,
|
|
1325
|
+
emoji: false,
|
|
1326
|
+
});
|
|
1327
|
+
if (extensions) {
|
|
1328
|
+
converter.addExtension(extensions);
|
|
1329
|
+
}
|
|
1330
|
+
DOMPurify.addHook('beforeSanitizeElements', function (node) {
|
|
1331
|
+
// nodeType 1 = element type
|
|
1332
|
+
// transform anchor tags
|
|
1333
|
+
if (node.nodeType === 1 && node.nodeName.toLowerCase() === 'a') {
|
|
1334
|
+
node.setAttribute('rel', 'noopener noreferrer');
|
|
1335
|
+
return node;
|
|
1336
|
+
}
|
|
1337
|
+
// add PF class to ul and ol lists
|
|
1338
|
+
if (node.nodeType === 1 &&
|
|
1339
|
+
(node.nodeName.toLowerCase() === 'ul' || node.nodeName.toLowerCase() === 'ol')) {
|
|
1340
|
+
node.setAttribute('class', 'pf-v5-c-list');
|
|
1341
|
+
return node;
|
|
1342
|
+
}
|
|
1343
|
+
});
|
|
1344
|
+
// Add a hook to make all links open a new window
|
|
1345
|
+
DOMPurify.addHook('afterSanitizeAttributes', function (node) {
|
|
1346
|
+
// set all elements owning target to target=_blank
|
|
1347
|
+
if ('target' in node) {
|
|
1348
|
+
node.setAttribute('target', '_blank');
|
|
1349
|
+
}
|
|
1350
|
+
// set non-HTML/MathML links to xlink:show=new
|
|
1351
|
+
if (!node.hasAttribute('target') &&
|
|
1352
|
+
(node.hasAttribute('xlink:href') || node.hasAttribute('href'))) {
|
|
1353
|
+
node.setAttribute('xlink:show', 'new');
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
return DOMPurify.sanitize(converter.makeHtml(markdown), {
|
|
1357
|
+
USE_PROFILES: {
|
|
1358
|
+
html: true,
|
|
1359
|
+
svg: true,
|
|
1360
|
+
},
|
|
1361
|
+
});
|
|
1362
|
+
};
|
|
1363
|
+
const SyncMarkdownView = ({ content, emptyMsg, extensions, renderExtension, exactHeight, inline, className, }) => {
|
|
1364
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1365
|
+
const markup = React__namespace.useMemo(() => markdownConvert(content || emptyMsg || getResource('Not available'), extensions), [content, emptyMsg, extensions, getResource]);
|
|
1366
|
+
const innerProps = {
|
|
1367
|
+
renderExtension: (extensions === null || extensions === void 0 ? void 0 : extensions.length) > 0 ? renderExtension : undefined,
|
|
1368
|
+
exactHeight,
|
|
1369
|
+
markup,
|
|
1370
|
+
isEmpty: !content,
|
|
1371
|
+
className,
|
|
1372
|
+
};
|
|
1373
|
+
return inline ? React__namespace.createElement(InlineMarkdownView, Object.assign({}, innerProps)) : React__namespace.createElement(IFrameMarkdownView, Object.assign({}, innerProps));
|
|
1374
|
+
};
|
|
1375
|
+
const uniqueId = (function () {
|
|
1376
|
+
let num = 0;
|
|
1377
|
+
return function (prefix) {
|
|
1378
|
+
const prefixStr = String(prefix) || '';
|
|
1379
|
+
num += 1;
|
|
1380
|
+
return prefixStr + num;
|
|
1381
|
+
};
|
|
1382
|
+
})();
|
|
1383
|
+
const RenderExtension = ({ renderExtension, selector, markup, docContext, }) => {
|
|
1384
|
+
const forceRender = useForceRender();
|
|
1385
|
+
const markupRef = React__namespace.useRef(null);
|
|
1386
|
+
const shouldRenderExtension = React__namespace.useCallback(() => {
|
|
1387
|
+
if (markupRef.current === markup) {
|
|
1388
|
+
return true;
|
|
1389
|
+
}
|
|
1390
|
+
markupRef.current = markup;
|
|
1391
|
+
return false;
|
|
1392
|
+
}, [markup]);
|
|
1393
|
+
/**
|
|
1394
|
+
* During a render cycle in which markup changes, renderExtension receives an old copy of document
|
|
1395
|
+
* because react is still updating the dom using `dangerouslySetInnerHTML` with latest markdown markup
|
|
1396
|
+
* which causes the component rendered by renderExtension to receive old copy of document
|
|
1397
|
+
* use forceRender to delay the rendering of extension by one render cycle
|
|
1398
|
+
*/
|
|
1399
|
+
React__namespace.useEffect(() => {
|
|
1400
|
+
if (renderExtension) {
|
|
1401
|
+
forceRender();
|
|
1402
|
+
}
|
|
1403
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1404
|
+
}, [markup]);
|
|
1405
|
+
return (React__namespace.createElement(React__namespace.Fragment, null, shouldRenderExtension() ? renderExtension === null || renderExtension === void 0 ? void 0 : renderExtension(docContext !== null && docContext !== void 0 ? docContext : document, selector) : null));
|
|
1406
|
+
};
|
|
1407
|
+
const InlineMarkdownView = ({ markup, isEmpty, renderExtension, className, }) => {
|
|
1408
|
+
const id = React__namespace.useMemo(() => uniqueId('markdown'), []);
|
|
1409
|
+
return (React__namespace.createElement("div", { className: reactStyles.css('pfext-markdown-view', { 'is-empty': isEmpty }, className), id: id },
|
|
1410
|
+
React__namespace.createElement("div", { dangerouslySetInnerHTML: { __html: markup } }),
|
|
1411
|
+
renderExtension && (React__namespace.createElement(RenderExtension, { renderExtension: renderExtension, selector: `#${id}`, markup: markup }))));
|
|
1412
|
+
};
|
|
1413
|
+
const IFrameMarkdownView = ({ exactHeight, markup, isEmpty, renderExtension, className, }) => {
|
|
1414
|
+
const [frame, setFrame] = React__namespace.useState();
|
|
1415
|
+
const [loaded, setLoaded] = React__namespace.useState(false);
|
|
1416
|
+
const updateTimeoutHandle = React__namespace.useRef();
|
|
1417
|
+
const updateDimensions = React__namespace.useCallback(() => {
|
|
1418
|
+
var _a;
|
|
1419
|
+
if (!((_a = frame === null || frame === void 0 ? void 0 : frame.contentWindow) === null || _a === void 0 ? void 0 : _a.document.body.firstChild)) {
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight}px`;
|
|
1423
|
+
// Let the new height take effect, then reset again once we recompute
|
|
1424
|
+
updateTimeoutHandle.current = setTimeout(() => {
|
|
1425
|
+
if (exactHeight) {
|
|
1426
|
+
frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight}px`;
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
// Increase by 15px for the case where a horizontal scrollbar might appear
|
|
1430
|
+
frame.style.height = `${frame.contentWindow.document.body.firstElementChild.scrollHeight + 15}px`;
|
|
1431
|
+
}
|
|
1432
|
+
});
|
|
1433
|
+
}, [frame, exactHeight]);
|
|
1434
|
+
React__namespace.useEffect(() => () => {
|
|
1435
|
+
clearTimeout(updateTimeoutHandle.current);
|
|
1436
|
+
}, []);
|
|
1437
|
+
const onLoad = React__namespace.useCallback(() => {
|
|
1438
|
+
updateDimensions();
|
|
1439
|
+
setLoaded(true);
|
|
1440
|
+
}, [updateDimensions]);
|
|
1441
|
+
// Find the app's stylesheets and inject them into the frame to ensure consistent styling.
|
|
1442
|
+
const filteredLinks = Array.from(document.getElementsByTagName('link')).filter((l) => l.href.includes('app-bundle'));
|
|
1443
1443
|
const linkRefs = filteredLinks.reduce((refs, link) => `${refs}
|
|
1444
|
-
<link rel="stylesheet" href="${link.href}">`, '');
|
|
1444
|
+
<link rel="stylesheet" href="${link.href}">`, '');
|
|
1445
1445
|
const contents = `
|
|
1446
1446
|
${linkRefs}
|
|
1447
1447
|
<style type="text/css">
|
|
@@ -1466,1161 +1466,1161 @@ const IFrameMarkdownView = ({ exactHeight, markup, isEmpty, renderExtension, cla
|
|
|
1466
1466
|
padding-top: 0;
|
|
1467
1467
|
}
|
|
1468
1468
|
</style>
|
|
1469
|
-
<body class="pf-m-redhat-font"><div style="overflow-y: auto;">${markup}</div></body>`;
|
|
1470
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1471
|
-
React__namespace.createElement("iframe", { sandbox: "allow-popups allow-popups-to-escape-sandbox allow-same-origin", srcDoc: contents, style: { border: '0px', display: 'block', width: '100%', height: '0' }, ref: (r) => setFrame(r), onLoad: () => onLoad(), className: className }),
|
|
1472
|
-
loaded && frame && renderExtension && (React__namespace.createElement(RenderExtension, { markup: markup, selector: '', renderExtension: renderExtension, docContext: frame.contentDocument }))));
|
|
1469
|
+
<body class="pf-m-redhat-font"><div style="overflow-y: auto;">${markup}</div></body>`;
|
|
1470
|
+
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1471
|
+
React__namespace.createElement("iframe", { sandbox: "allow-popups allow-popups-to-escape-sandbox allow-same-origin", srcDoc: contents, style: { border: '0px', display: 'block', width: '100%', height: '0' }, ref: (r) => setFrame(r), onLoad: () => onLoad(), className: className }),
|
|
1472
|
+
loaded && frame && renderExtension && (React__namespace.createElement(RenderExtension, { markup: markup, selector: '', renderExtension: renderExtension, docContext: frame.contentDocument }))));
|
|
1473
1473
|
};
|
|
1474
1474
|
|
|
1475
|
-
const LINK_LABEL = '[\\d\\w\\s-()$!]+';
|
|
1476
|
-
const HIGHLIGHT_ACTIONS = ['highlight'];
|
|
1477
|
-
const SELECTOR_ID = `[\\w-]+`;
|
|
1478
|
-
// [linkLabel]{{action id}}
|
|
1475
|
+
const LINK_LABEL = '[\\d\\w\\s-()$!]+';
|
|
1476
|
+
const HIGHLIGHT_ACTIONS = ['highlight'];
|
|
1477
|
+
const SELECTOR_ID = `[\\w-]+`;
|
|
1478
|
+
// [linkLabel]{{action id}}
|
|
1479
1479
|
const HIGHLIGHT_REGEXP = new RegExp(`\\[(${LINK_LABEL})]{{(${HIGHLIGHT_ACTIONS.join('|')}) (${SELECTOR_ID})}}`, 'g');
|
|
1480
1480
|
|
|
1481
|
-
const removeParagraphWrap = (markdown) => markdown.replace(/^<p>|<\/p>$/g, '');
|
|
1482
|
-
const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
|
|
1483
|
-
const { markdown } = React__namespace.useContext(QuickStartContext);
|
|
1484
|
-
const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
|
|
1485
|
-
const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
|
|
1486
|
-
const admonitionShowdownExtension = useAdmonitionShowdownExtension();
|
|
1487
|
-
const codeShowdownExtension = useCodeShowdownExtension();
|
|
1488
|
-
const accordionShowdownExtension = useAccordionShowdownExtension();
|
|
1489
|
-
return (React__namespace.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
|
|
1490
|
-
{
|
|
1491
|
-
type: 'lang',
|
|
1492
|
-
regex: HIGHLIGHT_REGEXP,
|
|
1493
|
-
replace: (text, linkLabel, linkType, linkId) => {
|
|
1494
|
-
if (!linkLabel || !linkType || !linkId) {
|
|
1495
|
-
return text;
|
|
1496
|
-
}
|
|
1497
|
-
return `<button class="pf-v5-c-button pf-m-inline pf-m-link" data-highlight="${linkId}">${linkLabel}</button>`;
|
|
1498
|
-
},
|
|
1499
|
-
},
|
|
1500
|
-
{
|
|
1501
|
-
type: 'output',
|
|
1502
|
-
filter(text) {
|
|
1503
|
-
// check HTML for patterns like: <em>Status: unknown</em>{#extension-requirement-status}
|
|
1504
|
-
// and replace with <em id="extension-requirement-status">Status: unknown</em>
|
|
1505
|
-
return text.replace(/<em>(.*)<\/em>{#(.*)}/g, '<em id="$2">$1</em>');
|
|
1506
|
-
},
|
|
1507
|
-
},
|
|
1508
|
-
inlineCopyClipboardShowdownExtension,
|
|
1509
|
-
multilineCopyClipboardShowdownExtension,
|
|
1510
|
-
admonitionShowdownExtension,
|
|
1511
|
-
codeShowdownExtension,
|
|
1512
|
-
accordionShowdownExtension,
|
|
1513
|
-
...(markdown ? markdown.extensions : []),
|
|
1514
|
-
], renderExtension: (docContext, rootSelector) => (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1515
|
-
React__namespace.createElement(AccordionRenderExtension, { docContext: docContext }),
|
|
1516
|
-
React__namespace.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
|
|
1517
|
-
React__namespace.createElement(MarkdownCopyClipboard, { docContext: docContext, rootSelector: rootSelector }),
|
|
1518
|
-
markdown &&
|
|
1519
|
-
markdown.renderExtension &&
|
|
1520
|
-
markdown.renderExtension(docContext, rootSelector))), className: className }));
|
|
1521
|
-
};
|
|
1522
|
-
|
|
1523
|
-
var AdmonitionType;
|
|
1524
|
-
(function (AdmonitionType) {
|
|
1525
|
-
AdmonitionType["TIP"] = "TIP";
|
|
1526
|
-
AdmonitionType["NOTE"] = "NOTE";
|
|
1527
|
-
AdmonitionType["IMPORTANT"] = "IMPORTANT";
|
|
1528
|
-
AdmonitionType["WARNING"] = "WARNING";
|
|
1529
|
-
AdmonitionType["CAUTION"] = "CAUTION";
|
|
1530
|
-
})(AdmonitionType || (AdmonitionType = {}));
|
|
1531
|
-
const admonitionToAlertVariantMap = {
|
|
1532
|
-
[AdmonitionType.NOTE]: { variant: 'info' },
|
|
1533
|
-
[AdmonitionType.TIP]: { variant: 'default', customIcon: React__namespace.createElement(LightbulbIcon__default['default'], null) },
|
|
1534
|
-
[AdmonitionType.IMPORTANT]: { variant: 'danger' },
|
|
1535
|
-
[AdmonitionType.CAUTION]: { variant: 'warning', customIcon: React__namespace.createElement(FireIcon__default['default'], null) },
|
|
1536
|
-
[AdmonitionType.WARNING]: { variant: 'warning' },
|
|
1537
|
-
};
|
|
1538
|
-
const useAdmonitionShowdownExtension = () =>
|
|
1539
|
-
// const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
|
|
1540
|
-
React__namespace.useMemo(() => ({
|
|
1541
|
-
type: 'lang',
|
|
1542
|
-
regex: /\[(.+)]{{(admonition) ([\w-]+)}}/g,
|
|
1543
|
-
replace: (text, content, admonitionLabel, admonitionType, groupId) => {
|
|
1544
|
-
if (!content || !admonitionLabel || !admonitionType || !groupId) {
|
|
1545
|
-
return text;
|
|
1546
|
-
}
|
|
1547
|
-
admonitionType = admonitionType.toUpperCase();
|
|
1548
|
-
const { variant, customIcon } = admonitionToAlertVariantMap[admonitionType];
|
|
1549
|
-
const style = admonitionType === AdmonitionType.CAUTION ? { backgroundColor: '#ec7a0915' } : {};
|
|
1550
|
-
const mdContent = React__namespace.createElement(QuickStartMarkdownView, { content: content });
|
|
1551
|
-
const pfAlert = (React__namespace.createElement(reactCore.Alert, { variant: variant, customIcon: customIcon && customIcon, isInline: true, title: admonitionType, className: "pfext-markdown-admonition", style: style }, mdContent));
|
|
1552
|
-
return removeTemplateWhitespace(server.renderToStaticMarkup(pfAlert));
|
|
1553
|
-
},
|
|
1481
|
+
const removeParagraphWrap = (markdown) => markdown.replace(/^<p>|<\/p>$/g, '');
|
|
1482
|
+
const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
|
|
1483
|
+
const { markdown } = React__namespace.useContext(QuickStartContext);
|
|
1484
|
+
const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
|
|
1485
|
+
const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
|
|
1486
|
+
const admonitionShowdownExtension = useAdmonitionShowdownExtension();
|
|
1487
|
+
const codeShowdownExtension = useCodeShowdownExtension();
|
|
1488
|
+
const accordionShowdownExtension = useAccordionShowdownExtension();
|
|
1489
|
+
return (React__namespace.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
|
|
1490
|
+
{
|
|
1491
|
+
type: 'lang',
|
|
1492
|
+
regex: HIGHLIGHT_REGEXP,
|
|
1493
|
+
replace: (text, linkLabel, linkType, linkId) => {
|
|
1494
|
+
if (!linkLabel || !linkType || !linkId) {
|
|
1495
|
+
return text;
|
|
1496
|
+
}
|
|
1497
|
+
return `<button class="pf-v5-c-button pf-m-inline pf-m-link" data-highlight="${linkId}">${linkLabel}</button>`;
|
|
1498
|
+
},
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
type: 'output',
|
|
1502
|
+
filter(text) {
|
|
1503
|
+
// check HTML for patterns like: <em>Status: unknown</em>{#extension-requirement-status}
|
|
1504
|
+
// and replace with <em id="extension-requirement-status">Status: unknown</em>
|
|
1505
|
+
return text.replace(/<em>(.*)<\/em>{#(.*)}/g, '<em id="$2">$1</em>');
|
|
1506
|
+
},
|
|
1507
|
+
},
|
|
1508
|
+
inlineCopyClipboardShowdownExtension,
|
|
1509
|
+
multilineCopyClipboardShowdownExtension,
|
|
1510
|
+
admonitionShowdownExtension,
|
|
1511
|
+
codeShowdownExtension,
|
|
1512
|
+
accordionShowdownExtension,
|
|
1513
|
+
...(markdown ? markdown.extensions : []),
|
|
1514
|
+
], renderExtension: (docContext, rootSelector) => (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1515
|
+
React__namespace.createElement(AccordionRenderExtension, { docContext: docContext }),
|
|
1516
|
+
React__namespace.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
|
|
1517
|
+
React__namespace.createElement(MarkdownCopyClipboard, { docContext: docContext, rootSelector: rootSelector }),
|
|
1518
|
+
markdown &&
|
|
1519
|
+
markdown.renderExtension &&
|
|
1520
|
+
markdown.renderExtension(docContext, rootSelector))), className: className }));
|
|
1521
|
+
};
|
|
1522
|
+
|
|
1523
|
+
var AdmonitionType;
|
|
1524
|
+
(function (AdmonitionType) {
|
|
1525
|
+
AdmonitionType["TIP"] = "TIP";
|
|
1526
|
+
AdmonitionType["NOTE"] = "NOTE";
|
|
1527
|
+
AdmonitionType["IMPORTANT"] = "IMPORTANT";
|
|
1528
|
+
AdmonitionType["WARNING"] = "WARNING";
|
|
1529
|
+
AdmonitionType["CAUTION"] = "CAUTION";
|
|
1530
|
+
})(AdmonitionType || (AdmonitionType = {}));
|
|
1531
|
+
const admonitionToAlertVariantMap = {
|
|
1532
|
+
[AdmonitionType.NOTE]: { variant: 'info' },
|
|
1533
|
+
[AdmonitionType.TIP]: { variant: 'default', customIcon: React__namespace.createElement(LightbulbIcon__default['default'], null) },
|
|
1534
|
+
[AdmonitionType.IMPORTANT]: { variant: 'danger' },
|
|
1535
|
+
[AdmonitionType.CAUTION]: { variant: 'warning', customIcon: React__namespace.createElement(FireIcon__default['default'], null) },
|
|
1536
|
+
[AdmonitionType.WARNING]: { variant: 'warning' },
|
|
1537
|
+
};
|
|
1538
|
+
const useAdmonitionShowdownExtension = () =>
|
|
1539
|
+
// const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
|
|
1540
|
+
React__namespace.useMemo(() => ({
|
|
1541
|
+
type: 'lang',
|
|
1542
|
+
regex: /\[(.+)]{{(admonition) ([\w-]+)}}/g,
|
|
1543
|
+
replace: (text, content, admonitionLabel, admonitionType, groupId) => {
|
|
1544
|
+
if (!content || !admonitionLabel || !admonitionType || !groupId) {
|
|
1545
|
+
return text;
|
|
1546
|
+
}
|
|
1547
|
+
admonitionType = admonitionType.toUpperCase();
|
|
1548
|
+
const { variant, customIcon } = admonitionToAlertVariantMap[admonitionType];
|
|
1549
|
+
const style = admonitionType === AdmonitionType.CAUTION ? { backgroundColor: '#ec7a0915' } : {};
|
|
1550
|
+
const mdContent = React__namespace.createElement(QuickStartMarkdownView, { content: content });
|
|
1551
|
+
const pfAlert = (React__namespace.createElement(reactCore.Alert, { variant: variant, customIcon: customIcon && customIcon, isInline: true, title: admonitionType, className: "pfext-markdown-admonition", style: style }, mdContent));
|
|
1552
|
+
return removeTemplateWhitespace(server.renderToStaticMarkup(pfAlert));
|
|
1553
|
+
},
|
|
1554
1554
|
}), []);
|
|
1555
1555
|
|
|
1556
|
-
const useCodeShowdownExtension = () => React__namespace.useMemo(() => ({
|
|
1557
|
-
type: 'output',
|
|
1558
|
-
regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
|
|
1559
|
-
replace: (text, content) => {
|
|
1560
|
-
if (!content) {
|
|
1561
|
-
return text;
|
|
1562
|
-
}
|
|
1563
|
-
const pfCodeBlock = React__namespace.createElement(reactCore.CodeBlock, null, content);
|
|
1564
|
-
return removeTemplateWhitespace(server.renderToStaticMarkup(pfCodeBlock));
|
|
1565
|
-
},
|
|
1556
|
+
const useCodeShowdownExtension = () => React__namespace.useMemo(() => ({
|
|
1557
|
+
type: 'output',
|
|
1558
|
+
regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
|
|
1559
|
+
replace: (text, content) => {
|
|
1560
|
+
if (!content) {
|
|
1561
|
+
return text;
|
|
1562
|
+
}
|
|
1563
|
+
const pfCodeBlock = React__namespace.createElement(reactCore.CodeBlock, null, content);
|
|
1564
|
+
return removeTemplateWhitespace(server.renderToStaticMarkup(pfCodeBlock));
|
|
1565
|
+
},
|
|
1566
1566
|
}), []);
|
|
1567
1567
|
|
|
1568
|
-
const useAccordionShowdownExtension = () => React__namespace.useMemo(() => ({
|
|
1569
|
-
type: 'lang',
|
|
1570
|
-
regex: /\[(.+)]{{(accordion) ("(.*?)")}}/g,
|
|
1571
|
-
replace: (_text, accordionContent, _command, accordionHeading) => {
|
|
1572
|
-
const accordionId = String(accordionHeading).replace(/\s/g, '-');
|
|
1573
|
-
return removeTemplateWhitespace(server.renderToStaticMarkup(React__namespace.createElement(reactCore.Accordion, { asDefinitionList: true },
|
|
1574
|
-
React__namespace.createElement(reactCore.AccordionItem, null,
|
|
1575
|
-
React__namespace.createElement(reactCore.AccordionToggle, { isExpanded: false, id: `${ACCORDION_MARKDOWN_BUTTON_ID}-${accordionId}` }, accordionHeading),
|
|
1576
|
-
React__namespace.createElement(reactCore.AccordionContent, { id: `${ACCORDION_MARKDOWN_CONTENT_ID}-${accordionId}`, isHidden: !false }, accordionContent)))));
|
|
1577
|
-
},
|
|
1568
|
+
const useAccordionShowdownExtension = () => React__namespace.useMemo(() => ({
|
|
1569
|
+
type: 'lang',
|
|
1570
|
+
regex: /\[(.+)]{{(accordion) ("(.*?)")}}/g,
|
|
1571
|
+
replace: (_text, accordionContent, _command, accordionHeading) => {
|
|
1572
|
+
const accordionId = String(accordionHeading).replace(/\s/g, '-');
|
|
1573
|
+
return removeTemplateWhitespace(server.renderToStaticMarkup(React__namespace.createElement(reactCore.Accordion, { asDefinitionList: true },
|
|
1574
|
+
React__namespace.createElement(reactCore.AccordionItem, null,
|
|
1575
|
+
React__namespace.createElement(reactCore.AccordionToggle, { isExpanded: false, id: `${ACCORDION_MARKDOWN_BUTTON_ID}-${accordionId}` }, accordionHeading),
|
|
1576
|
+
React__namespace.createElement(reactCore.AccordionContent, { id: `${ACCORDION_MARKDOWN_CONTENT_ID}-${accordionId}`, isHidden: !false }, accordionContent)))));
|
|
1577
|
+
},
|
|
1578
1578
|
}), []);
|
|
1579
1579
|
|
|
1580
|
-
const AccordionShowdownHandler = ({ buttonElement, contentElement, }) => {
|
|
1581
|
-
const [expanded, setExpanded] = React__namespace.useState(false);
|
|
1582
|
-
const handleClick = () => {
|
|
1583
|
-
const expandedModifier = 'pf-m-expanded';
|
|
1584
|
-
buttonElement.className = `pf-v5-c-accordion__toggle ${!expanded ? expandedModifier : ''}`;
|
|
1585
|
-
contentElement.hidden = expanded;
|
|
1586
|
-
contentElement.className = `pf-v5-c-accordion__expanded-content ${!expanded ? expandedModifier : ''}`;
|
|
1587
|
-
setExpanded(!expanded);
|
|
1588
|
-
};
|
|
1589
|
-
useEventListener(buttonElement, 'click', handleClick);
|
|
1590
|
-
return React__namespace.createElement(React__namespace.Fragment, null);
|
|
1591
|
-
};
|
|
1592
|
-
const AccordionRenderExtension = ({ docContext }) => {
|
|
1593
|
-
const buttonElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_BUTTON_ID}]`);
|
|
1594
|
-
const contentElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_CONTENT_ID}]`);
|
|
1595
|
-
return buttonElements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(buttonElements).map((elm) => {
|
|
1596
|
-
const content = Array.from(contentElements).find((elm2) => {
|
|
1597
|
-
const elmId = elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1];
|
|
1598
|
-
const elm2Id = elm2.id.split(ACCORDION_MARKDOWN_CONTENT_ID)[1];
|
|
1599
|
-
return elmId === elm2Id;
|
|
1600
|
-
});
|
|
1601
|
-
return (React__namespace.createElement(AccordionShowdownHandler, { key: elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1], buttonElement: elm, contentElement: content }));
|
|
1602
|
-
}))) : null;
|
|
1603
|
-
};
|
|
1604
|
-
|
|
1605
|
-
const FallbackImg = ({ src, alt, className, fallback }) => {
|
|
1606
|
-
const [isSrcValid, setIsSrcValid] = React__namespace.useState(true);
|
|
1607
|
-
if (src && isSrcValid) {
|
|
1608
|
-
return React__namespace.createElement("img", { className: className, src: src, alt: alt, onError: () => setIsSrcValid(false) });
|
|
1609
|
-
}
|
|
1610
|
-
return React__namespace.createElement(React__namespace.Fragment, null, fallback);
|
|
1580
|
+
const AccordionShowdownHandler = ({ buttonElement, contentElement, }) => {
|
|
1581
|
+
const [expanded, setExpanded] = React__namespace.useState(false);
|
|
1582
|
+
const handleClick = () => {
|
|
1583
|
+
const expandedModifier = 'pf-m-expanded';
|
|
1584
|
+
buttonElement.className = `pf-v5-c-accordion__toggle ${!expanded ? expandedModifier : ''}`;
|
|
1585
|
+
contentElement.hidden = expanded;
|
|
1586
|
+
contentElement.className = `pf-v5-c-accordion__expanded-content ${!expanded ? expandedModifier : ''}`;
|
|
1587
|
+
setExpanded(!expanded);
|
|
1588
|
+
};
|
|
1589
|
+
useEventListener(buttonElement, 'click', handleClick);
|
|
1590
|
+
return React__namespace.createElement(React__namespace.Fragment, null);
|
|
1591
|
+
};
|
|
1592
|
+
const AccordionRenderExtension = ({ docContext }) => {
|
|
1593
|
+
const buttonElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_BUTTON_ID}]`);
|
|
1594
|
+
const contentElements = docContext.querySelectorAll(`[id ^= ${ACCORDION_MARKDOWN_CONTENT_ID}]`);
|
|
1595
|
+
return buttonElements.length > 0 ? (React__namespace.createElement(React__namespace.Fragment, null, Array.from(buttonElements).map((elm) => {
|
|
1596
|
+
const content = Array.from(contentElements).find((elm2) => {
|
|
1597
|
+
const elmId = elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1];
|
|
1598
|
+
const elm2Id = elm2.id.split(ACCORDION_MARKDOWN_CONTENT_ID)[1];
|
|
1599
|
+
return elmId === elm2Id;
|
|
1600
|
+
});
|
|
1601
|
+
return (React__namespace.createElement(AccordionShowdownHandler, { key: elm.id.split(ACCORDION_MARKDOWN_BUTTON_ID)[1], buttonElement: elm, contentElement: content }));
|
|
1602
|
+
}))) : null;
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1605
|
+
const FallbackImg = ({ src, alt, className, fallback }) => {
|
|
1606
|
+
const [isSrcValid, setIsSrcValid] = React__namespace.useState(true);
|
|
1607
|
+
if (src && isSrcValid) {
|
|
1608
|
+
return React__namespace.createElement("img", { className: className, src: src, alt: alt, onError: () => setIsSrcValid(false) });
|
|
1609
|
+
}
|
|
1610
|
+
return React__namespace.createElement(React__namespace.Fragment, null, fallback);
|
|
1611
1611
|
};
|
|
1612
1612
|
|
|
1613
1613
|
const DASH = '-';
|
|
1614
1614
|
|
|
1615
|
-
const PopoverStatus = ({ hideHeader, children, isVisible = null, statusBody, title, onHide, onShow, }) => (React__namespace.createElement(reactCore.Popover, { position: reactCore.PopoverPosition.right, headerContent: hideHeader ? null : title, bodyContent: children, "aria-label": title, onHide: onHide, onShow: onShow, isVisible: isVisible },
|
|
1615
|
+
const PopoverStatus = ({ hideHeader, children, isVisible = null, statusBody, title, onHide, onShow, }) => (React__namespace.createElement(reactCore.Popover, { position: reactCore.PopoverPosition.right, headerContent: hideHeader ? null : title, bodyContent: children, "aria-label": title, onHide: onHide, onShow: onShow, isVisible: isVisible },
|
|
1616
1616
|
React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true }, statusBody)));
|
|
1617
1617
|
|
|
1618
|
-
const StatusIconAndText = ({ icon, title, spin, iconOnly, noTooltip, className, }) => {
|
|
1619
|
-
if (!title) {
|
|
1620
|
-
return React__namespace.createElement(React__namespace.Fragment, null, DASH);
|
|
1621
|
-
}
|
|
1622
|
-
return (React__namespace.createElement("span", { className: reactStyles.css('pfext-icon-and-text', className), title: iconOnly && !noTooltip ? title : undefined },
|
|
1623
|
-
icon &&
|
|
1624
|
-
React__namespace.cloneElement(icon, {
|
|
1625
|
-
className: reactStyles.css(spin && 'fa-spin', icon.props.className, !iconOnly && 'pfext-icon-and-text__icon pfext-icon-flex-child'),
|
|
1626
|
-
}),
|
|
1627
|
-
!iconOnly && React__namespace.createElement(CamelCaseWrap, { value: title, dataTest: "status-text" })));
|
|
1618
|
+
const StatusIconAndText = ({ icon, title, spin, iconOnly, noTooltip, className, }) => {
|
|
1619
|
+
if (!title) {
|
|
1620
|
+
return React__namespace.createElement(React__namespace.Fragment, null, DASH);
|
|
1621
|
+
}
|
|
1622
|
+
return (React__namespace.createElement("span", { className: reactStyles.css('pfext-icon-and-text', className), title: iconOnly && !noTooltip ? title : undefined },
|
|
1623
|
+
icon &&
|
|
1624
|
+
React__namespace.cloneElement(icon, {
|
|
1625
|
+
className: reactStyles.css(spin && 'fa-spin', icon.props.className, !iconOnly && 'pfext-icon-and-text__icon pfext-icon-flex-child'),
|
|
1626
|
+
}),
|
|
1627
|
+
!iconOnly && React__namespace.createElement(CamelCaseWrap, { value: title, dataTest: "status-text" })));
|
|
1628
1628
|
};
|
|
1629
1629
|
|
|
1630
|
-
const GenericStatus = (props) => {
|
|
1631
|
-
const { Icon, children, popoverTitle, title, noTooltip, iconOnly } = props, restProps = tslib.__rest(props, ["Icon", "children", "popoverTitle", "title", "noTooltip", "iconOnly"]);
|
|
1632
|
-
const renderIcon = iconOnly && !noTooltip ? React__namespace.createElement(Icon, { title: title }) : React__namespace.createElement(Icon, null);
|
|
1633
|
-
const statusBody = (React__namespace.createElement(StatusIconAndText, Object.assign({}, restProps, { noTooltip: noTooltip, title: title, iconOnly: iconOnly, icon: renderIcon })));
|
|
1634
|
-
return React__namespace.Children.toArray(children).length ? (React__namespace.createElement(PopoverStatus, Object.assign({ title: popoverTitle || title }, restProps, { statusBody: statusBody }), children)) : (statusBody);
|
|
1630
|
+
const GenericStatus = (props) => {
|
|
1631
|
+
const { Icon, children, popoverTitle, title, noTooltip, iconOnly } = props, restProps = tslib.__rest(props, ["Icon", "children", "popoverTitle", "title", "noTooltip", "iconOnly"]);
|
|
1632
|
+
const renderIcon = iconOnly && !noTooltip ? React__namespace.createElement(Icon, { title: title }) : React__namespace.createElement(Icon, null);
|
|
1633
|
+
const statusBody = (React__namespace.createElement(StatusIconAndText, Object.assign({}, restProps, { noTooltip: noTooltip, title: title, iconOnly: iconOnly, icon: renderIcon })));
|
|
1634
|
+
return React__namespace.Children.toArray(children).length ? (React__namespace.createElement(PopoverStatus, Object.assign({ title: popoverTitle || title }, restProps, { statusBody: statusBody }), children)) : (statusBody);
|
|
1635
1635
|
};
|
|
1636
1636
|
|
|
1637
|
-
const GreenCheckCircleIcon = ({ className, title, size }) => (React__namespace.createElement(reactCore.Icon, { size: size },
|
|
1637
|
+
const GreenCheckCircleIcon = ({ className, title, size }) => (React__namespace.createElement(reactCore.Icon, { size: size },
|
|
1638
1638
|
React__namespace.createElement(CheckCircleIcon__default['default'], { "data-test": "success-icon", color: okColor__default['default'].value, className: className, title: title })));
|
|
1639
1639
|
|
|
1640
|
-
const SuccessStatus = (props) => (React__namespace.createElement(GenericStatus, Object.assign({}, props, { Icon: GreenCheckCircleIcon, title: props.title || 'Healthy' })));
|
|
1640
|
+
const SuccessStatus = (props) => (React__namespace.createElement(GenericStatus, Object.assign({}, props, { Icon: GreenCheckCircleIcon, title: props.title || 'Healthy' })));
|
|
1641
1641
|
SuccessStatus.displayName = 'SuccessStatus';
|
|
1642
1642
|
|
|
1643
|
-
const Status = ({ status, title, iconOnly, noTooltip, className, }) => {
|
|
1644
|
-
const statusProps = { title: title || status, iconOnly, noTooltip, className };
|
|
1645
|
-
switch (status) {
|
|
1646
|
-
case 'In Progress':
|
|
1647
|
-
return React__namespace.createElement(StatusIconAndText, Object.assign({}, statusProps, { icon: React__namespace.createElement(SyncAltIcon__default['default'], null) }));
|
|
1648
|
-
case 'Complete':
|
|
1649
|
-
return React__namespace.createElement(SuccessStatus, Object.assign({}, statusProps));
|
|
1650
|
-
default:
|
|
1651
|
-
return React__namespace.createElement(React__namespace.Fragment, null, status || DASH);
|
|
1652
|
-
}
|
|
1653
|
-
};
|
|
1643
|
+
const Status = ({ status, title, iconOnly, noTooltip, className, }) => {
|
|
1644
|
+
const statusProps = { title: title || status, iconOnly, noTooltip, className };
|
|
1645
|
+
switch (status) {
|
|
1646
|
+
case 'In Progress':
|
|
1647
|
+
return React__namespace.createElement(StatusIconAndText, Object.assign({}, statusProps, { icon: React__namespace.createElement(SyncAltIcon__default['default'], null) }));
|
|
1648
|
+
case 'Complete':
|
|
1649
|
+
return React__namespace.createElement(SuccessStatus, Object.assign({}, statusProps));
|
|
1650
|
+
default:
|
|
1651
|
+
return React__namespace.createElement(React__namespace.Fragment, null, status || DASH);
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
1654
|
const StatusIcon = ({ status }) => (React__namespace.createElement(Status, { status: status, iconOnly: true }));
|
|
1655
1655
|
|
|
1656
|
-
const QuickStartTileDescription = ({ description, prerequisites, }) => {
|
|
1657
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1658
|
-
const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
|
|
1659
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1660
|
-
React__namespace.createElement(QuickStartMarkdownView, { content: description, className: "pfext-quick-start-tile-description" }),
|
|
1661
|
-
(prereqs === null || prereqs === void 0 ? void 0 : prereqs.length) > 0 && (React__namespace.createElement("div", { className: "pfext-quick-start-tile-prerequisites" },
|
|
1662
|
-
React__namespace.createElement(reactCore.Text, { component: reactCore.TextVariants.h5, className: "pfext-quick-start-tile-prerequisites__text" },
|
|
1663
|
-
getResource('Prerequisites ({{totalPrereqs}})').replace('{{totalPrereqs}}', prereqs.length),
|
|
1664
|
-
' '),
|
|
1665
|
-
React__namespace.createElement(reactCore.Popover, { "aria-label": getResource('Prerequisites'), headerContent: getResource('Prerequisites'), className: "pfext-quick-start__base", bodyContent: React__namespace.createElement("div", { className: "pfext-popover__base" },
|
|
1666
|
-
React__namespace.createElement(reactCore.TextList, { "aria-label": getResource('Prerequisites'), className: "pfext-quick-start-tile-prerequisites-list" }, prereqs.map((prerequisite, index) => (
|
|
1667
|
-
// eslint-disable-next-line react/no-array-index-key
|
|
1668
|
-
React__namespace.createElement(reactCore.TextListItem, { key: index },
|
|
1669
|
-
React__namespace.createElement(QuickStartMarkdownView, { content: prerequisite })))))) },
|
|
1670
|
-
React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true, className: "pfext-quick-start-tile-prerequisites__icon", "data-testid": "qs-card-prereqs", onClick: (e) => {
|
|
1671
|
-
e.preventDefault();
|
|
1672
|
-
e.stopPropagation();
|
|
1673
|
-
}, "aria-label": getResource('Show prerequisites') },
|
|
1674
|
-
React__namespace.createElement(InfoCircleIcon__default['default'], null)))))));
|
|
1675
|
-
};
|
|
1676
|
-
|
|
1677
|
-
const QuickStartTileFooter = ({ quickStartId, status, totalTasks, }) => {
|
|
1678
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1679
|
-
const { activeQuickStartID, startQuickStart, restartQuickStart } = React__namespace.useContext(QuickStartContext);
|
|
1680
|
-
const start = React__namespace.useCallback((e) => {
|
|
1681
|
-
e.preventDefault();
|
|
1682
|
-
e.stopPropagation();
|
|
1683
|
-
startQuickStart(quickStartId, totalTasks);
|
|
1684
|
-
}, [quickStartId, startQuickStart, totalTasks]);
|
|
1685
|
-
const restart = React__namespace.useCallback((e) => {
|
|
1686
|
-
e.preventDefault();
|
|
1687
|
-
e.stopPropagation();
|
|
1688
|
-
restartQuickStart(quickStartId, totalTasks);
|
|
1689
|
-
}, [quickStartId, restartQuickStart, totalTasks]);
|
|
1690
|
-
return (React__namespace.createElement(reactCore.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
|
|
1691
|
-
status === exports.QuickStartStatus.NOT_STARTED && (React__namespace.createElement(reactCore.FlexItem, null,
|
|
1692
|
-
React__namespace.createElement(reactCore.Button, { onClick: start, variant: "link", isInline: true, "data-testid": "qs-card-notStarted-start", id: `${quickStartId}-start`, "aria-labelledby": `${quickStartId}-start ${quickStartId}` }, getResource('Start')))),
|
|
1693
|
-
status === exports.QuickStartStatus.IN_PROGRESS && activeQuickStartID !== quickStartId && (React__namespace.createElement(reactCore.FlexItem, null,
|
|
1694
|
-
React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true, "data-testid": "qs-card-inProgress-resume", id: `${quickStartId}-continue`, "aria-labelledby": `${quickStartId}-continue ${quickStartId}` }, getResource('Continue')))),
|
|
1695
|
-
status === exports.QuickStartStatus.COMPLETE && (React__namespace.createElement(reactCore.FlexItem, null,
|
|
1696
|
-
React__namespace.createElement(reactCore.Button, { onClick: restart, variant: "link", isInline: true, "data-testid": "qs-card-complete-restart", id: `${quickStartId}-restart`, "aria-labelledby": `${quickStartId}-restart ${quickStartId}` }, getResource('Restart')))),
|
|
1697
|
-
status === exports.QuickStartStatus.IN_PROGRESS && (React__namespace.createElement(reactCore.FlexItem, null,
|
|
1698
|
-
React__namespace.createElement(reactCore.Button, { onClick: restart, variant: "link", isInline: true, "data-testid": "qs-card-inProgress-restart", id: `${quickStartId}-restart`, "aria-labelledby": `${quickStartId}-restart ${quickStartId}` }, getResource('Restart'))))));
|
|
1699
|
-
};
|
|
1700
|
-
|
|
1701
|
-
const QuickStartTileFooterExternal = ({ link, quickStartId, }) => {
|
|
1702
|
-
const { href, text } = link;
|
|
1703
|
-
return (React__namespace.createElement(reactCore.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
|
|
1704
|
-
React__namespace.createElement(reactCore.FlexItem, null,
|
|
1705
|
-
React__namespace.createElement(reactCore.Button, { component: "a", href: href, target: "_blank", rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: React__namespace.createElement(ExternalLinkAltIcon__default['default'], null), iconPosition: "right", id: quickStartId, "aria-labelledby": `${quickStartId}-external ${quickStartId}` }, text || href))));
|
|
1706
|
-
};
|
|
1707
|
-
|
|
1708
|
-
const statusColorMap = {
|
|
1709
|
-
[exports.QuickStartStatus.COMPLETE]: 'green',
|
|
1710
|
-
[exports.QuickStartStatus.IN_PROGRESS]: 'purple',
|
|
1711
|
-
[exports.QuickStartStatus.NOT_STARTED]: 'grey',
|
|
1712
|
-
};
|
|
1713
|
-
const QuickStartTileHeader = ({ status, duration, name, type, quickStartId, }) => {
|
|
1714
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1715
|
-
const statusLocaleMap = {
|
|
1716
|
-
[exports.QuickStartStatus.COMPLETE]: getResource('Complete'),
|
|
1717
|
-
[exports.QuickStartStatus.IN_PROGRESS]: getResource('In progress'),
|
|
1718
|
-
[exports.QuickStartStatus.NOT_STARTED]: getResource('Not started'),
|
|
1719
|
-
};
|
|
1720
|
-
return (React__namespace.createElement("div", { className: "pfext-quick-start-tile-header" },
|
|
1721
|
-
React__namespace.createElement(reactCore.Title, { headingLevel: "h3", "data-test": "title", id: quickStartId },
|
|
1722
|
-
React__namespace.createElement(QuickStartMarkdownView, { content: name })),
|
|
1723
|
-
React__namespace.createElement("div", { className: "pfext-quick-start-tile-header__status" },
|
|
1724
|
-
type && (React__namespace.createElement(reactCore.Label, { className: "pfext-quick-start-tile-header--margin", color: type.color }, type.text)),
|
|
1725
|
-
duration && (React__namespace.createElement(reactCore.Label, { variant: "outline", "data-test": "duration", icon: React__namespace.createElement(OutlinedClockIcon__default['default'], null), className: "pfext-quick-start-tile-header--margin" }, getResource('{{duration, number}} minutes', duration).replace('{{duration, number}}', duration))),
|
|
1726
|
-
status !== exports.QuickStartStatus.NOT_STARTED && (React__namespace.createElement(reactCore.Label, { variant: "outline", color: statusColorMap[status], icon: React__namespace.createElement(StatusIcon, { status: status }), "data-test": "status" }, statusLocaleMap[status])))));
|
|
1727
|
-
};
|
|
1728
|
-
|
|
1729
|
-
const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, }) => {
|
|
1730
|
-
const { metadata: { name: id }, spec: { icon, tasks, displayName, description, durationMinutes, prerequisites, link, type }, } = quickStart;
|
|
1731
|
-
const { setActiveQuickStart, footer } = React__namespace.useContext(QuickStartContext);
|
|
1732
|
-
const ref = React__namespace.useRef(null);
|
|
1733
|
-
let quickStartIcon;
|
|
1734
|
-
if (typeof icon === 'object') {
|
|
1735
|
-
quickStartIcon = icon;
|
|
1736
|
-
}
|
|
1737
|
-
else {
|
|
1738
|
-
quickStartIcon = (React__namespace.createElement(FallbackImg, { className: "pfext-catalog-item-icon__img--large", src: icon, alt: "", fallback: React__namespace.createElement(RocketIcon__default['default'], null) }));
|
|
1739
|
-
}
|
|
1740
|
-
const footerComponent = React__namespace.useMemo(() => {
|
|
1741
|
-
if (footer && footer.show === false) {
|
|
1742
|
-
return null;
|
|
1743
|
-
}
|
|
1744
|
-
if (link) {
|
|
1745
|
-
return React__namespace.createElement(QuickStartTileFooterExternal, { link: link, quickStartId: id });
|
|
1746
|
-
}
|
|
1747
|
-
return React__namespace.createElement(QuickStartTileFooter, { quickStartId: id, status: status, totalTasks: tasks === null || tasks === void 0 ? void 0 : tasks.length });
|
|
1748
|
-
}, [footer, id, link, status, tasks === null || tasks === void 0 ? void 0 : tasks.length]);
|
|
1749
|
-
const handleClick = (e) => {
|
|
1750
|
-
var _a;
|
|
1751
|
-
if ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) {
|
|
1752
|
-
if (link) {
|
|
1753
|
-
window.open(link.href);
|
|
1754
|
-
}
|
|
1755
|
-
else {
|
|
1756
|
-
setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
|
|
1757
|
-
}
|
|
1758
|
-
onClick();
|
|
1759
|
-
}
|
|
1760
|
-
};
|
|
1761
|
-
return (React__namespace.createElement("div", { ref: ref },
|
|
1762
|
-
React__namespace.createElement(CatalogTile, { id: id + '-catalog-tile', style: {
|
|
1763
|
-
cursor: 'pointer',
|
|
1764
|
-
}, icon: quickStartIcon, className: "pfext-quick-start-tile", "data-testid": `qs-card-${camelize(displayName)}`, featured: isActive, title: React__namespace.createElement(QuickStartTileHeader, { name: displayName, status: status, duration: durationMinutes, type: type, quickStartId: id }), onClick: handleClick, onKeyDown: (event) => {
|
|
1765
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
1766
|
-
setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
|
|
1767
|
-
onClick();
|
|
1768
|
-
}
|
|
1769
|
-
},
|
|
1770
|
-
// https://github.com/patternfly/patternfly-react/issues/7039
|
|
1771
|
-
href: link === null || link === void 0 ? void 0 : link.href, "data-test": `tile ${id}`, description: React__namespace.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent, tabIndex: 0 })));
|
|
1772
|
-
};
|
|
1773
|
-
|
|
1774
|
-
const QuickStartCatalog = ({ quickStarts }) => {
|
|
1775
|
-
const { activeQuickStartID, allQuickStartStates } = React__namespace.useContext(QuickStartContext);
|
|
1776
|
-
return (React__namespace.createElement("div", { className: "pfext-page-layout__content" },
|
|
1777
|
-
React__namespace.createElement(reactCore.Gallery, { className: "pfext-quick-start-catalog__gallery", hasGutter: true }, quickStarts.map((quickStart) => {
|
|
1778
|
-
const { metadata: { name: id }, } = quickStart;
|
|
1779
|
-
return (React__namespace.createElement(reactCore.GalleryItem, { key: id, className: "pfext-quick-start-catalog__gallery-item" },
|
|
1780
|
-
React__namespace.createElement(QuickStartTile, { quickStart: quickStart, isActive: id === activeQuickStartID, status: getQuickStartStatus(allQuickStartStates, id) })));
|
|
1781
|
-
}))));
|
|
1782
|
-
};
|
|
1783
|
-
|
|
1784
|
-
const QuickStartCatalogFilterSearch = (_a) => {
|
|
1785
|
-
var { searchInputText, handleTextChange } = _a, props = tslib.__rest(_a, ["searchInputText", "handleTextChange"]);
|
|
1786
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1787
|
-
return (React__namespace.createElement(reactCore.ToolbarItem, { className: "pfext-quick-start-catalog-filter__input" },
|
|
1788
|
-
React__namespace.createElement(reactCore.SearchInput, Object.assign({ placeholder: getResource('Filter by keyword...'), value: searchInputText, onChange: (_ev, value) => handleTextChange(value), onClear: () => handleTextChange('') }, props))));
|
|
1789
|
-
};
|
|
1790
|
-
const QuickStartCatalogFilterSelect = (_a) => {
|
|
1791
|
-
var { isDropdownOpen, setIsDropdownOpen, onRowfilterSelect, selectedFilters, dropdownItems } = _a, props = tslib.__rest(_a, ["isDropdownOpen", "setIsDropdownOpen", "onRowfilterSelect", "selectedFilters", "dropdownItems"]);
|
|
1792
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1793
|
-
const toggle = (toggleRef) => (React__namespace.createElement(reactCore.MenuToggle, { isFullWidth: true, ref: toggleRef, onClick: () => setIsDropdownOpen(!isDropdownOpen), isExpanded: isDropdownOpen },
|
|
1794
|
-
getResource('Status'),
|
|
1795
|
-
selectedFilters.length > 0 && React__namespace.createElement(reactCore.Badge, { isRead: true }, selectedFilters.length)));
|
|
1796
|
-
return (React__namespace.createElement(reactCore.ToolbarItem, null,
|
|
1797
|
-
React__namespace.createElement(reactCore.Select, Object.assign({ "aria-label": getResource('Select filter'), isOpen: isDropdownOpen, selected: selectedFilters, onSelect: onRowfilterSelect, onOpenChange: (isOpen) => setIsDropdownOpen(isOpen), toggle: toggle }, props),
|
|
1798
|
-
React__namespace.createElement(reactCore.SelectList, null, dropdownItems))));
|
|
1799
|
-
};
|
|
1800
|
-
const QuickStartCatalogFilterCount = ({ quickStartsCount }) => {
|
|
1801
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1802
|
-
return (React__namespace.createElement(reactCore.ToolbarItem, { className: "pfext-quick-start-catalog-filter__count", align: { default: 'alignRight' } }, getResource('{{count, number}} item', quickStartsCount).replace('{{count, number}}', quickStartsCount)));
|
|
1803
|
-
};
|
|
1804
|
-
const QuickStartCatalogFilterSearchWrapper = ({ onSearchInputChange = () => { } }) => {
|
|
1805
|
-
const { useQueryParams, filter, setFilter } = React__namespace.useContext(QuickStartContext);
|
|
1806
|
-
React__namespace.useEffect(() => {
|
|
1807
|
-
// use this effect to clear the search when a `clear all` action is performed higher up
|
|
1808
|
-
const unlisten = history.listen(({ location }) => {
|
|
1809
|
-
const searchParams = new URLSearchParams(location.search);
|
|
1810
|
-
const searchQuery = searchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
|
|
1811
|
-
if (searchQuery === '') {
|
|
1812
|
-
setFilter('keyword', '');
|
|
1813
|
-
onSearchInputChange('');
|
|
1814
|
-
}
|
|
1815
|
-
});
|
|
1816
|
-
return () => {
|
|
1817
|
-
unlisten();
|
|
1818
|
-
};
|
|
1819
|
-
}, [onSearchInputChange, setFilter]);
|
|
1820
|
-
const handleTextChange = (val) => {
|
|
1821
|
-
if (val.length > 0) {
|
|
1822
|
-
useQueryParams && setQueryArgument(QUICKSTART_SEARCH_FILTER_KEY, val);
|
|
1823
|
-
}
|
|
1824
|
-
else {
|
|
1825
|
-
useQueryParams && removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
|
|
1826
|
-
}
|
|
1827
|
-
if ((filter === null || filter === void 0 ? void 0 : filter.keyword) !== val) {
|
|
1828
|
-
setFilter('keyword', val);
|
|
1829
|
-
}
|
|
1830
|
-
onSearchInputChange(val);
|
|
1831
|
-
};
|
|
1832
|
-
return (React__namespace.createElement(QuickStartCatalogFilterSearch, { searchInputText: filter === null || filter === void 0 ? void 0 : filter.keyword, handleTextChange: handleTextChange }));
|
|
1833
|
-
};
|
|
1834
|
-
// compare string/number arrays
|
|
1835
|
-
const equalsIgnoreOrder = (a, b) => {
|
|
1836
|
-
if (a.length !== b.length) {
|
|
1837
|
-
return false;
|
|
1838
|
-
}
|
|
1839
|
-
const uniqueValues = new Set([...a, ...b]);
|
|
1840
|
-
for (const v of uniqueValues) {
|
|
1841
|
-
const aCount = a.filter((e) => e === v).length;
|
|
1842
|
-
const bCount = b.filter((e) => e === v).length;
|
|
1843
|
-
if (aCount !== bCount) {
|
|
1844
|
-
return false;
|
|
1845
|
-
}
|
|
1846
|
-
}
|
|
1847
|
-
return true;
|
|
1848
|
-
};
|
|
1849
|
-
const QuickStartCatalogFilterStatusWrapper = ({ onStatusChange = () => { } }) => {
|
|
1850
|
-
const { useQueryParams, filter, setFilter } = React__namespace.useContext(QuickStartContext);
|
|
1851
|
-
React__namespace.useEffect(() => {
|
|
1852
|
-
// use this effect to clear the status when a `clear all` action is performed higher up
|
|
1853
|
-
const unlisten = history.listen(({ location }) => {
|
|
1854
|
-
var _a;
|
|
1855
|
-
const searchParams = new URLSearchParams(location.search);
|
|
1856
|
-
const updatedStatusFilters = ((_a = searchParams.get(QUICKSTART_STATUS_FILTER_KEY)) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
|
|
1857
|
-
if (updatedStatusFilters.length === 0) {
|
|
1858
|
-
setFilter('status', []);
|
|
1859
|
-
onStatusChange([]);
|
|
1860
|
-
}
|
|
1861
|
-
});
|
|
1862
|
-
return () => {
|
|
1863
|
-
unlisten();
|
|
1864
|
-
};
|
|
1865
|
-
});
|
|
1866
|
-
const [isDropdownOpen, setIsDropdownOpen] = React__namespace.useState(false);
|
|
1867
|
-
const onRowfilterSelect = React__namespace.useCallback((_e, selectedValue) => {
|
|
1868
|
-
setIsDropdownOpen(false);
|
|
1869
|
-
const selection = Object.entries(filter.status.statusTypes).find(([_key, value]) => value === selectedValue)[0];
|
|
1870
|
-
const selectedFiltersList = filter.status.statusFilters.includes(selection)
|
|
1871
|
-
? filter.status.statusFilters.filter((status) => status !== selection)
|
|
1872
|
-
: [...filter.status.statusFilters, selection];
|
|
1873
|
-
if (!equalsIgnoreOrder(filter.status.statusFilters, selectedFiltersList)) {
|
|
1874
|
-
setFilter('status', selectedFiltersList);
|
|
1875
|
-
}
|
|
1876
|
-
if (selectedFiltersList.length > 0) {
|
|
1877
|
-
useQueryParams && setQueryArgument('status', selectedFiltersList.join(','));
|
|
1878
|
-
}
|
|
1879
|
-
else {
|
|
1880
|
-
useQueryParams && removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
|
|
1881
|
-
}
|
|
1882
|
-
onStatusChange(selectedFiltersList);
|
|
1883
|
-
}, [filter.status.statusFilters, onStatusChange, setFilter, useQueryParams]);
|
|
1884
|
-
const dropdownItems = Object.entries(filter.status.statusTypes).map(([key, value]) => (React__namespace.createElement(reactCore.SelectOption, { key: key, "data-key": key, value: value, hasCheckbox: true, isSelected: filter.status.statusFilters.includes(key) },
|
|
1885
|
-
React__namespace.createElement(React__namespace.Fragment, null, value))));
|
|
1886
|
-
return (React__namespace.createElement(QuickStartCatalogFilterSelect, { isDropdownOpen: isDropdownOpen, setIsDropdownOpen: setIsDropdownOpen, onRowfilterSelect: onRowfilterSelect, selectedFilters: filter.status.statusFilters, dropdownItems: dropdownItems }));
|
|
1887
|
-
};
|
|
1656
|
+
const QuickStartTileDescription = ({ description, prerequisites, }) => {
|
|
1657
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1658
|
+
const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
|
|
1659
|
+
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1660
|
+
React__namespace.createElement(QuickStartMarkdownView, { content: description, className: "pfext-quick-start-tile-description" }),
|
|
1661
|
+
(prereqs === null || prereqs === void 0 ? void 0 : prereqs.length) > 0 && (React__namespace.createElement("div", { className: "pfext-quick-start-tile-prerequisites" },
|
|
1662
|
+
React__namespace.createElement(reactCore.Text, { component: reactCore.TextVariants.h5, className: "pfext-quick-start-tile-prerequisites__text" },
|
|
1663
|
+
getResource('Prerequisites ({{totalPrereqs}})').replace('{{totalPrereqs}}', prereqs.length),
|
|
1664
|
+
' '),
|
|
1665
|
+
React__namespace.createElement(reactCore.Popover, { "aria-label": getResource('Prerequisites'), headerContent: getResource('Prerequisites'), className: "pfext-quick-start__base", bodyContent: React__namespace.createElement("div", { className: "pfext-popover__base" },
|
|
1666
|
+
React__namespace.createElement(reactCore.TextList, { "aria-label": getResource('Prerequisites'), className: "pfext-quick-start-tile-prerequisites-list" }, prereqs.map((prerequisite, index) => (
|
|
1667
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
1668
|
+
React__namespace.createElement(reactCore.TextListItem, { key: index },
|
|
1669
|
+
React__namespace.createElement(QuickStartMarkdownView, { content: prerequisite })))))) },
|
|
1670
|
+
React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true, className: "pfext-quick-start-tile-prerequisites__icon", "data-testid": "qs-card-prereqs", onClick: (e) => {
|
|
1671
|
+
e.preventDefault();
|
|
1672
|
+
e.stopPropagation();
|
|
1673
|
+
}, "aria-label": getResource('Show prerequisites') },
|
|
1674
|
+
React__namespace.createElement(InfoCircleIcon__default['default'], null)))))));
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
const QuickStartTileFooter = ({ quickStartId, status, totalTasks, }) => {
|
|
1678
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1679
|
+
const { activeQuickStartID, startQuickStart, restartQuickStart } = React__namespace.useContext(QuickStartContext);
|
|
1680
|
+
const start = React__namespace.useCallback((e) => {
|
|
1681
|
+
e.preventDefault();
|
|
1682
|
+
e.stopPropagation();
|
|
1683
|
+
startQuickStart(quickStartId, totalTasks);
|
|
1684
|
+
}, [quickStartId, startQuickStart, totalTasks]);
|
|
1685
|
+
const restart = React__namespace.useCallback((e) => {
|
|
1686
|
+
e.preventDefault();
|
|
1687
|
+
e.stopPropagation();
|
|
1688
|
+
restartQuickStart(quickStartId, totalTasks);
|
|
1689
|
+
}, [quickStartId, restartQuickStart, totalTasks]);
|
|
1690
|
+
return (React__namespace.createElement(reactCore.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
|
|
1691
|
+
status === exports.QuickStartStatus.NOT_STARTED && (React__namespace.createElement(reactCore.FlexItem, null,
|
|
1692
|
+
React__namespace.createElement(reactCore.Button, { onClick: start, variant: "link", isInline: true, "data-testid": "qs-card-notStarted-start", id: `${quickStartId}-start`, "aria-labelledby": `${quickStartId}-start ${quickStartId}` }, getResource('Start')))),
|
|
1693
|
+
status === exports.QuickStartStatus.IN_PROGRESS && activeQuickStartID !== quickStartId && (React__namespace.createElement(reactCore.FlexItem, null,
|
|
1694
|
+
React__namespace.createElement(reactCore.Button, { variant: "link", isInline: true, "data-testid": "qs-card-inProgress-resume", id: `${quickStartId}-continue`, "aria-labelledby": `${quickStartId}-continue ${quickStartId}` }, getResource('Continue')))),
|
|
1695
|
+
status === exports.QuickStartStatus.COMPLETE && (React__namespace.createElement(reactCore.FlexItem, null,
|
|
1696
|
+
React__namespace.createElement(reactCore.Button, { onClick: restart, variant: "link", isInline: true, "data-testid": "qs-card-complete-restart", id: `${quickStartId}-restart`, "aria-labelledby": `${quickStartId}-restart ${quickStartId}` }, getResource('Restart')))),
|
|
1697
|
+
status === exports.QuickStartStatus.IN_PROGRESS && (React__namespace.createElement(reactCore.FlexItem, null,
|
|
1698
|
+
React__namespace.createElement(reactCore.Button, { onClick: restart, variant: "link", isInline: true, "data-testid": "qs-card-inProgress-restart", id: `${quickStartId}-restart`, "aria-labelledby": `${quickStartId}-restart ${quickStartId}` }, getResource('Restart'))))));
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
const QuickStartTileFooterExternal = ({ link, quickStartId, }) => {
|
|
1702
|
+
const { href, text } = link;
|
|
1703
|
+
return (React__namespace.createElement(reactCore.Flex, { justifyContent: { default: 'justifyContentSpaceBetween' } },
|
|
1704
|
+
React__namespace.createElement(reactCore.FlexItem, null,
|
|
1705
|
+
React__namespace.createElement(reactCore.Button, { component: "a", href: href, target: "_blank", rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: React__namespace.createElement(ExternalLinkAltIcon__default['default'], null), iconPosition: "right", id: quickStartId, "aria-labelledby": `${quickStartId}-external ${quickStartId}` }, text || href))));
|
|
1706
|
+
};
|
|
1707
|
+
|
|
1708
|
+
const statusColorMap = {
|
|
1709
|
+
[exports.QuickStartStatus.COMPLETE]: 'green',
|
|
1710
|
+
[exports.QuickStartStatus.IN_PROGRESS]: 'purple',
|
|
1711
|
+
[exports.QuickStartStatus.NOT_STARTED]: 'grey',
|
|
1712
|
+
};
|
|
1713
|
+
const QuickStartTileHeader = ({ status, duration, name, type, quickStartId, }) => {
|
|
1714
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1715
|
+
const statusLocaleMap = {
|
|
1716
|
+
[exports.QuickStartStatus.COMPLETE]: getResource('Complete'),
|
|
1717
|
+
[exports.QuickStartStatus.IN_PROGRESS]: getResource('In progress'),
|
|
1718
|
+
[exports.QuickStartStatus.NOT_STARTED]: getResource('Not started'),
|
|
1719
|
+
};
|
|
1720
|
+
return (React__namespace.createElement("div", { className: "pfext-quick-start-tile-header" },
|
|
1721
|
+
React__namespace.createElement(reactCore.Title, { headingLevel: "h3", "data-test": "title", id: quickStartId },
|
|
1722
|
+
React__namespace.createElement(QuickStartMarkdownView, { content: name })),
|
|
1723
|
+
React__namespace.createElement("div", { className: "pfext-quick-start-tile-header__status" },
|
|
1724
|
+
type && (React__namespace.createElement(reactCore.Label, { className: "pfext-quick-start-tile-header--margin", color: type.color }, type.text)),
|
|
1725
|
+
duration && (React__namespace.createElement(reactCore.Label, { variant: "outline", "data-test": "duration", icon: React__namespace.createElement(OutlinedClockIcon__default['default'], null), className: "pfext-quick-start-tile-header--margin" }, getResource('{{duration, number}} minutes', duration).replace('{{duration, number}}', duration))),
|
|
1726
|
+
status !== exports.QuickStartStatus.NOT_STARTED && (React__namespace.createElement(reactCore.Label, { variant: "outline", color: statusColorMap[status], icon: React__namespace.createElement(StatusIcon, { status: status }), "data-test": "status" }, statusLocaleMap[status])))));
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, }) => {
|
|
1730
|
+
const { metadata: { name: id }, spec: { icon, tasks, displayName, description, durationMinutes, prerequisites, link, type }, } = quickStart;
|
|
1731
|
+
const { setActiveQuickStart, footer } = React__namespace.useContext(QuickStartContext);
|
|
1732
|
+
const ref = React__namespace.useRef(null);
|
|
1733
|
+
let quickStartIcon;
|
|
1734
|
+
if (typeof icon === 'object') {
|
|
1735
|
+
quickStartIcon = icon;
|
|
1736
|
+
}
|
|
1737
|
+
else {
|
|
1738
|
+
quickStartIcon = (React__namespace.createElement(FallbackImg, { className: "pfext-catalog-item-icon__img--large", src: icon, alt: "", fallback: React__namespace.createElement(RocketIcon__default['default'], null) }));
|
|
1739
|
+
}
|
|
1740
|
+
const footerComponent = React__namespace.useMemo(() => {
|
|
1741
|
+
if (footer && footer.show === false) {
|
|
1742
|
+
return null;
|
|
1743
|
+
}
|
|
1744
|
+
if (link) {
|
|
1745
|
+
return React__namespace.createElement(QuickStartTileFooterExternal, { link: link, quickStartId: id });
|
|
1746
|
+
}
|
|
1747
|
+
return React__namespace.createElement(QuickStartTileFooter, { quickStartId: id, status: status, totalTasks: tasks === null || tasks === void 0 ? void 0 : tasks.length });
|
|
1748
|
+
}, [footer, id, link, status, tasks === null || tasks === void 0 ? void 0 : tasks.length]);
|
|
1749
|
+
const handleClick = (e) => {
|
|
1750
|
+
var _a;
|
|
1751
|
+
if ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.contains(e.target)) {
|
|
1752
|
+
if (link) {
|
|
1753
|
+
window.open(link.href);
|
|
1754
|
+
}
|
|
1755
|
+
else {
|
|
1756
|
+
setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
|
|
1757
|
+
}
|
|
1758
|
+
onClick();
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
return (React__namespace.createElement("div", { ref: ref },
|
|
1762
|
+
React__namespace.createElement(CatalogTile, { id: id + '-catalog-tile', style: {
|
|
1763
|
+
cursor: 'pointer',
|
|
1764
|
+
}, icon: quickStartIcon, className: "pfext-quick-start-tile", "data-testid": `qs-card-${camelize(displayName)}`, featured: isActive, title: React__namespace.createElement(QuickStartTileHeader, { name: displayName, status: status, duration: durationMinutes, type: type, quickStartId: id }), onClick: handleClick, onKeyDown: (event) => {
|
|
1765
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
1766
|
+
setActiveQuickStart(id, tasks === null || tasks === void 0 ? void 0 : tasks.length);
|
|
1767
|
+
onClick();
|
|
1768
|
+
}
|
|
1769
|
+
},
|
|
1770
|
+
// https://github.com/patternfly/patternfly-react/issues/7039
|
|
1771
|
+
href: link === null || link === void 0 ? void 0 : link.href, "data-test": `tile ${id}`, description: React__namespace.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent, tabIndex: 0 })));
|
|
1772
|
+
};
|
|
1773
|
+
|
|
1774
|
+
const QuickStartCatalog = ({ quickStarts }) => {
|
|
1775
|
+
const { activeQuickStartID, allQuickStartStates } = React__namespace.useContext(QuickStartContext);
|
|
1776
|
+
return (React__namespace.createElement("div", { className: "pfext-page-layout__content" },
|
|
1777
|
+
React__namespace.createElement(reactCore.Gallery, { className: "pfext-quick-start-catalog__gallery", hasGutter: true }, quickStarts.map((quickStart) => {
|
|
1778
|
+
const { metadata: { name: id }, } = quickStart;
|
|
1779
|
+
return (React__namespace.createElement(reactCore.GalleryItem, { key: id, className: "pfext-quick-start-catalog__gallery-item" },
|
|
1780
|
+
React__namespace.createElement(QuickStartTile, { quickStart: quickStart, isActive: id === activeQuickStartID, status: getQuickStartStatus(allQuickStartStates, id) })));
|
|
1781
|
+
}))));
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
const QuickStartCatalogFilterSearch = (_a) => {
|
|
1785
|
+
var { searchInputText, handleTextChange } = _a, props = tslib.__rest(_a, ["searchInputText", "handleTextChange"]);
|
|
1786
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1787
|
+
return (React__namespace.createElement(reactCore.ToolbarItem, { className: "pfext-quick-start-catalog-filter__input" },
|
|
1788
|
+
React__namespace.createElement(reactCore.SearchInput, Object.assign({ placeholder: getResource('Filter by keyword...'), value: searchInputText, onChange: (_ev, value) => handleTextChange(value), onClear: () => handleTextChange('') }, props))));
|
|
1789
|
+
};
|
|
1790
|
+
const QuickStartCatalogFilterSelect = (_a) => {
|
|
1791
|
+
var { isDropdownOpen, setIsDropdownOpen, onRowfilterSelect, selectedFilters, dropdownItems } = _a, props = tslib.__rest(_a, ["isDropdownOpen", "setIsDropdownOpen", "onRowfilterSelect", "selectedFilters", "dropdownItems"]);
|
|
1792
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1793
|
+
const toggle = (toggleRef) => (React__namespace.createElement(reactCore.MenuToggle, { isFullWidth: true, ref: toggleRef, onClick: () => setIsDropdownOpen(!isDropdownOpen), isExpanded: isDropdownOpen },
|
|
1794
|
+
getResource('Status'),
|
|
1795
|
+
selectedFilters.length > 0 && React__namespace.createElement(reactCore.Badge, { isRead: true }, selectedFilters.length)));
|
|
1796
|
+
return (React__namespace.createElement(reactCore.ToolbarItem, null,
|
|
1797
|
+
React__namespace.createElement(reactCore.Select, Object.assign({ "aria-label": getResource('Select filter'), isOpen: isDropdownOpen, selected: selectedFilters, onSelect: onRowfilterSelect, onOpenChange: (isOpen) => setIsDropdownOpen(isOpen), toggle: toggle }, props),
|
|
1798
|
+
React__namespace.createElement(reactCore.SelectList, null, dropdownItems))));
|
|
1799
|
+
};
|
|
1800
|
+
const QuickStartCatalogFilterCount = ({ quickStartsCount }) => {
|
|
1801
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1802
|
+
return (React__namespace.createElement(reactCore.ToolbarItem, { className: "pfext-quick-start-catalog-filter__count", align: { default: 'alignRight' } }, getResource('{{count, number}} item', quickStartsCount).replace('{{count, number}}', quickStartsCount)));
|
|
1803
|
+
};
|
|
1804
|
+
const QuickStartCatalogFilterSearchWrapper = ({ onSearchInputChange = () => { } }) => {
|
|
1805
|
+
const { useQueryParams, filter, setFilter } = React__namespace.useContext(QuickStartContext);
|
|
1806
|
+
React__namespace.useEffect(() => {
|
|
1807
|
+
// use this effect to clear the search when a `clear all` action is performed higher up
|
|
1808
|
+
const unlisten = history.listen(({ location }) => {
|
|
1809
|
+
const searchParams = new URLSearchParams(location.search);
|
|
1810
|
+
const searchQuery = searchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
|
|
1811
|
+
if (searchQuery === '') {
|
|
1812
|
+
setFilter('keyword', '');
|
|
1813
|
+
onSearchInputChange('');
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
return () => {
|
|
1817
|
+
unlisten();
|
|
1818
|
+
};
|
|
1819
|
+
}, [onSearchInputChange, setFilter]);
|
|
1820
|
+
const handleTextChange = (val) => {
|
|
1821
|
+
if (val.length > 0) {
|
|
1822
|
+
useQueryParams && setQueryArgument(QUICKSTART_SEARCH_FILTER_KEY, val);
|
|
1823
|
+
}
|
|
1824
|
+
else {
|
|
1825
|
+
useQueryParams && removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
|
|
1826
|
+
}
|
|
1827
|
+
if ((filter === null || filter === void 0 ? void 0 : filter.keyword) !== val) {
|
|
1828
|
+
setFilter('keyword', val);
|
|
1829
|
+
}
|
|
1830
|
+
onSearchInputChange(val);
|
|
1831
|
+
};
|
|
1832
|
+
return (React__namespace.createElement(QuickStartCatalogFilterSearch, { searchInputText: filter === null || filter === void 0 ? void 0 : filter.keyword, handleTextChange: handleTextChange }));
|
|
1833
|
+
};
|
|
1834
|
+
// compare string/number arrays
|
|
1835
|
+
const equalsIgnoreOrder = (a, b) => {
|
|
1836
|
+
if (a.length !== b.length) {
|
|
1837
|
+
return false;
|
|
1838
|
+
}
|
|
1839
|
+
const uniqueValues = new Set([...a, ...b]);
|
|
1840
|
+
for (const v of uniqueValues) {
|
|
1841
|
+
const aCount = a.filter((e) => e === v).length;
|
|
1842
|
+
const bCount = b.filter((e) => e === v).length;
|
|
1843
|
+
if (aCount !== bCount) {
|
|
1844
|
+
return false;
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
return true;
|
|
1848
|
+
};
|
|
1849
|
+
const QuickStartCatalogFilterStatusWrapper = ({ onStatusChange = () => { } }) => {
|
|
1850
|
+
const { useQueryParams, filter, setFilter } = React__namespace.useContext(QuickStartContext);
|
|
1851
|
+
React__namespace.useEffect(() => {
|
|
1852
|
+
// use this effect to clear the status when a `clear all` action is performed higher up
|
|
1853
|
+
const unlisten = history.listen(({ location }) => {
|
|
1854
|
+
var _a;
|
|
1855
|
+
const searchParams = new URLSearchParams(location.search);
|
|
1856
|
+
const updatedStatusFilters = ((_a = searchParams.get(QUICKSTART_STATUS_FILTER_KEY)) === null || _a === void 0 ? void 0 : _a.split(',')) || [];
|
|
1857
|
+
if (updatedStatusFilters.length === 0) {
|
|
1858
|
+
setFilter('status', []);
|
|
1859
|
+
onStatusChange([]);
|
|
1860
|
+
}
|
|
1861
|
+
});
|
|
1862
|
+
return () => {
|
|
1863
|
+
unlisten();
|
|
1864
|
+
};
|
|
1865
|
+
});
|
|
1866
|
+
const [isDropdownOpen, setIsDropdownOpen] = React__namespace.useState(false);
|
|
1867
|
+
const onRowfilterSelect = React__namespace.useCallback((_e, selectedValue) => {
|
|
1868
|
+
setIsDropdownOpen(false);
|
|
1869
|
+
const selection = Object.entries(filter.status.statusTypes).find(([_key, value]) => value === selectedValue)[0];
|
|
1870
|
+
const selectedFiltersList = filter.status.statusFilters.includes(selection)
|
|
1871
|
+
? filter.status.statusFilters.filter((status) => status !== selection)
|
|
1872
|
+
: [...filter.status.statusFilters, selection];
|
|
1873
|
+
if (!equalsIgnoreOrder(filter.status.statusFilters, selectedFiltersList)) {
|
|
1874
|
+
setFilter('status', selectedFiltersList);
|
|
1875
|
+
}
|
|
1876
|
+
if (selectedFiltersList.length > 0) {
|
|
1877
|
+
useQueryParams && setQueryArgument('status', selectedFiltersList.join(','));
|
|
1878
|
+
}
|
|
1879
|
+
else {
|
|
1880
|
+
useQueryParams && removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
|
|
1881
|
+
}
|
|
1882
|
+
onStatusChange(selectedFiltersList);
|
|
1883
|
+
}, [filter.status.statusFilters, onStatusChange, setFilter, useQueryParams]);
|
|
1884
|
+
const dropdownItems = Object.entries(filter.status.statusTypes).map(([key, value]) => (React__namespace.createElement(reactCore.SelectOption, { key: key, "data-key": key, value: value, hasCheckbox: true, isSelected: filter.status.statusFilters.includes(key) },
|
|
1885
|
+
React__namespace.createElement(React__namespace.Fragment, null, value))));
|
|
1886
|
+
return (React__namespace.createElement(QuickStartCatalogFilterSelect, { isDropdownOpen: isDropdownOpen, setIsDropdownOpen: setIsDropdownOpen, onRowfilterSelect: onRowfilterSelect, selectedFilters: filter.status.statusFilters, dropdownItems: dropdownItems }));
|
|
1887
|
+
};
|
|
1888
1888
|
const QuickStartCatalogFilterCountWrapper = ({ quickStartsCount }) => React__namespace.createElement(QuickStartCatalogFilterCount, { quickStartsCount: quickStartsCount });
|
|
1889
1889
|
|
|
1890
|
-
const QuickStartCatalogFilter = (_a) => {
|
|
1891
|
-
var { quickStartsCount, onSearchInputChange = () => { }, onStatusChange = () => { } } = _a, props = tslib.__rest(_a, ["quickStartsCount", "onSearchInputChange", "onStatusChange"]);
|
|
1892
|
-
return (React__namespace.createElement(reactCore.Toolbar, Object.assign({ usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, props),
|
|
1893
|
-
React__namespace.createElement(reactCore.ToolbarContent, null,
|
|
1894
|
-
React__namespace.createElement(QuickStartCatalogFilterSearchWrapper, { onSearchInputChange: onSearchInputChange }),
|
|
1895
|
-
React__namespace.createElement(QuickStartCatalogFilterStatusWrapper, { onStatusChange: onStatusChange }),
|
|
1896
|
-
React__namespace.createElement(QuickStartCatalogFilterCountWrapper, { quickStartsCount: quickStartsCount }))));
|
|
1897
|
-
};
|
|
1898
|
-
|
|
1899
|
-
const QuickStartCatalogEmptyState = ({ clearFilters }) => {
|
|
1900
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1901
|
-
return (React__namespace.createElement(reactCore.EmptyState, null,
|
|
1902
|
-
React__namespace.createElement(reactCore.EmptyStateHeader, { titleText: React__namespace.createElement(React__namespace.Fragment, null, getResource('No results found')), icon: React__namespace.createElement(reactCore.EmptyStateIcon, { icon: SearchIcon__default['default'] }), headingLevel: "h4" }),
|
|
1903
|
-
React__namespace.createElement(reactCore.EmptyStateBody, null, getResource('No results match the filter criteria. Remove filters or clear all filters to show results.')),
|
|
1904
|
-
React__namespace.createElement(reactCore.EmptyStateFooter, null,
|
|
1905
|
-
React__namespace.createElement(reactCore.EmptyStateActions, null,
|
|
1906
|
-
React__namespace.createElement(reactCore.Button, { variant: "link", onClick: clearFilters, "data-test": "clear-filter button" }, getResource('Clear all filters'))))));
|
|
1907
|
-
};
|
|
1908
|
-
const QuickStartCatalogPage = ({ quickStarts, showFilter, sortFnc = (q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName), title, hint, showTitle = true, }) => {
|
|
1909
|
-
const sortFncCallback = React__namespace.useCallback(sortFnc, [sortFnc]);
|
|
1910
|
-
const { allQuickStarts = [], setAllQuickStarts, allQuickStartStates, getResource, filter, setFilter, loading, } = React__namespace.useContext(QuickStartContext);
|
|
1911
|
-
React__namespace.useEffect(() => {
|
|
1912
|
-
// passed through prop, not context
|
|
1913
|
-
if (quickStarts && JSON.stringify(quickStarts) !== JSON.stringify(allQuickStarts)) {
|
|
1914
|
-
setAllQuickStarts(quickStarts);
|
|
1915
|
-
}
|
|
1916
|
-
}, [quickStarts, allQuickStarts, setAllQuickStarts]);
|
|
1917
|
-
const initialFilteredQuickStarts = showFilter
|
|
1918
|
-
? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
|
|
1919
|
-
: allQuickStarts;
|
|
1920
|
-
const [filteredQuickStarts, setFilteredQuickStarts] = React__namespace.useState(initialFilteredQuickStarts);
|
|
1921
|
-
React__namespace.useEffect(() => {
|
|
1922
|
-
const filteredQs = showFilter
|
|
1923
|
-
? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
|
|
1924
|
-
: allQuickStarts;
|
|
1925
|
-
// also needs a check whether the content of the QS changed
|
|
1926
|
-
if (filteredQs.length !== filteredQuickStarts.length ||
|
|
1927
|
-
JSON.stringify(filteredQs) !== JSON.stringify(filteredQuickStarts)) {
|
|
1928
|
-
setFilteredQuickStarts(filteredQs);
|
|
1929
|
-
}
|
|
1930
|
-
}, [
|
|
1931
|
-
allQuickStarts,
|
|
1932
|
-
allQuickStartStates,
|
|
1933
|
-
showFilter,
|
|
1934
|
-
filter.keyword,
|
|
1935
|
-
filter.status.statusFilters,
|
|
1936
|
-
sortFncCallback,
|
|
1937
|
-
filteredQuickStarts,
|
|
1938
|
-
]);
|
|
1939
|
-
const clearFilters = () => {
|
|
1940
|
-
setFilter('keyword', '');
|
|
1941
|
-
setFilter('status', []);
|
|
1942
|
-
clearFilterParams();
|
|
1943
|
-
setFilteredQuickStarts(allQuickStarts.sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName)));
|
|
1944
|
-
};
|
|
1945
|
-
const onSearchInputChange = (searchValue) => {
|
|
1946
|
-
const result = filterQuickStarts(allQuickStarts, searchValue, filter.status.statusFilters, allQuickStartStates).sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName));
|
|
1947
|
-
if (searchValue !== filter.keyword) {
|
|
1948
|
-
setFilter('keyword', searchValue);
|
|
1949
|
-
}
|
|
1950
|
-
if (result.length !== filteredQuickStarts.length) {
|
|
1951
|
-
setFilteredQuickStarts(result);
|
|
1952
|
-
}
|
|
1953
|
-
};
|
|
1954
|
-
const onStatusChange = (statusList) => {
|
|
1955
|
-
const result = filterQuickStarts(allQuickStarts, filter.keyword, statusList, allQuickStartStates).sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName));
|
|
1956
|
-
if (JSON.stringify(statusList) !== JSON.stringify(filter.status)) {
|
|
1957
|
-
setFilter('status', statusList);
|
|
1958
|
-
}
|
|
1959
|
-
if (result.length !== filteredQuickStarts.length) {
|
|
1960
|
-
setFilteredQuickStarts(result);
|
|
1961
|
-
}
|
|
1962
|
-
};
|
|
1963
|
-
if (loading) {
|
|
1964
|
-
return React__namespace.createElement(LoadingBox, null);
|
|
1965
|
-
}
|
|
1966
|
-
if (!allQuickStarts || allQuickStarts.length === 0) {
|
|
1967
|
-
return React__namespace.createElement(EmptyBox, { label: getResource('Quick Starts') });
|
|
1968
|
-
}
|
|
1969
|
-
return (React__namespace.createElement("div", { className: "pfext-quick-start__base" },
|
|
1970
|
-
showTitle && (React__namespace.createElement("div", { className: "pfext-page-layout__header" },
|
|
1971
|
-
React__namespace.createElement(reactCore.Text, { component: "h1", className: "pfext-page-layout__title", "data-test": "page-title" }, title || getResource('Quick Starts')),
|
|
1972
|
-
hint && React__namespace.createElement("div", { className: "pfext-page-layout__hint" }, hint))),
|
|
1973
|
-
showTitle && React__namespace.createElement(reactCore.Divider, { component: "div" }),
|
|
1974
|
-
showFilter && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1975
|
-
React__namespace.createElement(QuickStartCatalogFilter, { quickStartsCount: filteredQuickStarts.length, onSearchInputChange: onSearchInputChange, onStatusChange: onStatusChange }),
|
|
1976
|
-
React__namespace.createElement(reactCore.Divider, { component: "div" }))),
|
|
1977
|
-
React__namespace.createElement(React__namespace.Fragment, null, filteredQuickStarts.length === 0 ? (React__namespace.createElement(QuickStartCatalogEmptyState, { clearFilters: clearFilters })) : (React__namespace.createElement(QuickStartCatalog, { quickStarts: filteredQuickStarts })))));
|
|
1978
|
-
};
|
|
1979
|
-
|
|
1980
|
-
const QuickStartCatalogHeader = ({ title, hint, }) => (React__namespace.createElement("div", { className: "pfext-page-layout__header" },
|
|
1981
|
-
React__namespace.createElement("h1", { "data-pf-content": "true", className: "pfext-page-layout__title" }, title),
|
|
1890
|
+
const QuickStartCatalogFilter = (_a) => {
|
|
1891
|
+
var { quickStartsCount, onSearchInputChange = () => { }, onStatusChange = () => { } } = _a, props = tslib.__rest(_a, ["quickStartsCount", "onSearchInputChange", "onStatusChange"]);
|
|
1892
|
+
return (React__namespace.createElement(reactCore.Toolbar, Object.assign({ usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, props),
|
|
1893
|
+
React__namespace.createElement(reactCore.ToolbarContent, null,
|
|
1894
|
+
React__namespace.createElement(QuickStartCatalogFilterSearchWrapper, { onSearchInputChange: onSearchInputChange }),
|
|
1895
|
+
React__namespace.createElement(QuickStartCatalogFilterStatusWrapper, { onStatusChange: onStatusChange }),
|
|
1896
|
+
React__namespace.createElement(QuickStartCatalogFilterCountWrapper, { quickStartsCount: quickStartsCount }))));
|
|
1897
|
+
};
|
|
1898
|
+
|
|
1899
|
+
const QuickStartCatalogEmptyState = ({ clearFilters }) => {
|
|
1900
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1901
|
+
return (React__namespace.createElement(reactCore.EmptyState, null,
|
|
1902
|
+
React__namespace.createElement(reactCore.EmptyStateHeader, { titleText: React__namespace.createElement(React__namespace.Fragment, null, getResource('No results found')), icon: React__namespace.createElement(reactCore.EmptyStateIcon, { icon: SearchIcon__default['default'] }), headingLevel: "h4" }),
|
|
1903
|
+
React__namespace.createElement(reactCore.EmptyStateBody, null, getResource('No results match the filter criteria. Remove filters or clear all filters to show results.')),
|
|
1904
|
+
React__namespace.createElement(reactCore.EmptyStateFooter, null,
|
|
1905
|
+
React__namespace.createElement(reactCore.EmptyStateActions, null,
|
|
1906
|
+
React__namespace.createElement(reactCore.Button, { variant: "link", onClick: clearFilters, "data-test": "clear-filter button" }, getResource('Clear all filters'))))));
|
|
1907
|
+
};
|
|
1908
|
+
const QuickStartCatalogPage = ({ quickStarts, showFilter, sortFnc = (q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName), title, hint, showTitle = true, }) => {
|
|
1909
|
+
const sortFncCallback = React__namespace.useCallback(sortFnc, [sortFnc]);
|
|
1910
|
+
const { allQuickStarts = [], setAllQuickStarts, allQuickStartStates, getResource, filter, setFilter, loading, } = React__namespace.useContext(QuickStartContext);
|
|
1911
|
+
React__namespace.useEffect(() => {
|
|
1912
|
+
// passed through prop, not context
|
|
1913
|
+
if (quickStarts && JSON.stringify(quickStarts) !== JSON.stringify(allQuickStarts)) {
|
|
1914
|
+
setAllQuickStarts(quickStarts);
|
|
1915
|
+
}
|
|
1916
|
+
}, [quickStarts, allQuickStarts, setAllQuickStarts]);
|
|
1917
|
+
const initialFilteredQuickStarts = showFilter
|
|
1918
|
+
? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
|
|
1919
|
+
: allQuickStarts;
|
|
1920
|
+
const [filteredQuickStarts, setFilteredQuickStarts] = React__namespace.useState(initialFilteredQuickStarts);
|
|
1921
|
+
React__namespace.useEffect(() => {
|
|
1922
|
+
const filteredQs = showFilter
|
|
1923
|
+
? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
|
|
1924
|
+
: allQuickStarts;
|
|
1925
|
+
// also needs a check whether the content of the QS changed
|
|
1926
|
+
if (filteredQs.length !== filteredQuickStarts.length ||
|
|
1927
|
+
JSON.stringify(filteredQs) !== JSON.stringify(filteredQuickStarts)) {
|
|
1928
|
+
setFilteredQuickStarts(filteredQs);
|
|
1929
|
+
}
|
|
1930
|
+
}, [
|
|
1931
|
+
allQuickStarts,
|
|
1932
|
+
allQuickStartStates,
|
|
1933
|
+
showFilter,
|
|
1934
|
+
filter.keyword,
|
|
1935
|
+
filter.status.statusFilters,
|
|
1936
|
+
sortFncCallback,
|
|
1937
|
+
filteredQuickStarts,
|
|
1938
|
+
]);
|
|
1939
|
+
const clearFilters = () => {
|
|
1940
|
+
setFilter('keyword', '');
|
|
1941
|
+
setFilter('status', []);
|
|
1942
|
+
clearFilterParams();
|
|
1943
|
+
setFilteredQuickStarts(allQuickStarts.sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName)));
|
|
1944
|
+
};
|
|
1945
|
+
const onSearchInputChange = (searchValue) => {
|
|
1946
|
+
const result = filterQuickStarts(allQuickStarts, searchValue, filter.status.statusFilters, allQuickStartStates).sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName));
|
|
1947
|
+
if (searchValue !== filter.keyword) {
|
|
1948
|
+
setFilter('keyword', searchValue);
|
|
1949
|
+
}
|
|
1950
|
+
if (result.length !== filteredQuickStarts.length) {
|
|
1951
|
+
setFilteredQuickStarts(result);
|
|
1952
|
+
}
|
|
1953
|
+
};
|
|
1954
|
+
const onStatusChange = (statusList) => {
|
|
1955
|
+
const result = filterQuickStarts(allQuickStarts, filter.keyword, statusList, allQuickStartStates).sort((q1, q2) => q1.spec.displayName.localeCompare(q2.spec.displayName));
|
|
1956
|
+
if (JSON.stringify(statusList) !== JSON.stringify(filter.status)) {
|
|
1957
|
+
setFilter('status', statusList);
|
|
1958
|
+
}
|
|
1959
|
+
if (result.length !== filteredQuickStarts.length) {
|
|
1960
|
+
setFilteredQuickStarts(result);
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
if (loading) {
|
|
1964
|
+
return React__namespace.createElement(LoadingBox, null);
|
|
1965
|
+
}
|
|
1966
|
+
if (!allQuickStarts || allQuickStarts.length === 0) {
|
|
1967
|
+
return React__namespace.createElement(EmptyBox, { label: getResource('Quick Starts') });
|
|
1968
|
+
}
|
|
1969
|
+
return (React__namespace.createElement("div", { className: "pfext-quick-start__base" },
|
|
1970
|
+
showTitle && (React__namespace.createElement("div", { className: "pfext-page-layout__header" },
|
|
1971
|
+
React__namespace.createElement(reactCore.Text, { component: "h1", className: "pfext-page-layout__title", "data-test": "page-title" }, title || getResource('Quick Starts')),
|
|
1972
|
+
hint && React__namespace.createElement("div", { className: "pfext-page-layout__hint" }, hint))),
|
|
1973
|
+
showTitle && React__namespace.createElement(reactCore.Divider, { component: "div" }),
|
|
1974
|
+
showFilter && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1975
|
+
React__namespace.createElement(QuickStartCatalogFilter, { quickStartsCount: filteredQuickStarts.length, onSearchInputChange: onSearchInputChange, onStatusChange: onStatusChange }),
|
|
1976
|
+
React__namespace.createElement(reactCore.Divider, { component: "div" }))),
|
|
1977
|
+
React__namespace.createElement(React__namespace.Fragment, null, filteredQuickStarts.length === 0 ? (React__namespace.createElement(QuickStartCatalogEmptyState, { clearFilters: clearFilters })) : (React__namespace.createElement(QuickStartCatalog, { quickStarts: filteredQuickStarts })))));
|
|
1978
|
+
};
|
|
1979
|
+
|
|
1980
|
+
const QuickStartCatalogHeader = ({ title, hint, }) => (React__namespace.createElement("div", { className: "pfext-page-layout__header" },
|
|
1981
|
+
React__namespace.createElement("h1", { "data-pf-content": "true", className: "pfext-page-layout__title" }, title),
|
|
1982
1982
|
hint && React__namespace.createElement("div", { className: "pfext-page-layout__hint" }, hint)));
|
|
1983
1983
|
|
|
1984
1984
|
const QuickStartCatalogSection = ({ children }) => (React__namespace.createElement("div", { className: "pfext-page-layout__content" }, children));
|
|
1985
1985
|
|
|
1986
1986
|
const QuickStartCatalogToolbar = ({ children }) => (React__namespace.createElement(reactCore.Toolbar, { usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, children));
|
|
1987
1987
|
|
|
1988
|
-
const QuickStartCloseModal = ({ isOpen, onConfirm, onCancel, }) => {
|
|
1989
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1990
|
-
return (React__namespace.createElement(Modal, { className: "pfext-quick-start-drawer__modal pfext-quick-start__base", isOpen: isOpen, variant: reactCore.ModalVariant.small, showClose: false, "data-test": "leave-quickstart", title: getResource('Leave quick start?'), footer: React__namespace.createElement(reactCore.Flex, null,
|
|
1991
|
-
React__namespace.createElement(reactCore.FlexItem, { align: { default: 'alignRight' } },
|
|
1992
|
-
React__namespace.createElement(reactCore.Button, { variant: "secondary", "data-test": "cancel button", onClick: onCancel }, getResource('Cancel'))),
|
|
1993
|
-
React__namespace.createElement(reactCore.FlexItem, null,
|
|
1994
|
-
React__namespace.createElement(reactCore.Button, { variant: "primary", "data-test": "leave button", onClick: onConfirm }, getResource('Leave')))), isFullScreen: true }, getResource('Your progress will be saved.')));
|
|
1995
|
-
};
|
|
1996
|
-
|
|
1997
|
-
const TaskIcon = ({ taskIndex, taskStatus }) => {
|
|
1998
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1999
|
-
const success = taskStatus === exports.QuickStartTaskStatus.SUCCESS;
|
|
2000
|
-
const failed = taskStatus === exports.QuickStartTaskStatus.FAILED;
|
|
2001
|
-
const classNames = reactStyles.css('pfext-icon-and-text__icon', {
|
|
2002
|
-
'pfext-quick-start-task-header__task-icon-init': !failed && !success,
|
|
2003
|
-
});
|
|
2004
|
-
let content;
|
|
2005
|
-
if (success) {
|
|
2006
|
-
content = (React__namespace.createElement(reactCore.Icon, { size: "md" },
|
|
2007
|
-
React__namespace.createElement(CheckCircleIcon__default['default'], { className: "pfext-quick-start-task-header__task-icon-success" }),
|
|
2008
|
-
' '));
|
|
2009
|
-
}
|
|
2010
|
-
else if (failed) {
|
|
2011
|
-
content = (React__namespace.createElement(reactCore.Icon, { size: "md" },
|
|
2012
|
-
React__namespace.createElement(ExclamationCircleIcon__default['default'], { className: "pfext-quick-start-task-header__task-icon-failed" })));
|
|
2013
|
-
}
|
|
2014
|
-
else {
|
|
2015
|
-
content = getResource('{{taskIndex, number}}', taskIndex).replace('{{taskIndex, number}}', taskIndex);
|
|
2016
|
-
}
|
|
2017
|
-
return React__namespace.createElement("span", { className: classNames }, content);
|
|
2018
|
-
};
|
|
2019
|
-
const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
|
|
2020
|
-
const titleRef = React__namespace.useRef(null);
|
|
2021
|
-
React__namespace.useEffect(() => {
|
|
2022
|
-
if (isActiveTask) {
|
|
2023
|
-
// Focus the WizardNavItem button element that contains the title
|
|
2024
|
-
titleRef.current.parentNode.focus();
|
|
2025
|
-
}
|
|
2026
|
-
}, [isActiveTask]);
|
|
2027
|
-
const classNames = reactStyles.css('pfext-quick-start-task-header__title', {
|
|
2028
|
-
'pfext-quick-start-task-header__title-success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
|
|
2029
|
-
'pfext-quick-start-task-header__title-failed': taskStatus === (exports.QuickStartTaskStatus.FAILED || exports.QuickStartTaskStatus.VISITED),
|
|
2030
|
-
});
|
|
2031
|
-
// const notCompleted = taskStatus === QuickStartTaskStatus.VISITED;
|
|
2032
|
-
// const skippedReview = taskStatus === QuickStartTaskStatus.REVIEW;
|
|
2033
|
-
const failedReview = taskStatus === exports.QuickStartTaskStatus.FAILED;
|
|
2034
|
-
// TODO: toned down when this is shown, investigate further when we should display it
|
|
2035
|
-
// related: https://github.com/patternfly/patternfly-quickstarts/issues/104
|
|
2036
|
-
const tryAgain = failedReview && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2037
|
-
React__namespace.createElement("div", null),
|
|
2038
|
-
React__namespace.createElement("div", { className: "pfext-quick-start-task-header__tryagain" }, "Try the steps again.")));
|
|
2039
|
-
const content = (React__namespace.createElement("div", { className: "pfext-quick-start-task-header", ref: titleRef },
|
|
2040
|
-
React__namespace.createElement(TaskIcon, { taskIndex: taskIndex, taskStatus: taskStatus }),
|
|
2041
|
-
React__namespace.createElement(reactCore.Title, { headingLevel: "h3", size: size, className: classNames },
|
|
2042
|
-
React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: removeParagraphWrap(markdownConvert(title)) } }),
|
|
2043
|
-
isActiveTask && subtitle && (React__namespace.createElement("span", { className: "pfext-quick-start-task-header__subtitle", "data-test-id": "quick-start-task-subtitle" },
|
|
2044
|
-
' ',
|
|
2045
|
-
subtitle))),
|
|
2046
|
-
tryAgain));
|
|
2047
|
-
return (React__namespace.createElement(reactCore.WizardNavItem, { content: content, stepIndex: taskIndex, onClick: () => onTaskSelect(taskIndex - 1), component: "button", isCurrent: isActiveTask }, children));
|
|
1988
|
+
const QuickStartCloseModal = ({ isOpen, onConfirm, onCancel, }) => {
|
|
1989
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1990
|
+
return (React__namespace.createElement(Modal, { className: "pfext-quick-start-drawer__modal pfext-quick-start__base", isOpen: isOpen, variant: reactCore.ModalVariant.small, showClose: false, "data-test": "leave-quickstart", title: getResource('Leave quick start?'), footer: React__namespace.createElement(reactCore.Flex, null,
|
|
1991
|
+
React__namespace.createElement(reactCore.FlexItem, { align: { default: 'alignRight' } },
|
|
1992
|
+
React__namespace.createElement(reactCore.Button, { variant: "secondary", "data-test": "cancel button", onClick: onCancel }, getResource('Cancel'))),
|
|
1993
|
+
React__namespace.createElement(reactCore.FlexItem, null,
|
|
1994
|
+
React__namespace.createElement(reactCore.Button, { variant: "primary", "data-test": "leave button", onClick: onConfirm }, getResource('Leave')))), isFullScreen: true }, getResource('Your progress will be saved.')));
|
|
1995
|
+
};
|
|
1996
|
+
|
|
1997
|
+
const TaskIcon = ({ taskIndex, taskStatus }) => {
|
|
1998
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
1999
|
+
const success = taskStatus === exports.QuickStartTaskStatus.SUCCESS;
|
|
2000
|
+
const failed = taskStatus === exports.QuickStartTaskStatus.FAILED;
|
|
2001
|
+
const classNames = reactStyles.css('pfext-icon-and-text__icon', {
|
|
2002
|
+
'pfext-quick-start-task-header__task-icon-init': !failed && !success,
|
|
2003
|
+
});
|
|
2004
|
+
let content;
|
|
2005
|
+
if (success) {
|
|
2006
|
+
content = (React__namespace.createElement(reactCore.Icon, { size: "md" },
|
|
2007
|
+
React__namespace.createElement(CheckCircleIcon__default['default'], { className: "pfext-quick-start-task-header__task-icon-success" }),
|
|
2008
|
+
' '));
|
|
2009
|
+
}
|
|
2010
|
+
else if (failed) {
|
|
2011
|
+
content = (React__namespace.createElement(reactCore.Icon, { size: "md" },
|
|
2012
|
+
React__namespace.createElement(ExclamationCircleIcon__default['default'], { className: "pfext-quick-start-task-header__task-icon-failed" })));
|
|
2013
|
+
}
|
|
2014
|
+
else {
|
|
2015
|
+
content = getResource('{{taskIndex, number}}', taskIndex).replace('{{taskIndex, number}}', taskIndex);
|
|
2016
|
+
}
|
|
2017
|
+
return React__namespace.createElement("span", { className: classNames }, content);
|
|
2018
|
+
};
|
|
2019
|
+
const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
|
|
2020
|
+
const titleRef = React__namespace.useRef(null);
|
|
2021
|
+
React__namespace.useEffect(() => {
|
|
2022
|
+
if (isActiveTask) {
|
|
2023
|
+
// Focus the WizardNavItem button element that contains the title
|
|
2024
|
+
titleRef.current.parentNode.focus();
|
|
2025
|
+
}
|
|
2026
|
+
}, [isActiveTask]);
|
|
2027
|
+
const classNames = reactStyles.css('pfext-quick-start-task-header__title', {
|
|
2028
|
+
'pfext-quick-start-task-header__title-success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
|
|
2029
|
+
'pfext-quick-start-task-header__title-failed': taskStatus === (exports.QuickStartTaskStatus.FAILED || exports.QuickStartTaskStatus.VISITED),
|
|
2030
|
+
});
|
|
2031
|
+
// const notCompleted = taskStatus === QuickStartTaskStatus.VISITED;
|
|
2032
|
+
// const skippedReview = taskStatus === QuickStartTaskStatus.REVIEW;
|
|
2033
|
+
const failedReview = taskStatus === exports.QuickStartTaskStatus.FAILED;
|
|
2034
|
+
// TODO: toned down when this is shown, investigate further when we should display it
|
|
2035
|
+
// related: https://github.com/patternfly/patternfly-quickstarts/issues/104
|
|
2036
|
+
const tryAgain = failedReview && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2037
|
+
React__namespace.createElement("div", null),
|
|
2038
|
+
React__namespace.createElement("div", { className: "pfext-quick-start-task-header__tryagain" }, "Try the steps again.")));
|
|
2039
|
+
const content = (React__namespace.createElement("div", { className: "pfext-quick-start-task-header", ref: titleRef },
|
|
2040
|
+
React__namespace.createElement(TaskIcon, { taskIndex: taskIndex, taskStatus: taskStatus }),
|
|
2041
|
+
React__namespace.createElement(reactCore.Title, { headingLevel: "h3", size: size, className: classNames },
|
|
2042
|
+
React__namespace.createElement("span", { dangerouslySetInnerHTML: { __html: removeParagraphWrap(markdownConvert(title)) } }),
|
|
2043
|
+
isActiveTask && subtitle && (React__namespace.createElement("span", { className: "pfext-quick-start-task-header__subtitle", "data-test-id": "quick-start-task-subtitle" },
|
|
2044
|
+
' ',
|
|
2045
|
+
subtitle))),
|
|
2046
|
+
tryAgain));
|
|
2047
|
+
return (React__namespace.createElement(reactCore.WizardNavItem, { content: content, stepIndex: taskIndex, onClick: () => onTaskSelect(taskIndex - 1), component: "button", isCurrent: isActiveTask }, children));
|
|
2048
2048
|
};
|
|
2049
2049
|
|
|
2050
2050
|
const QuickStartTaskHeaderList = ({ tasks, allTaskStatuses, onTaskSelect, }) => tasks.length > 0 ? (React__namespace.createElement(reactCore.List, { className: "pfext-quick-start-task-header__list" }, tasks.map((task, index) => (React__namespace.createElement(QuickStartTaskHeader, { key: task.title, title: task.title, taskIndex: index + 1, size: "md", taskStatus: allTaskStatuses[index], onTaskSelect: onTaskSelect }))))) : null;
|
|
2051
2051
|
|
|
2052
|
-
const QuickStartConclusion = ({ tasks, conclusion, allTaskStatuses, nextQuickStarts, onQuickStartChange, onTaskSelect, }) => {
|
|
2053
|
-
const hasFailedTask = allTaskStatuses.includes(exports.QuickStartTaskStatus.FAILED);
|
|
2054
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
2055
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2056
|
-
React__namespace.createElement(QuickStartTaskHeaderList, { tasks: tasks, allTaskStatuses: allTaskStatuses, onTaskSelect: onTaskSelect }),
|
|
2057
|
-
React__namespace.createElement(QuickStartMarkdownView, { content: hasFailedTask
|
|
2058
|
-
? getResource('One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.')
|
|
2059
|
-
: conclusion }),
|
|
2060
|
-
!hasFailedTask &&
|
|
2061
|
-
nextQuickStarts &&
|
|
2062
|
-
nextQuickStarts.length > 0 &&
|
|
2063
|
-
nextQuickStarts.map((nextQuickStart, index) => {
|
|
2064
|
-
var _a;
|
|
2065
|
-
return (React__namespace.createElement(reactCore.Button, { variant: "link", onClick: () => onQuickStartChange(nextQuickStart.metadata.name), isInline: true, isBlock: true, key: index },
|
|
2066
|
-
getResource('Start {{nextQSDisplayName}} quick start').replace('{{nextQSDisplayName}}', (_a = nextQuickStart === null || nextQuickStart === void 0 ? void 0 : nextQuickStart.spec) === null || _a === void 0 ? void 0 : _a.displayName),
|
|
2067
|
-
' ',
|
|
2068
|
-
React__namespace.createElement(ArrowRightIcon__default['default'], { style: { marginLeft: 'var(--pf-v5-global--spacer--xs)', verticalAlign: 'middle' } })));
|
|
2069
|
-
})));
|
|
2070
|
-
};
|
|
2071
|
-
|
|
2072
|
-
const QuickStartIntroduction = ({ tasks, introduction, allTaskStatuses, prerequisites, onTaskSelect, }) => {
|
|
2073
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
2074
|
-
const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
|
|
2075
|
-
const [isPrereqsExpanded, setIsPrereqsExpanded] = React__namespace.useState(false);
|
|
2076
|
-
const prereqList = (prereqs === null || prereqs === void 0 ? void 0 : prereqs.length) > 0 && (React__namespace.createElement(reactCore.ExpandableSection, { toggleText: getResource('View Prerequisites ({{totalPrereqs}})').replace('{{totalPrereqs}}', prereqs.length), onToggle: () => setIsPrereqsExpanded(!isPrereqsExpanded), className: "pfext-quick-start-intro__prereq" },
|
|
2077
|
-
React__namespace.createElement(reactCore.List, { className: "pfext-quick-start-intro__prereq-list" }, prereqs.map((pr) => (React__namespace.createElement(reactCore.ListItem, { key: pr, className: "pfext-quick-start-intro__prereq-list__item" },
|
|
2078
|
-
React__namespace.createElement("span", { className: "pfext-quick-start-intro__prereq-list__item-content" },
|
|
2079
|
-
React__namespace.createElement(QuickStartMarkdownView, { content: pr }))))))));
|
|
2080
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2081
|
-
React__namespace.createElement(QuickStartMarkdownView, { content: introduction }),
|
|
2082
|
-
prereqList,
|
|
2083
|
-
React__namespace.createElement("p", { style: { marginBottom: 'var(--pf-v5-global--spacer--md)' } },
|
|
2084
|
-
getResource('In this quick start, you will complete {{count, number}} task', tasks.length).replace('{{count, number}}', tasks.length),
|
|
2085
|
-
":"),
|
|
2086
|
-
React__namespace.createElement(QuickStartTaskHeaderList, { tasks: tasks, allTaskStatuses: allTaskStatuses, onTaskSelect: onTaskSelect })));
|
|
2087
|
-
};
|
|
2088
|
-
|
|
2089
|
-
const getAlertVariant = (status) => {
|
|
2090
|
-
switch (status) {
|
|
2091
|
-
case exports.QuickStartTaskStatus.SUCCESS:
|
|
2092
|
-
return 'success';
|
|
2093
|
-
case exports.QuickStartTaskStatus.FAILED:
|
|
2094
|
-
return 'danger';
|
|
2095
|
-
default:
|
|
2096
|
-
return 'info';
|
|
2097
|
-
}
|
|
2098
|
-
};
|
|
2099
|
-
const QuickStartTaskReview = ({ review, taskStatus, onTaskReview, }) => {
|
|
2100
|
-
const { instructions, failedTaskHelp: taskHelp } = review;
|
|
2101
|
-
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
2102
|
-
const alertClassNames = reactStyles.css('pfext-quick-start-task-review', {
|
|
2103
|
-
'pfext-quick-start-task-review--success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
|
|
2104
|
-
'pfext-quick-start-task-review--failed': taskStatus === exports.QuickStartTaskStatus.FAILED,
|
|
2105
|
-
});
|
|
2106
|
-
const title = React__namespace.createElement("span", { className: alertClassNames }, getResource('Check your work'));
|
|
2107
|
-
return (React__namespace.createElement(reactCore.Alert, { className: "pfext-quick-start-task-review-alert", variant: getAlertVariant(taskStatus), title: title, isInline: true, role: "alert" },
|
|
2108
|
-
React__namespace.createElement(QuickStartMarkdownView, { content: instructions }),
|
|
2109
|
-
React__namespace.createElement("span", { className: "pfext-quick-start-task-review__actions" },
|
|
2110
|
-
React__namespace.createElement(reactCore.Radio, { id: "review-success", name: "review-success", "data-testid": "qs-drawer-check-yes", label: getResource('Yes'), className: "pfext-quick-start-task-review__radio", isChecked: taskStatus === exports.QuickStartTaskStatus.SUCCESS, onChange: () => onTaskReview(exports.QuickStartTaskStatus.SUCCESS) }),
|
|
2111
|
-
React__namespace.createElement(reactCore.Radio, { id: "review-failed", name: "review-failed", "data-testid": "qs-drawer-check-no", label: getResource('No'), className: "pfext-quick-start-task-review__radio", isChecked: taskStatus === exports.QuickStartTaskStatus.FAILED, onChange: () => onTaskReview(exports.QuickStartTaskStatus.FAILED) })),
|
|
2112
|
-
taskStatus === exports.QuickStartTaskStatus.FAILED && taskHelp && (React__namespace.createElement(QuickStartMarkdownView, { content: taskHelp, exactHeight: true }))));
|
|
2113
|
-
};
|
|
2114
|
-
|
|
2115
|
-
const QuickStartTasks = ({ tasks, taskNumber, allTaskStatuses, onTaskReview, onTaskSelect, }) => {
|
|
2116
|
-
const { getResource, alwaysShowTaskReview } = React__namespace.useContext(QuickStartContext);
|
|
2117
|
-
return (React__namespace.createElement("div", { className: "pfext-quick-start-tasks__list" },
|
|
2118
|
-
React__namespace.createElement("ul", null, tasks
|
|
2119
|
-
.filter((_, index) => allTaskStatuses[index] !== exports.QuickStartTaskStatus.INIT)
|
|
2120
|
-
.map((task, index) => {
|
|
2121
|
-
const { title, description, review } = task;
|
|
2122
|
-
const isActiveTask = index === taskNumber;
|
|
2123
|
-
const taskStatus = allTaskStatuses[index];
|
|
2124
|
-
const shouldShowTaskReview = (!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) || alwaysShowTaskReview) &&
|
|
2125
|
-
review;
|
|
2126
|
-
return (React__namespace.createElement(React__namespace.Fragment, { key: title },
|
|
2127
|
-
React__namespace.createElement(QuickStartTaskHeader, { taskIndex: index + 1, title: title, size: "md", subtitle: getResource('{{index, number}} of {{tasks, number}}')
|
|
2128
|
-
.replace('{{index, number}}', index + 1)
|
|
2129
|
-
.replace('{{tasks, number}}', tasks.length), taskStatus: taskStatus, isActiveTask: isActiveTask, onTaskSelect: onTaskSelect }, isActiveTask && (React__namespace.createElement("div", { className: "pfext-quick-start-task__content" },
|
|
2130
|
-
React__namespace.createElement(QuickStartMarkdownView, { content: description }),
|
|
2131
|
-
shouldShowTaskReview && (React__namespace.createElement(QuickStartTaskReview, { review: review, taskStatus: taskStatus, onTaskReview: onTaskReview })))))));
|
|
2132
|
-
}))));
|
|
2133
|
-
};
|
|
2134
|
-
|
|
2135
|
-
const QuickStartContent = React__namespace.forwardRef(({ quickStart, nextQuickStarts = [], taskNumber, allTaskStatuses, onTaskSelect, onTaskReview, onQuickStartChange, }, ref) => {
|
|
2136
|
-
const { spec: { introduction, tasks, conclusion, prerequisites }, } = quickStart;
|
|
2137
|
-
const totalTasks = tasks.length;
|
|
2138
|
-
return (React__namespace.createElement("div", { className: "pfext-quick-start-content", ref: ref },
|
|
2139
|
-
taskNumber === -1 && (React__namespace.createElement(QuickStartIntroduction, { tasks: tasks, allTaskStatuses: allTaskStatuses, introduction: introduction, prerequisites: prerequisites, onTaskSelect: onTaskSelect })),
|
|
2140
|
-
taskNumber > -1 && taskNumber < totalTasks && (React__namespace.createElement(QuickStartTasks, { tasks: tasks, taskNumber: taskNumber, allTaskStatuses: allTaskStatuses, onTaskReview: onTaskReview, onTaskSelect: onTaskSelect })),
|
|
2141
|
-
taskNumber === totalTasks && (React__namespace.createElement(QuickStartConclusion, { tasks: tasks, conclusion: conclusion, allTaskStatuses: allTaskStatuses, nextQuickStarts: nextQuickStarts, onQuickStartChange: onQuickStartChange, onTaskSelect: onTaskSelect }))));
|
|
2052
|
+
const QuickStartConclusion = ({ tasks, conclusion, allTaskStatuses, nextQuickStarts, onQuickStartChange, onTaskSelect, }) => {
|
|
2053
|
+
const hasFailedTask = allTaskStatuses.includes(exports.QuickStartTaskStatus.FAILED);
|
|
2054
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
2055
|
+
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2056
|
+
React__namespace.createElement(QuickStartTaskHeaderList, { tasks: tasks, allTaskStatuses: allTaskStatuses, onTaskSelect: onTaskSelect }),
|
|
2057
|
+
React__namespace.createElement(QuickStartMarkdownView, { content: hasFailedTask
|
|
2058
|
+
? getResource('One or more verifications did not pass during this quick start. Revisit the tasks or the help links, and then try again.')
|
|
2059
|
+
: conclusion }),
|
|
2060
|
+
!hasFailedTask &&
|
|
2061
|
+
nextQuickStarts &&
|
|
2062
|
+
nextQuickStarts.length > 0 &&
|
|
2063
|
+
nextQuickStarts.map((nextQuickStart, index) => {
|
|
2064
|
+
var _a;
|
|
2065
|
+
return (React__namespace.createElement(reactCore.Button, { variant: "link", onClick: () => onQuickStartChange(nextQuickStart.metadata.name), isInline: true, isBlock: true, key: index },
|
|
2066
|
+
getResource('Start {{nextQSDisplayName}} quick start').replace('{{nextQSDisplayName}}', (_a = nextQuickStart === null || nextQuickStart === void 0 ? void 0 : nextQuickStart.spec) === null || _a === void 0 ? void 0 : _a.displayName),
|
|
2067
|
+
' ',
|
|
2068
|
+
React__namespace.createElement(ArrowRightIcon__default['default'], { style: { marginLeft: 'var(--pf-v5-global--spacer--xs)', verticalAlign: 'middle' } })));
|
|
2069
|
+
})));
|
|
2070
|
+
};
|
|
2071
|
+
|
|
2072
|
+
const QuickStartIntroduction = ({ tasks, introduction, allTaskStatuses, prerequisites, onTaskSelect, }) => {
|
|
2073
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
2074
|
+
const prereqs = prerequisites === null || prerequisites === void 0 ? void 0 : prerequisites.filter((p) => p);
|
|
2075
|
+
const [isPrereqsExpanded, setIsPrereqsExpanded] = React__namespace.useState(false);
|
|
2076
|
+
const prereqList = (prereqs === null || prereqs === void 0 ? void 0 : prereqs.length) > 0 && (React__namespace.createElement(reactCore.ExpandableSection, { toggleText: getResource('View Prerequisites ({{totalPrereqs}})').replace('{{totalPrereqs}}', prereqs.length), onToggle: () => setIsPrereqsExpanded(!isPrereqsExpanded), className: "pfext-quick-start-intro__prereq" },
|
|
2077
|
+
React__namespace.createElement(reactCore.List, { className: "pfext-quick-start-intro__prereq-list" }, prereqs.map((pr) => (React__namespace.createElement(reactCore.ListItem, { key: pr, className: "pfext-quick-start-intro__prereq-list__item" },
|
|
2078
|
+
React__namespace.createElement("span", { className: "pfext-quick-start-intro__prereq-list__item-content" },
|
|
2079
|
+
React__namespace.createElement(QuickStartMarkdownView, { content: pr }))))))));
|
|
2080
|
+
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2081
|
+
React__namespace.createElement(QuickStartMarkdownView, { content: introduction }),
|
|
2082
|
+
prereqList,
|
|
2083
|
+
React__namespace.createElement("p", { style: { marginBottom: 'var(--pf-v5-global--spacer--md)' } },
|
|
2084
|
+
getResource('In this quick start, you will complete {{count, number}} task', tasks.length).replace('{{count, number}}', tasks.length),
|
|
2085
|
+
":"),
|
|
2086
|
+
React__namespace.createElement(QuickStartTaskHeaderList, { tasks: tasks, allTaskStatuses: allTaskStatuses, onTaskSelect: onTaskSelect })));
|
|
2087
|
+
};
|
|
2088
|
+
|
|
2089
|
+
const getAlertVariant = (status) => {
|
|
2090
|
+
switch (status) {
|
|
2091
|
+
case exports.QuickStartTaskStatus.SUCCESS:
|
|
2092
|
+
return 'success';
|
|
2093
|
+
case exports.QuickStartTaskStatus.FAILED:
|
|
2094
|
+
return 'danger';
|
|
2095
|
+
default:
|
|
2096
|
+
return 'info';
|
|
2097
|
+
}
|
|
2098
|
+
};
|
|
2099
|
+
const QuickStartTaskReview = ({ review, taskStatus, onTaskReview, }) => {
|
|
2100
|
+
const { instructions, failedTaskHelp: taskHelp } = review;
|
|
2101
|
+
const { getResource } = React__namespace.useContext(QuickStartContext);
|
|
2102
|
+
const alertClassNames = reactStyles.css('pfext-quick-start-task-review', {
|
|
2103
|
+
'pfext-quick-start-task-review--success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
|
|
2104
|
+
'pfext-quick-start-task-review--failed': taskStatus === exports.QuickStartTaskStatus.FAILED,
|
|
2105
|
+
});
|
|
2106
|
+
const title = React__namespace.createElement("span", { className: alertClassNames }, getResource('Check your work'));
|
|
2107
|
+
return (React__namespace.createElement(reactCore.Alert, { className: "pfext-quick-start-task-review-alert", variant: getAlertVariant(taskStatus), title: title, isInline: true, role: "alert" },
|
|
2108
|
+
React__namespace.createElement(QuickStartMarkdownView, { content: instructions }),
|
|
2109
|
+
React__namespace.createElement("span", { className: "pfext-quick-start-task-review__actions" },
|
|
2110
|
+
React__namespace.createElement(reactCore.Radio, { id: "review-success", name: "review-success", "data-testid": "qs-drawer-check-yes", label: getResource('Yes'), className: "pfext-quick-start-task-review__radio", isChecked: taskStatus === exports.QuickStartTaskStatus.SUCCESS, onChange: () => onTaskReview(exports.QuickStartTaskStatus.SUCCESS) }),
|
|
2111
|
+
React__namespace.createElement(reactCore.Radio, { id: "review-failed", name: "review-failed", "data-testid": "qs-drawer-check-no", label: getResource('No'), className: "pfext-quick-start-task-review__radio", isChecked: taskStatus === exports.QuickStartTaskStatus.FAILED, onChange: () => onTaskReview(exports.QuickStartTaskStatus.FAILED) })),
|
|
2112
|
+
taskStatus === exports.QuickStartTaskStatus.FAILED && taskHelp && (React__namespace.createElement(QuickStartMarkdownView, { content: taskHelp, exactHeight: true }))));
|
|
2113
|
+
};
|
|
2114
|
+
|
|
2115
|
+
const QuickStartTasks = ({ tasks, taskNumber, allTaskStatuses, onTaskReview, onTaskSelect, }) => {
|
|
2116
|
+
const { getResource, alwaysShowTaskReview } = React__namespace.useContext(QuickStartContext);
|
|
2117
|
+
return (React__namespace.createElement("div", { className: "pfext-quick-start-tasks__list" },
|
|
2118
|
+
React__namespace.createElement("ul", null, tasks
|
|
2119
|
+
.filter((_, index) => allTaskStatuses[index] !== exports.QuickStartTaskStatus.INIT)
|
|
2120
|
+
.map((task, index) => {
|
|
2121
|
+
const { title, description, review } = task;
|
|
2122
|
+
const isActiveTask = index === taskNumber;
|
|
2123
|
+
const taskStatus = allTaskStatuses[index];
|
|
2124
|
+
const shouldShowTaskReview = (!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) || alwaysShowTaskReview) &&
|
|
2125
|
+
review;
|
|
2126
|
+
return (React__namespace.createElement(React__namespace.Fragment, { key: title },
|
|
2127
|
+
React__namespace.createElement(QuickStartTaskHeader, { taskIndex: index + 1, title: title, size: "md", subtitle: getResource('{{index, number}} of {{tasks, number}}')
|
|
2128
|
+
.replace('{{index, number}}', index + 1)
|
|
2129
|
+
.replace('{{tasks, number}}', tasks.length), taskStatus: taskStatus, isActiveTask: isActiveTask, onTaskSelect: onTaskSelect }, isActiveTask && (React__namespace.createElement("div", { className: "pfext-quick-start-task__content" },
|
|
2130
|
+
React__namespace.createElement(QuickStartMarkdownView, { content: description }),
|
|
2131
|
+
shouldShowTaskReview && (React__namespace.createElement(QuickStartTaskReview, { review: review, taskStatus: taskStatus, onTaskReview: onTaskReview })))))));
|
|
2132
|
+
}))));
|
|
2133
|
+
};
|
|
2134
|
+
|
|
2135
|
+
const QuickStartContent = React__namespace.forwardRef(({ quickStart, nextQuickStarts = [], taskNumber, allTaskStatuses, onTaskSelect, onTaskReview, onQuickStartChange, }, ref) => {
|
|
2136
|
+
const { spec: { introduction, tasks, conclusion, prerequisites }, } = quickStart;
|
|
2137
|
+
const totalTasks = tasks.length;
|
|
2138
|
+
return (React__namespace.createElement("div", { className: "pfext-quick-start-content", ref: ref },
|
|
2139
|
+
taskNumber === -1 && (React__namespace.createElement(QuickStartIntroduction, { tasks: tasks, allTaskStatuses: allTaskStatuses, introduction: introduction, prerequisites: prerequisites, onTaskSelect: onTaskSelect })),
|
|
2140
|
+
taskNumber > -1 && taskNumber < totalTasks && (React__namespace.createElement(QuickStartTasks, { tasks: tasks, taskNumber: taskNumber, allTaskStatuses: allTaskStatuses, onTaskReview: onTaskReview, onTaskSelect: onTaskSelect })),
|
|
2141
|
+
taskNumber === totalTasks && (React__namespace.createElement(QuickStartConclusion, { tasks: tasks, conclusion: conclusion, allTaskStatuses: allTaskStatuses, nextQuickStarts: nextQuickStarts, onQuickStartChange: onQuickStartChange, onTaskSelect: onTaskSelect }))));
|
|
2142
2142
|
});
|
|
2143
2143
|
|
|
2144
|
-
const QuickStartFooter = ({ status, taskNumber, totalTasks, onNext, onBack, footerClass, quickStartId, }) => {
|
|
2145
|
-
const { restartQuickStart, getResource } = React__namespace.useContext(QuickStartContext);
|
|
2146
|
-
const PrimaryButtonText = React__namespace.useMemo(() => ({
|
|
2147
|
-
START: getResource('Start'),
|
|
2148
|
-
CONTINUE: getResource('Continue'),
|
|
2149
|
-
NEXT: getResource('Next'),
|
|
2150
|
-
CLOSE: getResource('Close'),
|
|
2151
|
-
}), [getResource]);
|
|
2152
|
-
const SecondaryButtonText = React__namespace.useMemo(() => ({
|
|
2153
|
-
BACK: getResource('Back'),
|
|
2154
|
-
RESTART: getResource('Restart'),
|
|
2155
|
-
}), [getResource]);
|
|
2156
|
-
const onRestart = React__namespace.useCallback((e) => {
|
|
2157
|
-
e.preventDefault();
|
|
2158
|
-
e.stopPropagation();
|
|
2159
|
-
restartQuickStart(quickStartId, totalTasks);
|
|
2160
|
-
}, [quickStartId, restartQuickStart, totalTasks]);
|
|
2161
|
-
const getPrimaryButtonText = React__namespace.useMemo(() => {
|
|
2162
|
-
if (status === exports.QuickStartStatus.NOT_STARTED) {
|
|
2163
|
-
return PrimaryButtonText.START;
|
|
2164
|
-
}
|
|
2165
|
-
if (taskNumber === totalTasks) {
|
|
2166
|
-
return PrimaryButtonText.CLOSE;
|
|
2167
|
-
}
|
|
2168
|
-
if (taskNumber > -1 && taskNumber < totalTasks) {
|
|
2169
|
-
return PrimaryButtonText.NEXT;
|
|
2170
|
-
}
|
|
2171
|
-
return PrimaryButtonText.CONTINUE;
|
|
2172
|
-
}, [taskNumber, totalTasks, PrimaryButtonText, status]);
|
|
2173
|
-
const getPrimaryButton = React__namespace.useMemo(() => (React__namespace.createElement(reactCore.Button, { variant: "primary", className: "pfext-quick-start-footer__actionbtn", onClick: onNext, "data-testid": `qs-drawer-${camelize(getPrimaryButtonText)}`, "data-test": `${getPrimaryButtonText} button` }, getPrimaryButtonText)), [getPrimaryButtonText, onNext]);
|
|
2174
|
-
const getSecondaryButton = React__namespace.useMemo(() => taskNumber === -1 && status !== exports.QuickStartStatus.NOT_STARTED ? (React__namespace.createElement(reactCore.Button, { variant: "secondary", onClick: onRestart, "data-testid": "qs-drawer-restart" }, SecondaryButtonText.RESTART)) : (taskNumber > -1 && (React__namespace.createElement(reactCore.Button, { variant: "secondary", onClick: onBack, "data-testid": "qs-drawer-back" }, SecondaryButtonText.BACK))), [onRestart, onBack, SecondaryButtonText, status, taskNumber]);
|
|
2175
|
-
const getSideNoteAction = React__namespace.useMemo(() => taskNumber !== -1 && (React__namespace.createElement(reactCore.Button, { variant: "link", className: "pfext-quick-start-footer__restartbtn", onClick: onRestart, "data-testid": "qs-drawer-side-note-action" }, SecondaryButtonText.RESTART)), [taskNumber, onRestart, SecondaryButtonText.RESTART]);
|
|
2176
|
-
return (React__namespace.createElement("div", { className: `pfext-quick-start-footer ${footerClass}` },
|
|
2177
|
-
getPrimaryButton,
|
|
2178
|
-
getSecondaryButton,
|
|
2179
|
-
getSideNoteAction));
|
|
2180
|
-
};
|
|
2181
|
-
|
|
2182
|
-
const QuickStartController = ({ quickStart, nextQuickStarts, contentRef, footerClass, }) => {
|
|
2183
|
-
const { metadata: { name }, spec: { tasks = [] }, } = quickStart;
|
|
2184
|
-
const totalTasks = tasks === null || tasks === void 0 ? void 0 : tasks.length;
|
|
2185
|
-
const { activeQuickStartState, setActiveQuickStart, setQuickStartTaskNumber, setQuickStartTaskStatus, nextStep, previousStep, } = React__namespace.useContext(QuickStartContext);
|
|
2186
|
-
const status = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.status;
|
|
2187
|
-
const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
|
|
2188
|
-
const allTaskStatuses = tasks.map((task, index) => activeQuickStartState[`taskStatus${index}`]);
|
|
2189
|
-
const handleQuickStartChange = React__namespace.useCallback((quickStartId) => setActiveQuickStart(quickStartId), [setActiveQuickStart]);
|
|
2190
|
-
const handleTaskStatusChange = React__namespace.useCallback((newTaskStatus) => setQuickStartTaskStatus(newTaskStatus), [setQuickStartTaskStatus]);
|
|
2191
|
-
const getQuickStartActiveTask = React__namespace.useCallback(() => {
|
|
2192
|
-
let activeTaskNumber = 0;
|
|
2193
|
-
while (activeTaskNumber !== totalTasks &&
|
|
2194
|
-
activeQuickStartState[`taskStatus${activeTaskNumber}`]
|
|
2195
|
-
activeTaskNumber++;
|
|
2196
|
-
}
|
|
2197
|
-
return activeTaskNumber;
|
|
2198
|
-
}, [totalTasks, activeQuickStartState]);
|
|
2199
|
-
const handleQuickStartContinue = React__namespace.useCallback(() => {
|
|
2200
|
-
const activeTaskNumber = getQuickStartActiveTask();
|
|
2201
|
-
setQuickStartTaskNumber(name, activeTaskNumber);
|
|
2202
|
-
}, [getQuickStartActiveTask, setQuickStartTaskNumber, name]);
|
|
2203
|
-
const handleNext = React__namespace.useCallback(() => {
|
|
2204
|
-
if (status === exports.QuickStartStatus.COMPLETE && taskNumber === totalTasks) {
|
|
2205
|
-
return handleQuickStartChange('');
|
|
2206
|
-
}
|
|
2207
|
-
if (status !== exports.QuickStartStatus.NOT_STARTED && taskNumber === -1) {
|
|
2208
|
-
return handleQuickStartContinue();
|
|
2209
|
-
}
|
|
2210
|
-
return nextStep(totalTasks);
|
|
2211
|
-
}, [handleQuickStartChange, nextStep, status, taskNumber, totalTasks, handleQuickStartContinue]);
|
|
2212
|
-
const handleBack = React__namespace.useCallback(() => previousStep(), [previousStep]);
|
|
2213
|
-
const handleTaskSelect = React__namespace.useCallback((selectedTaskNumber) => {
|
|
2214
|
-
setQuickStartTaskNumber(name, selectedTaskNumber);
|
|
2215
|
-
}, [name, setQuickStartTaskNumber]);
|
|
2216
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2217
|
-
React__namespace.createElement(QuickStartContent, { quickStart: quickStart, nextQuickStarts: nextQuickStarts, taskNumber: taskNumber, allTaskStatuses: allTaskStatuses, onTaskSelect: handleTaskSelect, onTaskReview: handleTaskStatusChange, onQuickStartChange: handleQuickStartChange, ref: contentRef }),
|
|
2218
|
-
React__namespace.createElement(QuickStartFooter, { status: status, taskNumber: taskNumber, totalTasks: totalTasks, onNext: handleNext, onBack: handleBack, footerClass: footerClass, quickStartId: quickStart.metadata.name })));
|
|
2219
|
-
};
|
|
2220
|
-
|
|
2221
|
-
const getElement = (appendTo) => {
|
|
2222
|
-
if (typeof appendTo === 'function') {
|
|
2223
|
-
return appendTo();
|
|
2224
|
-
}
|
|
2225
|
-
return appendTo;
|
|
2226
|
-
};
|
|
2227
|
-
const useScrollTopOnTaskNumberChange = (node, taskNumber) => {
|
|
2228
|
-
React__namespace.useEffect(() => {
|
|
2229
|
-
if (node) {
|
|
2230
|
-
node.scrollTo({ top: 0, behavior: 'smooth' });
|
|
2231
|
-
}
|
|
2232
|
-
}, [taskNumber, node]);
|
|
2233
|
-
};
|
|
2234
|
-
const QuickStartPanelContent = (_a) => {
|
|
2235
|
-
var { quickStarts = [], handleClose, activeQuickStartID, appendTo, isResizable = true, showClose = true, headerVariant = '' } = _a, props = tslib.__rest(_a, ["quickStarts", "handleClose", "activeQuickStartID", "appendTo", "isResizable", "showClose", "headerVariant"]);
|
|
2236
|
-
const titleRef = React__namespace.useRef(null);
|
|
2237
|
-
const { getResource, activeQuickStartState } = React__namespace.useContext(QuickStartContext);
|
|
2238
|
-
const [contentRef, setContentRef] = React__namespace.useState();
|
|
2239
|
-
const shadows = useScrollShadows(contentRef);
|
|
2240
|
-
const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
|
|
2241
|
-
const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
|
|
2242
|
-
useScrollTopOnTaskNumberChange(contentRef, taskNumber);
|
|
2243
|
-
const nextQuickStarts = quickStarts.filter((qs) => { var _a; return (_a = quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.nextQuickStart) === null || _a === void 0 ? void 0 : _a.includes(qs.metadata.name); });
|
|
2244
|
-
const headerClasses = reactStyles.css('pfext-quick-start-panel-content__header', {
|
|
2245
|
-
'pfext-quick-start-panel-content__header__shadow': shadows === Shadows.top || shadows === Shadows.both,
|
|
2246
|
-
'pfext-quick-start-panel-content__header--blue-white': headerVariant === 'blue-white',
|
|
2247
|
-
});
|
|
2248
|
-
const footerClass = reactStyles.css({
|
|
2249
|
-
'pfext-quick-start-panel-content__footer__shadow': shadows === Shadows.bottom || shadows === Shadows.both,
|
|
2250
|
-
});
|
|
2251
|
-
const getStep = () => {
|
|
2252
|
-
const tasks = quickStart.spec.tasks.length;
|
|
2253
|
-
if (Number.parseInt(taskNumber) === -1) {
|
|
2254
|
-
return 'intro';
|
|
2255
|
-
}
|
|
2256
|
-
if (Number.parseInt(taskNumber) === tasks) {
|
|
2257
|
-
return 'conclusion';
|
|
2258
|
-
}
|
|
2259
|
-
return Number.parseInt(taskNumber) + 1;
|
|
2260
|
-
};
|
|
2261
|
-
React__namespace.useEffect(() => {
|
|
2262
|
-
if (quickStart) {
|
|
2263
|
-
titleRef.current.focus();
|
|
2264
|
-
}
|
|
2265
|
-
}, [quickStart]);
|
|
2266
|
-
const content = quickStart ? (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base", "data-testid": `qs-drawer-${camelize(quickStart.spec.displayName)}`, "data-qs": `qs-step-${getStep()}`, "data-test": "quickstart drawer" }, props),
|
|
2267
|
-
React__namespace.createElement("div", { className: headerClasses },
|
|
2268
|
-
React__namespace.createElement(reactCore.DrawerHead, null,
|
|
2269
|
-
React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title", tabIndex: -1, ref: titleRef },
|
|
2270
|
-
React__namespace.createElement(reactCore.Title, { headingLevel: "h2", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } },
|
|
2271
|
-
React__namespace.createElement("span", { dangerouslySetInnerHTML: {
|
|
2272
|
-
__html: removeParagraphWrap(markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName)),
|
|
2273
|
-
} }),
|
|
2274
|
-
' ',
|
|
2275
|
-
React__namespace.createElement("small", { className: "pfext-quick-start-panel-content__duration" }, (quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
|
|
2276
|
-
? getResource('{{type}} • {{duration, number}} minutes', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
|
|
2277
|
-
.replace('{{duration, number}}', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
|
|
2278
|
-
.replace('{{type}}', getResource('Type'))
|
|
2279
|
-
: getResource('Type')))),
|
|
2280
|
-
showClose && (React__namespace.createElement(reactCore.DrawerActions, null,
|
|
2281
|
-
React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: handleClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))))),
|
|
2282
|
-
React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" },
|
|
2283
|
-
React__namespace.createElement(QuickStartController, { quickStart: quickStart, nextQuickStarts: nextQuickStarts, footerClass: footerClass, contentRef: setContentRef })))) : null;
|
|
2284
|
-
if (appendTo) {
|
|
2285
|
-
return ReactDOM__namespace.createPortal(content, getElement(appendTo));
|
|
2286
|
-
}
|
|
2287
|
-
return content;
|
|
2288
|
-
};
|
|
2289
|
-
|
|
2290
|
-
const QuickStartContainer = (_a) => {
|
|
2291
|
-
var { quickStarts, children, activeQuickStartID, allQuickStartStates, setActiveQuickStartID, setAllQuickStartStates, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress, resourceBundle, showCardFooters, useLegacyHeaderColors, language, loading = false, useQueryParams = true, markdown, contextProps, alwaysShowTaskReview = true } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "activeQuickStartID", "allQuickStartStates", "setActiveQuickStartID", "setAllQuickStartStates", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress", "resourceBundle", "showCardFooters", "useLegacyHeaderColors", "language", "loading", "useQueryParams", "markdown", "contextProps", "alwaysShowTaskReview"]);
|
|
2292
|
-
const valuesForQuickstartContext = useValuesForQuickStartContext(Object.assign({ allQuickStarts: quickStarts, activeQuickStartID,
|
|
2293
|
-
setActiveQuickStartID,
|
|
2294
|
-
allQuickStartStates,
|
|
2295
|
-
setAllQuickStartStates, footer: {
|
|
2296
|
-
show: showCardFooters,
|
|
2297
|
-
}, useLegacyHeaderColors,
|
|
2298
|
-
language, resourceBundle: Object.assign({}, resourceBundle), loading,
|
|
2299
|
-
useQueryParams,
|
|
2300
|
-
markdown,
|
|
2301
|
-
alwaysShowTaskReview }, contextProps));
|
|
2302
|
-
React__namespace.useEffect(() => {
|
|
2303
|
-
if (quickStarts &&
|
|
2304
|
-
JSON.stringify(quickStarts) !== JSON.stringify(valuesForQuickstartContext.allQuickStarts)) {
|
|
2305
|
-
valuesForQuickstartContext.setAllQuickStarts(quickStarts);
|
|
2306
|
-
}
|
|
2307
|
-
}, [quickStarts, valuesForQuickstartContext]);
|
|
2308
|
-
React__namespace.useEffect(() => {
|
|
2309
|
-
if (loading !== valuesForQuickstartContext.loading) {
|
|
2310
|
-
valuesForQuickstartContext.setLoading(loading);
|
|
2311
|
-
}
|
|
2312
|
-
}, [loading, valuesForQuickstartContext]);
|
|
2313
|
-
const drawerProps = Object.assign({ appendTo,
|
|
2314
|
-
fullWidth,
|
|
2315
|
-
onCloseInProgress,
|
|
2316
|
-
onCloseNotInProgress }, props);
|
|
2317
|
-
return (React__namespace.createElement(QuickStartContext.Provider, { value: valuesForQuickstartContext },
|
|
2318
|
-
React__namespace.createElement(QuickStartDrawer, Object.assign({}, drawerProps), children)));
|
|
2319
|
-
};
|
|
2320
|
-
const QuickStartDrawer = (_a) => {
|
|
2321
|
-
var { quickStarts = [], children, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress"]);
|
|
2322
|
-
const { activeQuickStartID, setActiveQuickStart, allQuickStarts = [], activeQuickStartState, allQuickStartStates, setAllQuickStartStates, useLegacyHeaderColors, } = React__namespace.useContext(QuickStartContext);
|
|
2323
|
-
const combinedQuickStarts = allQuickStarts.concat(quickStarts);
|
|
2324
|
-
React__namespace.useEffect(() => {
|
|
2325
|
-
const params = new URLSearchParams(window.location.search);
|
|
2326
|
-
// if there is a quick start param, but the quick start is not active, set it
|
|
2327
|
-
// this can happen if a new browser session is opened or an incognito window for example
|
|
2328
|
-
const quickStartIdFromParam = params.get(QUICKSTART_ID_FILTER_KEY) || '';
|
|
2329
|
-
if (quickStartIdFromParam && activeQuickStartID !== quickStartIdFromParam) {
|
|
2330
|
-
const activeQuickStart = getQuickStartByName(quickStartIdFromParam, combinedQuickStarts);
|
|
2331
|
-
// don't try to load a quick start that is actually just an external resource (spec.link)
|
|
2332
|
-
if (combinedQuickStarts.length > 0 && activeQuickStart && !activeQuickStart.spec.link) {
|
|
2333
|
-
setActiveQuickStart(quickStartIdFromParam);
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}, [activeQuickStartID, combinedQuickStarts, setActiveQuickStart]);
|
|
2337
|
-
React__namespace.useEffect(() => {
|
|
2338
|
-
// If activeQuickStartID was changed through prop from QuickStartContainer, need to init the state if it does not exist yet
|
|
2339
|
-
if (activeQuickStartID && !allQuickStartStates[activeQuickStartID]) {
|
|
2340
|
-
setAllQuickStartStates(Object.assign(Object.assign({}, allQuickStartStates), { [activeQuickStartID]: getDefaultQuickStartState() }));
|
|
2341
|
-
}
|
|
2342
|
-
}, [activeQuickStartID, allQuickStartStates, setAllQuickStartStates]);
|
|
2343
|
-
const [modalOpen, setModalOpen] = React__namespace.useState(false);
|
|
2344
|
-
const activeQuickStartStatus = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.status;
|
|
2345
|
-
const onClose = () => setActiveQuickStart('');
|
|
2346
|
-
const handleClose = () => {
|
|
2347
|
-
if (activeQuickStartStatus === exports.QuickStartStatus.IN_PROGRESS) {
|
|
2348
|
-
if (onCloseInProgress) {
|
|
2349
|
-
onCloseInProgress();
|
|
2350
|
-
}
|
|
2351
|
-
else {
|
|
2352
|
-
setModalOpen(true);
|
|
2353
|
-
}
|
|
2354
|
-
}
|
|
2355
|
-
else if (onCloseNotInProgress) {
|
|
2356
|
-
onCloseNotInProgress();
|
|
2357
|
-
}
|
|
2358
|
-
else {
|
|
2359
|
-
onClose();
|
|
2360
|
-
}
|
|
2361
|
-
};
|
|
2362
|
-
const onModalConfirm = () => {
|
|
2363
|
-
setModalOpen(false);
|
|
2364
|
-
onClose();
|
|
2365
|
-
};
|
|
2366
|
-
const onModalCancel = () => setModalOpen(false);
|
|
2367
|
-
const fullWidthPanelStyle = fullWidth
|
|
2368
|
-
? {
|
|
2369
|
-
style: {
|
|
2370
|
-
flex: 1,
|
|
2371
|
-
},
|
|
2372
|
-
}
|
|
2373
|
-
: {};
|
|
2374
|
-
const fullWidthBodyStyle = fullWidth
|
|
2375
|
-
? {
|
|
2376
|
-
style: {
|
|
2377
|
-
display: activeQuickStartID ? 'none' : 'flex',
|
|
2378
|
-
},
|
|
2379
|
-
}
|
|
2380
|
-
: {};
|
|
2381
|
-
const panelContent = (React__namespace.createElement(QuickStartPanelContent, Object.assign({ quickStarts: combinedQuickStarts, handleClose: handleClose, activeQuickStartID: activeQuickStartID, appendTo: appendTo, isResizable: !fullWidth, headerVariant: useLegacyHeaderColors ? '' : 'blue-white' }, fullWidthPanelStyle)));
|
|
2382
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2383
|
-
React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeQuickStartID, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, Object.assign({ panelContent: panelContent }, fullWidthBodyStyle),
|
|
2384
|
-
React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-v5-c-drawer__main" }, panelContent))),
|
|
2385
|
-
React__namespace.createElement(QuickStartCloseModal, { isOpen: modalOpen, onConfirm: onModalConfirm, onCancel: onModalCancel })));
|
|
2386
|
-
};
|
|
2387
|
-
|
|
2388
|
-
const HelpTopicContextDefaults = {
|
|
2389
|
-
helpTopics: [],
|
|
2390
|
-
setHelpTopics: () => { },
|
|
2391
|
-
activeHelpTopic: null,
|
|
2392
|
-
setActiveHelpTopicByName: () => { },
|
|
2393
|
-
filteredHelpTopics: [],
|
|
2394
|
-
setFilteredHelpTopics: () => { },
|
|
2395
|
-
loading: false,
|
|
2396
|
-
};
|
|
2397
|
-
const HelpTopicContext = React__default['default'].createContext(HelpTopicContextDefaults);
|
|
2398
|
-
const useValuesForHelpTopicContext = (value = {}) => {
|
|
2399
|
-
const combinedValue = Object.assign(Object.assign({}, HelpTopicContextDefaults), value);
|
|
2400
|
-
const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
|
|
2401
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
2402
|
-
const [helpTopics, setHelpTopics] = React__default['default'].useState(combinedValue.helpTopics || []);
|
|
2403
|
-
const [activeHelpTopic, setActiveHelpTopic] = React__default['default'].useState(combinedValue.activeHelpTopic || null);
|
|
2404
|
-
const setActiveHelpTopicByName = React__default['default'].useCallback((helpTopicName) => {
|
|
2405
|
-
const topic = helpTopics.find((t) => t.name === helpTopicName);
|
|
2406
|
-
if (!helpTopicName) {
|
|
2407
|
-
setActiveHelpTopic(null);
|
|
2408
|
-
return;
|
|
2409
|
-
}
|
|
2410
|
-
setActiveHelpTopic(topic);
|
|
2411
|
-
}, [helpTopics]);
|
|
2412
|
-
const [filteredHelpTopics, setFilteredHelpTopics] = React__default['default'].useState(combinedValue.filteredHelpTopics || []);
|
|
2413
|
-
return {
|
|
2414
|
-
helpTopics,
|
|
2415
|
-
setHelpTopics,
|
|
2416
|
-
activeHelpTopic,
|
|
2417
|
-
setActiveHelpTopicByName,
|
|
2418
|
-
filteredHelpTopics,
|
|
2419
|
-
setFilteredHelpTopics,
|
|
2420
|
-
loading,
|
|
2421
|
-
setLoading,
|
|
2422
|
-
};
|
|
2423
|
-
};
|
|
2424
|
-
|
|
2425
|
-
const HelpTopicPanelContent = (_a) => {
|
|
2426
|
-
var _b, _c;
|
|
2427
|
-
var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true, onClose } = _a, props = tslib.__rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable", "onClose"]);
|
|
2428
|
-
const { setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
|
|
2429
|
-
const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React__namespace.useState(false);
|
|
2430
|
-
const toggleHelpTopicMenu = () => {
|
|
2431
|
-
setIsHelpTopicMenuOpen(!isHelpTopicMenuOpen);
|
|
2432
|
-
};
|
|
2433
|
-
const onSelectHelpTopic = (_event, value) => {
|
|
2434
|
-
const topicName = value;
|
|
2435
|
-
setActiveHelpTopicByName(topicName.toString());
|
|
2436
|
-
toggleHelpTopicMenu();
|
|
2437
|
-
};
|
|
2438
|
-
const helpTopicOptions = filteredHelpTopics.length > 1 &&
|
|
2439
|
-
filteredHelpTopics.map((topic) => (React__namespace.createElement(reactCore.SelectOption, { key: topic.name, value: topic.name }, topic.title)));
|
|
2440
|
-
const paddingContainer = (children) => React__namespace.createElement("div", { style: { padding: '24px' } }, children);
|
|
2441
|
-
const panelBodyItems = (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2442
|
-
paddingContainer(React__namespace.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
|
|
2443
|
-
!!((_b = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _b === void 0 ? void 0 : _b.length) && React__namespace.createElement(reactCore.Divider, null),
|
|
2444
|
-
paddingContainer(React__namespace.createElement(reactCore.Stack, { hasGutter: true }, (_c = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _c === void 0 ? void 0 : _c.map(({ href, text, newTab, isExternal }, index) => (React__namespace.createElement(reactCore.StackItem, { key: index },
|
|
2445
|
-
React__namespace.createElement(reactCore.Button, { component: "a", href: href, target: newTab ? '_blank' : '', rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: isExternal ? React__namespace.createElement(ExternalLinkAltIcon__default['default'], null) : null, iconPosition: "right", style: { fontSize: 'inherit' } }, text || href))))))));
|
|
2446
|
-
const content = (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base" }, props),
|
|
2447
|
-
React__namespace.createElement("div", null,
|
|
2448
|
-
React__namespace.createElement(reactCore.DrawerHead, null,
|
|
2449
|
-
React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title" },
|
|
2450
|
-
helpTopicOptions && (React__namespace.createElement(reactCore.Select, { isPlain: true, id: "help-topics-select", selected: activeHelpTopic, isOpen: isHelpTopicMenuOpen, onSelect: onSelectHelpTopic, onOpenChange: (isOpen) => setIsHelpTopicMenuOpen(isOpen), toggle: (toggleRef) => (React__namespace.createElement(reactCore.MenuToggle, { isFullWidth: true, ref: toggleRef, icon: React__namespace.createElement(BarsIcon__default['default'], null), onClick: toggleHelpTopicMenu, isExpanded: isHelpTopicMenuOpen }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)) },
|
|
2451
|
-
React__namespace.createElement(reactCore.SelectList, null, helpTopicOptions))),
|
|
2452
|
-
React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)),
|
|
2453
|
-
React__namespace.createElement(reactCore.DrawerActions, null,
|
|
2454
|
-
React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: onClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))),
|
|
2455
|
-
React__namespace.createElement(reactCore.Divider, null),
|
|
2456
|
-
React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" }, panelBodyItems))));
|
|
2457
|
-
return content;
|
|
2458
|
-
};
|
|
2459
|
-
|
|
2460
|
-
const HelpTopicContainer = (_a) => {
|
|
2461
|
-
var { helpTopics, children, resourceBundle, language, loading = false, markdown, contextProps } = _a, props = tslib.__rest(_a, ["helpTopics", "children", "resourceBundle", "language", "loading", "markdown", "contextProps"]);
|
|
2462
|
-
const valuesForHelpTopicContext = useValuesForHelpTopicContext(Object.assign({ helpTopics,
|
|
2463
|
-
language, resourceBundle: Object.assign({}, resourceBundle), loading,
|
|
2464
|
-
markdown }, contextProps));
|
|
2465
|
-
React__namespace.useEffect(() => {
|
|
2466
|
-
if (loading !== valuesForHelpTopicContext.loading) {
|
|
2467
|
-
valuesForHelpTopicContext.setLoading(loading);
|
|
2468
|
-
}
|
|
2469
|
-
}, [loading, valuesForHelpTopicContext]);
|
|
2470
|
-
React__namespace.useEffect(() => {
|
|
2471
|
-
if (helpTopics &&
|
|
2472
|
-
JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)) {
|
|
2473
|
-
valuesForHelpTopicContext.setHelpTopics(helpTopics);
|
|
2474
|
-
}
|
|
2475
|
-
}, [helpTopics, valuesForHelpTopicContext]);
|
|
2476
|
-
return (React__namespace.createElement(HelpTopicContext.Provider, { value: valuesForHelpTopicContext },
|
|
2477
|
-
React__namespace.createElement(HelpTopicDrawer, Object.assign({}, props), children)));
|
|
2478
|
-
};
|
|
2479
|
-
const HelpTopicDrawer = (_a) => {
|
|
2480
|
-
var { children } = _a, props = tslib.__rest(_a, ["children"]);
|
|
2481
|
-
const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
|
|
2482
|
-
const onClose = () => {
|
|
2483
|
-
setActiveHelpTopicByName('');
|
|
2484
|
-
};
|
|
2485
|
-
const panelContent = (React__namespace.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics, onClose: onClose }));
|
|
2486
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2487
|
-
React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeHelpTopic, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, { panelContent: panelContent },
|
|
2488
|
-
React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-v5-c-drawer__main" }, panelContent)))));
|
|
2489
|
-
};
|
|
2490
|
-
|
|
2491
|
-
const useLocalStorage = (key, initialValue) => {
|
|
2492
|
-
// State to store our value
|
|
2493
|
-
// Pass initial state function to useState so logic is only executed once
|
|
2494
|
-
const [storedValue, setStoredValue] = React.useState(() => {
|
|
2495
|
-
try {
|
|
2496
|
-
// Get from local storage by key
|
|
2497
|
-
const item = window.localStorage.getItem(key);
|
|
2498
|
-
// Parse stored json or if none return initialValue
|
|
2499
|
-
return item ? JSON.parse(item) : initialValue;
|
|
2500
|
-
}
|
|
2501
|
-
catch (error) {
|
|
2502
|
-
// If error also return initialValue
|
|
2503
|
-
// eslint-disable-next-line no-console
|
|
2504
|
-
console.log(error);
|
|
2505
|
-
return initialValue;
|
|
2506
|
-
}
|
|
2507
|
-
});
|
|
2508
|
-
// Return a wrapped version of useState's setter function that ...
|
|
2509
|
-
// ... persists the new value to localStorage.
|
|
2510
|
-
const setValue = (value) => {
|
|
2511
|
-
try {
|
|
2512
|
-
// Allow value to be a function so we have same API as useState
|
|
2513
|
-
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
2514
|
-
// Save state
|
|
2515
|
-
setStoredValue(valueToStore);
|
|
2516
|
-
// Save to local storage
|
|
2517
|
-
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
2518
|
-
}
|
|
2519
|
-
catch (error) {
|
|
2520
|
-
// A more advanced implementation would handle the error case
|
|
2521
|
-
// eslint-disable-next-line no-console
|
|
2522
|
-
console.log(error);
|
|
2523
|
-
}
|
|
2524
|
-
};
|
|
2525
|
-
return [storedValue, setValue];
|
|
2526
|
-
};
|
|
2527
|
-
|
|
2528
|
-
/* eslint-disable */
|
|
2529
|
-
// Brought in from dev to publish this with QS module
|
|
2530
|
-
// Dev now imports from here
|
|
2531
|
-
const ProcQuickStartParser = (quickStart, environmentVariables) => {
|
|
2532
|
-
var _a;
|
|
2533
|
-
const replaceEnvironmentVariables = (s) => s === null || s === void 0 ? void 0 : s.replace(/\${(\w+)}/, (substring, name) => {
|
|
2534
|
-
return environmentVariables ? ([name] ? environmentVariables[name] : substring) : substring;
|
|
2535
|
-
});
|
|
2536
|
-
quickStart.spec.tasks = (_a = quickStart.spec.tasks) === null || _a === void 0 ? void 0 : _a.map((task, index) => {
|
|
2537
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2538
|
-
let proc;
|
|
2539
|
-
let answer;
|
|
2540
|
-
if (typeof task === 'string') {
|
|
2541
|
-
proc = task;
|
|
2542
|
-
answer = {};
|
|
2543
|
-
}
|
|
2544
|
-
else {
|
|
2545
|
-
proc = task.proc;
|
|
2546
|
-
answer = task;
|
|
2547
|
-
delete task.proc;
|
|
2548
|
-
}
|
|
2549
|
-
let description = '', procedure, verification, title, summaryFailed, success, reviewFailed, prerequisites;
|
|
2550
|
-
if (proc) {
|
|
2551
|
-
const taskDOM = document.createElement('div');
|
|
2552
|
-
taskDOM.innerHTML = proc;
|
|
2553
|
-
// remove the screencapture images
|
|
2554
|
-
taskDOM.querySelectorAll('.imageblock.screencapture').forEach((node) => {
|
|
2555
|
-
var _a;
|
|
2556
|
-
(_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(node);
|
|
2557
|
-
});
|
|
2558
|
-
title = (_a = taskDOM
|
|
2559
|
-
.querySelector('h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child')) === null || _a === void 0 ? void 0 : _a.innerHTML.trim();
|
|
2560
|
-
let sectionBody = taskDOM.querySelector('.sectionbody');
|
|
2561
|
-
if (!(sectionBody === null || sectionBody === void 0 ? void 0 : sectionBody.hasChildNodes())) {
|
|
2562
|
-
// possibly in other templates, where we want to look for article
|
|
2563
|
-
sectionBody = taskDOM.querySelector('article');
|
|
2564
|
-
}
|
|
2565
|
-
if (sectionBody) {
|
|
2566
|
-
for (let i = 0; i < sectionBody.children.length || 0; i++) {
|
|
2567
|
-
/**
|
|
2568
|
-
child typically looks like:
|
|
2144
|
+
const QuickStartFooter = ({ status, taskNumber, totalTasks, onNext, onBack, footerClass, quickStartId, }) => {
|
|
2145
|
+
const { restartQuickStart, getResource } = React__namespace.useContext(QuickStartContext);
|
|
2146
|
+
const PrimaryButtonText = React__namespace.useMemo(() => ({
|
|
2147
|
+
START: getResource('Start'),
|
|
2148
|
+
CONTINUE: getResource('Continue'),
|
|
2149
|
+
NEXT: getResource('Next'),
|
|
2150
|
+
CLOSE: getResource('Close'),
|
|
2151
|
+
}), [getResource]);
|
|
2152
|
+
const SecondaryButtonText = React__namespace.useMemo(() => ({
|
|
2153
|
+
BACK: getResource('Back'),
|
|
2154
|
+
RESTART: getResource('Restart'),
|
|
2155
|
+
}), [getResource]);
|
|
2156
|
+
const onRestart = React__namespace.useCallback((e) => {
|
|
2157
|
+
e.preventDefault();
|
|
2158
|
+
e.stopPropagation();
|
|
2159
|
+
restartQuickStart(quickStartId, totalTasks);
|
|
2160
|
+
}, [quickStartId, restartQuickStart, totalTasks]);
|
|
2161
|
+
const getPrimaryButtonText = React__namespace.useMemo(() => {
|
|
2162
|
+
if (status === exports.QuickStartStatus.NOT_STARTED) {
|
|
2163
|
+
return PrimaryButtonText.START;
|
|
2164
|
+
}
|
|
2165
|
+
if (taskNumber === totalTasks) {
|
|
2166
|
+
return PrimaryButtonText.CLOSE;
|
|
2167
|
+
}
|
|
2168
|
+
if (taskNumber > -1 && taskNumber < totalTasks) {
|
|
2169
|
+
return PrimaryButtonText.NEXT;
|
|
2170
|
+
}
|
|
2171
|
+
return PrimaryButtonText.CONTINUE;
|
|
2172
|
+
}, [taskNumber, totalTasks, PrimaryButtonText, status]);
|
|
2173
|
+
const getPrimaryButton = React__namespace.useMemo(() => (React__namespace.createElement(reactCore.Button, { variant: "primary", className: "pfext-quick-start-footer__actionbtn", onClick: onNext, "data-testid": `qs-drawer-${camelize(getPrimaryButtonText)}`, "data-test": `${getPrimaryButtonText} button` }, getPrimaryButtonText)), [getPrimaryButtonText, onNext]);
|
|
2174
|
+
const getSecondaryButton = React__namespace.useMemo(() => taskNumber === -1 && status !== exports.QuickStartStatus.NOT_STARTED ? (React__namespace.createElement(reactCore.Button, { variant: "secondary", onClick: onRestart, "data-testid": "qs-drawer-restart" }, SecondaryButtonText.RESTART)) : (taskNumber > -1 && (React__namespace.createElement(reactCore.Button, { variant: "secondary", onClick: onBack, "data-testid": "qs-drawer-back" }, SecondaryButtonText.BACK))), [onRestart, onBack, SecondaryButtonText, status, taskNumber]);
|
|
2175
|
+
const getSideNoteAction = React__namespace.useMemo(() => taskNumber !== -1 && (React__namespace.createElement(reactCore.Button, { variant: "link", className: "pfext-quick-start-footer__restartbtn", onClick: onRestart, "data-testid": "qs-drawer-side-note-action" }, SecondaryButtonText.RESTART)), [taskNumber, onRestart, SecondaryButtonText.RESTART]);
|
|
2176
|
+
return (React__namespace.createElement("div", { className: `pfext-quick-start-footer ${footerClass}` },
|
|
2177
|
+
getPrimaryButton,
|
|
2178
|
+
getSecondaryButton,
|
|
2179
|
+
getSideNoteAction));
|
|
2180
|
+
};
|
|
2181
|
+
|
|
2182
|
+
const QuickStartController = ({ quickStart, nextQuickStarts, contentRef, footerClass, }) => {
|
|
2183
|
+
const { metadata: { name }, spec: { tasks = [] }, } = quickStart;
|
|
2184
|
+
const totalTasks = tasks === null || tasks === void 0 ? void 0 : tasks.length;
|
|
2185
|
+
const { activeQuickStartState, setActiveQuickStart, setQuickStartTaskNumber, setQuickStartTaskStatus, nextStep, previousStep, } = React__namespace.useContext(QuickStartContext);
|
|
2186
|
+
const status = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.status;
|
|
2187
|
+
const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
|
|
2188
|
+
const allTaskStatuses = tasks.map((task, index) => activeQuickStartState[`taskStatus${index}`]);
|
|
2189
|
+
const handleQuickStartChange = React__namespace.useCallback((quickStartId) => setActiveQuickStart(quickStartId), [setActiveQuickStart]);
|
|
2190
|
+
const handleTaskStatusChange = React__namespace.useCallback((newTaskStatus) => setQuickStartTaskStatus(newTaskStatus), [setQuickStartTaskStatus]);
|
|
2191
|
+
const getQuickStartActiveTask = React__namespace.useCallback(() => {
|
|
2192
|
+
let activeTaskNumber = 0;
|
|
2193
|
+
while (activeTaskNumber !== totalTasks &&
|
|
2194
|
+
activeQuickStartState[`taskStatus${activeTaskNumber}`] === exports.QuickStartTaskStatus.SUCCESS) {
|
|
2195
|
+
activeTaskNumber++;
|
|
2196
|
+
}
|
|
2197
|
+
return activeTaskNumber;
|
|
2198
|
+
}, [totalTasks, activeQuickStartState]);
|
|
2199
|
+
const handleQuickStartContinue = React__namespace.useCallback(() => {
|
|
2200
|
+
const activeTaskNumber = getQuickStartActiveTask();
|
|
2201
|
+
setQuickStartTaskNumber(name, activeTaskNumber);
|
|
2202
|
+
}, [getQuickStartActiveTask, setQuickStartTaskNumber, name]);
|
|
2203
|
+
const handleNext = React__namespace.useCallback(() => {
|
|
2204
|
+
if (status === exports.QuickStartStatus.COMPLETE && taskNumber === totalTasks) {
|
|
2205
|
+
return handleQuickStartChange('');
|
|
2206
|
+
}
|
|
2207
|
+
if (status !== exports.QuickStartStatus.NOT_STARTED && taskNumber === -1) {
|
|
2208
|
+
return handleQuickStartContinue();
|
|
2209
|
+
}
|
|
2210
|
+
return nextStep(totalTasks);
|
|
2211
|
+
}, [handleQuickStartChange, nextStep, status, taskNumber, totalTasks, handleQuickStartContinue]);
|
|
2212
|
+
const handleBack = React__namespace.useCallback(() => previousStep(), [previousStep]);
|
|
2213
|
+
const handleTaskSelect = React__namespace.useCallback((selectedTaskNumber) => {
|
|
2214
|
+
setQuickStartTaskNumber(name, selectedTaskNumber);
|
|
2215
|
+
}, [name, setQuickStartTaskNumber]);
|
|
2216
|
+
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2217
|
+
React__namespace.createElement(QuickStartContent, { quickStart: quickStart, nextQuickStarts: nextQuickStarts, taskNumber: taskNumber, allTaskStatuses: allTaskStatuses, onTaskSelect: handleTaskSelect, onTaskReview: handleTaskStatusChange, onQuickStartChange: handleQuickStartChange, ref: contentRef }),
|
|
2218
|
+
React__namespace.createElement(QuickStartFooter, { status: status, taskNumber: taskNumber, totalTasks: totalTasks, onNext: handleNext, onBack: handleBack, footerClass: footerClass, quickStartId: quickStart.metadata.name })));
|
|
2219
|
+
};
|
|
2220
|
+
|
|
2221
|
+
const getElement = (appendTo) => {
|
|
2222
|
+
if (typeof appendTo === 'function') {
|
|
2223
|
+
return appendTo();
|
|
2224
|
+
}
|
|
2225
|
+
return appendTo;
|
|
2226
|
+
};
|
|
2227
|
+
const useScrollTopOnTaskNumberChange = (node, taskNumber) => {
|
|
2228
|
+
React__namespace.useEffect(() => {
|
|
2229
|
+
if (node) {
|
|
2230
|
+
node.scrollTo({ top: 0, behavior: 'smooth' });
|
|
2231
|
+
}
|
|
2232
|
+
}, [taskNumber, node]);
|
|
2233
|
+
};
|
|
2234
|
+
const QuickStartPanelContent = (_a) => {
|
|
2235
|
+
var { quickStarts = [], handleClose, activeQuickStartID, appendTo, isResizable = true, showClose = true, headerVariant = '' } = _a, props = tslib.__rest(_a, ["quickStarts", "handleClose", "activeQuickStartID", "appendTo", "isResizable", "showClose", "headerVariant"]);
|
|
2236
|
+
const titleRef = React__namespace.useRef(null);
|
|
2237
|
+
const { getResource, activeQuickStartState } = React__namespace.useContext(QuickStartContext);
|
|
2238
|
+
const [contentRef, setContentRef] = React__namespace.useState();
|
|
2239
|
+
const shadows = useScrollShadows(contentRef);
|
|
2240
|
+
const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
|
|
2241
|
+
const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
|
|
2242
|
+
useScrollTopOnTaskNumberChange(contentRef, taskNumber);
|
|
2243
|
+
const nextQuickStarts = quickStarts.filter((qs) => { var _a; return (_a = quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.nextQuickStart) === null || _a === void 0 ? void 0 : _a.includes(qs.metadata.name); });
|
|
2244
|
+
const headerClasses = reactStyles.css('pfext-quick-start-panel-content__header', {
|
|
2245
|
+
'pfext-quick-start-panel-content__header__shadow': shadows === Shadows.top || shadows === Shadows.both,
|
|
2246
|
+
'pfext-quick-start-panel-content__header--blue-white': headerVariant === 'blue-white',
|
|
2247
|
+
});
|
|
2248
|
+
const footerClass = reactStyles.css({
|
|
2249
|
+
'pfext-quick-start-panel-content__footer__shadow': shadows === Shadows.bottom || shadows === Shadows.both,
|
|
2250
|
+
});
|
|
2251
|
+
const getStep = () => {
|
|
2252
|
+
const tasks = quickStart.spec.tasks.length;
|
|
2253
|
+
if (Number.parseInt(taskNumber) === -1) {
|
|
2254
|
+
return 'intro';
|
|
2255
|
+
}
|
|
2256
|
+
if (Number.parseInt(taskNumber) === tasks) {
|
|
2257
|
+
return 'conclusion';
|
|
2258
|
+
}
|
|
2259
|
+
return Number.parseInt(taskNumber) + 1;
|
|
2260
|
+
};
|
|
2261
|
+
React__namespace.useEffect(() => {
|
|
2262
|
+
if (quickStart) {
|
|
2263
|
+
titleRef.current.focus();
|
|
2264
|
+
}
|
|
2265
|
+
}, [quickStart]);
|
|
2266
|
+
const content = quickStart ? (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base", "data-testid": `qs-drawer-${camelize(quickStart.spec.displayName)}`, "data-qs": `qs-step-${getStep()}`, "data-test": "quickstart drawer" }, props),
|
|
2267
|
+
React__namespace.createElement("div", { className: headerClasses },
|
|
2268
|
+
React__namespace.createElement(reactCore.DrawerHead, null,
|
|
2269
|
+
React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title", tabIndex: -1, ref: titleRef },
|
|
2270
|
+
React__namespace.createElement(reactCore.Title, { headingLevel: "h2", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } },
|
|
2271
|
+
React__namespace.createElement("span", { dangerouslySetInnerHTML: {
|
|
2272
|
+
__html: removeParagraphWrap(markdownConvert(quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.displayName)),
|
|
2273
|
+
} }),
|
|
2274
|
+
' ',
|
|
2275
|
+
React__namespace.createElement("small", { className: "pfext-quick-start-panel-content__duration" }, (quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
|
|
2276
|
+
? getResource('{{type}} • {{duration, number}} minutes', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
|
|
2277
|
+
.replace('{{duration, number}}', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
|
|
2278
|
+
.replace('{{type}}', getResource('Type'))
|
|
2279
|
+
: getResource('Type')))),
|
|
2280
|
+
showClose && (React__namespace.createElement(reactCore.DrawerActions, null,
|
|
2281
|
+
React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: handleClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))))),
|
|
2282
|
+
React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" },
|
|
2283
|
+
React__namespace.createElement(QuickStartController, { quickStart: quickStart, nextQuickStarts: nextQuickStarts, footerClass: footerClass, contentRef: setContentRef })))) : null;
|
|
2284
|
+
if (appendTo) {
|
|
2285
|
+
return ReactDOM__namespace.createPortal(content, getElement(appendTo));
|
|
2286
|
+
}
|
|
2287
|
+
return content;
|
|
2288
|
+
};
|
|
2289
|
+
|
|
2290
|
+
const QuickStartContainer = (_a) => {
|
|
2291
|
+
var { quickStarts, children, activeQuickStartID, allQuickStartStates, setActiveQuickStartID, setAllQuickStartStates, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress, resourceBundle, showCardFooters, useLegacyHeaderColors, language, loading = false, useQueryParams = true, markdown, contextProps, alwaysShowTaskReview = true } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "activeQuickStartID", "allQuickStartStates", "setActiveQuickStartID", "setAllQuickStartStates", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress", "resourceBundle", "showCardFooters", "useLegacyHeaderColors", "language", "loading", "useQueryParams", "markdown", "contextProps", "alwaysShowTaskReview"]);
|
|
2292
|
+
const valuesForQuickstartContext = useValuesForQuickStartContext(Object.assign({ allQuickStarts: quickStarts, activeQuickStartID,
|
|
2293
|
+
setActiveQuickStartID,
|
|
2294
|
+
allQuickStartStates,
|
|
2295
|
+
setAllQuickStartStates, footer: {
|
|
2296
|
+
show: showCardFooters,
|
|
2297
|
+
}, useLegacyHeaderColors,
|
|
2298
|
+
language, resourceBundle: Object.assign({}, resourceBundle), loading,
|
|
2299
|
+
useQueryParams,
|
|
2300
|
+
markdown,
|
|
2301
|
+
alwaysShowTaskReview }, contextProps));
|
|
2302
|
+
React__namespace.useEffect(() => {
|
|
2303
|
+
if (quickStarts &&
|
|
2304
|
+
JSON.stringify(quickStarts) !== JSON.stringify(valuesForQuickstartContext.allQuickStarts)) {
|
|
2305
|
+
valuesForQuickstartContext.setAllQuickStarts(quickStarts);
|
|
2306
|
+
}
|
|
2307
|
+
}, [quickStarts, valuesForQuickstartContext]);
|
|
2308
|
+
React__namespace.useEffect(() => {
|
|
2309
|
+
if (loading !== valuesForQuickstartContext.loading) {
|
|
2310
|
+
valuesForQuickstartContext.setLoading(loading);
|
|
2311
|
+
}
|
|
2312
|
+
}, [loading, valuesForQuickstartContext]);
|
|
2313
|
+
const drawerProps = Object.assign({ appendTo,
|
|
2314
|
+
fullWidth,
|
|
2315
|
+
onCloseInProgress,
|
|
2316
|
+
onCloseNotInProgress }, props);
|
|
2317
|
+
return (React__namespace.createElement(QuickStartContext.Provider, { value: valuesForQuickstartContext },
|
|
2318
|
+
React__namespace.createElement(QuickStartDrawer, Object.assign({}, drawerProps), children)));
|
|
2319
|
+
};
|
|
2320
|
+
const QuickStartDrawer = (_a) => {
|
|
2321
|
+
var { quickStarts = [], children, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress"]);
|
|
2322
|
+
const { activeQuickStartID, setActiveQuickStart, allQuickStarts = [], activeQuickStartState, allQuickStartStates, setAllQuickStartStates, useLegacyHeaderColors, } = React__namespace.useContext(QuickStartContext);
|
|
2323
|
+
const combinedQuickStarts = allQuickStarts.concat(quickStarts);
|
|
2324
|
+
React__namespace.useEffect(() => {
|
|
2325
|
+
const params = new URLSearchParams(window.location.search);
|
|
2326
|
+
// if there is a quick start param, but the quick start is not active, set it
|
|
2327
|
+
// this can happen if a new browser session is opened or an incognito window for example
|
|
2328
|
+
const quickStartIdFromParam = params.get(QUICKSTART_ID_FILTER_KEY) || '';
|
|
2329
|
+
if (quickStartIdFromParam && activeQuickStartID !== quickStartIdFromParam) {
|
|
2330
|
+
const activeQuickStart = getQuickStartByName(quickStartIdFromParam, combinedQuickStarts);
|
|
2331
|
+
// don't try to load a quick start that is actually just an external resource (spec.link)
|
|
2332
|
+
if (combinedQuickStarts.length > 0 && activeQuickStart && !activeQuickStart.spec.link) {
|
|
2333
|
+
setActiveQuickStart(quickStartIdFromParam);
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
}, [activeQuickStartID, combinedQuickStarts, setActiveQuickStart]);
|
|
2337
|
+
React__namespace.useEffect(() => {
|
|
2338
|
+
// If activeQuickStartID was changed through prop from QuickStartContainer, need to init the state if it does not exist yet
|
|
2339
|
+
if (activeQuickStartID && !allQuickStartStates[activeQuickStartID]) {
|
|
2340
|
+
setAllQuickStartStates(Object.assign(Object.assign({}, allQuickStartStates), { [activeQuickStartID]: getDefaultQuickStartState() }));
|
|
2341
|
+
}
|
|
2342
|
+
}, [activeQuickStartID, allQuickStartStates, setAllQuickStartStates]);
|
|
2343
|
+
const [modalOpen, setModalOpen] = React__namespace.useState(false);
|
|
2344
|
+
const activeQuickStartStatus = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.status;
|
|
2345
|
+
const onClose = () => setActiveQuickStart('');
|
|
2346
|
+
const handleClose = () => {
|
|
2347
|
+
if (activeQuickStartStatus === exports.QuickStartStatus.IN_PROGRESS) {
|
|
2348
|
+
if (onCloseInProgress) {
|
|
2349
|
+
onCloseInProgress();
|
|
2350
|
+
}
|
|
2351
|
+
else {
|
|
2352
|
+
setModalOpen(true);
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
else if (onCloseNotInProgress) {
|
|
2356
|
+
onCloseNotInProgress();
|
|
2357
|
+
}
|
|
2358
|
+
else {
|
|
2359
|
+
onClose();
|
|
2360
|
+
}
|
|
2361
|
+
};
|
|
2362
|
+
const onModalConfirm = () => {
|
|
2363
|
+
setModalOpen(false);
|
|
2364
|
+
onClose();
|
|
2365
|
+
};
|
|
2366
|
+
const onModalCancel = () => setModalOpen(false);
|
|
2367
|
+
const fullWidthPanelStyle = fullWidth
|
|
2368
|
+
? {
|
|
2369
|
+
style: {
|
|
2370
|
+
flex: 1,
|
|
2371
|
+
},
|
|
2372
|
+
}
|
|
2373
|
+
: {};
|
|
2374
|
+
const fullWidthBodyStyle = fullWidth
|
|
2375
|
+
? {
|
|
2376
|
+
style: {
|
|
2377
|
+
display: activeQuickStartID ? 'none' : 'flex',
|
|
2378
|
+
},
|
|
2379
|
+
}
|
|
2380
|
+
: {};
|
|
2381
|
+
const panelContent = (React__namespace.createElement(QuickStartPanelContent, Object.assign({ quickStarts: combinedQuickStarts, handleClose: handleClose, activeQuickStartID: activeQuickStartID, appendTo: appendTo, isResizable: !fullWidth, headerVariant: useLegacyHeaderColors ? '' : 'blue-white' }, fullWidthPanelStyle)));
|
|
2382
|
+
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2383
|
+
React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeQuickStartID, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, Object.assign({ panelContent: panelContent }, fullWidthBodyStyle),
|
|
2384
|
+
React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-v5-c-drawer__main" }, panelContent))),
|
|
2385
|
+
React__namespace.createElement(QuickStartCloseModal, { isOpen: modalOpen, onConfirm: onModalConfirm, onCancel: onModalCancel })));
|
|
2386
|
+
};
|
|
2387
|
+
|
|
2388
|
+
const HelpTopicContextDefaults = {
|
|
2389
|
+
helpTopics: [],
|
|
2390
|
+
setHelpTopics: () => { },
|
|
2391
|
+
activeHelpTopic: null,
|
|
2392
|
+
setActiveHelpTopicByName: () => { },
|
|
2393
|
+
filteredHelpTopics: [],
|
|
2394
|
+
setFilteredHelpTopics: () => { },
|
|
2395
|
+
loading: false,
|
|
2396
|
+
};
|
|
2397
|
+
const HelpTopicContext = React__default['default'].createContext(HelpTopicContextDefaults);
|
|
2398
|
+
const useValuesForHelpTopicContext = (value = {}) => {
|
|
2399
|
+
const combinedValue = Object.assign(Object.assign({}, HelpTopicContextDefaults), value);
|
|
2400
|
+
const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
|
|
2401
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
2402
|
+
const [helpTopics, setHelpTopics] = React__default['default'].useState(combinedValue.helpTopics || []);
|
|
2403
|
+
const [activeHelpTopic, setActiveHelpTopic] = React__default['default'].useState(combinedValue.activeHelpTopic || null);
|
|
2404
|
+
const setActiveHelpTopicByName = React__default['default'].useCallback((helpTopicName) => {
|
|
2405
|
+
const topic = helpTopics.find((t) => t.name === helpTopicName);
|
|
2406
|
+
if (!helpTopicName) {
|
|
2407
|
+
setActiveHelpTopic(null);
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2410
|
+
setActiveHelpTopic(topic);
|
|
2411
|
+
}, [helpTopics]);
|
|
2412
|
+
const [filteredHelpTopics, setFilteredHelpTopics] = React__default['default'].useState(combinedValue.filteredHelpTopics || []);
|
|
2413
|
+
return {
|
|
2414
|
+
helpTopics,
|
|
2415
|
+
setHelpTopics,
|
|
2416
|
+
activeHelpTopic,
|
|
2417
|
+
setActiveHelpTopicByName,
|
|
2418
|
+
filteredHelpTopics,
|
|
2419
|
+
setFilteredHelpTopics,
|
|
2420
|
+
loading,
|
|
2421
|
+
setLoading,
|
|
2422
|
+
};
|
|
2423
|
+
};
|
|
2424
|
+
|
|
2425
|
+
const HelpTopicPanelContent = (_a) => {
|
|
2426
|
+
var _b, _c;
|
|
2427
|
+
var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true, onClose } = _a, props = tslib.__rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable", "onClose"]);
|
|
2428
|
+
const { setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
|
|
2429
|
+
const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React__namespace.useState(false);
|
|
2430
|
+
const toggleHelpTopicMenu = () => {
|
|
2431
|
+
setIsHelpTopicMenuOpen(!isHelpTopicMenuOpen);
|
|
2432
|
+
};
|
|
2433
|
+
const onSelectHelpTopic = (_event, value) => {
|
|
2434
|
+
const topicName = value;
|
|
2435
|
+
setActiveHelpTopicByName(topicName.toString());
|
|
2436
|
+
toggleHelpTopicMenu();
|
|
2437
|
+
};
|
|
2438
|
+
const helpTopicOptions = filteredHelpTopics.length > 1 &&
|
|
2439
|
+
filteredHelpTopics.map((topic) => (React__namespace.createElement(reactCore.SelectOption, { key: topic.name, value: topic.name }, topic.title)));
|
|
2440
|
+
const paddingContainer = (children) => React__namespace.createElement("div", { style: { padding: '24px' } }, children);
|
|
2441
|
+
const panelBodyItems = (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2442
|
+
paddingContainer(React__namespace.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
|
|
2443
|
+
!!((_b = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _b === void 0 ? void 0 : _b.length) && React__namespace.createElement(reactCore.Divider, null),
|
|
2444
|
+
paddingContainer(React__namespace.createElement(reactCore.Stack, { hasGutter: true }, (_c = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _c === void 0 ? void 0 : _c.map(({ href, text, newTab, isExternal }, index) => (React__namespace.createElement(reactCore.StackItem, { key: index },
|
|
2445
|
+
React__namespace.createElement(reactCore.Button, { component: "a", href: href, target: newTab ? '_blank' : '', rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: isExternal ? React__namespace.createElement(ExternalLinkAltIcon__default['default'], null) : null, iconPosition: "right", style: { fontSize: 'inherit' } }, text || href))))))));
|
|
2446
|
+
const content = (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base" }, props),
|
|
2447
|
+
React__namespace.createElement("div", null,
|
|
2448
|
+
React__namespace.createElement(reactCore.DrawerHead, null,
|
|
2449
|
+
React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title" },
|
|
2450
|
+
helpTopicOptions && (React__namespace.createElement(reactCore.Select, { isPlain: true, id: "help-topics-select", selected: activeHelpTopic, isOpen: isHelpTopicMenuOpen, onSelect: onSelectHelpTopic, onOpenChange: (isOpen) => setIsHelpTopicMenuOpen(isOpen), toggle: (toggleRef) => (React__namespace.createElement(reactCore.MenuToggle, { isFullWidth: true, ref: toggleRef, icon: React__namespace.createElement(BarsIcon__default['default'], null), onClick: toggleHelpTopicMenu, isExpanded: isHelpTopicMenuOpen }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)) },
|
|
2451
|
+
React__namespace.createElement(reactCore.SelectList, null, helpTopicOptions))),
|
|
2452
|
+
React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-v5-global--spacer--md)' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)),
|
|
2453
|
+
React__namespace.createElement(reactCore.DrawerActions, null,
|
|
2454
|
+
React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: onClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))),
|
|
2455
|
+
React__namespace.createElement(reactCore.Divider, null),
|
|
2456
|
+
React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" }, panelBodyItems))));
|
|
2457
|
+
return content;
|
|
2458
|
+
};
|
|
2459
|
+
|
|
2460
|
+
const HelpTopicContainer = (_a) => {
|
|
2461
|
+
var { helpTopics, children, resourceBundle, language, loading = false, markdown, contextProps } = _a, props = tslib.__rest(_a, ["helpTopics", "children", "resourceBundle", "language", "loading", "markdown", "contextProps"]);
|
|
2462
|
+
const valuesForHelpTopicContext = useValuesForHelpTopicContext(Object.assign({ helpTopics,
|
|
2463
|
+
language, resourceBundle: Object.assign({}, resourceBundle), loading,
|
|
2464
|
+
markdown }, contextProps));
|
|
2465
|
+
React__namespace.useEffect(() => {
|
|
2466
|
+
if (loading !== valuesForHelpTopicContext.loading) {
|
|
2467
|
+
valuesForHelpTopicContext.setLoading(loading);
|
|
2468
|
+
}
|
|
2469
|
+
}, [loading, valuesForHelpTopicContext]);
|
|
2470
|
+
React__namespace.useEffect(() => {
|
|
2471
|
+
if (helpTopics &&
|
|
2472
|
+
JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)) {
|
|
2473
|
+
valuesForHelpTopicContext.setHelpTopics(helpTopics);
|
|
2474
|
+
}
|
|
2475
|
+
}, [helpTopics, valuesForHelpTopicContext]);
|
|
2476
|
+
return (React__namespace.createElement(HelpTopicContext.Provider, { value: valuesForHelpTopicContext },
|
|
2477
|
+
React__namespace.createElement(HelpTopicDrawer, Object.assign({}, props), children)));
|
|
2478
|
+
};
|
|
2479
|
+
const HelpTopicDrawer = (_a) => {
|
|
2480
|
+
var { children } = _a, props = tslib.__rest(_a, ["children"]);
|
|
2481
|
+
const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
|
|
2482
|
+
const onClose = () => {
|
|
2483
|
+
setActiveHelpTopicByName('');
|
|
2484
|
+
};
|
|
2485
|
+
const panelContent = (React__namespace.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics, onClose: onClose }));
|
|
2486
|
+
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2487
|
+
React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeHelpTopic, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, { panelContent: panelContent },
|
|
2488
|
+
React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-v5-c-drawer__main" }, panelContent)))));
|
|
2489
|
+
};
|
|
2490
|
+
|
|
2491
|
+
const useLocalStorage = (key, initialValue) => {
|
|
2492
|
+
// State to store our value
|
|
2493
|
+
// Pass initial state function to useState so logic is only executed once
|
|
2494
|
+
const [storedValue, setStoredValue] = React.useState(() => {
|
|
2495
|
+
try {
|
|
2496
|
+
// Get from local storage by key
|
|
2497
|
+
const item = window.localStorage.getItem(key);
|
|
2498
|
+
// Parse stored json or if none return initialValue
|
|
2499
|
+
return item ? JSON.parse(item) : initialValue;
|
|
2500
|
+
}
|
|
2501
|
+
catch (error) {
|
|
2502
|
+
// If error also return initialValue
|
|
2503
|
+
// eslint-disable-next-line no-console
|
|
2504
|
+
console.log(error);
|
|
2505
|
+
return initialValue;
|
|
2506
|
+
}
|
|
2507
|
+
});
|
|
2508
|
+
// Return a wrapped version of useState's setter function that ...
|
|
2509
|
+
// ... persists the new value to localStorage.
|
|
2510
|
+
const setValue = (value) => {
|
|
2511
|
+
try {
|
|
2512
|
+
// Allow value to be a function so we have same API as useState
|
|
2513
|
+
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
2514
|
+
// Save state
|
|
2515
|
+
setStoredValue(valueToStore);
|
|
2516
|
+
// Save to local storage
|
|
2517
|
+
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
2518
|
+
}
|
|
2519
|
+
catch (error) {
|
|
2520
|
+
// A more advanced implementation would handle the error case
|
|
2521
|
+
// eslint-disable-next-line no-console
|
|
2522
|
+
console.log(error);
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
return [storedValue, setValue];
|
|
2526
|
+
};
|
|
2527
|
+
|
|
2528
|
+
/* eslint-disable */
|
|
2529
|
+
// Brought in from dev to publish this with QS module
|
|
2530
|
+
// Dev now imports from here
|
|
2531
|
+
const ProcQuickStartParser = (quickStart, environmentVariables) => {
|
|
2532
|
+
var _a;
|
|
2533
|
+
const replaceEnvironmentVariables = (s) => s === null || s === void 0 ? void 0 : s.replace(/\${(\w+)}/, (substring, name) => {
|
|
2534
|
+
return environmentVariables ? ([name] ? environmentVariables[name] : substring) : substring;
|
|
2535
|
+
});
|
|
2536
|
+
quickStart.spec.tasks = (_a = quickStart.spec.tasks) === null || _a === void 0 ? void 0 : _a.map((task, index) => {
|
|
2537
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2538
|
+
let proc;
|
|
2539
|
+
let answer;
|
|
2540
|
+
if (typeof task === 'string') {
|
|
2541
|
+
proc = task;
|
|
2542
|
+
answer = {};
|
|
2543
|
+
}
|
|
2544
|
+
else {
|
|
2545
|
+
proc = task.proc;
|
|
2546
|
+
answer = task;
|
|
2547
|
+
delete task.proc;
|
|
2548
|
+
}
|
|
2549
|
+
let description = '', procedure, verification, title, summaryFailed, success, reviewFailed, prerequisites;
|
|
2550
|
+
if (proc) {
|
|
2551
|
+
const taskDOM = document.createElement('div');
|
|
2552
|
+
taskDOM.innerHTML = proc;
|
|
2553
|
+
// remove the screencapture images
|
|
2554
|
+
taskDOM.querySelectorAll('.imageblock.screencapture').forEach((node) => {
|
|
2555
|
+
var _a;
|
|
2556
|
+
(_a = node.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(node);
|
|
2557
|
+
});
|
|
2558
|
+
title = (_a = taskDOM
|
|
2559
|
+
.querySelector('h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child')) === null || _a === void 0 ? void 0 : _a.innerHTML.trim();
|
|
2560
|
+
let sectionBody = taskDOM.querySelector('.sectionbody');
|
|
2561
|
+
if (!(sectionBody === null || sectionBody === void 0 ? void 0 : sectionBody.hasChildNodes())) {
|
|
2562
|
+
// possibly in other templates, where we want to look for article
|
|
2563
|
+
sectionBody = taskDOM.querySelector('article');
|
|
2564
|
+
}
|
|
2565
|
+
if (sectionBody) {
|
|
2566
|
+
for (let i = 0; i < sectionBody.children.length || 0; i++) {
|
|
2567
|
+
/**
|
|
2568
|
+
child typically looks like:
|
|
2569
2569
|
|
|
2570
|
-
<div class="paragraph|olist|ulist|admonitionblock">
|
|
2571
|
-
<div class="title">Procedure|Prerequisites|Verification|Note|Warning</div>
|
|
2572
|
-
<ol|ul class="arabic">
|
|
2573
|
-
<li>
|
|
2574
|
-
<li>...
|
|
2575
|
-
</ol|ul>
|
|
2576
|
-
</div>
|
|
2570
|
+
<div class="paragraph|olist|ulist|admonitionblock">
|
|
2571
|
+
<div class="title">Procedure|Prerequisites|Verification|Note|Warning</div>
|
|
2572
|
+
<ol|ul class="arabic">
|
|
2573
|
+
<li>
|
|
2574
|
+
<li>...
|
|
2575
|
+
</ol|ul>
|
|
2576
|
+
</div>
|
|
2577
2577
|
|
|
2578
|
-
And the below code extracts the <ol> or <ul>
|
|
2579
|
-
Except for when there is no <div class="title|heading"/>, then the description is extracted
|
|
2580
|
-
in the else if below
|
|
2581
|
-
*/
|
|
2582
|
-
const child = sectionBody.children.item(i);
|
|
2583
|
-
// find the title
|
|
2584
|
-
const sectionTitle = child === null || child === void 0 ? void 0 : child.querySelector('.heading,.title');
|
|
2585
|
-
// should this section be assigned to a specific section
|
|
2586
|
-
const sectionTitleText = (_b = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _b === void 0 ? void 0 : _b.trim();
|
|
2587
|
-
const isKnownSection = ['Procedure', 'Verification', 'Prerequisites'].includes((_c = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim());
|
|
2588
|
-
if (isKnownSection) {
|
|
2589
|
-
switch (sectionTitleText) {
|
|
2590
|
-
case 'Procedure':
|
|
2591
|
-
procedure = (_d = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _d === void 0 ? void 0 : _d.outerHTML.trim();
|
|
2592
|
-
break;
|
|
2593
|
-
case 'Verification':
|
|
2594
|
-
verification = (_e = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _e === void 0 ? void 0 : _e.outerHTML.trim();
|
|
2595
|
-
break;
|
|
2596
|
-
case 'Prerequisites':
|
|
2597
|
-
prerequisites = (_f = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _f === void 0 ? void 0 : _f.outerHTML.trim();
|
|
2598
|
-
break;
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
else if (!procedure) {
|
|
2602
|
-
// Otherwise if it comes before a procedure it's part of the description
|
|
2603
|
-
description = description + (child === null || child === void 0 ? void 0 : child.outerHTML.trim());
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
success = (_g = taskDOM.querySelector('.qs-summary.success')) === null || _g === void 0 ? void 0 : _g.innerHTML.trim();
|
|
2608
|
-
reviewFailed = (_h = taskDOM.querySelector('.qs-review.failed')) === null || _h === void 0 ? void 0 : _h.innerHTML.trim();
|
|
2609
|
-
summaryFailed = (_j = taskDOM.querySelector('.qs-summary.failed')) === null || _j === void 0 ? void 0 : _j.innerHTML.trim();
|
|
2610
|
-
}
|
|
2611
|
-
answer.title = replaceEnvironmentVariables(answer.title || title);
|
|
2612
|
-
answer.description = replaceEnvironmentVariables(answer.description || `${description} ${prerequisites || ''} ${procedure}`);
|
|
2613
|
-
answer.review = answer.review || {};
|
|
2614
|
-
answer.review.instructions = replaceEnvironmentVariables(((_k = answer.review) === null || _k === void 0 ? void 0 : _k.instructions) || verification || 'Have you completed these steps?');
|
|
2615
|
-
answer.review.failedTaskHelp = replaceEnvironmentVariables(answer.review.failedTaskHelp ||
|
|
2616
|
-
reviewFailed ||
|
|
2617
|
-
'This task isn’t verified yet. Try the task again.');
|
|
2618
|
-
answer.summary = answer.summary || {};
|
|
2619
|
-
answer.summary.success = replaceEnvironmentVariables(answer.summary.success || success || 'You have completed this task!');
|
|
2620
|
-
answer.summary.failed = replaceEnvironmentVariables(answer.summary.failed || summaryFailed || 'Try the steps again.');
|
|
2621
|
-
return answer;
|
|
2622
|
-
});
|
|
2623
|
-
return quickStart;
|
|
2578
|
+
And the below code extracts the <ol> or <ul>
|
|
2579
|
+
Except for when there is no <div class="title|heading"/>, then the description is extracted
|
|
2580
|
+
in the else if below
|
|
2581
|
+
*/
|
|
2582
|
+
const child = sectionBody.children.item(i);
|
|
2583
|
+
// find the title
|
|
2584
|
+
const sectionTitle = child === null || child === void 0 ? void 0 : child.querySelector('.heading,.title');
|
|
2585
|
+
// should this section be assigned to a specific section
|
|
2586
|
+
const sectionTitleText = (_b = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _b === void 0 ? void 0 : _b.trim();
|
|
2587
|
+
const isKnownSection = ['Procedure', 'Verification', 'Prerequisites'].includes((_c = sectionTitle === null || sectionTitle === void 0 ? void 0 : sectionTitle.textContent) === null || _c === void 0 ? void 0 : _c.trim());
|
|
2588
|
+
if (isKnownSection) {
|
|
2589
|
+
switch (sectionTitleText) {
|
|
2590
|
+
case 'Procedure':
|
|
2591
|
+
procedure = (_d = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _d === void 0 ? void 0 : _d.outerHTML.trim();
|
|
2592
|
+
break;
|
|
2593
|
+
case 'Verification':
|
|
2594
|
+
verification = (_e = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _e === void 0 ? void 0 : _e.outerHTML.trim();
|
|
2595
|
+
break;
|
|
2596
|
+
case 'Prerequisites':
|
|
2597
|
+
prerequisites = (_f = child === null || child === void 0 ? void 0 : child.querySelector(':not(.heading):not(.title)')) === null || _f === void 0 ? void 0 : _f.outerHTML.trim();
|
|
2598
|
+
break;
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
else if (!procedure) {
|
|
2602
|
+
// Otherwise if it comes before a procedure it's part of the description
|
|
2603
|
+
description = description + (child === null || child === void 0 ? void 0 : child.outerHTML.trim());
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
success = (_g = taskDOM.querySelector('.qs-summary.success')) === null || _g === void 0 ? void 0 : _g.innerHTML.trim();
|
|
2608
|
+
reviewFailed = (_h = taskDOM.querySelector('.qs-review.failed')) === null || _h === void 0 ? void 0 : _h.innerHTML.trim();
|
|
2609
|
+
summaryFailed = (_j = taskDOM.querySelector('.qs-summary.failed')) === null || _j === void 0 ? void 0 : _j.innerHTML.trim();
|
|
2610
|
+
}
|
|
2611
|
+
answer.title = replaceEnvironmentVariables(answer.title || title);
|
|
2612
|
+
answer.description = replaceEnvironmentVariables(answer.description || `${description} ${prerequisites || ''} ${procedure}`);
|
|
2613
|
+
answer.review = answer.review || {};
|
|
2614
|
+
answer.review.instructions = replaceEnvironmentVariables(((_k = answer.review) === null || _k === void 0 ? void 0 : _k.instructions) || verification || 'Have you completed these steps?');
|
|
2615
|
+
answer.review.failedTaskHelp = replaceEnvironmentVariables(answer.review.failedTaskHelp ||
|
|
2616
|
+
reviewFailed ||
|
|
2617
|
+
'This task isn’t verified yet. Try the task again.');
|
|
2618
|
+
answer.summary = answer.summary || {};
|
|
2619
|
+
answer.summary.success = replaceEnvironmentVariables(answer.summary.success || success || 'You have completed this task!');
|
|
2620
|
+
answer.summary.failed = replaceEnvironmentVariables(answer.summary.failed || summaryFailed || 'Try the steps again.');
|
|
2621
|
+
return answer;
|
|
2622
|
+
});
|
|
2623
|
+
return quickStart;
|
|
2624
2624
|
};
|
|
2625
2625
|
|
|
2626
2626
|
exports.Box = Box;
|