@patternfly/quickstarts 2.2.1 → 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 (203) hide show
  1. package/README.md +20 -20
  2. package/dist/ConsoleShared/src/components/markdown-extensions/code-extension.d.ts +7 -0
  3. package/dist/ConsoleShared/src/components/markdown-extensions/index.d.ts +1 -0
  4. package/dist/HelpTopicDrawer.d.ts +8 -2
  5. package/dist/QuickStartDrawer.d.ts +21 -2
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.es.js +127 -21
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/index.js +126 -19
  10. package/dist/index.js.map +1 -1
  11. package/dist/patternfly-docs/quick-starts/design-guidelines/design-guidelines.md +105 -0
  12. package/dist/patternfly-docs/quick-starts/design-guidelines/img/card-elements copy.png +0 -0
  13. package/dist/patternfly-docs/quick-starts/design-guidelines/img/card-elements.png +0 -0
  14. package/dist/patternfly-docs/quick-starts/design-guidelines/img/catalog-elements.png +0 -0
  15. package/dist/patternfly-docs/quick-starts/design-guidelines/img/check-your-work.png +0 -0
  16. package/dist/patternfly-docs/quick-starts/design-guidelines/img/introduction-screen.png +0 -0
  17. package/dist/patternfly-docs/quick-starts/design-guidelines/img/mixed-catalog.png +0 -0
  18. package/dist/patternfly-docs/quick-starts/design-guidelines/img/prerequisites.png +0 -0
  19. package/dist/patternfly-docs/quick-starts/design-guidelines/img/qs-context.png +0 -0
  20. package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel-elements.png +0 -0
  21. package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel-resized.png +0 -0
  22. package/dist/patternfly-docs/quick-starts/design-guidelines/img/side-panel.png +0 -0
  23. package/dist/patternfly-docs/quick-starts/design-guidelines/img/task-no.png +0 -0
  24. package/dist/patternfly-docs/quick-starts/design-guidelines/img/task-yes.png +0 -0
  25. package/dist/patternfly-docs/quick-starts/design-guidelines/img/task.png +0 -0
  26. package/dist/patternfly-docs/quick-starts/examples/Basic.jsx +73 -0
  27. package/dist/patternfly-docs/quick-starts/examples/HelpTopic.jsx +53 -0
  28. package/dist/patternfly-docs/quick-starts/examples/about.md +77 -0
  29. package/dist/patternfly-docs/quick-starts/examples/basic.md +27 -0
  30. package/dist/patternfly-docs/quick-starts/examples/example-data/example-help-topics.js +173 -0
  31. package/dist/patternfly-docs/quick-starts/examples/example-data/example-quickstarts.js +215 -0
  32. package/dist/patternfly-docs/quick-starts/examples/example-data/index.js +15 -0
  33. package/dist/patternfly-docs/quick-starts/examples/help-topics.md +25 -0
  34. package/dist/patternfly-docs/quick-starts/examples/img/catalog.png +0 -0
  35. package/dist/patternfly-docs/quick-starts/examples/img/help-topic.png +0 -0
  36. package/dist/patternfly-docs/quick-starts/examples/img/side-panel.png +0 -0
  37. package/dist/patternfly-nested.css +11 -1
  38. package/dist/quickstarts-base.css +49 -11
  39. package/dist/quickstarts-full.es.js +451 -305
  40. package/dist/quickstarts-full.es.js.map +1 -1
  41. package/dist/quickstarts-standalone.css +5 -15
  42. package/dist/quickstarts-standalone.min.css +1 -1
  43. package/dist/quickstarts.css +49 -11
  44. package/dist/quickstarts.min.css +1 -1
  45. package/dist/utils/asciidoc-procedure-parser.d.ts +12 -0
  46. package/dist/utils/help-topic-types.d.ts +7 -1
  47. package/package.json +11 -4
  48. package/src/ConsoleInternal/components/_icon-and-text.scss +14 -0
  49. package/src/ConsoleInternal/components/_markdown-view.scss +19 -0
  50. package/src/ConsoleInternal/components/catalog/_catalog.scss +390 -0
  51. package/src/ConsoleInternal/components/markdown-view.tsx +305 -0
  52. package/src/ConsoleInternal/components/utils/_status-box.scss +58 -0
  53. package/src/ConsoleInternal/components/utils/camel-case-wrap.tsx +33 -0
  54. package/src/ConsoleInternal/components/utils/index.tsx +3 -0
  55. package/src/ConsoleInternal/components/utils/router.ts +47 -0
  56. package/src/ConsoleInternal/components/utils/status-box.tsx +94 -0
  57. package/src/ConsoleInternal/module/k8s/types.ts +53 -0
  58. package/src/ConsoleShared/index.ts +1 -0
  59. package/src/ConsoleShared/src/components/index.ts +7 -0
  60. package/src/ConsoleShared/src/components/layout/PageLayout.scss +29 -0
  61. package/src/ConsoleShared/src/components/markdown-extensions/MarkdownCopyClipboard.tsx +93 -0
  62. package/src/ConsoleShared/src/components/markdown-extensions/__tests__/MarkdownCopyClipboard.spec.tsx +25 -0
  63. package/src/ConsoleShared/src/components/markdown-extensions/__tests__/test-data.ts +5 -0
  64. package/src/ConsoleShared/src/components/markdown-extensions/admonition-extension.tsx +66 -0
  65. package/src/ConsoleShared/src/components/markdown-extensions/code-extension.tsx +25 -0
  66. package/src/ConsoleShared/src/components/markdown-extensions/const.ts +3 -0
  67. package/src/ConsoleShared/src/components/markdown-extensions/index.ts +5 -0
  68. package/src/ConsoleShared/src/components/markdown-extensions/inline-clipboard-extension.tsx +45 -0
  69. package/src/ConsoleShared/src/components/markdown-extensions/multiline-clipboard-extension.tsx +50 -0
  70. package/src/ConsoleShared/src/components/markdown-extensions/showdown-extension.scss +52 -0
  71. package/src/ConsoleShared/src/components/markdown-extensions/utils.ts +3 -0
  72. package/src/ConsoleShared/src/components/markdown-highlight-extension/MarkdownHighlightExtension.tsx +64 -0
  73. package/src/ConsoleShared/src/components/markdown-highlight-extension/highlight-consts.ts +9 -0
  74. package/src/ConsoleShared/src/components/markdown-highlight-extension/index.ts +1 -0
  75. package/src/ConsoleShared/src/components/modal/Modal.scss +3 -0
  76. package/src/ConsoleShared/src/components/modal/Modal.tsx +19 -0
  77. package/src/ConsoleShared/src/components/modal/index.ts +1 -0
  78. package/src/ConsoleShared/src/components/popper/Portal.tsx +23 -0
  79. package/src/ConsoleShared/src/components/popper/SimplePopper.tsx +90 -0
  80. package/src/ConsoleShared/src/components/popper/index.ts +2 -0
  81. package/src/ConsoleShared/src/components/spotlight/InteractiveSpotlight.tsx +58 -0
  82. package/src/ConsoleShared/src/components/spotlight/Spotlight.tsx +35 -0
  83. package/src/ConsoleShared/src/components/spotlight/StaticSpotlight.tsx +32 -0
  84. package/src/ConsoleShared/src/components/spotlight/index.ts +1 -0
  85. package/src/ConsoleShared/src/components/spotlight/spotlight.scss +63 -0
  86. package/src/ConsoleShared/src/components/status/GenericStatus.tsx +33 -0
  87. package/src/ConsoleShared/src/components/status/NotStartedIcon.tsx +27 -0
  88. package/src/ConsoleShared/src/components/status/PopoverStatus.tsx +42 -0
  89. package/src/ConsoleShared/src/components/status/Status.tsx +38 -0
  90. package/src/ConsoleShared/src/components/status/StatusIconAndText.tsx +42 -0
  91. package/src/ConsoleShared/src/components/status/icons.tsx +77 -0
  92. package/src/ConsoleShared/src/components/status/index.tsx +1 -0
  93. package/src/ConsoleShared/src/components/status/statuses.tsx +36 -0
  94. package/src/ConsoleShared/src/components/status/types.ts +7 -0
  95. package/src/ConsoleShared/src/components/utils/FallbackImg.tsx +20 -0
  96. package/src/ConsoleShared/src/components/utils/index.ts +1 -0
  97. package/src/ConsoleShared/src/constants/index.ts +1 -0
  98. package/src/ConsoleShared/src/constants/ui.ts +1 -0
  99. package/src/ConsoleShared/src/hooks/index.ts +6 -0
  100. package/src/ConsoleShared/src/hooks/scroll.ts +52 -0
  101. package/src/ConsoleShared/src/hooks/useBoundingClientRect.ts +18 -0
  102. package/src/ConsoleShared/src/hooks/useEventListener.ts +14 -0
  103. package/src/ConsoleShared/src/hooks/useForceRender.ts +6 -0
  104. package/src/ConsoleShared/src/hooks/useResizeObserver.ts +20 -0
  105. package/src/ConsoleShared/src/hooks/useScrollShadows.ts +45 -0
  106. package/src/ConsoleShared/src/index.ts +4 -0
  107. package/src/ConsoleShared/src/utils/index.ts +1 -0
  108. package/src/ConsoleShared/src/utils/useCombineRefs.ts +17 -0
  109. package/src/HelpTopicDrawer.tsx +124 -0
  110. package/src/HelpTopicPanelContent.tsx +152 -0
  111. package/src/QuickStartCatalogPage.tsx +190 -0
  112. package/src/QuickStartCloseModal.tsx +47 -0
  113. package/src/QuickStartController.tsx +113 -0
  114. package/src/QuickStartDrawer.scss +11 -0
  115. package/src/QuickStartDrawer.tsx +265 -0
  116. package/src/QuickStartMarkdownView.tsx +75 -0
  117. package/src/QuickStartPanelContent.scss +46 -0
  118. package/src/QuickStartPanelContent.tsx +153 -0
  119. package/src/__tests__/quick-start-utils.spec.tsx +16 -0
  120. package/src/catalog/Catalog/QuickStartCatalogHeader.tsx +18 -0
  121. package/src/catalog/Catalog/QuickStartCatalogSection.tsx +9 -0
  122. package/src/catalog/Catalog/QuickStartCatalogToolbar.tsx +12 -0
  123. package/src/catalog/Catalog/index.ts +3 -0
  124. package/src/catalog/QuickStartCatalog.scss +8 -0
  125. package/src/catalog/QuickStartCatalog.tsx +42 -0
  126. package/src/catalog/QuickStartTile.scss +11 -0
  127. package/src/catalog/QuickStartTile.tsx +105 -0
  128. package/src/catalog/QuickStartTileDescription.scss +29 -0
  129. package/src/catalog/QuickStartTileDescription.tsx +79 -0
  130. package/src/catalog/QuickStartTileFooter.tsx +101 -0
  131. package/src/catalog/QuickStartTileFooterExternal.tsx +40 -0
  132. package/src/catalog/QuickStartTileHeader.scss +12 -0
  133. package/src/catalog/QuickStartTileHeader.tsx +77 -0
  134. package/src/catalog/Toolbar/QuickStartCatalogFilter.scss +25 -0
  135. package/src/catalog/Toolbar/QuickStartCatalogFilter.tsx +34 -0
  136. package/src/catalog/Toolbar/QuickStartCatalogFilterItems.tsx +199 -0
  137. package/src/catalog/__tests__/QuickStartCatalog.spec.tsx +35 -0
  138. package/src/catalog/__tests__/QuickStartTile.spec.tsx +38 -0
  139. package/src/catalog/__tests__/QuickStartTileDescription.spec.tsx +44 -0
  140. package/src/catalog/index.ts +9 -0
  141. package/src/controller/QuickStartConclusion.tsx +63 -0
  142. package/src/controller/QuickStartContent.scss +12 -0
  143. package/src/controller/QuickStartContent.tsx +72 -0
  144. package/src/controller/QuickStartFooter.scss +13 -0
  145. package/src/controller/QuickStartFooter.tsx +128 -0
  146. package/src/controller/QuickStartIntroduction.scss +35 -0
  147. package/src/controller/QuickStartIntroduction.tsx +66 -0
  148. package/src/controller/QuickStartTaskHeader.scss +58 -0
  149. package/src/controller/QuickStartTaskHeader.tsx +116 -0
  150. package/src/controller/QuickStartTaskHeaderList.scss +17 -0
  151. package/src/controller/QuickStartTaskHeaderList.tsx +35 -0
  152. package/src/controller/QuickStartTaskReview.scss +30 -0
  153. package/src/controller/QuickStartTaskReview.tsx +81 -0
  154. package/src/controller/QuickStartTasks.scss +89 -0
  155. package/src/controller/QuickStartTasks.tsx +75 -0
  156. package/src/controller/__tests__/QuickStartConclusion.spec.tsx +95 -0
  157. package/src/controller/__tests__/QuickStartContent.spec.tsx +52 -0
  158. package/src/controller/__tests__/QuickStartFooter.spec.tsx +148 -0
  159. package/src/controller/__tests__/QuickStartTaskHeader.spec.tsx +56 -0
  160. package/src/controller/__tests__/QuickStartTaskReview.spec.tsx +45 -0
  161. package/src/controller/__tests__/QuickStartTasks.spec.tsx +81 -0
  162. package/src/data/mocks/json/explore-pipeline-quickstart.ts +66 -0
  163. package/src/data/mocks/json/explore-serverless-quickstart.ts +90 -0
  164. package/src/data/mocks/json/monitor-sampleapp-quickstart.ts +77 -0
  165. package/src/data/mocks/json/tour-icons.ts +3 -0
  166. package/src/data/mocks/yamls/add-healthchecks-quickstart.yaml +67 -0
  167. package/src/data/mocks/yamls/explore-pipeline-quickstart.yaml +57 -0
  168. package/src/data/mocks/yamls/explore-serverless-quickstart.yaml +83 -0
  169. package/src/data/mocks/yamls/install-associate-pipeline-quickstart.yaml +74 -0
  170. package/src/data/mocks/yamls/monitor-sampleapp-quickstart.yaml +66 -0
  171. package/src/data/mocks/yamls/sample-application-quickstart.yaml +97 -0
  172. package/src/data/mocks/yamls/serverless-application-quickstart.yaml +141 -0
  173. package/src/data/quick-start-test-data.ts +10 -0
  174. package/src/data/test-utils.ts +11 -0
  175. package/src/declaration.d.ts +2 -0
  176. package/src/index.ts +17 -0
  177. package/src/locales/en/quickstart.json +46 -0
  178. package/src/styles/_base.scss +54 -0
  179. package/src/styles/_dark-custom-override.scss +62 -0
  180. package/src/styles/legacy-bootstrap/README.md +21 -0
  181. package/src/styles/legacy-bootstrap/_code.scss +44 -0
  182. package/src/styles/legacy-bootstrap/_tables.scss +38 -0
  183. package/src/styles/legacy-bootstrap/_type.scss +90 -0
  184. package/src/styles/legacy-bootstrap/_variables.scss +48 -0
  185. package/src/styles/legacy-bootstrap.scss +5 -0
  186. package/src/styles/patternfly-global-entry.ts +1 -0
  187. package/src/styles/patternfly-global.scss +28 -0
  188. package/src/styles/patternfly-nested-entry.ts +1 -0
  189. package/src/styles/patternfly-nested.scss +18 -0
  190. package/src/styles/quickstarts-standalone-entry.ts +1 -0
  191. package/src/styles/quickstarts-standalone.scss +7 -0
  192. package/src/styles/style.scss +12 -0
  193. package/src/styles/vendor-entry.ts +1 -0
  194. package/src/styles/vendor.scss +7 -0
  195. package/src/utils/PluralResolver.ts +356 -0
  196. package/src/utils/asciidoc-procedure-parser.ts +132 -0
  197. package/src/utils/const.ts +10 -0
  198. package/src/utils/help-topic-context.tsx +74 -0
  199. package/src/utils/help-topic-types.ts +16 -0
  200. package/src/utils/quick-start-context.tsx +477 -0
  201. package/src/utils/quick-start-types.ts +72 -0
  202. package/src/utils/quick-start-utils.ts +92 -0
  203. package/src/utils/useLocalStorage.ts +38 -0
