@patternfly/quickstarts 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/HelpTopicDrawer.d.ts +8 -2
  2. package/dist/QuickStartDrawer.d.ts +21 -2
  3. package/dist/index.es.js.map +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/patternfly-docs/quick-starts/design-guidelines/design-guidelines.md +105 -0
  6. package/dist/patternfly-docs/quick-starts/design-guidelines/img/card-elements copy.png +0 -0
  7. package/dist/patternfly-docs/quick-starts/design-guidelines/img/card-elements.png +0 -0
  8. package/dist/patternfly-docs/quick-starts/design-guidelines/img/catalog-elements.png +0 -0
  9. package/dist/patternfly-docs/quick-starts/design-guidelines/img/check-your-work.png +0 -0
  10. package/dist/patternfly-docs/quick-starts/design-guidelines/img/introduction-screen.png +0 -0
  11. package/dist/patternfly-docs/quick-starts/design-guidelines/img/mixed-catalog.png +0 -0
  12. package/dist/patternfly-docs/quick-starts/design-guidelines/img/prerequisites.png +0 -0
  13. package/dist/patternfly-docs/quick-starts/design-guidelines/img/qs-context.png +0 -0
  14. package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel-elements.png +0 -0
  15. package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel-resized.png +0 -0
  16. package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel.png +0 -0
  17. package/dist/patternfly-docs/quick-starts/design-guidelines/img/task-no.png +0 -0
  18. package/dist/patternfly-docs/quick-starts/design-guidelines/img/task-yes.png +0 -0
  19. package/dist/patternfly-docs/quick-starts/design-guidelines/img/task.png +0 -0
  20. package/dist/patternfly-docs/quick-starts/examples/Basic.jsx +73 -0
  21. package/dist/patternfly-docs/quick-starts/examples/HelpTopic.jsx +53 -0
  22. package/dist/patternfly-docs/quick-starts/examples/about.md +77 -0
  23. package/dist/patternfly-docs/quick-starts/examples/basic.md +27 -0
  24. package/dist/patternfly-docs/quick-starts/examples/example-data/example-help-topics.js +173 -0
  25. package/dist/patternfly-docs/quick-starts/examples/example-data/example-quickstarts.js +215 -0
  26. package/dist/patternfly-docs/quick-starts/examples/example-data/index.js +15 -0
  27. package/dist/patternfly-docs/quick-starts/examples/help-topics.md +25 -0
  28. package/dist/patternfly-docs/quick-starts/examples/img/catalog.png +0 -0
  29. package/dist/patternfly-docs/quick-starts/examples/img/help-topic.png +0 -0
  30. package/dist/patternfly-docs/quick-starts/examples/img/side-panel.png +0 -0
  31. package/dist/quickstarts-full.es.js.map +1 -1
  32. package/package.json +11 -4
  33. package/src/ConsoleInternal/components/_icon-and-text.scss +14 -0
  34. package/src/ConsoleInternal/components/_markdown-view.scss +19 -0
  35. package/src/ConsoleInternal/components/catalog/_catalog.scss +390 -0
  36. package/src/ConsoleInternal/components/markdown-view.tsx +305 -0
  37. package/src/ConsoleInternal/components/utils/_status-box.scss +58 -0
  38. package/src/ConsoleInternal/components/utils/camel-case-wrap.tsx +33 -0
  39. package/src/ConsoleInternal/components/utils/index.tsx +3 -0
  40. package/src/ConsoleInternal/components/utils/router.ts +47 -0
  41. package/src/ConsoleInternal/components/utils/status-box.tsx +94 -0
  42. package/src/ConsoleInternal/module/k8s/types.ts +53 -0
  43. package/src/ConsoleShared/index.ts +1 -0
  44. package/src/ConsoleShared/src/components/index.ts +7 -0
  45. package/src/ConsoleShared/src/components/layout/PageLayout.scss +29 -0
  46. package/src/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.tsx +93 -0
  47. package/src/ConsoleShared/src/components/markdown-extensions/__tests__/MarkdownCopyClipboard.spec.tsx +25 -0
  48. package/src/ConsoleShared/src/components/markdown-extensions/__tests__/test-data.ts +5 -0
  49. package/src/ConsoleShared/src/components/markdown-extensions/admonition-extension.tsx +66 -0
  50. package/src/ConsoleShared/src/components/markdown-extensions/code-extension.tsx +25 -0
  51. package/src/ConsoleShared/src/components/markdown-extensions/const.ts +3 -0
  52. package/src/ConsoleShared/src/components/markdown-extensions/index.ts +5 -0
  53. package/src/ConsoleShared/src/components/markdown-extensions/inline-clipboard-extension.tsx +45 -0
  54. package/src/ConsoleShared/src/components/markdown-extensions/multiline-clipboard-extension.tsx +50 -0
  55. package/src/ConsoleShared/src/components/markdown-extensions/showdown-extension.scss +52 -0
  56. package/src/ConsoleShared/src/components/markdown-extensions/utils.ts +3 -0
  57. package/src/ConsoleShared/src/components/markdown-highlight-extension/MarkdownHighlightExtension.tsx +64 -0
  58. package/src/ConsoleShared/src/components/markdown-highlight-extension/highlight-consts.ts +9 -0
  59. package/src/ConsoleShared/src/components/markdown-highlight-extension/index.ts +1 -0
  60. package/src/ConsoleShared/src/components/modal/Modal.scss +3 -0
  61. package/src/ConsoleShared/src/components/modal/Modal.tsx +19 -0
  62. package/src/ConsoleShared/src/components/modal/index.ts +1 -0
  63. package/src/ConsoleShared/src/components/popper/Portal.tsx +23 -0
  64. package/src/ConsoleShared/src/components/popper/SimplePopper.tsx +90 -0
  65. package/src/ConsoleShared/src/components/popper/index.ts +2 -0
  66. package/src/ConsoleShared/src/components/spotlight/InteractiveSpotlight.tsx +58 -0
  67. package/src/ConsoleShared/src/components/spotlight/Spotlight.tsx +35 -0
  68. package/src/ConsoleShared/src/components/spotlight/StaticSpotlight.tsx +32 -0
  69. package/src/ConsoleShared/src/components/spotlight/index.ts +1 -0
  70. package/src/ConsoleShared/src/components/spotlight/spotlight.scss +63 -0
  71. package/src/ConsoleShared/src/components/status/GenericStatus.tsx +33 -0
  72. package/src/ConsoleShared/src/components/status/NotStartedIcon.tsx +27 -0
  73. package/src/ConsoleShared/src/components/status/PopoverStatus.tsx +42 -0
  74. package/src/ConsoleShared/src/components/status/Status.tsx +38 -0
  75. package/src/ConsoleShared/src/components/status/StatusIconAndText.tsx +42 -0
  76. package/src/ConsoleShared/src/components/status/icons.tsx +77 -0
  77. package/src/ConsoleShared/src/components/status/index.tsx +1 -0
  78. package/src/ConsoleShared/src/components/status/statuses.tsx +36 -0
  79. package/src/ConsoleShared/src/components/status/types.ts +7 -0
  80. package/src/ConsoleShared/src/components/utils/FallbackImg.tsx +20 -0
  81. package/src/ConsoleShared/src/components/utils/index.ts +1 -0
  82. package/src/ConsoleShared/src/constants/index.ts +1 -0
  83. package/src/ConsoleShared/src/constants/ui.ts +1 -0
  84. package/src/ConsoleShared/src/hooks/index.ts +6 -0
  85. package/src/ConsoleShared/src/hooks/scroll.ts +52 -0
  86. package/src/ConsoleShared/src/hooks/useBoundingClientRect.ts +18 -0
  87. package/src/ConsoleShared/src/hooks/useEventListener.ts +14 -0
  88. package/src/ConsoleShared/src/hooks/useForceRender.ts +6 -0
  89. package/src/ConsoleShared/src/hooks/useResizeObserver.ts +20 -0
  90. package/src/ConsoleShared/src/hooks/useScrollShadows.ts +45 -0
  91. package/src/ConsoleShared/src/index.ts +4 -0
  92. package/src/ConsoleShared/src/utils/index.ts +1 -0
  93. package/src/ConsoleShared/src/utils/useCombineRefs.ts +17 -0
  94. package/src/HelpTopicDrawer.tsx +124 -0
  95. package/src/HelpTopicPanelContent.tsx +152 -0
  96. package/src/QuickStartCatalogPage.tsx +190 -0
  97. package/src/QuickStartCloseModal.tsx +47 -0
  98. package/src/QuickStartController.tsx +113 -0
  99. package/src/QuickStartDrawer.scss +11 -0
  100. package/src/QuickStartDrawer.tsx +265 -0
  101. package/src/QuickStartMarkdownView.tsx +75 -0
  102. package/src/QuickStartPanelContent.scss +46 -0
  103. package/src/QuickStartPanelContent.tsx +153 -0
  104. package/src/__tests__/quick-start-utils.spec.tsx +16 -0
  105. package/src/catalog/Catalog/QuickStartCatalogHeader.tsx +18 -0
  106. package/src/catalog/Catalog/QuickStartCatalogSection.tsx +9 -0
  107. package/src/catalog/Catalog/QuickStartCatalogToolbar.tsx +12 -0
  108. package/src/catalog/Catalog/index.ts +3 -0
  109. package/src/catalog/QuickStartCatalog.scss +8 -0
  110. package/src/catalog/QuickStartCatalog.tsx +42 -0
  111. package/src/catalog/QuickStartTile.scss +11 -0
  112. package/src/catalog/QuickStartTile.tsx +105 -0
  113. package/src/catalog/QuickStartTileDescription.scss +29 -0
  114. package/src/catalog/QuickStartTileDescription.tsx +79 -0
  115. package/src/catalog/QuickStartTileFooter.tsx +101 -0
  116. package/src/catalog/QuickStartTileFooterExternal.tsx +40 -0
  117. package/src/catalog/QuickStartTileHeader.scss +12 -0
  118. package/src/catalog/QuickStartTileHeader.tsx +77 -0
  119. package/src/catalog/Toolbar/QuickStartCatalogFilter.scss +25 -0
  120. package/src/catalog/Toolbar/QuickStartCatalogFilter.tsx +34 -0
  121. package/src/catalog/Toolbar/QuickStartCatalogFilterItems.tsx +199 -0
  122. package/src/catalog/__tests__/QuickStartCatalog.spec.tsx +35 -0
  123. package/src/catalog/__tests__/QuickStartTile.spec.tsx +38 -0
  124. package/src/catalog/__tests__/QuickStartTileDescription.spec.tsx +44 -0
  125. package/src/catalog/index.ts +9 -0
  126. package/src/controller/QuickStartConclusion.tsx +63 -0
  127. package/src/controller/QuickStartContent.scss +12 -0
  128. package/src/controller/QuickStartContent.tsx +72 -0
  129. package/src/controller/QuickStartFooter.scss +13 -0
  130. package/src/controller/QuickStartFooter.tsx +128 -0
  131. package/src/controller/QuickStartIntroduction.scss +35 -0
  132. package/src/controller/QuickStartIntroduction.tsx +66 -0
  133. package/src/controller/QuickStartTaskHeader.scss +58 -0
  134. package/src/controller/QuickStartTaskHeader.tsx +116 -0
  135. package/src/controller/QuickStartTaskHeaderList.scss +17 -0
  136. package/src/controller/QuickStartTaskHeaderList.tsx +35 -0
  137. package/src/controller/QuickStartTaskReview.scss +30 -0
  138. package/src/controller/QuickStartTaskReview.tsx +81 -0
  139. package/src/controller/QuickStartTasks.scss +89 -0
  140. package/src/controller/QuickStartTasks.tsx +75 -0
  141. package/src/controller/__tests__/QuickStartConclusion.spec.tsx +95 -0
  142. package/src/controller/__tests__/QuickStartContent.spec.tsx +52 -0
  143. package/src/controller/__tests__/QuickStartFooter.spec.tsx +148 -0
  144. package/src/controller/__tests__/QuickStartTaskHeader.spec.tsx +56 -0
  145. package/src/controller/__tests__/QuickStartTaskReview.spec.tsx +45 -0
  146. package/src/controller/__tests__/QuickStartTasks.spec.tsx +81 -0
  147. package/src/data/mocks/json/explore-pipeline-quickstart.ts +66 -0
  148. package/src/data/mocks/json/explore-serverless-quickstart.ts +90 -0
  149. package/src/data/mocks/json/monitor-sampleapp-quickstart.ts +77 -0
  150. package/src/data/mocks/json/tour-icons.ts +3 -0
  151. package/src/data/mocks/yamls/add-healthchecks-quickstart.yaml +67 -0
  152. package/src/data/mocks/yamls/explore-pipeline-quickstart.yaml +57 -0
  153. package/src/data/mocks/yamls/explore-serverless-quickstart.yaml +83 -0
  154. package/src/data/mocks/yamls/install-associate-pipeline-quickstart.yaml +74 -0
  155. package/src/data/mocks/yamls/monitor-sampleapp-quickstart.yaml +66 -0
  156. package/src/data/mocks/yamls/sample-application-quickstart.yaml +97 -0
  157. package/src/data/mocks/yamls/serverless-application-quickstart.yaml +141 -0
  158. package/src/data/quick-start-test-data.ts +10 -0
  159. package/src/data/test-utils.ts +11 -0
  160. package/src/declaration.d.ts +2 -0
  161. package/src/index.ts +17 -0
  162. package/src/locales/en/quickstart.json +46 -0
  163. package/src/styles/_base.scss +54 -0
  164. package/src/styles/_dark-custom-override.scss +62 -0
  165. package/src/styles/legacy-bootstrap/README.md +21 -0
  166. package/src/styles/legacy-bootstrap/_code.scss +44 -0
  167. package/src/styles/legacy-bootstrap/_tables.scss +38 -0
  168. package/src/styles/legacy-bootstrap/_type.scss +90 -0
  169. package/src/styles/legacy-bootstrap/_variables.scss +48 -0
  170. package/src/styles/legacy-bootstrap.scss +5 -0
  171. package/src/styles/patternfly-global-entry.ts +1 -0
  172. package/src/styles/patternfly-global.scss +28 -0
  173. package/src/styles/patternfly-nested-entry.ts +1 -0
  174. package/src/styles/patternfly-nested.scss +18 -0
  175. package/src/styles/quickstarts-standalone-entry.ts +1 -0
  176. package/src/styles/quickstarts-standalone.scss +7 -0
  177. package/src/styles/style.scss +12 -0
  178. package/src/styles/vendor-entry.ts +1 -0
  179. package/src/styles/vendor.scss +7 -0
  180. package/src/utils/PluralResolver.ts +356 -0
  181. package/src/utils/asciidoc-procedure-parser.ts +132 -0
  182. package/src/utils/const.ts +10 -0
  183. package/src/utils/help-topic-context.tsx +74 -0
  184. package/src/utils/help-topic-types.ts +16 -0
  185. package/src/utils/quick-start-context.tsx +477 -0
  186. package/src/utils/quick-start-types.ts +72 -0
  187. package/src/utils/quick-start-utils.ts +92 -0
  188. package/src/utils/useLocalStorage.ts +38 -0
