@patternfly/quickstarts 2.0.1 → 2.2.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/index.js CHANGED
@@ -11,6 +11,8 @@ var tslib = require('tslib');
11
11
  var ReactDOM = require('react-dom');
12
12
  var server = require('react-dom/server');
13
13
  var CopyIcon = require('@patternfly/react-icons/dist/js/icons/copy-icon');
14
+ var LightbulbIcon = require('@patternfly/react-icons/dist/js/icons/lightbulb-icon');
15
+ var FireIcon = require('@patternfly/react-icons/dist/js/icons/fire-icon');
14
16
  var SyncAltIcon = require('@patternfly/react-icons/dist/js/icons/sync-alt-icon');
15
17
  var CheckCircleIcon = require('@patternfly/react-icons/dist/js/icons/check-circle-icon');
16
18
  var ExclamationCircleIcon = require('@patternfly/react-icons/dist/js/icons/exclamation-circle-icon');
@@ -22,6 +24,7 @@ var showdown = require('showdown');
22
24
  var ExternalLinkAltIcon = require('@patternfly/react-icons/dist/js/icons/external-link-alt-icon');
23
25
  var OutlinedClockIcon = require('@patternfly/react-icons/dist/js/icons/outlined-clock-icon');
24
26
  var ArrowRightIcon = require('@patternfly/react-icons/dist/js/icons/arrow-right-icon');
27
+ var BarsIcon = require('@patternfly/react-icons/dist/js/icons/bars-icon');
25
28
 
26
29
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
27
30
 
@@ -51,6 +54,8 @@ var SearchIcon__default = /*#__PURE__*/_interopDefaultLegacy(SearchIcon);
51
54
  var RocketIcon__default = /*#__PURE__*/_interopDefaultLegacy(RocketIcon);
52
55
  var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
53
56
  var CopyIcon__default = /*#__PURE__*/_interopDefaultLegacy(CopyIcon);
57
+ var LightbulbIcon__default = /*#__PURE__*/_interopDefaultLegacy(LightbulbIcon);
58
+ var FireIcon__default = /*#__PURE__*/_interopDefaultLegacy(FireIcon);
54
59
  var SyncAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(SyncAltIcon);
55
60
  var CheckCircleIcon__default = /*#__PURE__*/_interopDefaultLegacy(CheckCircleIcon);
56
61
  var ExclamationCircleIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExclamationCircleIcon);
@@ -58,6 +63,7 @@ var InfoCircleIcon__default = /*#__PURE__*/_interopDefaultLegacy(InfoCircleIcon)
58
63
  var ExternalLinkAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(ExternalLinkAltIcon);
59
64
  var OutlinedClockIcon__default = /*#__PURE__*/_interopDefaultLegacy(OutlinedClockIcon);
60
65
  var ArrowRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowRightIcon);
66
+ var BarsIcon__default = /*#__PURE__*/_interopDefaultLegacy(BarsIcon);
61
67
 
62
68
  function _extends() {
63
69
  _extends = Object.assign || function (target) {
@@ -109,7 +115,8 @@ const QUICKSTART_ID_FILTER_KEY = 'quickstart';
109
115
  const QUICKSTART_TASKS_INITIAL_STATES = [
110
116
  exports.QuickStartTaskStatus.INIT,
111
117
  exports.QuickStartTaskStatus.VISITED,
112
- ];
118
+ ];
119
+ const HELP_TOPIC_NAME_KEY = 'topic';
113
120
 
114
121
  let createHistory;
115
122
  try {
@@ -164,6 +171,7 @@ var Yes = "Yes";
164
171
  var No = "No";
165
172
  var Cancel = "Cancel";
166
173
  var Leave = "Leave";
174
+ var Type = "Quick start";
167
175
  var en = {
168
176
  "No results found": "No results found",
169
177
  "No results match the filter criteria. Remove filters or clear all filters to show results.": "No results match the filter criteria. Remove filters or clear all filters to show results.",
@@ -207,7 +215,8 @@ var en = {
207
215
  "Not available": "Not available",
208
216
  "Copy to clipboard": "Copy to clipboard",
209
217
  "Successfully copied to clipboard!": "Successfully copied to clipboard!",
210
- "Quick start • {{duration, number}} minutes": "Quick start • {{duration, number}} minutes"
218
+ Type: Type,
219
+ "{{type}} • {{duration, number}} minutes": "{{type}} • {{duration, number}} minutes"
211
220
  };
212
221
 
213
222
  /* eslint-disable */
@@ -620,7 +629,7 @@ const QuickStartContextDefaults = {
620
629
  useLegacyHeaderColors: false,
621
630
  markdown: null,
622
631
  loading: false,
623
- alwaysShowTaskReview: false,
632
+ alwaysShowTaskReview: true,
624
633
  };
625
634
  const QuickStartContext = React.createContext(QuickStartContextDefaults);
626
635
  const getResource = (resource, options, resourceBundle, lng) => {
@@ -717,7 +726,7 @@ const useValuesForQuickStartContext = (value = {}) => {
717
726
  useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
718
727
  return id;
719
728
  });
720
- setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.IN_PROGRESS) })));
729
+ setAllQuickStartStates((qs) => (Object.assign(Object.assign({}, qs), { [quickStartId]: getDefaultQuickStartState(totalTasks, exports.QuickStartStatus.NOT_STARTED) })));
721
730
  }, [setActiveQuickStartID, setAllQuickStartStates, useQueryParams]);
