@patternfly/quickstarts 0.0.0
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/README.md +546 -0
- package/dist/ConsoleInternal/components/markdown-view.d.ts +19 -0
- package/dist/ConsoleInternal/components/utils/camel-case-wrap.d.ts +6 -0
- package/dist/ConsoleInternal/components/utils/index.d.ts +3 -0
- package/dist/ConsoleInternal/components/utils/router.d.ts +9 -0
- package/dist/ConsoleInternal/components/utils/status-box.d.ts +20 -0
- package/dist/ConsoleInternal/module/k8s/types.d.ts +42 -0
- package/dist/ConsoleShared/index.d.ts +1 -0
- package/dist/ConsoleShared/src/components/index.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.d.ts +13 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/accordion-extension.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.d.ts +6 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/admonition-extension.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/code-extension.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/const.d.ts +5 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/index.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/inline-clipboard-extension.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/multiline-clipboard-extension.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/utils.d.ts +1 -0
- package/dist/ConsoleShared/src/components/markdown-highlight-extension/MarkdownHighlightExtension.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-highlight-extension/highlight-consts.d.ts +4 -0
- package/dist/ConsoleShared/src/components/markdown-highlight-extension/index.d.ts +1 -0
- package/dist/ConsoleShared/src/components/modal/Modal.d.ts +9 -0
- package/dist/ConsoleShared/src/components/modal/index.d.ts +1 -0
- package/dist/ConsoleShared/src/components/popper/Portal.d.ts +8 -0
- package/dist/ConsoleShared/src/components/popper/SimplePopper.d.ts +6 -0
- package/dist/ConsoleShared/src/components/popper/index.d.ts +2 -0
- package/dist/ConsoleShared/src/components/spotlight/InteractiveSpotlight.d.ts +7 -0
- package/dist/ConsoleShared/src/components/spotlight/Spotlight.d.ts +7 -0
- package/dist/ConsoleShared/src/components/spotlight/StaticSpotlight.d.ts +7 -0
- package/dist/ConsoleShared/src/components/spotlight/index.d.ts +1 -0
- package/dist/ConsoleShared/src/components/status/GenericStatus.d.ts +12 -0
- package/dist/ConsoleShared/src/components/status/NotStartedIcon.d.ts +3 -0
- package/dist/ConsoleShared/src/components/status/PopoverStatus.d.ts +13 -0
- package/dist/ConsoleShared/src/components/status/Status.d.ts +11 -0
- package/dist/ConsoleShared/src/components/status/StatusIconAndText.d.ts +8 -0
- package/dist/ConsoleShared/src/components/status/icons.d.ts +9 -0
- package/dist/ConsoleShared/src/components/status/index.d.ts +1 -0
- package/dist/ConsoleShared/src/components/status/statuses.d.ts +5 -0
- package/dist/ConsoleShared/src/components/status/types.d.ts +9 -0
- package/dist/ConsoleShared/src/components/utils/FallbackImg.d.ts +9 -0
- package/dist/ConsoleShared/src/components/utils/index.d.ts +1 -0
- package/dist/ConsoleShared/src/constants/index.d.ts +1 -0
- package/dist/ConsoleShared/src/constants/ui.d.ts +1 -0
- package/dist/ConsoleShared/src/hooks/index.d.ts +6 -0
- package/dist/ConsoleShared/src/hooks/scroll.d.ts +8 -0
- package/dist/ConsoleShared/src/hooks/useBoundingClientRect.d.ts +3 -0
- package/dist/ConsoleShared/src/hooks/useEventListener.d.ts +1 -0
- package/dist/ConsoleShared/src/hooks/useForceRender.d.ts +4 -0
- package/dist/ConsoleShared/src/hooks/useResizeObserver.d.ts +1 -0
- package/dist/ConsoleShared/src/hooks/useScrollShadows.d.ts +7 -0
- package/dist/ConsoleShared/src/index.d.ts +4 -0
- package/dist/ConsoleShared/src/utils/index.d.ts +1 -0
- package/dist/ConsoleShared/src/utils/useCombineRefs.d.ts +2 -0
- package/dist/HelpTopicDrawer.d.ts +33 -0
- package/dist/HelpTopicPanelContent.d.ts +11 -0
- package/dist/QuickStartCatalogPage.d.ts +14 -0
- package/dist/QuickStartCloseModal.d.ts +8 -0
- package/dist/QuickStartController.d.ts +10 -0
- package/dist/QuickStartDrawer.d.ts +62 -0
- package/dist/QuickStartMarkdownView.d.ts +9 -0
- package/dist/QuickStartPanelContent.d.ts +15 -0
- package/dist/catalog/Catalog/QuickStartCatalogHeader.d.ts +6 -0
- package/dist/catalog/Catalog/QuickStartCatalogSection.d.ts +5 -0
- package/dist/catalog/Catalog/QuickStartCatalogToolbar.d.ts +5 -0
- package/dist/catalog/Catalog/index.d.ts +3 -0
- package/dist/catalog/QuickStartCatalog.d.ts +8 -0
- package/dist/catalog/QuickStartTile.d.ts +14 -0
- package/dist/catalog/QuickStartTileDescription.d.ts +8 -0
- package/dist/catalog/QuickStartTileFooter.d.ts +8 -0
- package/dist/catalog/QuickStartTileFooterExternal.d.ts +8 -0
- package/dist/catalog/QuickStartTileHeader.d.ts +24 -0
- package/dist/catalog/Toolbar/QuickStartCatalogFilter.d.ts +10 -0
- package/dist/catalog/Toolbar/QuickStartCatalogFilterItems.d.ts +31 -0
- package/dist/catalog/index.d.ts +9 -0
- package/dist/controller/QuickStartConclusion.d.ts +12 -0
- package/dist/controller/QuickStartContent.d.ts +14 -0
- package/dist/controller/QuickStartFooter.d.ts +14 -0
- package/dist/controller/QuickStartIntroduction.d.ts +12 -0
- package/dist/controller/QuickStartTaskHeader.d.ts +15 -0
- package/dist/controller/QuickStartTaskHeaderList.d.ts +10 -0
- package/dist/controller/QuickStartTaskReview.d.ts +10 -0
- package/dist/controller/QuickStartTasks.d.ts +12 -0
- package/dist/data/mocks/json/explore-pipeline-quickstart.d.ts +2 -0
- package/dist/data/mocks/json/explore-serverless-quickstart.d.ts +2 -0
- package/dist/data/mocks/json/monitor-sampleapp-quickstart.d.ts +2 -0
- package/dist/data/mocks/json/tour-icons.d.ts +2 -0
- package/dist/data/quick-start-test-data.d.ts +2 -0
- package/dist/data/test-utils.d.ts +8 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.es.js +2593 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +2695 -0
- package/dist/index.js.map +1 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/design-guidelines.md +105 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/card-elements copy.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/card-elements.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/catalog-elements.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/check-your-work.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/introduction-screen.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/mixed-catalog.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/prerequisites.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/qs-context.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel-elements.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel-resized.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/task-no.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/task-yes.png +0 -0
- package/dist/patternfly-docs/quick-starts/design-guidelines/img/task.png +0 -0
- package/dist/patternfly-docs/quick-starts/examples/Basic.jsx +73 -0
- package/dist/patternfly-docs/quick-starts/examples/HelpTopic.jsx +51 -0
- package/dist/patternfly-docs/quick-starts/examples/about.md +84 -0
- package/dist/patternfly-docs/quick-starts/examples/basic.md +29 -0
- package/dist/patternfly-docs/quick-starts/examples/example-data/example-help-topics.js +173 -0
- package/dist/patternfly-docs/quick-starts/examples/example-data/example-quickstarts.js +215 -0
- package/dist/patternfly-docs/quick-starts/examples/example-data/index.js +15 -0
- package/dist/patternfly-docs/quick-starts/examples/help-topics.md +28 -0
- package/dist/patternfly-docs/quick-starts/examples/img/catalog.png +0 -0
- package/dist/patternfly-docs/quick-starts/examples/img/help-topic.png +0 -0
- package/dist/patternfly-docs/quick-starts/examples/img/side-panel.png +0 -0
- package/dist/patternfly-global.css +1302 -0
- package/dist/patternfly-nested.css +11812 -0
- package/dist/quickstarts-base.css +1219 -0
- package/dist/quickstarts-full.es.js +31861 -0
- package/dist/quickstarts-full.es.js.map +1 -0
- package/dist/quickstarts-standalone.css +868 -0
- package/dist/quickstarts-standalone.min.css +4 -0
- package/dist/quickstarts-vendor.css +165 -0
- package/dist/quickstarts.css +1383 -0
- package/dist/quickstarts.min.css +1 -0
- package/dist/styles/patternfly-global-entry.d.ts +1 -0
- package/dist/styles/patternfly-nested-entry.d.ts +1 -0
- package/dist/styles/quickstarts-standalone-entry.d.ts +1 -0
- package/dist/styles/vendor-entry.d.ts +1 -0
- package/dist/utils/PluralResolver.d.ts +16 -0
- package/dist/utils/asciidoc-procedure-parser.d.ts +12 -0
- package/dist/utils/const.d.ts +6 -0
- package/dist/utils/help-topic-context.d.ts +23 -0
- package/dist/utils/help-topic-types.d.ts +13 -0
- package/dist/utils/quick-start-context.d.ts +81 -0
- package/dist/utils/quick-start-types.d.ts +60 -0
- package/dist/utils/quick-start-utils.d.ts +10 -0
- package/dist/utils/useLocalStorage.d.ts +1 -0
- package/dist/vendor.js +2 -0
- package/dist/vendor.js.map +1 -0
- package/package.json +105 -0
- package/src/ConsoleInternal/components/_icon-and-text.scss +14 -0
- package/src/ConsoleInternal/components/_markdown-view.scss +19 -0
- package/src/ConsoleInternal/components/catalog/_catalog.scss +392 -0
- package/src/ConsoleInternal/components/markdown-view.tsx +276 -0
- package/src/ConsoleInternal/components/utils/_status-box.scss +58 -0
- package/src/ConsoleInternal/components/utils/camel-case-wrap.tsx +33 -0
- package/src/ConsoleInternal/components/utils/index.tsx +3 -0
- package/src/ConsoleInternal/components/utils/router.ts +45 -0
- package/src/ConsoleInternal/components/utils/status-box.tsx +56 -0
- package/src/ConsoleInternal/module/k8s/types.ts +53 -0
- package/src/ConsoleShared/index.ts +1 -0
- package/src/ConsoleShared/src/components/index.ts +7 -0
- package/src/ConsoleShared/src/components/layout/PageLayout.scss +29 -0
- package/src/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.tsx +95 -0
- package/src/ConsoleShared/src/components/markdown-extensions/__tests__/MarkdownCopyClipboard.spec.tsx +25 -0
- package/src/ConsoleShared/src/components/markdown-extensions/__tests__/test-data.ts +5 -0
- package/src/ConsoleShared/src/components/markdown-extensions/accordion-extension.tsx +51 -0
- package/src/ConsoleShared/src/components/markdown-extensions/accordion-render-extension.tsx +60 -0
- package/src/ConsoleShared/src/components/markdown-extensions/admonition-extension.tsx +67 -0
- package/src/ConsoleShared/src/components/markdown-extensions/code-extension.tsx +23 -0
- package/src/ConsoleShared/src/components/markdown-extensions/const.ts +5 -0
- package/src/ConsoleShared/src/components/markdown-extensions/index.ts +7 -0
- package/src/ConsoleShared/src/components/markdown-extensions/inline-clipboard-extension.tsx +39 -0
- package/src/ConsoleShared/src/components/markdown-extensions/multiline-clipboard-extension.tsx +44 -0
- package/src/ConsoleShared/src/components/markdown-extensions/showdown-extension.scss +52 -0
- package/src/ConsoleShared/src/components/markdown-extensions/utils.ts +1 -0
- package/src/ConsoleShared/src/components/markdown-highlight-extension/MarkdownHighlightExtension.tsx +65 -0
- package/src/ConsoleShared/src/components/markdown-highlight-extension/highlight-consts.ts +9 -0
- package/src/ConsoleShared/src/components/markdown-highlight-extension/index.ts +1 -0
- package/src/ConsoleShared/src/components/modal/Modal.scss +3 -0
- package/src/ConsoleShared/src/components/modal/Modal.tsx +19 -0
- package/src/ConsoleShared/src/components/modal/index.ts +1 -0
- package/src/ConsoleShared/src/components/popper/Portal.tsx +25 -0
- package/src/ConsoleShared/src/components/popper/SimplePopper.tsx +92 -0
- package/src/ConsoleShared/src/components/popper/index.ts +2 -0
- package/src/ConsoleShared/src/components/spotlight/InteractiveSpotlight.tsx +58 -0
- package/src/ConsoleShared/src/components/spotlight/Spotlight.tsx +35 -0
- package/src/ConsoleShared/src/components/spotlight/StaticSpotlight.tsx +32 -0
- package/src/ConsoleShared/src/components/spotlight/index.ts +1 -0
- package/src/ConsoleShared/src/components/spotlight/spotlight.scss +63 -0
- package/src/ConsoleShared/src/components/status/GenericStatus.tsx +34 -0
- package/src/ConsoleShared/src/components/status/NotStartedIcon.tsx +27 -0
- package/src/ConsoleShared/src/components/status/PopoverStatus.tsx +39 -0
- package/src/ConsoleShared/src/components/status/Status.tsx +38 -0
- package/src/ConsoleShared/src/components/status/StatusIconAndText.tsx +42 -0
- package/src/ConsoleShared/src/components/status/icons.tsx +39 -0
- package/src/ConsoleShared/src/components/status/index.tsx +1 -0
- package/src/ConsoleShared/src/components/status/statuses.tsx +20 -0
- package/src/ConsoleShared/src/components/status/types.ts +8 -0
- package/src/ConsoleShared/src/components/utils/FallbackImg.tsx +20 -0
- package/src/ConsoleShared/src/components/utils/index.ts +1 -0
- package/src/ConsoleShared/src/constants/index.ts +1 -0
- package/src/ConsoleShared/src/constants/ui.ts +1 -0
- package/src/ConsoleShared/src/hooks/index.ts +6 -0
- package/src/ConsoleShared/src/hooks/scroll.ts +52 -0
- package/src/ConsoleShared/src/hooks/useBoundingClientRect.ts +18 -0
- package/src/ConsoleShared/src/hooks/useEventListener.ts +14 -0
- package/src/ConsoleShared/src/hooks/useForceRender.ts +6 -0
- package/src/ConsoleShared/src/hooks/useResizeObserver.ts +19 -0
- package/src/ConsoleShared/src/hooks/useScrollShadows.ts +45 -0
- package/src/ConsoleShared/src/index.ts +4 -0
- package/src/ConsoleShared/src/utils/index.ts +1 -0
- package/src/ConsoleShared/src/utils/useCombineRefs.ts +16 -0
- package/src/HelpTopicDrawer.tsx +116 -0
- package/src/HelpTopicPanelContent.tsx +160 -0
- package/src/QuickStartCatalogPage.tsx +195 -0
- package/src/QuickStartCloseModal.tsx +47 -0
- package/src/QuickStartController.tsx +111 -0
- package/src/QuickStartDrawer.scss +11 -0
- package/src/QuickStartDrawer.tsx +265 -0
- package/src/QuickStartMarkdownView.tsx +80 -0
- package/src/QuickStartPanelContent.scss +46 -0
- package/src/QuickStartPanelContent.tsx +165 -0
- package/src/__tests__/quick-start-utils.spec.tsx +16 -0
- package/src/catalog/Catalog/QuickStartCatalogHeader.tsx +18 -0
- package/src/catalog/Catalog/QuickStartCatalogSection.tsx +9 -0
- package/src/catalog/Catalog/QuickStartCatalogToolbar.tsx +12 -0
- package/src/catalog/Catalog/index.ts +3 -0
- package/src/catalog/QuickStartCatalog.scss +8 -0
- package/src/catalog/QuickStartCatalog.tsx +42 -0
- package/src/catalog/QuickStartTile.scss +11 -0
- package/src/catalog/QuickStartTile.tsx +129 -0
- package/src/catalog/QuickStartTileDescription.scss +29 -0
- package/src/catalog/QuickStartTileDescription.tsx +79 -0
- package/src/catalog/QuickStartTileFooter.tsx +101 -0
- package/src/catalog/QuickStartTileFooterExternal.tsx +40 -0
- package/src/catalog/QuickStartTileHeader.scss +16 -0
- package/src/catalog/QuickStartTileHeader.tsx +105 -0
- package/src/catalog/Toolbar/QuickStartCatalogFilter.scss +25 -0
- package/src/catalog/Toolbar/QuickStartCatalogFilter.tsx +32 -0
- package/src/catalog/Toolbar/QuickStartCatalogFilterItems.tsx +218 -0
- package/src/catalog/__tests__/QuickStartCatalog.spec.tsx +35 -0
- package/src/catalog/__tests__/QuickStartTile.spec.tsx +38 -0
- package/src/catalog/__tests__/QuickStartTileDescription.spec.tsx +44 -0
- package/src/catalog/index.ts +9 -0
- package/src/controller/QuickStartConclusion.tsx +63 -0
- package/src/controller/QuickStartContent.scss +12 -0
- package/src/controller/QuickStartContent.tsx +72 -0
- package/src/controller/QuickStartFooter.scss +13 -0
- package/src/controller/QuickStartFooter.tsx +124 -0
- package/src/controller/QuickStartIntroduction.scss +35 -0
- package/src/controller/QuickStartIntroduction.tsx +64 -0
- package/src/controller/QuickStartTaskHeader.scss +58 -0
- package/src/controller/QuickStartTaskHeader.tsx +125 -0
- package/src/controller/QuickStartTaskHeaderList.scss +17 -0
- package/src/controller/QuickStartTaskHeaderList.tsx +33 -0
- package/src/controller/QuickStartTaskReview.scss +30 -0
- package/src/controller/QuickStartTaskReview.tsx +81 -0
- package/src/controller/QuickStartTasks.scss +89 -0
- package/src/controller/QuickStartTasks.tsx +75 -0
- package/src/controller/__tests__/QuickStartConclusion.spec.tsx +95 -0
- package/src/controller/__tests__/QuickStartContent.spec.tsx +52 -0
- package/src/controller/__tests__/QuickStartFooter.spec.tsx +148 -0
- package/src/controller/__tests__/QuickStartTaskHeader.spec.tsx +43 -0
- package/src/controller/__tests__/QuickStartTaskReview.spec.tsx +45 -0
- package/src/controller/__tests__/QuickStartTasks.spec.tsx +81 -0
- package/src/data/mocks/json/explore-pipeline-quickstart.ts +66 -0
- package/src/data/mocks/json/explore-serverless-quickstart.ts +90 -0
- package/src/data/mocks/json/monitor-sampleapp-quickstart.ts +77 -0
- package/src/data/mocks/json/tour-icons.ts +3 -0
- package/src/data/mocks/yamls/add-healthchecks-quickstart.yaml +67 -0
- package/src/data/mocks/yamls/explore-pipeline-quickstart.yaml +57 -0
- package/src/data/mocks/yamls/explore-serverless-quickstart.yaml +83 -0
- package/src/data/mocks/yamls/install-associate-pipeline-quickstart.yaml +74 -0
- package/src/data/mocks/yamls/monitor-sampleapp-quickstart.yaml +66 -0
- package/src/data/mocks/yamls/sample-application-quickstart.yaml +97 -0
- package/src/data/mocks/yamls/serverless-application-quickstart.yaml +141 -0
- package/src/data/quick-start-test-data.ts +10 -0
- package/src/data/test-utils.ts +11 -0
- package/src/declaration.d.ts +2 -0
- package/src/index.ts +17 -0
- package/src/locales/en/quickstart.json +46 -0
- package/src/styles/_base.scss +54 -0
- package/src/styles/_dark-custom-override.scss +62 -0
- package/src/styles/legacy-bootstrap/README.md +21 -0
- package/src/styles/legacy-bootstrap/_code.scss +46 -0
- package/src/styles/legacy-bootstrap/_tables.scss +38 -0
- package/src/styles/legacy-bootstrap/_type.scss +92 -0
- package/src/styles/legacy-bootstrap/_variables.scss +48 -0
- package/src/styles/legacy-bootstrap.scss +5 -0
- package/src/styles/patternfly-global-entry.ts +1 -0
- package/src/styles/patternfly-global.scss +28 -0
- package/src/styles/patternfly-nested-entry.ts +1 -0
- package/src/styles/patternfly-nested.scss +18 -0
- package/src/styles/quickstarts-standalone-entry.ts +1 -0
- package/src/styles/quickstarts-standalone.scss +7 -0
- package/src/styles/style.scss +12 -0
- package/src/styles/vendor-entry.ts +1 -0
- package/src/styles/vendor.scss +7 -0
- package/src/utils/PluralResolver.ts +362 -0
- package/src/utils/asciidoc-procedure-parser.ts +130 -0
- package/src/utils/const.ts +10 -0
- package/src/utils/help-topic-context.tsx +72 -0
- package/src/utils/help-topic-types.ts +16 -0
- package/src/utils/quick-start-context.tsx +473 -0
- package/src/utils/quick-start-types.ts +73 -0
- package/src/utils/quick-start-utils.ts +88 -0
- package/src/utils/useLocalStorage.ts +38 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// Brought in from dev to publish this with QS module
|
|
3
|
+
// Dev now imports from here
|
|
4
|
+
|
|
5
|
+
import { QuickStart, QuickStartTask } from './quick-start-types';
|
|
6
|
+
|
|
7
|
+
export const ProcQuickStartParser = (
|
|
8
|
+
quickStart: QuickStart & {
|
|
9
|
+
spec: {
|
|
10
|
+
tasks: undefined | QuickStartTask[] | string[];
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
environmentVariables?: { [name: string]: string },
|
|
14
|
+
) => {
|
|
15
|
+
const replaceEnvironmentVariables = (s: string | undefined) =>
|
|
16
|
+
s?.replace(/\${(\w+)}/, (substring, name) => {
|
|
17
|
+
return environmentVariables ? ([name] ? environmentVariables[name] : substring) : substring;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
quickStart.spec.tasks = quickStart.spec.tasks?.map((task: QuickStartTask | string, index) => {
|
|
21
|
+
let proc: string;
|
|
22
|
+
let answer: QuickStartTask;
|
|
23
|
+
if (typeof task === 'string') {
|
|
24
|
+
proc = task;
|
|
25
|
+
answer = {};
|
|
26
|
+
} else {
|
|
27
|
+
proc = task.proc;
|
|
28
|
+
answer = task;
|
|
29
|
+
delete task.proc;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let description = '',
|
|
33
|
+
procedure,
|
|
34
|
+
verification,
|
|
35
|
+
title,
|
|
36
|
+
summaryFailed,
|
|
37
|
+
success,
|
|
38
|
+
reviewFailed: string | undefined,
|
|
39
|
+
prerequisites;
|
|
40
|
+
if (proc) {
|
|
41
|
+
const taskDOM = document.createElement('div');
|
|
42
|
+
taskDOM.innerHTML = proc;
|
|
43
|
+
|
|
44
|
+
// remove the screencapture images
|
|
45
|
+
taskDOM.querySelectorAll('.imageblock.screencapture').forEach((node) => {
|
|
46
|
+
node.parentElement?.removeChild(node);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
title = taskDOM
|
|
50
|
+
.querySelector('h1:first-child,h2:first-child,h3:first-child,h4:first-child,h5:first-child')
|
|
51
|
+
?.innerHTML.trim();
|
|
52
|
+
let sectionBody = taskDOM.querySelector('.sectionbody');
|
|
53
|
+
if (!sectionBody?.hasChildNodes()) {
|
|
54
|
+
// possibly in other templates, where we want to look for article
|
|
55
|
+
sectionBody = taskDOM.querySelector('article');
|
|
56
|
+
}
|
|
57
|
+
if (sectionBody) {
|
|
58
|
+
for (let i = 0; i < sectionBody.children.length || 0; i++) {
|
|
59
|
+
/**
|
|
60
|
+
child typically looks like:
|
|
61
|
+
|
|
62
|
+
<div class="paragraph|olist|ulist|admonitionblock">
|
|
63
|
+
<div class="title">Procedure|Prerequisites|Verification|Note|Warning</div>
|
|
64
|
+
<ol|ul class="arabic">
|
|
65
|
+
<li>
|
|
66
|
+
<li>...
|
|
67
|
+
</ol|ul>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
And the below code extracts the <ol> or <ul>
|
|
71
|
+
Except for when there is no <div class="title|heading"/>, then the description is extracted
|
|
72
|
+
in the else if below
|
|
73
|
+
*/
|
|
74
|
+
const child = sectionBody.children.item(i);
|
|
75
|
+
// find the title
|
|
76
|
+
const sectionTitle = child?.querySelector('.heading,.title');
|
|
77
|
+
// should this section be assigned to a specific section
|
|
78
|
+
const sectionTitleText = sectionTitle?.textContent?.trim();
|
|
79
|
+
const isKnownSection = ['Procedure', 'Verification', 'Prerequisites'].includes(
|
|
80
|
+
sectionTitle?.textContent?.trim(),
|
|
81
|
+
);
|
|
82
|
+
if (isKnownSection) {
|
|
83
|
+
switch (sectionTitleText) {
|
|
84
|
+
case 'Procedure':
|
|
85
|
+
procedure = child?.querySelector(':not(.heading):not(.title)')?.outerHTML.trim();
|
|
86
|
+
break;
|
|
87
|
+
case 'Verification':
|
|
88
|
+
verification = child?.querySelector(':not(.heading):not(.title)')?.outerHTML.trim();
|
|
89
|
+
break;
|
|
90
|
+
case 'Prerequisites':
|
|
91
|
+
prerequisites = child
|
|
92
|
+
?.querySelector(':not(.heading):not(.title)')
|
|
93
|
+
?.outerHTML.trim();
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
} else if (!procedure) {
|
|
97
|
+
// Otherwise if it comes before a procedure it's part of the description
|
|
98
|
+
description = description + child?.outerHTML.trim();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
success = taskDOM.querySelector('.qs-summary.success')?.innerHTML.trim();
|
|
103
|
+
reviewFailed = taskDOM.querySelector('.qs-review.failed')?.innerHTML.trim();
|
|
104
|
+
summaryFailed = taskDOM.querySelector('.qs-summary.failed')?.innerHTML.trim();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
answer.title = replaceEnvironmentVariables(answer.title || title);
|
|
108
|
+
answer.description = replaceEnvironmentVariables(
|
|
109
|
+
answer.description || `${description} ${prerequisites || ''} ${procedure}`,
|
|
110
|
+
);
|
|
111
|
+
answer.review = answer.review || {};
|
|
112
|
+
answer.review.instructions = replaceEnvironmentVariables(
|
|
113
|
+
answer.review?.instructions || verification || 'Have you completed these steps?',
|
|
114
|
+
);
|
|
115
|
+
answer.review.failedTaskHelp = replaceEnvironmentVariables(
|
|
116
|
+
answer.review.failedTaskHelp ||
|
|
117
|
+
reviewFailed ||
|
|
118
|
+
'This task isn’t verified yet. Try the task again.',
|
|
119
|
+
);
|
|
120
|
+
answer.summary = answer.summary || {};
|
|
121
|
+
answer.summary.success = replaceEnvironmentVariables(
|
|
122
|
+
answer.summary.success || success || 'You have completed this task!',
|
|
123
|
+
);
|
|
124
|
+
answer.summary.failed = replaceEnvironmentVariables(
|
|
125
|
+
answer.summary.failed || summaryFailed || 'Try the steps again.',
|
|
126
|
+
);
|
|
127
|
+
return answer;
|
|
128
|
+
});
|
|
129
|
+
return quickStart;
|
|
130
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { QuickStartTaskStatus } from './quick-start-types';
|
|
2
|
+
|
|
3
|
+
export const QUICKSTART_SEARCH_FILTER_KEY = 'keyword';
|
|
4
|
+
export const QUICKSTART_STATUS_FILTER_KEY = 'status';
|
|
5
|
+
export const QUICKSTART_ID_FILTER_KEY = 'quickstart';
|
|
6
|
+
export const QUICKSTART_TASKS_INITIAL_STATES = [
|
|
7
|
+
QuickStartTaskStatus.INIT,
|
|
8
|
+
QuickStartTaskStatus.VISITED,
|
|
9
|
+
];
|
|
10
|
+
export const HELP_TOPIC_NAME_KEY = 'topic';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HelpTopic } from './help-topic-types';
|
|
3
|
+
|
|
4
|
+
export interface HelpTopicContextValues {
|
|
5
|
+
helpTopics?: HelpTopic[];
|
|
6
|
+
setHelpTopics?: React.Dispatch<React.SetStateAction<HelpTopic[]>>;
|
|
7
|
+
activeHelpTopic?: HelpTopic;
|
|
8
|
+
setActiveHelpTopicByName?: (helpTopicName: string) => void;
|
|
9
|
+
filteredHelpTopics?: HelpTopic[];
|
|
10
|
+
setFilteredHelpTopics?: React.Dispatch<React.SetStateAction<HelpTopic[]>>;
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
setLoading?: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const HelpTopicContextDefaults = {
|
|
16
|
+
helpTopics: [],
|
|
17
|
+
setHelpTopics: () => {},
|
|
18
|
+
activeHelpTopic: null,
|
|
19
|
+
setActiveHelpTopicByName: () => {},
|
|
20
|
+
filteredHelpTopics: [],
|
|
21
|
+
setFilteredHelpTopics: () => {},
|
|
22
|
+
loading: false,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const HelpTopicContext = React.createContext<HelpTopicContextValues>(
|
|
26
|
+
HelpTopicContextDefaults,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const useValuesForHelpTopicContext = (
|
|
30
|
+
value: HelpTopicContextValues = {},
|
|
31
|
+
): HelpTopicContextValues => {
|
|
32
|
+
const combinedValue = {
|
|
33
|
+
...HelpTopicContextDefaults,
|
|
34
|
+
...value,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const [loading, setLoading] = React.useState(combinedValue.loading);
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
40
|
+
const [helpTopics, setHelpTopics] = React.useState<HelpTopic[]>(combinedValue.helpTopics || []);
|
|
41
|
+
|
|
42
|
+
const [activeHelpTopic, setActiveHelpTopic] = React.useState(
|
|
43
|
+
combinedValue.activeHelpTopic || null,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const setActiveHelpTopicByName = React.useCallback(
|
|
47
|
+
(helpTopicName: string) => {
|
|
48
|
+
const topic = helpTopics.find((t) => t.name === helpTopicName);
|
|
49
|
+
if (!helpTopicName) {
|
|
50
|
+
setActiveHelpTopic(null);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
setActiveHelpTopic(topic);
|
|
54
|
+
},
|
|
55
|
+
[helpTopics],
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const [filteredHelpTopics, setFilteredHelpTopics] = React.useState(
|
|
59
|
+
combinedValue.filteredHelpTopics || [],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
helpTopics,
|
|
64
|
+
setHelpTopics,
|
|
65
|
+
activeHelpTopic,
|
|
66
|
+
setActiveHelpTopicByName,
|
|
67
|
+
filteredHelpTopics,
|
|
68
|
+
setFilteredHelpTopics,
|
|
69
|
+
loading,
|
|
70
|
+
setLoading,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface HelpTopicLink {
|
|
2
|
+
href: string;
|
|
3
|
+
text?: string;
|
|
4
|
+
// open link in new tab
|
|
5
|
+
newTab?: boolean;
|
|
6
|
+
// add PF icon indicating link is external
|
|
7
|
+
isExternal?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface HelpTopic {
|
|
11
|
+
name: string;
|
|
12
|
+
title: string;
|
|
13
|
+
tags: string[];
|
|
14
|
+
content: string;
|
|
15
|
+
links?: HelpTopicLink[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
import React, { createContext, useCallback } from 'react';
|
|
2
|
+
import { removeQueryArgument, setQueryArgument } from '../ConsoleInternal/components/utils/router';
|
|
3
|
+
import en from '../locales/en/quickstart.json';
|
|
4
|
+
import {
|
|
5
|
+
QUICKSTART_ID_FILTER_KEY,
|
|
6
|
+
QUICKSTART_SEARCH_FILTER_KEY,
|
|
7
|
+
QUICKSTART_STATUS_FILTER_KEY,
|
|
8
|
+
QUICKSTART_TASKS_INITIAL_STATES,
|
|
9
|
+
} from './const';
|
|
10
|
+
import PluralResolver from './PluralResolver';
|
|
11
|
+
import {
|
|
12
|
+
AllQuickStartStates,
|
|
13
|
+
QuickStart,
|
|
14
|
+
QuickStartState,
|
|
15
|
+
QuickStartStatus,
|
|
16
|
+
QuickStartTaskStatus,
|
|
17
|
+
} from './quick-start-types';
|
|
18
|
+
import { getQuickStartStatusCount, getTaskStatusKey } from './quick-start-utils';
|
|
19
|
+
|
|
20
|
+
const pluralResolver = new PluralResolver({ simplifyPluralSuffix: true });
|
|
21
|
+
|
|
22
|
+
export interface FooterProps {
|
|
23
|
+
show?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const getDefaultQuickStartState = (
|
|
27
|
+
totalTasks?: number,
|
|
28
|
+
initialStatus?: QuickStartStatus,
|
|
29
|
+
) => {
|
|
30
|
+
const defaultQuickStartState = {
|
|
31
|
+
status: initialStatus || QuickStartStatus.NOT_STARTED,
|
|
32
|
+
taskNumber: -1,
|
|
33
|
+
};
|
|
34
|
+
if (totalTasks) {
|
|
35
|
+
for (let i = 0; i < totalTasks; i++) {
|
|
36
|
+
defaultQuickStartState[getTaskStatusKey(i)] = QuickStartTaskStatus.INIT;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return defaultQuickStartState;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export interface QuickStartContextValues {
|
|
43
|
+
allQuickStarts?: QuickStart[];
|
|
44
|
+
setAllQuickStarts?: React.Dispatch<React.SetStateAction<QuickStart[]>>;
|
|
45
|
+
activeQuickStartID?: string;
|
|
46
|
+
setActiveQuickStartID?: React.Dispatch<React.SetStateAction<string>>;
|
|
47
|
+
allQuickStartStates?: AllQuickStartStates;
|
|
48
|
+
setAllQuickStartStates?: React.Dispatch<React.SetStateAction<AllQuickStartStates>>;
|
|
49
|
+
activeQuickStartState?: QuickStartState;
|
|
50
|
+
setActiveQuickStart?: (quickStartId: string, totalTasks?: number) => void;
|
|
51
|
+
startQuickStart?: (quickStartId: string, totalTasks?: number) => void;
|
|
52
|
+
restartQuickStart?: (quickStartId: string, totalTasks: number) => void;
|
|
53
|
+
nextStep?: (totalTasks: number) => void;
|
|
54
|
+
previousStep?: () => void;
|
|
55
|
+
setQuickStartTaskNumber?: (quickStartId: string, taskNumber: number) => void;
|
|
56
|
+
setQuickStartTaskStatus?: (taskStatus: QuickStartTaskStatus) => void;
|
|
57
|
+
getQuickStartForId?: (id: string) => QuickStartState;
|
|
58
|
+
footer?: FooterProps;
|
|
59
|
+
useLegacyHeaderColors?: boolean;
|
|
60
|
+
useQueryParams?: boolean;
|
|
61
|
+
markdown?: {
|
|
62
|
+
extensions?: any[];
|
|
63
|
+
renderExtension?: (docContext: Document, rootSelector: string) => React.ReactNode;
|
|
64
|
+
};
|
|
65
|
+
resourceBundle?: any;
|
|
66
|
+
getResource?: any;
|
|
67
|
+
setResourceBundle?: any;
|
|
68
|
+
language?: string;
|
|
69
|
+
setLanguage?: any;
|
|
70
|
+
filter?: {
|
|
71
|
+
keyword?: string;
|
|
72
|
+
status?: {
|
|
73
|
+
statusTypes?: any;
|
|
74
|
+
statusFilters?: any;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
setFilter?: any;
|
|
78
|
+
loading?: boolean;
|
|
79
|
+
setLoading?: any;
|
|
80
|
+
alwaysShowTaskReview?: boolean;
|
|
81
|
+
setAlwaysShowTaskReview?: any;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export const QuickStartContextDefaults = {
|
|
85
|
+
allQuickStarts: [],
|
|
86
|
+
activeQuickStartID: '',
|
|
87
|
+
allQuickStartStates: {},
|
|
88
|
+
activeQuickStartState: {},
|
|
89
|
+
setAllQuickStarts: () => {},
|
|
90
|
+
resourceBundle: en,
|
|
91
|
+
getResource: (resource: string) => resource,
|
|
92
|
+
language: 'en',
|
|
93
|
+
useQueryParams: true,
|
|
94
|
+
filter: {
|
|
95
|
+
keyword: '',
|
|
96
|
+
status: {
|
|
97
|
+
statusTypes: {},
|
|
98
|
+
statusFilters: [],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
setFilter: () => {},
|
|
102
|
+
footer: null,
|
|
103
|
+
useLegacyHeaderColors: false,
|
|
104
|
+
markdown: null,
|
|
105
|
+
loading: false,
|
|
106
|
+
alwaysShowTaskReview: true,
|
|
107
|
+
};
|
|
108
|
+
export const QuickStartContext = createContext<QuickStartContextValues>(QuickStartContextDefaults);
|
|
109
|
+
|
|
110
|
+
export const getResource = (resource: string, options: any, resourceBundle: any, lng: string) => {
|
|
111
|
+
if (options && !isNaN(options.count)) {
|
|
112
|
+
const suffix = pluralResolver.getSuffix(lng, options.count);
|
|
113
|
+
if (suffix && resourceBundle[`${resource}_${suffix}`]) {
|
|
114
|
+
// needs plural
|
|
115
|
+
return resourceBundle[`${resource}_${suffix}`];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return (resourceBundle && resourceBundle[resource]) || resource;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const useValuesForQuickStartContext = (
|
|
122
|
+
value: QuickStartContextValues = {},
|
|
123
|
+
): QuickStartContextValues => {
|
|
124
|
+
const combinedValue = {
|
|
125
|
+
...QuickStartContextDefaults,
|
|
126
|
+
...value,
|
|
127
|
+
};
|
|
128
|
+
const {
|
|
129
|
+
activeQuickStartID,
|
|
130
|
+
setActiveQuickStartID,
|
|
131
|
+
setAllQuickStartStates,
|
|
132
|
+
useQueryParams,
|
|
133
|
+
allQuickStartStates,
|
|
134
|
+
allQuickStarts = [],
|
|
135
|
+
footer,
|
|
136
|
+
useLegacyHeaderColors,
|
|
137
|
+
markdown,
|
|
138
|
+
} = combinedValue;
|
|
139
|
+
const [quickStarts, setQuickStarts] = React.useState(combinedValue.allQuickStarts || []);
|
|
140
|
+
const [resourceBundle, setResourceBundle] = React.useState({
|
|
141
|
+
...en,
|
|
142
|
+
...combinedValue.resourceBundle,
|
|
143
|
+
});
|
|
144
|
+
const [language, setLanguage] = React.useState(combinedValue.language);
|
|
145
|
+
const changeResourceBundle = (bundle: any, lng?: string) => {
|
|
146
|
+
lng && setLanguage(lng);
|
|
147
|
+
setResourceBundle({
|
|
148
|
+
...en,
|
|
149
|
+
...bundle,
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const findResource = useCallback(
|
|
153
|
+
(resource: string, count?: number) => getResource(
|
|
154
|
+
resource,
|
|
155
|
+
count !== undefined ? { count } : null,
|
|
156
|
+
resourceBundle,
|
|
157
|
+
language,
|
|
158
|
+
),
|
|
159
|
+
[resourceBundle, language],
|
|
160
|
+
);
|
|
161
|
+
const [loading, setLoading] = React.useState(combinedValue.loading);
|
|
162
|
+
const [alwaysShowTaskReview, setAlwaysShowTaskReview] = React.useState(
|
|
163
|
+
combinedValue.alwaysShowTaskReview,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const initialSearchParams = new URLSearchParams(window.location.search);
|
|
167
|
+
const initialSearchQuery = initialSearchParams.get(QUICKSTART_SEARCH_FILTER_KEY) || '';
|
|
168
|
+
const initialStatusFilters =
|
|
169
|
+
initialSearchParams.get(QUICKSTART_STATUS_FILTER_KEY)?.split(',') || [];
|
|
170
|
+
|
|
171
|
+
const quickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, allQuickStarts);
|
|
172
|
+
const [statusTypes, setStatusTypes] = React.useState({
|
|
173
|
+
[QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace(
|
|
174
|
+
'{{statusCount, number}}',
|
|
175
|
+
quickStartStatusCount[QuickStartStatus.COMPLETE],
|
|
176
|
+
),
|
|
177
|
+
[QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace(
|
|
178
|
+
'{{statusCount, number}}',
|
|
179
|
+
quickStartStatusCount[QuickStartStatus.IN_PROGRESS],
|
|
180
|
+
),
|
|
181
|
+
[QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace(
|
|
182
|
+
'{{statusCount, number}}',
|
|
183
|
+
quickStartStatusCount[QuickStartStatus.NOT_STARTED],
|
|
184
|
+
),
|
|
185
|
+
});
|
|
186
|
+
const [statusFilters, setStatusFilters] = React.useState<string[]>(initialStatusFilters);
|
|
187
|
+
|
|
188
|
+
const [filterKeyword, setFilterKeyword] = React.useState(initialSearchQuery);
|
|
189
|
+
|
|
190
|
+
const setFilter = (type: 'keyword' | 'status', val: any) => {
|
|
191
|
+
if (type === 'keyword') {
|
|
192
|
+
setFilterKeyword(val);
|
|
193
|
+
} else if (type === 'status') {
|
|
194
|
+
setStatusFilters(val);
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
React.useEffect(() => {
|
|
199
|
+
const updatedQuickStartStatusCount = getQuickStartStatusCount(allQuickStartStates, quickStarts);
|
|
200
|
+
setStatusTypes({
|
|
201
|
+
[QuickStartStatus.COMPLETE]: findResource('Complete ({{statusCount, number}})').replace(
|
|
202
|
+
'{{statusCount, number}}',
|
|
203
|
+
updatedQuickStartStatusCount[QuickStartStatus.COMPLETE],
|
|
204
|
+
),
|
|
205
|
+
[QuickStartStatus.IN_PROGRESS]: findResource('In progress ({{statusCount, number}})').replace(
|
|
206
|
+
'{{statusCount, number}}',
|
|
207
|
+
updatedQuickStartStatusCount[QuickStartStatus.IN_PROGRESS],
|
|
208
|
+
),
|
|
209
|
+
[QuickStartStatus.NOT_STARTED]: findResource('Not started ({{statusCount, number}})').replace(
|
|
210
|
+
'{{statusCount, number}}',
|
|
211
|
+
updatedQuickStartStatusCount[QuickStartStatus.NOT_STARTED],
|
|
212
|
+
),
|
|
213
|
+
});
|
|
214
|
+
}, [allQuickStartStates, findResource, quickStarts]);
|
|
215
|
+
|
|
216
|
+
const updateAllQuickStarts = (qs: QuickStart[]) => {
|
|
217
|
+
setQuickStarts(qs);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const setActiveQuickStart = useCallback(
|
|
221
|
+
(quickStartId: string, totalTasks?: number) => {
|
|
222
|
+
setActiveQuickStartID((id) => {
|
|
223
|
+
if (!quickStartId || id === quickStartId) {
|
|
224
|
+
useQueryParams && removeQueryArgument(QUICKSTART_ID_FILTER_KEY);
|
|
225
|
+
return '';
|
|
226
|
+
}
|
|
227
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
228
|
+
return quickStartId;
|
|
229
|
+
});
|
|
230
|
+
setAllQuickStartStates((qs) =>
|
|
231
|
+
!quickStartId || qs[quickStartId]
|
|
232
|
+
? qs
|
|
233
|
+
: { ...qs, [quickStartId]: getDefaultQuickStartState(totalTasks) },
|
|
234
|
+
);
|
|
235
|
+
},
|
|
236
|
+
[setActiveQuickStartID, setAllQuickStartStates, useQueryParams],
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
const startQuickStart = useCallback(
|
|
240
|
+
(quickStartId: string, totalTasks?: number) => {
|
|
241
|
+
setActiveQuickStartID((id) => {
|
|
242
|
+
if (!id || id !== quickStartId) {
|
|
243
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
244
|
+
return quickStartId;
|
|
245
|
+
}
|
|
246
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
|
|
247
|
+
return id;
|
|
248
|
+
});
|
|
249
|
+
setAllQuickStartStates((qs) => {
|
|
250
|
+
if (qs.hasOwnProperty(quickStartId)) {
|
|
251
|
+
return {
|
|
252
|
+
...qs,
|
|
253
|
+
[quickStartId]: {
|
|
254
|
+
...qs[quickStartId],
|
|
255
|
+
status: QuickStartStatus.IN_PROGRESS,
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
...qs,
|
|
261
|
+
[quickStartId]: getDefaultQuickStartState(totalTasks, QuickStartStatus.IN_PROGRESS),
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
},
|
|
265
|
+
[setActiveQuickStartID, setAllQuickStartStates, useQueryParams],
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
const restartQuickStart = useCallback(
|
|
269
|
+
(quickStartId: string, totalTasks: number) => {
|
|
270
|
+
setActiveQuickStartID((id) => {
|
|
271
|
+
if (!id || id !== quickStartId) {
|
|
272
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, quickStartId);
|
|
273
|
+
return quickStartId;
|
|
274
|
+
}
|
|
275
|
+
useQueryParams && setQueryArgument(QUICKSTART_ID_FILTER_KEY, id);
|
|
276
|
+
return id;
|
|
277
|
+
});
|
|
278
|
+
setAllQuickStartStates((qs) => ({
|
|
279
|
+
...qs,
|
|
280
|
+
[quickStartId]: getDefaultQuickStartState(totalTasks, QuickStartStatus.NOT_STARTED),
|
|
281
|
+
}));
|
|
282
|
+
},
|
|
283
|
+
[setActiveQuickStartID, setAllQuickStartStates, useQueryParams],
|
|
284
|
+
);
|
|
285
|
+
|
|
286
|
+
// When alwaysShowTaskReview preference is enabled, skip visited step and go directly to review
|
|
287
|
+
const stepAfterInitial = alwaysShowTaskReview
|
|
288
|
+
? QuickStartTaskStatus.REVIEW
|
|
289
|
+
: QuickStartTaskStatus.VISITED;
|
|
290
|
+
|
|
291
|
+
const nextStep = useCallback(
|
|
292
|
+
(totalTasks: number) => {
|
|
293
|
+
if (!activeQuickStartID) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
setAllQuickStartStates((qs) => {
|
|
298
|
+
const quickStart = qs[activeQuickStartID];
|
|
299
|
+
const status = quickStart?.status;
|
|
300
|
+
const taskNumber = quickStart?.taskNumber as number;
|
|
301
|
+
const taskStatus = quickStart[getTaskStatusKey(taskNumber)];
|
|
302
|
+
|
|
303
|
+
let updatedStatus;
|
|
304
|
+
let updatedTaskNumber;
|
|
305
|
+
let updatedTaskStatus;
|
|
306
|
+
|
|
307
|
+
if (status === QuickStartStatus.NOT_STARTED) {
|
|
308
|
+
updatedStatus = QuickStartStatus.IN_PROGRESS;
|
|
309
|
+
} else if (
|
|
310
|
+
status === QuickStartStatus.IN_PROGRESS &&
|
|
311
|
+
!QUICKSTART_TASKS_INITIAL_STATES.includes(taskStatus as any) &&
|
|
312
|
+
taskNumber === totalTasks - 1
|
|
313
|
+
) {
|
|
314
|
+
updatedStatus = QuickStartStatus.COMPLETE;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (taskStatus === QuickStartTaskStatus.VISITED) {
|
|
318
|
+
updatedTaskStatus = QuickStartTaskStatus.REVIEW;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (taskNumber < totalTasks && !updatedTaskStatus) {
|
|
322
|
+
updatedTaskNumber = taskNumber + 1;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const markInitialStepVisitedOrReview =
|
|
326
|
+
updatedTaskNumber > -1 &&
|
|
327
|
+
quickStart[getTaskStatusKey(updatedTaskNumber)] === QuickStartTaskStatus.INIT
|
|
328
|
+
? stepAfterInitial
|
|
329
|
+
: quickStart[getTaskStatusKey(updatedTaskNumber)];
|
|
330
|
+
const newState = {
|
|
331
|
+
...qs,
|
|
332
|
+
[activeQuickStartID]: {
|
|
333
|
+
...quickStart,
|
|
334
|
+
...(updatedStatus ? { status: updatedStatus } : {}),
|
|
335
|
+
...(updatedTaskNumber > -1
|
|
336
|
+
? {
|
|
337
|
+
taskNumber: updatedTaskNumber,
|
|
338
|
+
[getTaskStatusKey(updatedTaskNumber)]: markInitialStepVisitedOrReview,
|
|
339
|
+
}
|
|
340
|
+
: {}),
|
|
341
|
+
...(updatedTaskStatus ? { [getTaskStatusKey(taskNumber)]: updatedTaskStatus } : {}),
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
return newState;
|
|
345
|
+
});
|
|
346
|
+
},
|
|
347
|
+
[activeQuickStartID, setAllQuickStartStates, stepAfterInitial],
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
const previousStep = useCallback(() => {
|
|
351
|
+
setAllQuickStartStates((qs) => {
|
|
352
|
+
const quickStart = qs[activeQuickStartID];
|
|
353
|
+
const taskNumber = quickStart?.taskNumber as number;
|
|
354
|
+
|
|
355
|
+
if (taskNumber < 0) {
|
|
356
|
+
return qs;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return {
|
|
360
|
+
...qs,
|
|
361
|
+
[activeQuickStartID]: {
|
|
362
|
+
...quickStart,
|
|
363
|
+
taskNumber: taskNumber - 1,
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
});
|
|
367
|
+
}, [activeQuickStartID, setAllQuickStartStates]);
|
|
368
|
+
|
|
369
|
+
const setQuickStartTaskNumber = useCallback(
|
|
370
|
+
(quickStartId: string, taskNumber: number) => {
|
|
371
|
+
setAllQuickStartStates((qs) => {
|
|
372
|
+
const quickStart = qs[quickStartId];
|
|
373
|
+
const status = quickStart?.status;
|
|
374
|
+
let updatedStatus;
|
|
375
|
+
if (taskNumber > -1 && status === QuickStartStatus.NOT_STARTED) {
|
|
376
|
+
updatedStatus = QuickStartStatus.IN_PROGRESS;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
let updatedTaskStatus = {};
|
|
380
|
+
for (let taskIndex = 0; taskIndex <= taskNumber; taskIndex++) {
|
|
381
|
+
const taskStatus = quickStart[getTaskStatusKey(taskIndex)];
|
|
382
|
+
const newTaskStatus =
|
|
383
|
+
taskStatus === QuickStartTaskStatus.INIT ? stepAfterInitial : undefined;
|
|
384
|
+
if (newTaskStatus) {
|
|
385
|
+
updatedTaskStatus = {
|
|
386
|
+
...updatedTaskStatus,
|
|
387
|
+
[getTaskStatusKey(taskIndex)]: newTaskStatus,
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const updatedQuickStart = {
|
|
392
|
+
...quickStart,
|
|
393
|
+
...(updatedStatus ? { status: updatedStatus } : {}),
|
|
394
|
+
taskNumber,
|
|
395
|
+
...updatedTaskStatus,
|
|
396
|
+
};
|
|
397
|
+
return { ...qs, [quickStartId]: updatedQuickStart };
|
|
398
|
+
});
|
|
399
|
+
},
|
|
400
|
+
[setAllQuickStartStates, stepAfterInitial],
|
|
401
|
+
);
|
|
402
|
+
|
|
403
|
+
const setQuickStartTaskStatus = useCallback(
|
|
404
|
+
(taskStatus: QuickStartTaskStatus) => {
|
|
405
|
+
const quickStart = allQuickStartStates[activeQuickStartID];
|
|
406
|
+
const { taskNumber } = quickStart;
|
|
407
|
+
const updatedQuickStart = {
|
|
408
|
+
...quickStart,
|
|
409
|
+
[getTaskStatusKey(taskNumber as any)]: taskStatus,
|
|
410
|
+
};
|
|
411
|
+
setAllQuickStartStates((qs) => ({
|
|
412
|
+
...qs,
|
|
413
|
+
[activeQuickStartID]: updatedQuickStart,
|
|
414
|
+
}));
|
|
415
|
+
},
|
|
416
|
+
[allQuickStartStates, activeQuickStartID, setAllQuickStartStates],
|
|
417
|
+
);
|
|
418
|
+
|
|
419
|
+
const activeQuickStartState = allQuickStartStates?.[activeQuickStartID] ?? {};
|
|
420
|
+
|
|
421
|
+
const getQuickStartForId = useCallback((id: string) => allQuickStartStates[id], [
|
|
422
|
+
allQuickStartStates,
|
|
423
|
+
]);
|
|
424
|
+
|
|
425
|
+
return {
|
|
426
|
+
allQuickStarts: quickStarts,
|
|
427
|
+
setAllQuickStarts: updateAllQuickStarts, // revisit if this should be in public context API
|
|
428
|
+
activeQuickStartID,
|
|
429
|
+
setActiveQuickStartID,
|
|
430
|
+
allQuickStartStates,
|
|
431
|
+
setAllQuickStartStates,
|
|
432
|
+
activeQuickStartState,
|
|
433
|
+
setActiveQuickStart: value.setActiveQuickStart || setActiveQuickStart,
|
|
434
|
+
startQuickStart: value.startQuickStart || startQuickStart,
|
|
435
|
+
restartQuickStart: value.restartQuickStart || restartQuickStart,
|
|
436
|
+
nextStep: value.nextStep || nextStep,
|
|
437
|
+
previousStep: value.previousStep || previousStep,
|
|
438
|
+
setQuickStartTaskNumber, // revisit if this should be in public context API
|
|
439
|
+
setQuickStartTaskStatus, // revisit if this should be in public context API
|
|
440
|
+
getQuickStartForId,
|
|
441
|
+
footer,
|
|
442
|
+
useLegacyHeaderColors,
|
|
443
|
+
useQueryParams,
|
|
444
|
+
markdown,
|
|
445
|
+
resourceBundle,
|
|
446
|
+
getResource: findResource, // revisit if this should be in public context API
|
|
447
|
+
setResourceBundle: changeResourceBundle,
|
|
448
|
+
language,
|
|
449
|
+
setLanguage,
|
|
450
|
+
// revisit if this should be in public context API
|
|
451
|
+
filter: {
|
|
452
|
+
keyword: filterKeyword,
|
|
453
|
+
status: {
|
|
454
|
+
statusTypes,
|
|
455
|
+
statusFilters,
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
setFilter, // revisit if this should be in public context API
|
|
459
|
+
loading,
|
|
460
|
+
setLoading,
|
|
461
|
+
alwaysShowTaskReview,
|
|
462
|
+
setAlwaysShowTaskReview,
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
export const QuickStartContextProvider: React.FC<{
|
|
467
|
+
children: React.ReactNode;
|
|
468
|
+
value: QuickStartContextValues;
|
|
469
|
+
}> = ({ children, value }) => (
|
|
470
|
+
<QuickStartContext.Provider value={useValuesForQuickStartContext(value)}>
|
|
471
|
+
{children}
|
|
472
|
+
</QuickStartContext.Provider>
|
|
473
|
+
);
|