@@ -0,0 +1,265 @@
1
+ import './QuickStartDrawer.scss';
2
+ import * as React from 'react';
3
+ import { Drawer, DrawerContent, DrawerContentBody } from '@patternfly/react-core';
4
+ import QuickStartCloseModal from './QuickStartCloseModal';
5
+ import QuickStartPanelContent from './QuickStartPanelContent';
6
+ import {
7
+ getDefaultQuickStartState,
8
+ QuickStartContext,
9
+ QuickStartContextValues,
10
+ useValuesForQuickStartContext,
11
+ } from './utils/quick-start-context';
12
+ import { QUICKSTART_ID_FILTER_KEY } from './utils/const';
13
+ import { QuickStart, QuickStartStatus, AllQuickStartStates } from './utils/quick-start-types';
14
+ import { getQuickStartByName } from './utils/quick-start-utils';
15
+
16
+ export interface QuickStartContainerProps extends React.HTMLProps<HTMLDivElement> {
17
+ /** array of quick starts */
18
+ quickStarts: QuickStart[];
19
+ /** id of the currently active quick start */
20
+ activeQuickStartID: string;
21
+ /** setter for the active quick starts */
22
+ setActiveQuickStartID: React.Dispatch<React.SetStateAction<string>>;
23
+ /** quick starts state object */
24
+ allQuickStartStates: AllQuickStartStates;
25
+ /** setter for the quick starts state object */
26
+ setAllQuickStartStates: React.Dispatch<React.SetStateAction<AllQuickStartStates>>;
27
+ /** content to render within the container */
28
+ children?: React.ReactNode;
29
+ /** element to render the drawer panel into */
30
+ appendTo?: HTMLElement | (() => HTMLElement);
31
+ /** if true, the panel will take up the full browser width */
32
+ fullWidth?: boolean;
33
+ /** callback when an in-progress quick start is closed */
34
+ onCloseInProgress?: any;
35
+ /** callback when a not-in-progress quick start is closed */
36
+ onCloseNotInProgress?: any;
37
+ /** true to show footer buttons in the catalog tiles (default true) */
38
+ showCardFooters?: boolean;
39
+ /** true to use legacy drawer header variant colors */
40
+ useLegacyHeaderColors?: boolean;
41
+ /** text resources object */
42
+ resourceBundle?: any;
43
+ /** language of the current resource bundle
44
+ * Add custom strings: https://github.com/patternfly/patternfly-quickstarts/tree/main/packages/module#localization
45
+ */
46
+ language?: string;
47
+ /** if true, will show a loading spinner on the catalog page (default false) */
48
+ loading?: boolean;
49
+ /** if true, will update the browser URL with ?quickstart={ID} (default true) */
50
+ useQueryParams?: boolean;
51
+ /** if true, the TaskReview component, aka "Check your work", will be shown regardless of task status */
52
+ alwaysShowTaskReview?: boolean;
53
+ /**
54
+ * Additional markdown extensions and renderers to use
55
+ * Example usage: https://github.com/patternfly/patternfly-quickstarts/tree/main/packages/module#markdown-extensions
56
+ */
57
+ markdown?: {
58
+ extensions?: any[];
59
+ renderExtension?: (docContext: HTMLDocument, rootSelector: string) => React.ReactNode;
60
+ };
61
+ /** additional quick start context props */
62
+ contextProps?: QuickStartContextValues;
63
+ }
64
+
65
+ export const QuickStartContainer: React.FC<QuickStartContainerProps> = ({
66
+ quickStarts,
67
+ children,
68
+ activeQuickStartID,
69
+ allQuickStartStates,
70
+ setActiveQuickStartID,
71
+ setAllQuickStartStates,
72
+ appendTo,
73
+ fullWidth,
74
+ onCloseInProgress,
75
+ onCloseNotInProgress,
76
+ resourceBundle,
77
+ showCardFooters,
78
+ useLegacyHeaderColors,
79
+ language,
80
+ loading = false,
81
+ useQueryParams = true,
82
+ markdown,
83
+ contextProps,
84
+ alwaysShowTaskReview = true,
85
+ ...props
86
+ }: QuickStartContainerProps) => {
87
+ const valuesForQuickstartContext: QuickStartContextValues = useValuesForQuickStartContext({
88
+ allQuickStarts: quickStarts,
89
+ activeQuickStartID,
90
+ setActiveQuickStartID,
91
+ allQuickStartStates,
92
+ setAllQuickStartStates,
93
+ footer: {
94
+ show: showCardFooters,
95
+ },
96
+ useLegacyHeaderColors,
97
+ language,
98
+ resourceBundle: {
99
+ ...resourceBundle,
100
+ // Start: "Let's go!",
101
+ // Continue: 'Resume',
102
+ // Restart: 'Start over',
103
+ },
104
+ loading,
105
+ useQueryParams,
106
+ markdown,
107
+ alwaysShowTaskReview,
108
+ ...contextProps,
109
+ });
110
+
111
+ React.useEffect(() => {
112
+ if (
113
+ quickStarts &&
114
+ JSON.stringify(quickStarts) !== JSON.stringify(valuesForQuickstartContext.allQuickStarts)
115
+ ) {
116
+ valuesForQuickstartContext.setAllQuickStarts(quickStarts);
117
+ }
118
+ }, [quickStarts, valuesForQuickstartContext]);
119
+
120
+ React.useEffect(() => {
121
+ if (loading !== valuesForQuickstartContext.loading) {
122
+ valuesForQuickstartContext.setLoading(loading);
123
+ }
124
+ }, [loading, valuesForQuickstartContext]);
125
+
126
+ const drawerProps = {
127
+ appendTo,
128
+ fullWidth,
129
+ onCloseInProgress,
130
+ onCloseNotInProgress,
131
+ ...props,
132
+ };
133
+
134
+ return (
135
+ <QuickStartContext.Provider value={valuesForQuickstartContext}>
136
+ <QuickStartDrawer {...drawerProps}>{children}</QuickStartDrawer>
137
+ </QuickStartContext.Provider>
138
+ );
139
+ };
140
+
141
+ export interface QuickStartDrawerProps extends React.HTMLProps<HTMLDivElement> {
142
+ quickStarts?: QuickStart[];
143
+ children?: React.ReactNode;
144
+ appendTo?: HTMLElement | (() => HTMLElement);
145
+ fullWidth?: boolean;
146
+ onCloseInProgress?: any;
147
+ onCloseNotInProgress?: any;
148
+ }
149
+
150
+ export const QuickStartDrawer: React.FC<QuickStartDrawerProps> = ({
151
+ quickStarts = [],
152
+ children,
153
+ appendTo,
154
+ fullWidth,
155
+ onCloseInProgress,
156
+ onCloseNotInProgress,
157
+ ...props
158
+ }) => {
159
+ const {
160
+ activeQuickStartID,
161
+ setActiveQuickStart,
162
+ allQuickStarts = [],
163
+ activeQuickStartState,
164
+ allQuickStartStates,
165
+ setAllQuickStartStates,
166
+ useLegacyHeaderColors,
167
+ } = React.useContext<QuickStartContextValues>(QuickStartContext);
168
+ const combinedQuickStarts = allQuickStarts.concat(quickStarts);
169
+ React.useEffect(() => {
170
+ const params = new URLSearchParams(window.location.search);
171
+ // if there is a quick start param, but the quick start is not active, set it
172
+ // this can happen if a new browser session is opened or an incognito window for example
173
+ const quickStartIdFromParam = params.get(QUICKSTART_ID_FILTER_KEY) || '';
174
+ if (quickStartIdFromParam && activeQuickStartID !== quickStartIdFromParam) {
175
+ const activeQuickStart = getQuickStartByName(quickStartIdFromParam, combinedQuickStarts);
176
+ // don't try to load a quick start that is actually just an external resource (spec.link)
177
+ if (combinedQuickStarts.length > 0 && activeQuickStart && !activeQuickStart.spec.link) {
178
+ setActiveQuickStart(quickStartIdFromParam);
179
+ }
180
+ }
181
+ }, [activeQuickStartID, combinedQuickStarts, setActiveQuickStart]);
182
+
183
+ React.useEffect(() => {
184
+ // If activeQuickStartID was changed through prop from QuickStartContainer, need to init the state if it does not exist yet
185
+ if (activeQuickStartID && !allQuickStartStates[activeQuickStartID]) {
186
+ setAllQuickStartStates({
187
+ ...allQuickStartStates,
188
+ [activeQuickStartID]: getDefaultQuickStartState(),
189
+ });
190
+ }
191
+ }, [activeQuickStartID, allQuickStartStates, setAllQuickStartStates]);
192
+
193
+ const [modalOpen, setModalOpen] = React.useState<boolean>(false);
194
+ const activeQuickStartStatus = activeQuickStartState?.status;
195
+ const onClose = () => setActiveQuickStart('');
196
+ const handleClose = () => {
197
+ if (activeQuickStartStatus === QuickStartStatus.IN_PROGRESS) {
198
+ if (onCloseInProgress) {
199
+ onCloseInProgress();
200
+ } else {
201
+ setModalOpen(true);
202
+ }
203
+ } else if (onCloseNotInProgress) {
204
+ onCloseNotInProgress();
205
+ } else {
206
+ onClose();
207
+ }
208
+ };
209
+
210
+ const onModalConfirm = () => {
211
+ setModalOpen(false);
212
+ onClose();
213
+ };
214
+
215
+ const onModalCancel = () => setModalOpen(false);
216
+
217
+ const fullWidthPanelStyle = fullWidth
218
+ ? {
219
+ style: {
220
+ flex: 1,
221
+ },
222
+ }
223
+ : {};
224
+
225
+ const fullWidthBodyStyle = fullWidth
226
+ ? {
227
+ style: {
228
+ display: activeQuickStartID ? 'none' : 'flex',
229
+ },
230
+ }
231
+ : {};
232
+
233
+ const panelContent = (
234
+ <QuickStartPanelContent
235
+ quickStarts={combinedQuickStarts}
236
+ handleClose={handleClose}
237
+ activeQuickStartID={activeQuickStartID}
238
+ appendTo={appendTo}
239
+ isResizable={!fullWidth}
240
+ headerVariant={useLegacyHeaderColors ? '' : 'blue-white'}
241
+ {...fullWidthPanelStyle}
242
+ />
243
+ );
244
+
245
+ return (
246
+ <>
247
+ <Drawer isExpanded={!!activeQuickStartID} isInline {...props}>
248
+ {children ? (
249
+ <DrawerContent panelContent={panelContent} {...fullWidthBodyStyle}>
250
+ <DrawerContentBody className="pfext-quick-start-drawer__body">
251
+ {children}
252
+ </DrawerContentBody>
253
+ </DrawerContent>
254
+ ) : (
255
+ <div className="pf-c-drawer__main">{panelContent}</div>
256
+ )}
257
+ </Drawer>
258
+ <QuickStartCloseModal
259
+ isOpen={modalOpen}
260
+ onConfirm={onModalConfirm}
261
+ onCancel={onModalCancel}
262
+ />
263
+ </>
264
+ );
265
+ };
@@ -0,0 +1,75 @@
1
+ import * as React from 'react';
2
+ import { SyncMarkdownView } from '@console/internal/components/markdown-view';
3
+ import {
4
+ MarkdownCopyClipboard,
5
+ MarkdownHighlightExtension,
6
+ useInlineCopyClipboardShowdownExtension,
7
+ useMultilineCopyClipboardShowdownExtension,
8
+ useAdmonitionShowdownExtension,
9
+ useCodeShowdownExtension,
10
+ } from '@console/shared';
11
+ import { HIGHLIGHT_REGEXP } from '@console/shared/src/components/markdown-highlight-extension/highlight-consts';
12
+ import { QuickStartContext, QuickStartContextValues } from './utils/quick-start-context';
13
+
14
+ export const removeParagraphWrap = (markdown: string) => markdown.replace(/^<p>|<\/p>$/g, '');
15
+
16
+ type QuickStartMarkdownViewProps = {
17
+ content: string;
18
+ exactHeight?: boolean;
19
+ className?: string;
20
+ };
21
+
22
+ const QuickStartMarkdownView: React.FC<QuickStartMarkdownViewProps> = ({
23
+ content,
24
+ exactHeight,
25
+ className,
26
+ }) => {
27
+ const { markdown } = React.useContext<QuickStartContextValues>(QuickStartContext);
28
+ const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
29
+ const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
30
+ const admonitionShowdownExtension = useAdmonitionShowdownExtension();
31
+ const codeShowdownExtension = useCodeShowdownExtension();
32
+ return (
33
+ <SyncMarkdownView
34
+ inline
35
+ content={content}
36
+ exactHeight={exactHeight}
37
+ extensions={[
38
+ {
39
+ type: 'lang',
40
+ regex: HIGHLIGHT_REGEXP,
41
+ replace: (text: string, linkLabel: string, linkType: string, linkId: string): string => {
42
+ if (!linkLabel || !linkType || !linkId) {
43
+ return text;
44
+ }
45
+ return `<button class="pf-c-button pf-m-inline pf-m-link" data-highlight="${linkId}">${linkLabel}</button>`;
46
+ },
47
+ },
48
+ {
49
+ type: 'output',
50
+ filter: function(text) {
51
+ // check HTML for patterns like: <em>Status: unknown</em>{#extension-requirement-status}
52
+ // and replace with <em id="extension-requirement-status">Status: unknown</em>
53
+ return text.replace(/<em>(.*)<\/em>{#(.*)}/g, '<em id="$2">$1</em>');
54
+ },
55
+ },
56
+ inlineCopyClipboardShowdownExtension,
57
+ multilineCopyClipboardShowdownExtension,
58
+ admonitionShowdownExtension,
59
+ codeShowdownExtension,
60
+ ...(markdown ? markdown.extensions : []),
61
+ ]}
62
+ renderExtension={(docContext, rootSelector) => (
63
+ <>
64
+ <MarkdownHighlightExtension docContext={docContext} rootSelector={rootSelector} />
65
+ <MarkdownCopyClipboard docContext={docContext} rootSelector={rootSelector} />
66
+ {markdown &&
67
+ markdown.renderExtension &&
68
+ markdown.renderExtension(docContext, rootSelector)}
69
+ </>
70
+ )}
71
+ className={className}
72
+ />
73
+ );
74
+ };
75
+ export default QuickStartMarkdownView;
@@ -0,0 +1,46 @@
1
+ .pfext-quick-start-panel-content {
2
+ &__header {
3
+ position: sticky;
4
+ top: 0px;
5
+ background: inherit;
6
+ z-index: var(--pf-global--ZIndex--xs);
7
+ &__shadow {
8
+ box-shadow: var(--pf-global--BoxShadow--sm-bottom);
9
+ }
10
+ &--blue-white {
11
+ background-color: var(--pf-global--palette--blue-400);
12
+ .pfext-quick-start-panel-content__title {
13
+ color: var(--pf-global--Color--light-100);
14
+ }
15
+ .pfext-quick-start-panel-content__duration {
16
+ color: var(--pf-global--Color--light-200);
17
+ }
18
+ .pfext-quick-start-panel-content__close-button {
19
+ button {
20
+ color: var(--pf-global--Color--light-100) !important;
21
+ }
22
+ }
23
+ }
24
+ }
25
+ &__body {
26
+ display: flex;
27
+ flex-direction: column;
28
+ }
29
+ &__title {
30
+ display: flex;
31
+ align-items: center;
32
+ flex-wrap: wrap;
33
+ }
34
+ &__duration {
35
+ display: inline-block;
36
+ font-size: var(--pf-global--FontSize--md);
37
+ font-weight: 400;
38
+ line-height: 1;
39
+ color: #9c9c9c;
40
+ }
41
+ &__footer {
42
+ &__shadow {
43
+ box-shadow: var(--pf-global--BoxShadow--sm-top);
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,153 @@
1
+ import './QuickStartPanelContent.scss';
2
+ import * as React from 'react';
3
+ import {
4
+ DrawerActions,
5
+ DrawerCloseButton,
6
+ DrawerHead,
7
+ DrawerPanelBody,
8
+ DrawerPanelContent,
9
+ Title,
10
+ } from '@patternfly/react-core';
11
+ import { css } from '@patternfly/react-styles';
12
+ import * as ReactDOM from 'react-dom';
13
+ import { Shadows, useScrollShadows } from '@console/shared';
14
+ import QuickStartController from './QuickStartController';
15
+ import { QuickStartContext, QuickStartContextValues } from './utils/quick-start-context';
16
+ import { QuickStart } from './utils/quick-start-types';
17
+ import { camelize } from './utils/quick-start-utils';
18
+
19
+ type HandleClose = () => void;
20
+
21
+ type QuickStartPanelContentProps = {
22
+ quickStarts: QuickStart[];
23
+ activeQuickStartID: string;
24
+ handleClose: HandleClose;
25
+ appendTo?: HTMLElement | (() => HTMLElement);
26
+ isResizable?: boolean;
27
+ showClose?: boolean;
28
+ headerVariant?: '' | 'blue-white';
29
+ };
30
+
31
+ const getElement = (appendTo: HTMLElement | (() => HTMLElement)) => {
32
+ if (typeof appendTo === 'function') {
33
+ return appendTo();
34
+ }
35
+ return appendTo;
36
+ };
37
+
38
+ const useScrollTopOnTaskNumberChange = (node: HTMLElement, taskNumber: number): void => {
39
+ React.useEffect(() => {
40
+ if (node) {
41
+ node.scrollTo({ top: 0, behavior: 'smooth' });
42
+ }
43
+ }, [taskNumber, node]);
44
+ };
45
+
46
+ const QuickStartPanelContent: React.FC<QuickStartPanelContentProps> = ({
47
+ quickStarts = [],
48
+ handleClose,
49
+ activeQuickStartID,
50
+ appendTo,
51
+ isResizable = true,
52
+ showClose = true,
53
+ headerVariant = '',
54
+ ...props
55
+ }) => {
56
+ const { getResource, activeQuickStartState } = React.useContext<QuickStartContextValues>(
57
+ QuickStartContext,
58
+ );
59
+ const [contentRef, setContentRef] = React.useState<HTMLDivElement>();
60
+ const shadows = useScrollShadows(contentRef);
61
+ const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
62
+ const taskNumber = activeQuickStartState?.taskNumber;
63
+ useScrollTopOnTaskNumberChange(contentRef, taskNumber as number);
64
+ const nextQuickStarts: QuickStart[] = quickStarts.filter((qs: QuickStart) =>
65
+ quickStart?.spec.nextQuickStart?.includes(qs.metadata.name),
66
+ );
67
+
68
+ const headerClasses = css('pfext-quick-start-panel-content__header', {
69
+ 'pfext-quick-start-panel-content__header__shadow':
70
+ shadows === Shadows.top || shadows === Shadows.both,
71
+ 'pfext-quick-start-panel-content__header--blue-white': headerVariant === 'blue-white',
72
+ });
73
+
74
+ const footerClass = css({
75
+ 'pfext-quick-start-panel-content__footer__shadow':
76
+ shadows === Shadows.bottom || shadows === Shadows.both,
77
+ });
78
+
79
+ const getStep = () => {
80
+ const tasks = quickStart.spec.tasks.length;
81
+ if (Number.parseInt(taskNumber as string, 10) === -1) {
82
+ return 'intro';
83
+ }
84
+ if (Number.parseInt(taskNumber as string, 10) === tasks) {
85
+ return 'conclusion';
86
+ }
87
+ return Number.parseInt(taskNumber as string, 10) + 1;
88
+ };
89
+
90
+ const content = quickStart ? (
91
+ <DrawerPanelContent
92
+ isResizable={isResizable}
93
+ className="pfext-quick-start__base"
94
+ data-testid={`qs-drawer-${camelize(quickStart.spec.displayName)}`}
95
+ data-qs={`qs-step-${getStep()}`}
96
+ data-test="quickstart drawer"
97
+ {...props}
98
+ >
99
+ <div className={headerClasses}>
100
+ <DrawerHead>
101
+ <div className="pfext-quick-start-panel-content__title">
102
+ <Title
103
+ headingLevel="h1"
104
+ size="xl"
105
+ className="pfext-quick-start-panel-content__name"
106
+ style={{ marginRight: 'var(--pf-global--spacer--md)' }}
107
+ >
108
+ {quickStart?.spec.displayName}{' '}
109
+ <small className="pfext-quick-start-panel-content__duration">
110
+ {quickStart?.spec.durationMinutes
111
+ ? getResource(
112
+ '{{type}} • {{duration, number}} minutes',
113
+ quickStart?.spec.durationMinutes,
114
+ )
115
+ .replace('{{duration, number}}', quickStart?.spec.durationMinutes)
116
+ .replace('{{type}}', getResource('Type'))
117
+ : getResource('Type')}
118
+ </small>
119
+ </Title>
120
+ </div>
121
+ {showClose && (
122
+ <DrawerActions>
123
+ <DrawerCloseButton
124
+ onClick={handleClose}
125
+ className="pfext-quick-start-panel-content__close-button"
126
+ data-testid="qs-drawer-close"
127
+ />
128
+ </DrawerActions>
129
+ )}
130
+ </DrawerHead>
131
+ </div>
132
+ <DrawerPanelBody
133
+ hasNoPadding
134
+ className="pfext-quick-start-panel-content__body"
135
+ data-test="content"
136
+ >
137
+ <QuickStartController
138
+ quickStart={quickStart}
139
+ nextQuickStarts={nextQuickStarts}
140
+ footerClass={footerClass}
141
+ contentRef={setContentRef}
142
+ />
143
+ </DrawerPanelBody>
144
+ </DrawerPanelContent>
145
+ ) : null;
146
+
147
+ if (appendTo) {
148
+ return ReactDOM.createPortal(content, getElement(appendTo));
149
+ }
150
+ return content;
151
+ };
152
+
153
+ export default QuickStartPanelContent;
@@ -0,0 +1,16 @@
1
+ import { allQuickStarts } from '../data/quick-start-test-data';
2
+ import { getQuickStartByName, isDisabledQuickStart } from '../utils/quick-start-utils';
3
+
4
+ describe('quick-start-utils', () => {
5
+ it('should return the quick start corresponding to the id for getQuickStartByName function', () => {
6
+ const mockID = allQuickStarts[0].metadata.name;
7
+ const quickStart = getQuickStartByName(mockID, allQuickStarts);
8
+ expect(quickStart.metadata.name === mockID).toBe(true);
9
+ });
10
+
11
+ it('should filter out disabled quick starts', () => {
12
+ const disabledQuickStarts = [allQuickStarts[0].metadata.name]; // setting allQuickStart[0] as disabled
13
+ expect(isDisabledQuickStart(allQuickStarts[1], disabledQuickStarts)).toBe(false);
14
+ expect(isDisabledQuickStart(allQuickStarts[0], disabledQuickStarts)).toBe(true);
15
+ });
16
+ });
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+
3
+ export type QuickStartCatalogHeaderProps = {
4
+ title: string;
5
+ hint?: string;
6
+ };
7
+
8
+ export const QuickStartCatalogHeader: React.FC<QuickStartCatalogHeaderProps> = ({
9
+ title,
10
+ hint,
11
+ }) => (
12
+ <div className="pfext-page-layout__header">
13
+ <h1 data-pf-content="true" className="pfext-page-layout__title">
14
+ {title}
15
+ </h1>
16
+ {hint && <div className="pfext-page-layout__hint">{hint}</div>}
17
+ </div>
18
+ );
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+
3
+ export type QuickStartCatalogSectionProps = {
4
+ children: React.ReactNode;
5
+ };
6
+
7
+ export const QuickStartCatalogSection: React.FC<QuickStartCatalogSectionProps> = ({ children }) => (
8
+ <div className="pfext-page-layout__content">{children}</div>
9
+ );
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { Toolbar } from '@patternfly/react-core';
3
+
4
+ export type QuickStartCatalogToolbarProps = {
5
+ children: React.ReactNode;
6
+ };
7
+
8
+ export const QuickStartCatalogToolbar: React.FC<QuickStartCatalogToolbarProps> = ({ children }) => (
9
+ <Toolbar usePageInsets className="pfext-quick-start-catalog-filter__flex">
10
+ {children}
11
+ </Toolbar>
12
+ );
@@ -0,0 +1,3 @@
1
+ export * from './QuickStartCatalogHeader';
2
+ export * from './QuickStartCatalogSection';
3
+ export * from './QuickStartCatalogToolbar';
@@ -0,0 +1,8 @@
1
+ .pfext-quick-start-catalog {
2
+ &__gallery {
3
+ --pf-l-gallery--GridTemplateColumns: repeat(auto-fill, 300px) !important;
4
+ }
5
+ &__gallery-item {
6
+ display: inherit !important;
7
+ }
8
+ }
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { Gallery, GalleryItem } from '@patternfly/react-core';
3
+ import { QuickStartContext, QuickStartContextValues } from '../utils/quick-start-context';
4
+ import { QuickStart } from '../utils/quick-start-types';
5
+ import { getQuickStartStatus } from '../utils/quick-start-utils';
6
+ import QuickStartTile from './QuickStartTile';
7
+
8
+ import './QuickStartCatalog.scss';
9
+
10
+ type QuickStartCatalogProps = {
11
+ quickStarts: QuickStart[];
12
+ };
13
+
14
+ const QuickStartCatalog: React.FC<QuickStartCatalogProps> = ({ quickStarts }) => {
15
+ const { activeQuickStartID, allQuickStartStates } = React.useContext<QuickStartContextValues>(
16
+ QuickStartContext,
17
+ );
18
+
19
+ return (
20
+ <div className="pfext-page-layout__content">
21
+ <Gallery className="pfext-quick-start-catalog__gallery" hasGutter>
22
+ {quickStarts.map((quickStart) => {
23
+ const {
24
+ metadata: { name: id },
25
+ } = quickStart;
26
+
27
+ return (
28
+ <GalleryItem key={id} className="pfext-quick-start-catalog__gallery-item">
29
+ <QuickStartTile
30
+ quickStart={quickStart}
31
+ isActive={id === activeQuickStartID}
32
+ status={getQuickStartStatus(allQuickStartStates, id)}
33
+ />
34
+ </GalleryItem>
35
+ );
36
+ })}
37
+ </Gallery>
38
+ </div>
39
+ );
40
+ };
41
+
42
+ export default QuickStartCatalog;
@@ -0,0 +1,11 @@
1
+ .pfext-quick-start-tile {
2
+ height: 100%;
3
+ & .catalog-tile-pf-description .has-footer {
4
+ display: block;
5
+ -webkit-line-clamp: unset;
6
+ }
7
+
8
+ & .catalog-tile-pf-icon {
9
+ display: flex;
10
+ }
11
+ }