722
731
  // When alwaysShowTaskReview preference is enabled, skip visited step and go directly to review
723
732
  const stepAfterInitial = alwaysShowTaskReview
@@ -1315,6 +1324,39 @@ const useMultilineCopyClipboardShowdownExtension = () => {
1315
1324
  }), [getResource]);
1316
1325
  };
1317
1326
 
1327
+ var AdmonitionType;
1328
+ (function (AdmonitionType) {
1329
+ AdmonitionType["TIP"] = "TIP";
1330
+ AdmonitionType["NOTE"] = "NOTE";
1331
+ AdmonitionType["IMPORTANT"] = "IMPORTANT";
1332
+ AdmonitionType["WARNING"] = "WARNING";
1333
+ AdmonitionType["CAUTION"] = "CAUTION";
1334
+ })(AdmonitionType || (AdmonitionType = {}));
1335
+ const admonitionToAlertVariantMap = {
1336
+ [AdmonitionType.NOTE]: { variant: 'info' },
1337
+ [AdmonitionType.TIP]: { variant: 'default', customIcon: React__namespace.createElement(LightbulbIcon__default['default'], null) },
1338
+ [AdmonitionType.IMPORTANT]: { variant: 'danger' },
1339
+ [AdmonitionType.CAUTION]: { variant: 'warning', customIcon: React__namespace.createElement(FireIcon__default['default'], null) },
1340
+ [AdmonitionType.WARNING]: { variant: 'warning' },
1341
+ };
1342
+ const useAdmonitionShowdownExtension = () => {
1343
+ // const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
1344
+ return React__namespace.useMemo(() => ({
1345
+ type: 'lang',
1346
+ regex: /\[([\d\w\s-()$!]+)]{{(admonition) ([\w-]+)}}/g,
1347
+ replace: (text, content, admonitionLabel, admonitionType, groupId) => {
1348
+ if (!content || !admonitionLabel || !admonitionType || !groupId) {
1349
+ return text;
1350
+ }
1351
+ admonitionType = admonitionType.toUpperCase();
1352
+ const { variant, customIcon } = admonitionToAlertVariantMap[admonitionType];
1353
+ const style = admonitionType === AdmonitionType.CAUTION ? { backgroundColor: '#ec7a0915' } : {};
1354
+ const pfAlert = (React__namespace.createElement(reactCore.Alert, { variant: variant, customIcon: customIcon && customIcon, isInline: true, title: admonitionType, className: "pfext-markdown-admonition", style: style }, content));
1355
+ return removeTemplateWhitespace(server.renderToStaticMarkup(pfAlert));
1356
+ },
1357
+ }), []);
1358
+ };
1359
+
1318
1360
  const FallbackImg = ({ src, alt, className, fallback }) => {
1319
1361
  const [isSrcValid, setIsSrcValid] = React__namespace.useState(true);
1320
1362
  if (src && isSrcValid) {
@@ -1392,13 +1434,31 @@ const markdownConvert = (markdown, extensions) => {
1392
1434
  if (extensions) {
1393
1435
  converter.addExtension(extensions);
1394
1436
  }
1395
- // add hook to transform anchor tags
1396
1437
  DOMPurify.addHook('beforeSanitizeElements', function (node) {
1397
1438
  // nodeType 1 = element type
1439
+ // transform anchor tags
1398
1440
  if (node.nodeType === 1 && node.nodeName.toLowerCase() === 'a') {
1399
1441
  node.setAttribute('rel', 'noopener noreferrer');
1400
1442
  return node;
1401
1443
  }
1444
+ // add PF class to ul and ol lists
1445
+ if (node.nodeType === 1 &&
1446
+ (node.nodeName.toLowerCase() === 'ul' || node.nodeName.toLowerCase() === 'ol')) {
1447
+ node.setAttribute('class', 'pf-c-list');
1448
+ return node;
1449
+ }
1450
+ });
1451
+ // Add a hook to make all links open a new window
1452
+ DOMPurify.addHook('afterSanitizeAttributes', function (node) {
1453
+ // set all elements owning target to target=_blank
1454
+ if ('target' in node) {
1455
+ node.setAttribute('target', '_blank');
1456
+ }
1457
+ // set non-HTML/MathML links to xlink:show=new
1458
+ if (!node.hasAttribute('target') &&
1459
+ (node.hasAttribute('xlink:href') || node.hasAttribute('href'))) {
1460
+ node.setAttribute('xlink:show', 'new');
1461
+ }
1402
1462
  });
1403
1463
  return DOMPurify.sanitize(converter.makeHtml(markdown), {
1404
1464
  USE_PROFILES: {
@@ -1536,6 +1596,7 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1536
1596
  const { markdown } = React__namespace.useContext(QuickStartContext);
1537
1597
  const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
1538
1598
  const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
1599
+ const admonitionShowdownExtension = useAdmonitionShowdownExtension();
1539
1600
  return (React__namespace.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
1540
1601
  {
1541
1602
  type: 'lang',
@@ -1557,11 +1618,14 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
1557
1618
  },
1558
1619
  inlineCopyClipboardShowdownExtension,
1559
1620
  multilineCopyClipboardShowdownExtension,
1621
+ admonitionShowdownExtension,
1560
1622
  ...(markdown ? markdown.extensions : []),
1561
1623
  ], renderExtension: (docContext, rootSelector) => (React__namespace.createElement(React__namespace.Fragment, null,
1562
1624
  React__namespace.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
1563
1625
  React__namespace.createElement(MarkdownCopyClipboard, { docContext: docContext, rootSelector: rootSelector }),
1564
- markdown && markdown.renderExtension(docContext, rootSelector))), className: className }));
1626
+ markdown &&
1627
+ markdown.renderExtension &&
1628
+ markdown.renderExtension(docContext, rootSelector))), className: className }));
1565
1629
  };