@@ -0,0 +1,58 @@
1
+ .pfext-status-box {
2
+ padding: 40px 20px;
3
+
4
+ &__loading-message {
5
+ margin-top: var(--pf-global--spacer--sm);
6
+ }
7
+ }
8
+
9
+ .pfext-status-box--loading {
10
+ align-items: center;
11
+ display: flex;
12
+ height: 100%;
13
+ justify-content: center;
14
+ min-height: 50px;
15
+ width: 100%;
16
+ flex-direction: column;
17
+ }
18
+
19
+ .pfext-m-loader {
20
+ min-width: 18px;
21
+ }
22
+
23
+ .pfext-m-loader-dot__one,
24
+ .pfext-m-loader-dot__two,
25
+ .pfext-m-loader-dot__three {
26
+ animation-delay: 0;
27
+ animation-direction: normal;
28
+ animation-duration: 1s;
29
+ animation-fill-mode: forwards;
30
+ animation-iteration-count: infinite;
31
+ animation-name: bouncedelay;
32
+ animation-play-state: running;
33
+ animation-timing-function: ease-in-out;
34
+ background: #419eda;
35
+ border-radius: 100%;
36
+ display: inline-block;
37
+ height: 6px;
38
+ width: 6px;
39
+ }
40
+
41
+ .pfext-m-loader-dot__one {
42
+ animation-delay: -0.32s;
43
+ }
44
+
45
+ .pfext-m-loader-dot__two {
46
+ animation-delay: -0.16s;
47
+ }
48
+
49
+ @keyframes bouncedelay {
50
+ 0%,
51
+ 80%,
52
+ 100% {
53
+ transform: scale(0.25, 0.25);
54
+ }
55
+ 40% {
56
+ transform: scale(1, 1);
57
+ }
58
+ }
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+
3
+ const MEMO = {};
4
+
5
+ export const CamelCaseWrap: React.SFC<CamelCaseWrapProps> = ({ value, dataTest }) => {
6
+ if (!value) {
7
+ return '-';
8
+ }
9
+
10
+ if (MEMO[value]) {
11
+ return MEMO[value];
12
+ }
13
+
14
+ // Add word break points before capital letters (but keep consecutive capital letters together).
15
+ const words = value.match(/[A-Z]+[^A-Z]*|[^A-Z]+/g);
16
+ const rendered = (
17
+ <span data-test={dataTest}>
18
+ {words.map((word, i) => (
19
+ <React.Fragment key={i}>
20
+ {word}
21
+ {i !== words.length - 1 && <wbr />}
22
+ </React.Fragment>
23
+ ))}
24
+ </span>
25
+ );
26
+ MEMO[value] = rendered;
27
+ return rendered;
28
+ };
29
+
30
+ export type CamelCaseWrapProps = {
31
+ value: string;
32
+ dataTest?: string;
33
+ };
@@ -0,0 +1,3 @@
1
+ export * from './status-box';
2
+ export * from './router';
3
+ export * from './camel-case-wrap';
@@ -0,0 +1,47 @@
1
+ import { History, createBrowserHistory, createMemoryHistory } from 'history';
2
+ import { QUICKSTART_SEARCH_FILTER_KEY, QUICKSTART_STATUS_FILTER_KEY } from '../../../utils/const';
3
+
4
+ type AppHistory = History & { pushPath: History['push'] };
5
+
6
+ let createHistory;
7
+
8
+ try {
9
+ if (process.env.NODE_ENV === 'test') {
10
+ // Running in node. Can't use browser history
11
+ createHistory = createMemoryHistory;
12
+ } else {
13
+ createHistory = createBrowserHistory;
14
+ }
15
+ } catch (unused) {
16
+ createHistory = createBrowserHistory;
17
+ }
18
+
19
+ export const history: AppHistory = createHistory();
20
+
21
+ export const removeQueryArgument = (k: string) => {
22
+ const params = new URLSearchParams(window.location.search);
23
+ if (params.has(k)) {
24
+ params.delete(k);
25
+ const url = new URL(window.location.href);
26
+ // @ts-ignore
27
+ history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
28
+ }
29
+ };
30
+
31
+ export const setQueryArgument = (k: string, v: string) => {
32
+ if (!v) {
33
+ return removeQueryArgument(k);
34
+ }
35
+ const params = new URLSearchParams(window.location.search);
36
+ if (params.get(k) !== v) {
37
+ params.set(k, v);
38
+ const url = new URL(window.location.href);
39
+ // @ts-ignore
40
+ history.replace(`${url.pathname}?${params.toString()}${url.hash}`);
41
+ }
42
+ };
43
+
44
+ export const clearFilterParams = () => {
45
+ removeQueryArgument(QUICKSTART_SEARCH_FILTER_KEY);
46
+ removeQueryArgument(QUICKSTART_STATUS_FILTER_KEY);
47
+ };
@@ -0,0 +1,94 @@
1
+ import * as React from 'react';
2
+ import { css } from '@patternfly/react-styles';
3
+ import { QuickStartContext, QuickStartContextValues } from '../../../utils/quick-start-context';
4
+
5
+ export const Box: React.FC<BoxProps> = ({ children, className }) => (
6
+ <div className={css('pfext-status-box', className)}>{children}</div>
7
+ );
8
+
9
+ export const Loading: React.FC<LoadingProps> = ({ className }) => (
10
+ <div className={css('pfext-m-loader', className)}>
11
+ <div className="pfext-m-loader-dot__one" />
12
+ <div className="pfext-m-loader-dot__two" />
13
+ <div className="pfext-m-loader-dot__three" />
14
+ </div>
15
+ );
16
+ Loading.displayName = 'Loading';
17
+
18
+ export const LoadingBox: React.FC<LoadingBoxProps> = ({ className, message }) => (
19
+ <Box className={css('pfext-status-box--loading', className)}>
20
+ <Loading />
21
+ {message && <div className="pfext-status-box__loading-message">{message}</div>}
22
+ </Box>
23
+ );
24
+ LoadingBox.displayName = 'LoadingBox';
25
+
26
+ export const EmptyBox: React.FC<EmptyBoxProps> = ({ label }) => {
27
+ const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
28
+ return (
29
+ <Box>
30
+ <div data-test="empty-message" className="text-center">
31
+ {label
32
+ ? getResource('No {{label}} found').replace('{{label}}', label)
33
+ : getResource('Not found')}
34
+ </div>
35
+ </Box>
36
+ );
37
+ };
38
+ EmptyBox.displayName = 'EmptyBox';
39
+
40
+ type BoxProps = {
41
+ children: React.ReactNode;
42
+ className?: string;
43
+ };
44
+
45
+ type LoadErrorProps = {
46
+ label: string;
47
+ className?: string;
48
+ message?: string;
49
+ canRetry?: boolean;
50
+ };
51
+
52
+ type LoadingProps = {
53
+ className?: string;
54
+ };
55
+
56
+ type LoadingBoxProps = {
57
+ className?: string;
58
+ message?: string;
59
+ };
60
+
61
+ type EmptyBoxProps = {
62
+ label?: string;
63
+ };
64
+
65
+ type MsgBoxProps = {
66
+ title?: string;
67
+ detail?: React.ReactNode;
68
+ className?: string;
69
+ };
70
+
71
+ type AccessDeniedProps = {
72
+ message?: string;
73
+ };
74
+
75
+ type DataProps = {
76
+ NoDataEmptyMsg?: React.ComponentType;
77
+ EmptyMsg?: React.ComponentType;
78
+ label?: string;
79
+ unfilteredData?: any;
80
+ data?: any;
81
+ children?: React.ReactNode;
82
+ };
83
+
84
+ type StatusBoxProps = {
85
+ label?: string;
86
+ loadError?: any;
87
+ loaded?: boolean;
88
+ data?: any;
89
+ unfilteredData?: any;
90
+ skeleton?: React.ReactNode;
91
+ NoDataEmptyMsg?: React.ComponentType;
92
+ EmptyMsg?: React.ComponentType;
93
+ children?: React.ReactNode;
94
+ };
@@ -0,0 +1,53 @@
1
+ export type AccessReviewResourceAttributes = {
2
+ group?: string;
3
+ resource?: string;
4
+ subresource?: string;
5
+ verb?: K8sVerb;
6
+ name?: string;
7
+ namespace?: string;
8
+ };
9
+
10
+ export type K8sVerb =
11
+ | 'create'
12
+ | 'get'
13
+ | 'list'
14
+ | 'update'
15
+ | 'patch'
16
+ | 'delete'
17
+ | 'deletecollection'
18
+ | 'watch';
19
+
20
+ export type OwnerReference = {
21
+ name: string;
22
+ kind: string;
23
+ uid: string;
24
+ apiVersion: string;
25
+ controller?: boolean;
26
+ blockOwnerDeletion?: boolean;
27
+ };
28
+
29
+ export type ObjectMetadata = {
30
+ name: string;
31
+ annotations?: { [key: string]: string };
32
+ clusterName?: string;
33
+ creationTimestamp?: string;
34
+ deletionGracePeriodSeconds?: number;
35
+ deletionTimestamp?: string;
36
+ finalizers?: string[];
37
+ generateName?: string;
38
+ generation?: number;
39
+ labels?: { [key: string]: string };
40
+ managedFields?: any[];
41
+ namespace?: string;
42
+ ownerReferences?: OwnerReference[];
43
+ resourceVersion?: string;
44
+ uid?: string;
45
+ // language can be: en
46
+ language?: string;
47
+ // country can be: US
48
+ country?: string;
49
+ // locale is a combination of language and country, for example: en_US
50
+ locale?: string;
51
+ // anything else to custom define
52
+ [key: string]: any;
53
+ };
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,7 @@
1
+ export * from './modal';
2
+ export * from './spotlight';
3
+ export * from './markdown-highlight-extension';
4
+ export * from './markdown-extensions';
5
+ export * from './popper';
6
+ export * from './utils';
7
+ export * from './status';
@@ -0,0 +1,29 @@
1
+ .pfext-page-layout {
2
+ &__content {
3
+ padding: var(--pf-global--spacer--lg);
4
+ flex: 1;
5
+ }
6
+
7
+ &__header {
8
+ padding-top: 1px;
9
+ background-color: var(--pf-global--BackgroundColor--light-100);
10
+ }
11
+
12
+ &__hint {
13
+ padding-left: var(--pf-global--spacer--lg);
14
+ padding-right: var(--pf-global--spacer--lg);
15
+ padding-bottom: var(--pf-global--spacer--md);
16
+ font-size: 14px;
17
+ }
18
+
19
+ &__title {
20
+ padding-left: var(--pf-global--spacer--lg);
21
+ padding-right: var(--pf-global--spacer--lg);
22
+ font-size: var(--pf-global--FontSize--2xl);
23
+ margin-top: 23px;
24
+ margin-bottom: 11.5px;
25
+ font-family: var(--pf-global--FontFamily--heading--sans-serif);
26
+ font-weight: var(--pf-global--FontWeight--normal);
27
+ line-height: 1.1;
28
+ }
29
+ }
@@ -0,0 +1,93 @@
1
+ import * as React from 'react';
2
+ import { Tooltip } from '@patternfly/react-core';
3
+ import { QuickStartContext, QuickStartContextValues } from '@quickstarts/utils/quick-start-context';
4
+ import { useEventListener } from '../../hooks';
5
+ import { MARKDOWN_COPY_BUTTON_ID, MARKDOWN_SNIPPET_ID } from './const';
6
+
7
+ type CopyClipboardProps = {
8
+ element: HTMLElement;
9
+ rootSelector: string;
10
+ docContext: HTMLDocument;
11
+ };
12
+
13
+ export const CopyClipboard: React.FC<CopyClipboardProps> = ({
14
+ element,
15
+ rootSelector,
16
+ docContext,
17
+ }) => {
18
+ const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
19
+ const [showSuccessContent, setShowSuccessContent] = React.useState<boolean>(false);
20
+ const textToCopy = React.useMemo(() => {
21
+ const copyTextId = element.getAttribute(MARKDOWN_COPY_BUTTON_ID);
22
+ return (docContext.querySelector(
23
+ `${rootSelector} [${MARKDOWN_SNIPPET_ID}="${copyTextId}"]`,
24
+ ) as HTMLElement).innerText;
25
+ }, [element, docContext, rootSelector]);
26
+
27
+ useEventListener(
28
+ element,
29
+ 'click',
30
+ React.useCallback(() => {
31
+ navigator.clipboard
32
+ .writeText(textToCopy)
33
+ .then(() => {
34
+ setShowSuccessContent(true);
35
+ })
36
+ .catch(() => {});
37
+ }, [textToCopy]),
38
+ );
39
+
40
+ useEventListener(
41
+ element,
42
+ 'mouseleave',
43
+ React.useCallback(() => {
44
+ setShowSuccessContent(false);
45
+ }, []),
46
+ );
47
+
48
+ return showSuccessContent ? (
49
+ <Tooltip
50
+ key="after-copy"
51
+ isVisible
52
+ reference={() => element as HTMLElement}
53
+ content={getResource('Successfully copied to clipboard!')}
54
+ className="pfext-quick-start__base"
55
+ />
56
+ ) : (
57
+ <Tooltip
58
+ key="before-copy"
59
+ reference={() => element as HTMLElement}
60
+ content={getResource('Copy to clipboard')}
61
+ className="pfext-quick-start__base"
62
+ />
63
+ );
64
+ };
65
+
66
+ type MarkdownCopyClipboardProps = {
67
+ docContext: HTMLDocument;
68
+ rootSelector: string;
69
+ };
70
+
71
+ const MarkdownCopyClipboard: React.FC<MarkdownCopyClipboardProps> = ({
72
+ docContext,
73
+ rootSelector,
74
+ }) => {
75
+ const elements = docContext.querySelectorAll(`${rootSelector} [${MARKDOWN_COPY_BUTTON_ID}]`);
76
+ return elements.length > 0 ? (
77
+ <>
78
+ {Array.from(elements).map((elm) => {
79
+ const attributeValue = elm.getAttribute(MARKDOWN_COPY_BUTTON_ID);
80
+ return (
81
+ <CopyClipboard
82
+ key={attributeValue}
83
+ element={elm as HTMLElement}
84
+ rootSelector={rootSelector}
85
+ docContext={docContext}
86
+ />
87
+ );
88
+ })}
89
+ </>
90
+ ) : null;
91
+ };
92
+
93
+ export default MarkdownCopyClipboard;
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import MarkdownCopyClipboard, { CopyClipboard } from '../MarkdownCopyClipboard';
4
+ import { htmlDocumentForCopyClipboard } from './test-data';
5
+
6
+ describe('MarkdownCopyClipboard', () => {
7
+ beforeAll(() => {
8
+ document.body.innerHTML = htmlDocumentForCopyClipboard;
9
+ });
10
+ it('should render null if no element is found', () => {
11
+ const wrapper = shallow(
12
+ <MarkdownCopyClipboard docContext={document} rootSelector="#copy-markdown-3" />,
13
+ );
14
+ expect(wrapper.isEmptyRender()).toBe(true);
15
+ expect(wrapper.find(CopyClipboard).exists()).toBe(false);
16
+ });
17
+
18
+ it('should render null if no element is found', () => {
19
+ const wrapper = shallow(
20
+ <MarkdownCopyClipboard docContext={document} rootSelector="#copy-markdown-1" />,
21
+ );
22
+ expect(wrapper.isEmptyRender()).toBe(false);
23
+ expect(wrapper.find(CopyClipboard).exists()).toBe(true);
24
+ });
25
+ });
@@ -0,0 +1,5 @@
1
+ import { MARKDOWN_COPY_BUTTON_ID, MARKDOWN_SNIPPET_ID, MARKDOWN_EXECUTE_BUTTON_ID } from '../const';
2
+
3
+ export const htmlDocumentForCopyClipboard = `<div id="copy-markdown-1"><div ${MARKDOWN_SNIPPET_ID}="1234">some test data for testing</div><button ${MARKDOWN_COPY_BUTTON_ID}="1234"</button><div ${MARKDOWN_SNIPPET_ID}="12354">some test data for testing</div><button ${MARKDOWN_COPY_BUTTON_ID}="12354"</button></div>`;
4
+
5
+ export const htmlDocumentForExecuteButton = `<div id="execute-markdown-1"><div ${MARKDOWN_SNIPPET_ID}="1234">some test data for testing</div><button ${MARKDOWN_EXECUTE_BUTTON_ID}="1234"</button><div ${MARKDOWN_SNIPPET_ID}="12354">some test data for testing</div><button ${MARKDOWN_EXECUTE_BUTTON_ID}="12354"</button></div>`;
@@ -0,0 +1,66 @@
1
+ import * as React from 'react';
2
+ import { removeTemplateWhitespace } from './utils';
3
+ import { renderToStaticMarkup } from 'react-dom/server';
4
+ import { Alert } from '@patternfly/react-core';
5
+ import LightbulbIcon from '@patternfly/react-icons/dist/js/icons/lightbulb-icon';
6
+ import FireIcon from '@patternfly/react-icons/dist/js/icons/fire-icon';
7
+ import './showdown-extension.scss';
8
+
9
+ enum AdmonitionType {
10
+ TIP = 'TIP',
11
+ NOTE = 'NOTE',
12
+ IMPORTANT = 'IMPORTANT',
13
+ WARNING = 'WARNING',
14
+ CAUTION = 'CAUTION',
15
+ }
16
+
17
+ const admonitionToAlertVariantMap = {
18
+ [AdmonitionType.NOTE]: { variant: 'info' },
19
+ [AdmonitionType.TIP]: { variant: 'default', customIcon: <LightbulbIcon /> },
20
+ [AdmonitionType.IMPORTANT]: { variant: 'danger' },
21
+ [AdmonitionType.CAUTION]: { variant: 'warning', customIcon: <FireIcon /> },
22
+ [AdmonitionType.WARNING]: { variant: 'warning' },
23
+ };
24
+
25
+ const useAdmonitionShowdownExtension = () => {
26
+ // const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
27
+ return React.useMemo(
28
+ () => ({
29
+ type: 'lang',
30
+ regex: /\[([\d\w\s-()$!]+)]{{(admonition) ([\w-]+)}}/g,
31
+ replace: (
32
+ text: string,
33
+ content: string,
34
+ admonitionLabel: string,
35
+ admonitionType: string,
36
+ groupId: string,
37
+ ): string => {
38
+ if (!content || !admonitionLabel || !admonitionType || !groupId) {
39
+ return text;
40
+ }
41
+ admonitionType = admonitionType.toUpperCase();
42
+
43
+ const { variant, customIcon } = admonitionToAlertVariantMap[admonitionType];
44
+ const style =
45
+ admonitionType === AdmonitionType.CAUTION ? { backgroundColor: '#ec7a0915' } : {};
46
+
47
+ const pfAlert = (
48
+ <Alert
49
+ variant={variant}
50
+ customIcon={customIcon && customIcon}
51
+ isInline
52
+ title={admonitionType}
53
+ className="pfext-markdown-admonition"
54
+ style={style}
55
+ >
56
+ {content}
57
+ </Alert>
58
+ );
59
+ return removeTemplateWhitespace(renderToStaticMarkup(pfAlert));
60
+ },
61
+ }),
62
+ [],
63
+ );
64
+ };
65
+
66
+ export default useAdmonitionShowdownExtension;
@@ -0,0 +1,25 @@
1
+ import * as React from 'react';
2
+ import { removeTemplateWhitespace } from './utils';
3
+ import { renderToStaticMarkup } from 'react-dom/server';
4
+ import { CodeBlock } from '@patternfly/react-core';
5
+ import './showdown-extension.scss';
6
+
7
+ const useCodeShowdownExtension = () => {
8
+ return React.useMemo(
9
+ () => ({
10
+ type: 'output',
11
+ regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
12
+ replace: (text: string, content: string): string => {
13
+ if (!content) {
14
+ return text;
15
+ }
16
+ const pfCodeBlock = <CodeBlock>{content}</CodeBlock>;
17
+
18
+ return removeTemplateWhitespace(renderToStaticMarkup(pfCodeBlock));
19
+ },
20
+ }),
21
+ [],
22
+ );
23
+ };
24
+
25
+ export default useCodeShowdownExtension;
@@ -0,0 +1,3 @@
1
+ export const MARKDOWN_COPY_BUTTON_ID = 'data-copy-for';
2
+ export const MARKDOWN_EXECUTE_BUTTON_ID = 'data-execute-for';
3
+ export const MARKDOWN_SNIPPET_ID = 'data-snippet-id';
@@ -0,0 +1,5 @@
1
+ export { default as MarkdownCopyClipboard } from './MarkdownCopyClipboard';
2
+ export { default as useInlineCopyClipboardShowdownExtension } from './inline-clipboard-extension';
3
+ export { default as useMultilineCopyClipboardShowdownExtension } from './multiline-clipboard-extension';
4
+ export { default as useAdmonitionShowdownExtension } from './admonition-extension';
5
+ export { default as useCodeShowdownExtension } from './code-extension';
@@ -0,0 +1,45 @@
1
+ import * as React from 'react';
2
+ import { QuickStartContext, QuickStartContextValues } from '@quickstarts/utils/quick-start-context';
3
+ import { MARKDOWN_COPY_BUTTON_ID, MARKDOWN_SNIPPET_ID } from './const';
4
+ import { removeTemplateWhitespace } from './utils';
5
+ import { renderToStaticMarkup } from 'react-dom/server';
6
+ import CopyIcon from '@patternfly/react-icons/dist/js/icons/copy-icon';
7
+ import './showdown-extension.scss';
8
+
9
+ const useInlineCopyClipboardShowdownExtension = () => {
10
+ const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
11
+ return React.useMemo(
12
+ () => ({
13
+ type: 'lang',
14
+ regex: /`([^`](.*?)[^`])`{{copy}}/g,
15
+ replace: (
16
+ text: string,
17
+ group: string,
18
+ subGroup: string,
19
+ groupType: string,
20
+ groupId: string,
21
+ ): string => {
22
+ if (!group || !subGroup || !groupType || !groupId) {
23
+ return text;
24
+ }
25
+ return removeTemplateWhitespace(
26
+ `<span class="pf-c-clipboard-copy pf-m-inline">
27
+ <span class="pf-c-clipboard-copy__text" ${MARKDOWN_SNIPPET_ID}="${groupType}">${group}</span>
28
+ <span class="pf-c-clipboard-copy__actions">
29
+ <span class="pf-c-clipboard-copy__actions-item">
30
+ <button class="pf-c-button pf-m-plain" aria-label="${getResource(
31
+ 'Copy to clipboard',
32
+ )}" ${MARKDOWN_COPY_BUTTON_ID}="${groupType}">
33
+ ${renderToStaticMarkup(<CopyIcon />)}
34
+ </button>
35
+ </span>
36
+ </span>
37
+ </span>`,
38
+ );
39
+ },
40
+ }),
41
+ [getResource],
42
+ );
43
+ };
44
+
45
+ export default useInlineCopyClipboardShowdownExtension;
@@ -0,0 +1,50 @@
1
+ import * as React from 'react';
2
+ import { QuickStartContext, QuickStartContextValues } from '@quickstarts/utils/quick-start-context';
3
+ import { MARKDOWN_COPY_BUTTON_ID, MARKDOWN_SNIPPET_ID } from './const';
4
+ import { renderToStaticMarkup } from 'react-dom/server';
5
+ import CopyIcon from '@patternfly/react-icons/dist/js/icons/copy-icon';
6
+
7
+ import './showdown-extension.scss';
8
+
9
+ const useMultilineCopyClipboardShowdownExtension = () => {
10
+ const { getResource } = React.useContext<QuickStartContextValues>(QuickStartContext);
11
+ return React.useMemo(
12
+ () => ({
13
+ type: 'lang',
14
+ regex: /```[\n]((.*?\n)+)```{{copy}}/g,
15
+ replace: (
16
+ text: string,
17
+ group: string,
18
+ subgroup: string,
19
+ groupType: string,
20
+ groupId: string,
21
+ ): string => {
22
+ if (!group || !subgroup || !groupType || !groupId) {
23
+ return text;
24
+ }
25
+ return `<div class="pf-c-code-block">
26
+ <div class="pf-c-code-block__header">
27
+ <div class="pf-c-code-block__actions">
28
+ <div class="pf-c-code-block__actions-item">
29
+ <button class="pf-c-button pf-m-plain" type="button" aria-label="${getResource(
30
+ 'Copy to clipboard',
31
+ )}" ${MARKDOWN_COPY_BUTTON_ID}="${groupType}">
32
+ ${renderToStaticMarkup(<CopyIcon />)}
33
+ </button>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ <div class="pf-c-code-block__content">
38
+ <pre class="pf-c-code-block__pre pfext-code-block__pre">
39
+ <code class="pf-c-code-block__code"
40
+ ${MARKDOWN_SNIPPET_ID}="${groupType}">${group}</code>
41
+ </pre>
42
+ </div>
43
+ </div>`;
44
+ },
45
+ }),
46
+ [getResource],
47
+ );
48
+ };
49
+
50
+ export default useMultilineCopyClipboardShowdownExtension;