1566
1630
 
1567
1631
  const QuickStartTileDescription = ({ description, prerequisites, }) => {
@@ -1667,7 +1731,9 @@ const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, })
1667
1731
  // @ts-ignore
1668
1732
  component: "div", style: {
1669
1733
  cursor: 'pointer',
1670
- }, 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, "data-test": `tile ${id}`, description: React__namespace.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent })));
1734
+ }, 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,
1735
+ // https://github.com/patternfly/patternfly-react/issues/7039
1736
+ href: "#", "data-test": `tile ${id}`, description: React__namespace.createElement(QuickStartTileDescription, { description: description, prerequisites: prerequisites }), footer: footerComponent })));
1671
1737
  };
1672
1738
 
1673
1739
  const QuickStartCatalog = ({ quickStarts }) => {
@@ -1818,7 +1884,9 @@ const QuickStartCatalogPage = ({ quickStarts, showFilter, sortFnc = (q1, q2) =>
1818
1884
  const filteredQs = showFilter
1819
1885
  ? filterQuickStarts(allQuickStarts, filter.keyword, filter.status.statusFilters, allQuickStartStates).sort(sortFncCallback)
1820
1886
  : allQuickStarts;
1821
- if (filteredQs.length !== filteredQuickStarts.length) {
1887
+ // also needs a check whether the content of the QS changed
1888
+ if (filteredQs.length !== filteredQuickStarts.length ||
1889
+ JSON.stringify(filteredQs) !== JSON.stringify(filteredQuickStarts)) {
1822
1890
  setFilteredQuickStarts(filteredQs);
1823
1891
  }
1824
1892
  }, [
@@ -1907,14 +1975,17 @@ const TaskIcon = ({ taskIndex, taskStatus }) => {
1907
1975
  }
1908
1976
  return React__namespace.createElement("span", { className: classNames }, content);
1909
1977
  };
1910
- const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, }) => {
1978
+ const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, isActiveTask, onTaskSelect, children, }) => {
1911
1979
  const classNames = reactStyles.css('pfext-quick-start-task-header__title', {
1912
1980
  'pfext-quick-start-task-header__title-success': taskStatus === exports.QuickStartTaskStatus.SUCCESS,
1913
1981
  'pfext-quick-start-task-header__title-failed': taskStatus === (exports.QuickStartTaskStatus.FAILED || exports.QuickStartTaskStatus.VISITED),
1914
1982
  });
1915
- const notCompleted = taskStatus === exports.QuickStartTaskStatus.VISITED;
1916
- const skippedReviewOrFailed = taskStatus === exports.QuickStartTaskStatus.REVIEW || taskStatus === exports.QuickStartTaskStatus.FAILED;
1917
- const tryAgain = !isActiveTask && (skippedReviewOrFailed || notCompleted) && (React__namespace.createElement(React__namespace.Fragment, null,
1983
+ // const notCompleted = taskStatus === QuickStartTaskStatus.VISITED;
1984
+ // const skippedReview = taskStatus === QuickStartTaskStatus.REVIEW;
1985
+ const failedReview = taskStatus === exports.QuickStartTaskStatus.FAILED;
1986
+ // TODO: toned down when this is shown, investigate further when we should display it
1987
+ // related: https://github.com/patternfly/patternfly-quickstarts/issues/104
1988
+ const tryAgain = failedReview && (React__namespace.createElement(React__namespace.Fragment, null,
1918
1989
  React__namespace.createElement("div", null),
1919
1990
  React__namespace.createElement("div", { className: "pfext-quick-start-task-header__tryagain" }, "Try the steps again.")));
1920
1991
  const content = (React__namespace.createElement("div", { className: "pfext-quick-start-task-header" },
@@ -1925,7 +1996,7 @@ const QuickStartTaskHeader = ({ title, taskIndex, subtitle, taskStatus, size, is
1925
1996
  ' ',
1926
1997
  subtitle))),
1927
1998
  tryAgain));
1928
- return (React__namespace.createElement(reactCore.WizardNavItem, { content: content, step: taskIndex, onNavItemClick: () => onTaskSelect(taskIndex - 1), navItemComponent: "button", isCurrent: isActiveTask }));
1999
+ return (React__namespace.createElement(reactCore.WizardNavItem, { content: content, step: taskIndex, onNavItemClick: () => onTaskSelect(taskIndex - 1), navItemComponent: "button", isCurrent: isActiveTask }, children));
1929
2000
  };
1930
2001
 
1931
2002
  const QuickStartTaskHeaderList = ({ tasks, allTaskStatuses, onTaskSelect, }) => {
@@ -1959,7 +2030,8 @@ const QuickStartIntroduction = ({ tasks, introduction, allTaskStatuses, prerequi
1959
2030
  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" },
1960
2031
  React__namespace.createElement(reactCore.List, { className: "pfext-quick-start-intro__prereq-list" }, prereqs.map((pr) => {
1961
2032
  return (React__namespace.createElement(reactCore.ListItem, { key: pr, className: "pfext-quick-start-intro__prereq-list__item" },
1962
- React__namespace.createElement("span", { className: "pfext-quick-start-intro__prereq-list__item-content" }, pr)));
2033
+ React__namespace.createElement("span", { className: "pfext-quick-start-intro__prereq-list__item-content" },
2034
+ React__namespace.createElement(QuickStartMarkdownView, { content: pr }))));
1963
2035
  }))));
1964
2036
  return (React__namespace.createElement(React__namespace.Fragment, null,
1965
2037
  React__namespace.createElement(QuickStartMarkdownView, { content: introduction }),
@@ -1988,7 +2060,7 @@ const QuickStartTaskReview = ({ review, taskStatus, onTaskReview, }) => {
1988
2060
  'pfext-quick-start-task-review--failed': taskStatus === exports.QuickStartTaskStatus.FAILED,
1989
2061
  });
1990
2062
  const title = React__namespace.createElement("span", { className: alertClassNames }, getResource('Check your work'));
1991
- return (React__namespace.createElement(reactCore.Alert, { className: "pfext-quick-start-task-review-alert", variant: getAlertVariant(taskStatus), title: title, isInline: true },
2063
+ return (React__namespace.createElement(reactCore.Alert, { className: "pfext-quick-start-task-review-alert", variant: getAlertVariant(taskStatus), title: title, isInline: true, role: "alert" },
1992
2064
  React__namespace.createElement(QuickStartMarkdownView, { content: instructions }),
1993
2065
  React__namespace.createElement("span", { className: "pfext-quick-start-task-review__actions" },
1994
2066
  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) }),
@@ -1998,22 +2070,22 @@ const QuickStartTaskReview = ({ review, taskStatus, onTaskReview, }) => {
1998
2070
 
1999
2071
  const QuickStartTasks = ({ tasks, taskNumber, allTaskStatuses, onTaskReview, onTaskSelect, }) => {
2000
2072
  const { getResource, alwaysShowTaskReview } = React__namespace.useContext(QuickStartContext);
2001
- return (React__namespace.createElement("div", { className: "pfext-quick-start-tasks__list" }, tasks
2002
- .filter((_, index) => allTaskStatuses[index] !== exports.QuickStartTaskStatus.INIT)
2003
- .map((task, index) => {
2004
- const { title, description, review } = task;
2005
- const isActiveTask = index === taskNumber;
2006
- const taskStatus = allTaskStatuses[index];
2007
- const shouldShowTaskReview = (!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) || alwaysShowTaskReview) &&
2008
- review;
2009
- return (React__namespace.createElement(React__namespace.Fragment, { key: title },
2010
- React__namespace.createElement(QuickStartTaskHeader, { taskIndex: index + 1, title: title, size: "md", subtitle: getResource('{{index, number}} of {{tasks, number}}')
2011
- .replace('{{index, number}}', index + 1)
2012
- .replace('{{tasks, number}}', tasks.length), taskStatus: taskStatus, isActiveTask: isActiveTask, onTaskSelect: onTaskSelect }),
2013
- isActiveTask && (React__namespace.createElement("div", { className: "pfext-quick-start-task__content" },
2014
- React__namespace.createElement(QuickStartMarkdownView, { content: description }),
2015
- shouldShowTaskReview && (React__namespace.createElement(QuickStartTaskReview, { review: review, taskStatus: taskStatus, onTaskReview: onTaskReview }))))));
2016
- })));
2073
+ return (React__namespace.createElement("div", { className: "pfext-quick-start-tasks__list" },
2074
+ React__namespace.createElement("ul", null, tasks
2075
+ .filter((_, index) => allTaskStatuses[index] !== exports.QuickStartTaskStatus.INIT)
2076
+ .map((task, index) => {
2077
+ const { title, description, review } = task;
2078
+ const isActiveTask = index === taskNumber;
2079
+ const taskStatus = allTaskStatuses[index];
2080
+ const shouldShowTaskReview = (!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus) || alwaysShowTaskReview) &&
2081
+ review;
2082
+ return (React__namespace.createElement(React__namespace.Fragment, { key: title },
2083
+ React__namespace.createElement(QuickStartTaskHeader, { taskIndex: index + 1, title: title, size: "md", subtitle: getResource('{{index, number}} of {{tasks, number}}')
2084
+ .replace('{{index, number}}', index + 1)
2085
+ .replace('{{tasks, number}}', tasks.length), taskStatus: taskStatus, isActiveTask: isActiveTask, onTaskSelect: onTaskSelect }, isActiveTask && (React__namespace.createElement("div", { className: "pfext-quick-start-task__content" },
2086
+ React__namespace.createElement(QuickStartMarkdownView, { content: description }),
2087
+ shouldShowTaskReview && (React__namespace.createElement(QuickStartTaskReview, { review: review, taskStatus: taskStatus, onTaskReview: onTaskReview })))))));
2088
+ }))));
2017
2089
  };
2018
2090
 
2019
2091
  const QuickStartContent = React__namespace.forwardRef(({ quickStart, nextQuickStarts = [], taskNumber, allTaskStatuses, onTaskSelect, onTaskReview, onQuickStartChange, }, ref) => {
@@ -2123,11 +2195,10 @@ const useScrollTopOnTaskNumberChange = (node, taskNumber) => {
2123
2195
  };
2124
2196
  const QuickStartPanelContent = (_a) => {
2125
2197
  var { quickStarts = [], handleClose, activeQuickStartID, appendTo, isResizable = true, showClose = true, headerVariant = '' } = _a, props = tslib.__rest(_a, ["quickStarts", "handleClose", "activeQuickStartID", "appendTo", "isResizable", "showClose", "headerVariant"]);
2126
- const { getResource } = React__namespace.useContext(QuickStartContext);
2198
+ const { getResource, activeQuickStartState } = React__namespace.useContext(QuickStartContext);
2127
2199
  const [contentRef, setContentRef] = React__namespace.useState();
2128
2200
  const shadows = useScrollShadows(contentRef);
2129
2201
  const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
2130
- const { activeQuickStartState } = React__namespace.useContext(QuickStartContext);
2131
2202
  const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
2132
2203
  useScrollTopOnTaskNumberChange(contentRef, taskNumber);
2133
2204
  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); });
@@ -2155,7 +2226,10 @@ const QuickStartPanelContent = (_a) => {
2155
2226
  React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } }, quickStart === null || quickStart === void 0 ? void 0 :
2156
2227
  quickStart.spec.displayName,
2157
2228
  ' ',
2158
- React__namespace.createElement("small", { className: "pfext-quick-start-panel-content__duration" }, getResource('Quick start • {{duration, number}} minutes', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes).replace('{{duration, number}}', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)))),
2229
+ React__namespace.createElement("small", { className: "pfext-quick-start-panel-content__duration" }, (quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes) ? getResource('{{type}} • {{duration, number}} minutes', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
2230
+ .replace('{{duration, number}}', quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.durationMinutes)
2231
+ .replace('{{type}}', getResource('Type'))
2232
+ : getResource('Type')))),
2159
2233
  showClose && (React__namespace.createElement(reactCore.DrawerActions, null,
2160
2234
  React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: handleClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))))),
2161
2235
  React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" },
@@ -2167,7 +2241,7 @@ const QuickStartPanelContent = (_a) => {
2167
2241
  };
2168
2242
 
2169
2243
  const QuickStartContainer = (_a) => {
2170
- var { quickStarts, children, activeQuickStartID, allQuickStartStates, setActiveQuickStartID, setAllQuickStartStates, appendTo, fullWidth, onCloseInProgress, onCloseNotInProgress, resourceBundle, showCardFooters, useLegacyHeaderColors, language, loading = false, useQueryParams = true, markdown, contextProps, alwaysShowTaskReview = false } = _a, props = tslib.__rest(_a, ["quickStarts", "children", "activeQuickStartID", "allQuickStartStates", "setActiveQuickStartID", "setAllQuickStartStates", "appendTo", "fullWidth", "onCloseInProgress", "onCloseNotInProgress", "resourceBundle", "showCardFooters", "useLegacyHeaderColors", "language", "loading", "useQueryParams", "markdown", "contextProps", "alwaysShowTaskReview"]);
2244
+ 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"]);
2171
2245
  const valuesForQuickstartContext = useValuesForQuickStartContext(Object.assign({ allQuickStarts: quickStarts, activeQuickStartID,
2172
2246
  setActiveQuickStartID,
2173
2247
  allQuickStartStates,
@@ -2205,7 +2279,7 @@ const QuickStartDrawer = (_a) => {
2205
2279
  // if there is a quick start param, but the quick start is not active, set it
2206
2280
  // this can happen if a new browser session is opened or an incognito window for example
2207
2281
  const quickStartIdFromParam = params.get(QUICKSTART_ID_FILTER_KEY) || '';
2208
- if (quickStartIdFromParam && !activeQuickStartID) {
2282
+ if (quickStartIdFromParam && activeQuickStartID !== quickStartIdFromParam) {
2209
2283
  const activeQuickStart = getQuickStartByName(quickStartIdFromParam, combinedQuickStarts);
2210
2284
  // don't try to load a quick start that is actually just an external resource (spec.link)
2211
2285
  if (combinedQuickStarts.length > 0 && activeQuickStart && !activeQuickStart.spec.link) {
@@ -2264,6 +2338,125 @@ const QuickStartDrawer = (_a) => {
2264
2338
  React__namespace.createElement(QuickStartCloseModal, { isOpen: modalOpen, onConfirm: onModalConfirm, onCancel: onModalCancel })));
2265
2339
  };
2266
2340
 
2341
+ const HelpTopicContextDefaults = {
2342
+ helpTopics: [],
2343
+ setHelpTopics: () => { },
2344
+ activeHelpTopic: null,
2345
+ setActiveHelpTopicByName: () => { },
2346
+ filteredHelpTopics: [],
2347
+ setFilteredHelpTopics: () => { },
2348
+ loading: false,
2349
+ };
2350
+ const HelpTopicContext = React__default['default'].createContext(HelpTopicContextDefaults);
2351
+ const useValuesForHelpTopicContext = (value = {}) => {
2352
+ const combinedValue = Object.assign(Object.assign({}, HelpTopicContextDefaults), value);
2353
+ const [loading, setLoading] = React__default['default'].useState(combinedValue.loading);
2354
+ // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
2355
+ const [helpTopics, setHelpTopics] = React__default['default'].useState(combinedValue.helpTopics || []);
2356
+ const [activeHelpTopic, setActiveHelpTopic] = React__default['default'].useState(combinedValue.activeHelpTopic || null);
2357
+ const setActiveHelpTopicByName = React__default['default'].useCallback((helpTopicName) => {
2358
+ const topic = helpTopics.find((t) => {
2359
+ return t.name === helpTopicName;
2360
+ });
2361
+ if (!helpTopicName) {
2362
+ setActiveHelpTopic(null);
2363
+ return;
2364
+ }
2365
+ setActiveHelpTopic(topic);
2366
+ }, [helpTopics]);
2367
+ const [filteredHelpTopics, setFilteredHelpTopics] = React__default['default'].useState(combinedValue.filteredHelpTopics || []);
2368
+ return {
2369
+ helpTopics,
2370
+ setHelpTopics,
2371
+ activeHelpTopic,
2372
+ setActiveHelpTopicByName,
2373
+ filteredHelpTopics,
2374
+ setFilteredHelpTopics,
2375
+ loading,
2376
+ setLoading,
2377
+ };
2378
+ };
2379
+
2380
+ const HelpTopicPanelContent = (_a) => {
2381
+ var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true, onClose } = _a, props = tslib.__rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable", "onClose"]);
2382
+ const { setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
2383
+ const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React__namespace.useState(false);
2384
+ const toggleHelpTopicMenu = () => {
2385
+ setIsHelpTopicMenuOpen(!isHelpTopicMenuOpen);
2386
+ };
2387
+ const onSelectHelpTopic = (event) => {
2388
+ const topicName = event.currentTarget.id;
2389
+ setActiveHelpTopicByName(topicName);
2390
+ toggleHelpTopicMenu();
2391
+ };
2392
+ const menuItems = filteredHelpTopics.length > 0 &&
2393
+ filteredHelpTopics.map((topic) => {
2394
+ return (React__namespace.createElement(reactCore.OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
2395
+ });
2396
+ const paddingContainer = (children) => React__namespace.createElement("div", { style: { padding: '24px' } }, children);
2397
+ const panelBodyItems = (React__namespace.createElement(React__namespace.Fragment, null,
2398
+ paddingContainer(React__namespace.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
2399
+ React__namespace.createElement(reactCore.Divider, null),
2400
+ paddingContainer(activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links.map((link) => {
2401
+ return React__namespace.createElement(QuickStartMarkdownView, { key: link, content: link });
2402
+ }))));
2403
+ const content = (React__namespace.createElement(reactCore.DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base" }, props),
2404
+ React__namespace.createElement("div", null,
2405
+ React__namespace.createElement(reactCore.DrawerHead, null,
2406
+ React__namespace.createElement("div", { className: "pfext-quick-start-panel-content__title" },
2407
+ menuItems && (React__namespace.createElement(reactCore.OptionsMenu, { id: 'helptopics', isPlain: true, isOpen: isHelpTopicMenuOpen, toggle: React__namespace.createElement(reactCore.OptionsMenuToggle, { style: { paddingLeft: '0px' }, onToggle: toggleHelpTopicMenu, toggleTemplate: React__namespace.createElement(BarsIcon__default['default'], null) }), menuItems: menuItems })),
2408
+ React__namespace.createElement(reactCore.Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)),
2409
+ React__namespace.createElement(reactCore.DrawerActions, null,
2410
+ React__namespace.createElement(reactCore.DrawerCloseButton, { onClick: onClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))),
2411
+ React__namespace.createElement(reactCore.Divider, null),
2412
+ React__namespace.createElement(reactCore.DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" }, panelBodyItems))));
2413
+ return content;
2414
+ };
2415
+
2416
+ const HelpTopicContainer = (_a) => {
2417
+ var { helpTopics, children, resourceBundle, language, loading = false, markdown, contextProps } = _a, props = tslib.__rest(_a, ["helpTopics", "children", "resourceBundle", "language", "loading", "markdown", "contextProps"]);
2418
+ const valuesForHelpTopicContext = useValuesForHelpTopicContext(Object.assign({ helpTopics,
2419
+ language, resourceBundle: Object.assign({}, resourceBundle), loading,
2420
+ markdown }, contextProps));
2421
+ React__namespace.useEffect(() => {
2422
+ if (loading !== valuesForHelpTopicContext.loading) {
2423
+ valuesForHelpTopicContext.setLoading(loading);
2424
+ }
2425
+ }, [loading, valuesForHelpTopicContext]);
2426
+ React__namespace.useEffect(() => {
2427
+ if (helpTopics &&
2428
+ JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)) {
2429
+ valuesForHelpTopicContext.setHelpTopics(helpTopics);
2430
+ }
2431
+ }, [helpTopics, valuesForHelpTopicContext]);
2432
+ const drawerProps = Object.assign({}, props);
2433
+ return (React__namespace.createElement(HelpTopicContext.Provider, { value: valuesForHelpTopicContext },
2434
+ React__namespace.createElement(HelpTopicDrawer, Object.assign({}, drawerProps), children)));
2435
+ };
2436
+ const HelpTopicDrawer = (_a) => {
2437
+ var {
2438
+ // helpTopics,
2439
+ children } = _a, props = tslib.__rest(_a, ["children"]);
2440
+ const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } = React__namespace.useContext(HelpTopicContext);
2441
+ // Leave here if query param is desired for help topics later
2442
+ // React.useEffect(() => {
2443
+ // const params = new URLSearchParams(window.location.search);
2444
+ // // if there is a quick start param, but the quick start is not active, set it
2445
+ // // this can happen if a new browser session is opened or an incognito window for example
2446
+ // const helpTopicNameFromParam = params.get(HELP_TOPIC_NAME_KEY) || '';
2447
+ // if (helpTopicNameFromParam) {
2448
+ // setActiveHelpTopicByName(helpTopicNameFromParam);
2449
+ // }
2450
+ // }, [inContextHelpTopics, setActiveHelpTopicByName]);
2451
+ const onClose = () => {
2452
+ setActiveHelpTopicByName('');
2453
+ };
2454
+ const panelContent = (React__namespace.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics, onClose: onClose }));
2455
+ return (React__namespace.createElement(React__namespace.Fragment, null,
2456
+ React__namespace.createElement(reactCore.Drawer, Object.assign({ isExpanded: !!activeHelpTopic, isInline: true }, props), children ? (React__namespace.createElement(reactCore.DrawerContent, { panelContent: panelContent },
2457
+ React__namespace.createElement(reactCore.DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React__namespace.createElement("div", { className: "pf-c-drawer__main" }, panelContent)))));
2458
+ };
2459
+
2267
2460
  const useLocalStorage = (key, initialValue) => {
2268
2461
  // State to store our value
2269
2462
  // Pass initial state function to useState so logic is only executed once
@@ -2304,6 +2497,11 @@ const useLocalStorage = (key, initialValue) => {
2304
2497
  exports.Box = Box;
2305
2498
  exports.CamelCaseWrap = CamelCaseWrap;
2306
2499
  exports.EmptyBox = EmptyBox;
2500
+ exports.HELP_TOPIC_NAME_KEY = HELP_TOPIC_NAME_KEY;
2501
+ exports.HelpTopicContainer = HelpTopicContainer;
2502
+ exports.HelpTopicContext = HelpTopicContext;
2503
+ exports.HelpTopicContextDefaults = HelpTopicContextDefaults;
2504
+ exports.HelpTopicDrawer = HelpTopicDrawer;
2307
2505
  exports.Loading = Loading;
2308
2506
  exports.LoadingBox = LoadingBox;
2309
2507
  exports.QUICKSTART_ID_FILTER_KEY = QUICKSTART_ID_FILTER_KEY;
@@ -2352,5 +2550,6 @@ exports.isDisabledQuickStart = isDisabledQuickStart;
2352
2550
  exports.removeQueryArgument = removeQueryArgument;
2353
2551
  exports.setQueryArgument = setQueryArgument;
2354
2552
  exports.useLocalStorage = useLocalStorage;
2553
+ exports.useValuesForHelpTopicContext = useValuesForHelpTopicContext;
2355
2554
  exports.useValuesForQuickStartContext = useValuesForQuickStartContext;
2356
2555
  //# sourceMappingURL=index.js.map