@patternfly/quickstarts 2.1.0 → 2.2.2
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 +305 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/code-extension.d.ts +7 -0
- package/dist/ConsoleShared/src/components/markdown-extensions/index.d.ts +1 -0
- package/dist/HelpTopicDrawer.d.ts +26 -0
- package/dist/HelpTopicPanelContent.d.ts +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +136 -8
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +141 -6
- package/dist/index.js.map +1 -1
- package/dist/patternfly-nested.css +222 -2
- package/dist/quickstarts-base.css +49 -11
- package/dist/quickstarts-full.es.js +857 -275
- package/dist/quickstarts-full.es.js.map +1 -1
- package/dist/quickstarts-standalone.css +5 -15
- package/dist/quickstarts-standalone.min.css +1 -1
- package/dist/quickstarts.css +49 -11
- package/dist/quickstarts.min.css +1 -1
- package/dist/utils/const.d.ts +1 -0
- package/dist/utils/help-topic-context.d.ts +23 -0
- package/dist/utils/help-topic-types.d.ts +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -207,6 +207,30 @@ You can have inline or block copyable text.
|
|
|
207
207
|
```{{copy}}
|
|
208
208
|
```
|
|
209
209
|
|
|
210
|
+
## Markdown extensions
|
|
211
|
+
If your source material content is defined in markdown (yaml + markdown / json + markdown), then you can add your own markdown extensions, example:
|
|
212
|
+
```
|
|
213
|
+
const drawerProps: QuickStartContainerProps = {
|
|
214
|
+
markdown: {
|
|
215
|
+
extensions: [
|
|
216
|
+
// variable substitution example
|
|
217
|
+
// this replaces the strings [APPLICATION] and [PRODUCT]
|
|
218
|
+
{
|
|
219
|
+
type: 'output',
|
|
220
|
+
filter: function(html: string) {
|
|
221
|
+
html = html.replace(/\[APPLICATION\]/g, 'Mercury');
|
|
222
|
+
html = html.replace(/\[PRODUCT\]/g, 'Lightning');
|
|
223
|
+
|
|
224
|
+
return html;
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
return <QuickStartContainer {...drawerProps}>My page content</QuickStartContainer>
|
|
232
|
+
```
|
|
233
|
+
|
|
210
234
|
## Localization
|
|
211
235
|
We use English as the default language. You can override the default by providing your own key/value pairs to the `QuickStartContainer` or `QuickStartContextProvider` resourceBundle prop.
|
|
212
236
|
|
|
@@ -230,3 +254,284 @@ Use this [file](https://github.com/patternfly/patternfly-quickstarts/blob/main/p
|
|
|
230
254
|
Each language is different, especially when it comes to plurals. Try [this utility](https://jsfiddle.net/6bpxsgd4) sourced from [i18next](https://www.i18next.com/translation-function/plurals#how-to-find-the-correct-plural-suffix) to determine the suffixes for the right plural format.
|
|
231
255
|
|
|
232
256
|
For localizing the content of quick starts files, we provide the option to include `language` and `countryCode` key to your translated file. Based on these keys you can filter out quick starts. We have a demo of this behaviour in our [demo app](https://quickstarts.netlify.app/quickstarts-localized). You can have a look at the code [here](https://github.com/patternfly/patternfly-quickstarts/blob/main/packages/dev/src/AppLocalized.tsx).
|
|
257
|
+
|
|
258
|
+
## In-App / In Context Help Panel
|
|
259
|
+
|
|
260
|
+
The quickstarts package is being extended to support a side panel that displays smaller chunks (defined as the `HelpTopic` type) of documentation.
|
|
261
|
+
|
|
262
|
+
### Help Topic type definition
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
type HelpTopicLink = {
|
|
266
|
+
href: string;
|
|
267
|
+
text?: string;
|
|
268
|
+
// open link in new tab
|
|
269
|
+
newTab?: boolean;
|
|
270
|
+
// add PF icon indicating link is external
|
|
271
|
+
isExternal?: boolean;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
type HelpTopic = {
|
|
275
|
+
name: string;
|
|
276
|
+
title: string;
|
|
277
|
+
tags: string[];
|
|
278
|
+
content: string;
|
|
279
|
+
links: HelpTopicLink[];
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### Example Help Topic in yaml with markdown support for content and links
|
|
284
|
+
|
|
285
|
+
```yml
|
|
286
|
+
- name: auto-deploy
|
|
287
|
+
tags:
|
|
288
|
+
- page-1
|
|
289
|
+
title: Automatic Deployment
|
|
290
|
+
content: |-
|
|
291
|
+
**An Automatic Deployment** is...
|
|
292
|
+
|
|
293
|
+
Etiam viverra et tortor et maximus. Aliquam quis scelerisque metus. Proin luctus pretium sodales. Mauris nibh nibh, auctor eu scelerisque et, hendrerit a metus. Vivamus pharetra bibendum finibus. Sed a pulvinar ipsum. Fusce pharetra venenatis porttitor. Praesent justo metus, consectetur quis erat id, congue varius metus. Suspendisse dui est, tempor nec diam quis, facilisis sodales erat. Curabitur viverra convallis ex. Ut egestas condimentum augue, id euismod leo volutpat vitae. Quisque aliquet ac dolor quis pretium. Nunc at nibh quis arcu maximus elementum vel a mi.
|
|
294
|
+
links:
|
|
295
|
+
- text: 'Creating quick starts (external)'
|
|
296
|
+
href: 'https://docs.openshift.com/container-platform/4.9/web_console/creating-quick-start-tutorials.html'
|
|
297
|
+
isExternal: true
|
|
298
|
+
- text: 'Redhat Console (opens in new tab)'
|
|
299
|
+
href: 'https://console.redhat.com'
|
|
300
|
+
newTab: true
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Usage Example
|
|
304
|
+
|
|
305
|
+
See the [HelpTopicDemo](https://github.com/patternfly/patternfly-quickstarts/blob/6b35d3c346b3e92ed0003de955421c8dff58a22b/packages/dev/src/AppHelpTopicDemo.tsx)
|
|
306
|
+
|
|
307
|
+
- Similar to standard Quickstarts usage
|
|
308
|
+
- Load yaml defined `HelpTopic` array
|
|
309
|
+
- Pass `HelpTopicContainerProps`, including loaded `HelpTopics` to the `<HelpTopicContainer/>`
|
|
310
|
+
|
|
311
|
+
```tsx
|
|
312
|
+
import './App.css';
|
|
313
|
+
import { Page } from '@patternfly/react-core';
|
|
314
|
+
import { LoadingBox, HelpTopicContainerProps, HelpTopicContainer } from '@patternfly/quickstarts';
|
|
315
|
+
import { helpTopics } from './quickstarts-data/quick-start-test-data';
|
|
316
|
+
import React from 'react';
|
|
317
|
+
import i18n from './i18n/i18n';
|
|
318
|
+
import { AppHeader, AppSidebar } from './common/Page';
|
|
319
|
+
|
|
320
|
+
type AppProps = {
|
|
321
|
+
children?: React.ReactNode;
|
|
322
|
+
showCardFooters?: boolean;
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
const AppHelpTopicDemo: React.FC<AppProps> = ({ children }) => {
|
|
326
|
+
const language = localStorage.getItem('bridge/language') || 'en';
|
|
327
|
+
const resourceBundle = i18n.getResourceBundle(language, 'quickstart');
|
|
328
|
+
|
|
329
|
+
const [loading, setLoading] = React.useState(true);
|
|
330
|
+
React.useEffect(() => {
|
|
331
|
+
const load = async () => {
|
|
332
|
+
setLoading(false);
|
|
333
|
+
};
|
|
334
|
+
setTimeout(() => {
|
|
335
|
+
load();
|
|
336
|
+
}, 500);
|
|
337
|
+
}, []);
|
|
338
|
+
|
|
339
|
+
const inContextHelpProps: HelpTopicContainerProps = {
|
|
340
|
+
helpTopics,
|
|
341
|
+
resourceBundle,
|
|
342
|
+
language,
|
|
343
|
+
loading,
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
return (
|
|
347
|
+
<React.Suspense fallback={<LoadingBox />}>
|
|
348
|
+
<HelpTopicContainer {...inContextHelpProps}>
|
|
349
|
+
<Page header={AppHeader} sidebar={AppSidebar} isManagedSidebar>
|
|
350
|
+
{children}
|
|
351
|
+
</Page>
|
|
352
|
+
</HelpTopicContainer>
|
|
353
|
+
</React.Suspense>
|
|
354
|
+
);
|
|
355
|
+
};
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
In the example above `<HelpTopicContainer />` wraps the `<Page/>` element as well as a mock "console" showing how to trigger the side panel and allow navigation to all `HelpTopics` available on each console page:
|
|
359
|
+
|
|
360
|
+
Live [preview](https://deploy-preview-140--quickstarts.netlify.app/in-context-help) of code below:
|
|
361
|
+
|
|
362
|
+
```tsx
|
|
363
|
+
import * as React from 'react';
|
|
364
|
+
import {
|
|
365
|
+
Banner,
|
|
366
|
+
Button,
|
|
367
|
+
Divider,
|
|
368
|
+
Form,
|
|
369
|
+
FormGroup,
|
|
370
|
+
PageSection,
|
|
371
|
+
Popover,
|
|
372
|
+
Split,
|
|
373
|
+
SplitItem,
|
|
374
|
+
TextInput,
|
|
375
|
+
Title,
|
|
376
|
+
} from '@patternfly/react-core';
|
|
377
|
+
import { HelpTopicContext, HelpTopicContextValues } from '@patternfly/quickstarts';
|
|
378
|
+
import HelpIcon from '@patternfly/react-icons/dist/js/icons/help-icon';
|
|
379
|
+
import { HelpTopic } from '@patternfly/quickstarts/dist/utils/help-topic-types';
|
|
380
|
+
|
|
381
|
+
// Example usage of topics, render certain topics depending on the page
|
|
382
|
+
// used this case when "consolePageState" below is between 4 - 6
|
|
383
|
+
// these HelpTopics with the following names will be rendered
|
|
384
|
+
const helpTopicNamesByPage = [
|
|
385
|
+
['auto-deploy', 'code-sample', 'manual-deployment'],
|
|
386
|
+
['manual-deployment', 'target-port', 'build-configuration'],
|
|
387
|
+
['deploy-configuration', 'environment-variables', 'health-checks'],
|
|
388
|
+
];
|
|
389
|
+
|
|
390
|
+
interface FormGroupWithHelpTopicPopoverProps extends React.HTMLProps<HTMLDivElement> {
|
|
391
|
+
topic: HelpTopic;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// Example usage of setActiveHelpTopicByName()
|
|
395
|
+
// render a popover with a learn more link to open the drawer
|
|
396
|
+
const FormGroupWithHelpTopicPopover: React.FC<FormGroupWithHelpTopicPopoverProps> = ({ topic }) => {
|
|
397
|
+
const { setActiveHelpTopicByName } = React.useContext<HelpTopicContextValues>(HelpTopicContext);
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<FormGroup
|
|
401
|
+
label={topic.title}
|
|
402
|
+
isRequired
|
|
403
|
+
fieldId={topic.name}
|
|
404
|
+
key={topic.name}
|
|
405
|
+
labelIcon={
|
|
406
|
+
<Popover
|
|
407
|
+
bodyContent={(hide) => (
|
|
408
|
+
<div>
|
|
409
|
+
{topic.title} is quite amaizing{' '}
|
|
410
|
+
<Button
|
|
411
|
+
variant="link"
|
|
412
|
+
onClick={() => {
|
|
413
|
+
setActiveHelpTopicByName(topic.name);
|
|
414
|
+
hide();
|
|
415
|
+
}}
|
|
416
|
+
>
|
|
417
|
+
Learn more
|
|
418
|
+
</Button>
|
|
419
|
+
</div>
|
|
420
|
+
)}
|
|
421
|
+
>
|
|
422
|
+
<Button variant="plain">
|
|
423
|
+
<HelpIcon noVerticalAlign />
|
|
424
|
+
</Button>
|
|
425
|
+
</Popover>
|
|
426
|
+
}
|
|
427
|
+
>
|
|
428
|
+
<TextInput isRequired type="text" id={topic.name} />
|
|
429
|
+
</FormGroup>
|
|
430
|
+
);
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
export const MockConsole: React.FC = () => {
|
|
434
|
+
const { helpTopics, setFilteredHelpTopics, filteredHelpTopics, setActiveHelpTopicByName } =
|
|
435
|
+
React.useContext<HelpTopicContextValues>(HelpTopicContext);
|
|
436
|
+
|
|
437
|
+
// mock console page identifiers: 1 - 6
|
|
438
|
+
// click handlers to change page
|
|
439
|
+
const [consolePageState, setConsolePageState] = React.useState(1);
|
|
440
|
+
|
|
441
|
+
const handleClickNext = () => {
|
|
442
|
+
setActiveHelpTopicByName('');
|
|
443
|
+
if (consolePageState === 6) {
|
|
444
|
+
setConsolePageState(1);
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
setConsolePageState(consolePageState + 1);
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
const handleClickBack = () => {
|
|
451
|
+
setActiveHelpTopicByName('');
|
|
452
|
+
if (consolePageState === 6) {
|
|
453
|
+
setConsolePageState(4);
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
setConsolePageState(consolePageState - 1);
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// Example usage setFilteredHelpTopics()
|
|
460
|
+
// After rendering the console, set the filtered help topics
|
|
461
|
+
React.useEffect(() => {
|
|
462
|
+
// set filtered topics using tags, matching to the consolePageState
|
|
463
|
+
if (consolePageState < 4) {
|
|
464
|
+
const topics = helpTopics.filter((topic: HelpTopic) => {
|
|
465
|
+
const pageTagNumbers = topic.tags.map((tag: string) => {
|
|
466
|
+
return Number(tag.slice(-1));
|
|
467
|
+
});
|
|
468
|
+
return pageTagNumbers.includes(consolePageState);
|
|
469
|
+
});
|
|
470
|
+
setFilteredHelpTopics(topics);
|
|
471
|
+
} else {
|
|
472
|
+
// set filtered topics using the appropriate helpTopicNamesByPage array above
|
|
473
|
+
setFilteredHelpTopics(
|
|
474
|
+
helpTopics.filter((topic) => {
|
|
475
|
+
return helpTopicNamesByPage[consolePageState - 4].includes(topic.name);
|
|
476
|
+
}),
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
}, [consolePageState, helpTopics, setFilteredHelpTopics]);
|
|
480
|
+
|
|
481
|
+
// Render filteredHelpTopics in a <FormGroupWithHelpTopicPopover />
|
|
482
|
+
const formGroupsFromTags = filteredHelpTopics.map((topic: HelpTopic, index) => {
|
|
483
|
+
return <FormGroupWithHelpTopicPopover topic={topic} key={index} />;
|
|
484
|
+
});
|
|
485
|
+
|
|
486
|
+
// From an array of topic names, render all topics in a <FormGroupWithHelpTopicPopover />
|
|
487
|
+
const formGroupsFromTopicNames = (helpTopicNames: string[]) => {
|
|
488
|
+
return helpTopicNames.map((topicName: string, index) => {
|
|
489
|
+
const topicToRender = helpTopics.find((topic) => {
|
|
490
|
+
return topicName === topic.name;
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
if (topicToRender) {
|
|
494
|
+
return <FormGroupWithHelpTopicPopover topic={topicToRender} key={index} />;
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
return (
|
|
500
|
+
<>
|
|
501
|
+
<PageSection>
|
|
502
|
+
<Banner variant="info">
|
|
503
|
+
<Title headingLevel="h1">Console Page {consolePageState}</Title>
|
|
504
|
+
</Banner>
|
|
505
|
+
</PageSection>
|
|
506
|
+
<PageSection>
|
|
507
|
+
<Title headingLevel="h3">
|
|
508
|
+
Example usage of help topics opened via popover{' '}
|
|
509
|
+
<b>
|
|
510
|
+
{consolePageState < 4
|
|
511
|
+
? 'using tags that match the Console Page number'
|
|
512
|
+
: 'by defining which help topics should be present on each page'}
|
|
513
|
+
</b>
|
|
514
|
+
</Title>
|
|
515
|
+
<Divider />
|
|
516
|
+
<Form>
|
|
517
|
+
{consolePageState < 4
|
|
518
|
+
? formGroupsFromTags
|
|
519
|
+
: formGroupsFromTopicNames(helpTopicNamesByPage[consolePageState - 4])}
|
|
520
|
+
</Form>
|
|
521
|
+
</PageSection>
|
|
522
|
+
<PageSection>
|
|
523
|
+
<Split hasGutter>
|
|
524
|
+
<SplitItem>
|
|
525
|
+
<Button onClick={handleClickBack} variant="tertiary">
|
|
526
|
+
Previous
|
|
527
|
+
</Button>
|
|
528
|
+
</SplitItem>
|
|
529
|
+
<SplitItem>
|
|
530
|
+
<Button onClick={handleClickNext}>Next</Button>
|
|
531
|
+
</SplitItem>
|
|
532
|
+
</Split>
|
|
533
|
+
</PageSection>
|
|
534
|
+
</>
|
|
535
|
+
);
|
|
536
|
+
};
|
|
537
|
+
```
|
|
@@ -2,3 +2,4 @@ export { default as MarkdownCopyClipboard } from './MarkdownCopyClipboard';
|
|
|
2
2
|
export { default as useInlineCopyClipboardShowdownExtension } from './inline-clipboard-extension';
|
|
3
3
|
export { default as useMultilineCopyClipboardShowdownExtension } from './multiline-clipboard-extension';
|
|
4
4
|
export { default as useAdmonitionShowdownExtension } from './admonition-extension';
|
|
5
|
+
export { default as useCodeShowdownExtension } from './code-extension';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import './QuickStartDrawer.scss';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { QuickStartContextValues } from './utils/quick-start-context';
|
|
4
|
+
import { HelpTopic } from './utils/help-topic-types';
|
|
5
|
+
export interface HelpTopicContainerProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
|
+
helpTopics: HelpTopic[];
|
|
7
|
+
resourceBundle?: any;
|
|
8
|
+
language?: string;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Additional markdown extensions and renderers to use
|
|
12
|
+
* TODO: example usage - In the meantime you can take a look at:
|
|
13
|
+
* https://github.com/openshift/console/blob/master/frontend/packages/console-app/src/components/quick-starts/utils/quick-start-context.tsx#L235
|
|
14
|
+
*/
|
|
15
|
+
markdown?: {
|
|
16
|
+
extensions?: any[];
|
|
17
|
+
renderExtension?: (docContext: HTMLDocument, rootSelector: string) => React.ReactNode;
|
|
18
|
+
};
|
|
19
|
+
contextProps?: QuickStartContextValues;
|
|
20
|
+
}
|
|
21
|
+
export declare const HelpTopicContainer: React.FC<HelpTopicContainerProps>;
|
|
22
|
+
export interface HelpTopicDrawerProps extends React.HTMLProps<HTMLDivElement> {
|
|
23
|
+
helpTopics?: HelpTopic[];
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export declare const HelpTopicDrawer: React.FC<HelpTopicDrawerProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { HelpTopic } from './utils/help-topic-types';
|
|
3
|
+
import './QuickStartPanelContent.scss';
|
|
4
|
+
declare type HelpTopicPanelContentProps = {
|
|
5
|
+
activeHelpTopic: HelpTopic;
|
|
6
|
+
filteredHelpTopics?: HelpTopic[];
|
|
7
|
+
isResizable?: boolean;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
};
|
|
10
|
+
declare const HelpTopicPanelContent: React.FC<HelpTopicPanelContentProps>;
|
|
11
|
+
export default HelpTopicPanelContent;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ export * from './QuickStartCatalogPage';
|
|
|
3
3
|
export * from './catalog';
|
|
4
4
|
export * from './ConsoleInternal/components/utils';
|
|
5
5
|
export * from './QuickStartDrawer';
|
|
6
|
+
export * from './HelpTopicDrawer';
|
|
6
7
|
export * from './utils/const';
|
|
7
8
|
export * from './utils/quick-start-context';
|
|
8
9
|
export * from './utils/quick-start-types';
|
|
10
|
+
export * from './utils/help-topic-context';
|
|
11
|
+
export * from './utils/help-topic-types';
|
|
9
12
|
export * from './utils/quick-start-utils';
|
|
10
13
|
export * from './utils/useLocalStorage';
|
|
11
14
|
export { default as QuickStartPanelContent } from './QuickStartPanelContent';
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { createContext, useCallback, useEffect, useState } from 'react';
|
|
3
|
-
import { Card, CardHeader, CardActions, CardTitle, CardBody, CardFooter, Modal as Modal$1, Tooltip, Alert, Popover, PopoverPosition, Button, Text, TextVariants, TextList, TextListItem, Flex, FlexItem, Title, Label, Gallery, GalleryItem, ToolbarItem, SearchInput, Select, SelectVariant, SelectOption, Toolbar, ToolbarContent, EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStatePrimary, Divider, ModalVariant, WizardNavItem, List, ExpandableSection, ListItem, Radio, DrawerPanelContent, DrawerHead, DrawerActions, DrawerCloseButton, DrawerPanelBody, Drawer, DrawerContent, DrawerContentBody } from '@patternfly/react-core';
|
|
3
|
+
import { Card, CardHeader, CardActions, CardTitle, CardBody, CardFooter, Modal as Modal$1, Tooltip, Alert, CodeBlock, Popover, PopoverPosition, Button, Text, TextVariants, TextList, TextListItem, Flex, FlexItem, Title, Label, Gallery, GalleryItem, ToolbarItem, SearchInput, Select, SelectVariant, SelectOption, Toolbar, ToolbarContent, EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStatePrimary, Divider, ModalVariant, WizardNavItem, List, ExpandableSection, ListItem, Radio, DrawerPanelContent, DrawerHead, DrawerActions, DrawerCloseButton, DrawerPanelBody, Drawer, DrawerContent, DrawerContentBody, OptionsMenuItem, Stack, StackItem, OptionsMenu, OptionsMenuToggle } from '@patternfly/react-core';
|
|
4
4
|
import SearchIcon from '@patternfly/react-icons/dist/js/icons/search-icon';
|
|
5
5
|
import { css } from '@patternfly/react-styles';
|
|
6
6
|
import RocketIcon from '@patternfly/react-icons/dist/js/icons/rocket-icon';
|
|
@@ -21,6 +21,7 @@ import { Converter } from 'showdown';
|
|
|
21
21
|
import ExternalLinkAltIcon from '@patternfly/react-icons/dist/js/icons/external-link-alt-icon';
|
|
22
22
|
import OutlinedClockIcon from '@patternfly/react-icons/dist/js/icons/outlined-clock-icon';
|
|
23
23
|
import ArrowRightIcon from '@patternfly/react-icons/dist/js/icons/arrow-right-icon';
|
|
24
|
+
import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
|
|
24
25
|
|
|
25
26
|
function _extends() {
|
|
26
27
|
_extends = Object.assign || function (target) {
|
|
@@ -72,7 +73,8 @@ const QUICKSTART_ID_FILTER_KEY = 'quickstart';
|
|
|
72
73
|
const QUICKSTART_TASKS_INITIAL_STATES = [
|
|
73
74
|
QuickStartTaskStatus.INIT,
|
|
74
75
|
QuickStartTaskStatus.VISITED,
|
|
75
|
-
];
|
|
76
|
+
];
|
|
77
|
+
const HELP_TOPIC_NAME_KEY = 'topic';
|
|
76
78
|
|
|
77
79
|
let createHistory;
|
|
78
80
|
try {
|
|
@@ -1313,6 +1315,20 @@ const useAdmonitionShowdownExtension = () => {
|
|
|
1313
1315
|
}), []);
|
|
1314
1316
|
};
|
|
1315
1317
|
|
|
1318
|
+
const useCodeShowdownExtension = () => {
|
|
1319
|
+
return React.useMemo(() => ({
|
|
1320
|
+
type: 'output',
|
|
1321
|
+
regex: /<pre><code>(.*?)\n?<\/code><\/pre>/g,
|
|
1322
|
+
replace: (text, content) => {
|
|
1323
|
+
if (!content) {
|
|
1324
|
+
return text;
|
|
1325
|
+
}
|
|
1326
|
+
const pfCodeBlock = React.createElement(CodeBlock, null, content);
|
|
1327
|
+
return removeTemplateWhitespace(renderToStaticMarkup(pfCodeBlock));
|
|
1328
|
+
},
|
|
1329
|
+
}), []);
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1316
1332
|
const FallbackImg = ({ src, alt, className, fallback }) => {
|
|
1317
1333
|
const [isSrcValid, setIsSrcValid] = React.useState(true);
|
|
1318
1334
|
if (src && isSrcValid) {
|
|
@@ -1553,6 +1569,7 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
|
|
|
1553
1569
|
const inlineCopyClipboardShowdownExtension = useInlineCopyClipboardShowdownExtension();
|
|
1554
1570
|
const multilineCopyClipboardShowdownExtension = useMultilineCopyClipboardShowdownExtension();
|
|
1555
1571
|
const admonitionShowdownExtension = useAdmonitionShowdownExtension();
|
|
1572
|
+
const codeShowdownExtension = useCodeShowdownExtension();
|
|
1556
1573
|
return (React.createElement(SyncMarkdownView, { inline: true, content: content, exactHeight: exactHeight, extensions: [
|
|
1557
1574
|
{
|
|
1558
1575
|
type: 'lang',
|
|
@@ -1575,11 +1592,14 @@ const QuickStartMarkdownView = ({ content, exactHeight, className, }) => {
|
|
|
1575
1592
|
inlineCopyClipboardShowdownExtension,
|
|
1576
1593
|
multilineCopyClipboardShowdownExtension,
|
|
1577
1594
|
admonitionShowdownExtension,
|
|
1595
|
+
codeShowdownExtension,
|
|
1578
1596
|
...(markdown ? markdown.extensions : []),
|
|
1579
1597
|
], renderExtension: (docContext, rootSelector) => (React.createElement(React.Fragment, null,
|
|
1580
1598
|
React.createElement(MarkdownHighlightExtension, { docContext: docContext, rootSelector: rootSelector }),
|
|
1581
1599
|
React.createElement(MarkdownCopyClipboard, { docContext: docContext, rootSelector: rootSelector }),
|
|
1582
|
-
markdown &&
|
|
1600
|
+
markdown &&
|
|
1601
|
+
markdown.renderExtension &&
|
|
1602
|
+
markdown.renderExtension(docContext, rootSelector))), className: className }));
|
|
1583
1603
|
};
|
|
1584
1604
|
|
|
1585
1605
|
const QuickStartTileDescription = ({ description, prerequisites, }) => {
|
|
@@ -1692,7 +1712,7 @@ const QuickStartTile = ({ quickStart, status, isActive, onClick = () => { }, })
|
|
|
1692
1712
|
|
|
1693
1713
|
const QuickStartCatalog = ({ quickStarts }) => {
|
|
1694
1714
|
const { activeQuickStartID, allQuickStartStates } = React.useContext(QuickStartContext);
|
|
1695
|
-
return (React.createElement("div", { className: "pfext-page-layout__content
|
|
1715
|
+
return (React.createElement("div", { className: "pfext-page-layout__content" },
|
|
1696
1716
|
React.createElement(Gallery, { className: "pfext-quick-start-catalog__gallery", hasGutter: true }, quickStarts.map((quickStart) => {
|
|
1697
1717
|
const { metadata: { name: id }, } = quickStart;
|
|
1698
1718
|
return (React.createElement(GalleryItem, { key: id, className: "pfext-quick-start-catalog__gallery-item" },
|
|
@@ -1897,7 +1917,7 @@ const QuickStartCatalogHeader = ({ title, hint, }) => (React.createElement("div"
|
|
|
1897
1917
|
React.createElement("h1", { "data-pf-content": "true", className: "pfext-page-layout__title" }, title),
|
|
1898
1918
|
hint && React.createElement("div", { className: "pfext-page-layout__hint" }, hint)));
|
|
1899
1919
|
|
|
1900
|
-
const QuickStartCatalogSection = ({ children }) => (React.createElement("div", { className: "pfext-page-layout__content
|
|
1920
|
+
const QuickStartCatalogSection = ({ children }) => (React.createElement("div", { className: "pfext-page-layout__content" }, children));
|
|
1901
1921
|
|
|
1902
1922
|
const QuickStartCatalogToolbar = ({ children }) => (React.createElement(Toolbar, { usePageInsets: true, className: "pfext-quick-start-catalog-filter__flex" }, children));
|
|
1903
1923
|
|
|
@@ -2149,11 +2169,10 @@ const useScrollTopOnTaskNumberChange = (node, taskNumber) => {
|
|
|
2149
2169
|
};
|
|
2150
2170
|
const QuickStartPanelContent = (_a) => {
|
|
2151
2171
|
var { quickStarts = [], handleClose, activeQuickStartID, appendTo, isResizable = true, showClose = true, headerVariant = '' } = _a, props = __rest(_a, ["quickStarts", "handleClose", "activeQuickStartID", "appendTo", "isResizable", "showClose", "headerVariant"]);
|
|
2152
|
-
const { getResource } = React.useContext(QuickStartContext);
|
|
2172
|
+
const { getResource, activeQuickStartState } = React.useContext(QuickStartContext);
|
|
2153
2173
|
const [contentRef, setContentRef] = React.useState();
|
|
2154
2174
|
const shadows = useScrollShadows(contentRef);
|
|
2155
2175
|
const quickStart = quickStarts.find((qs) => qs.metadata.name === activeQuickStartID);
|
|
2156
|
-
const { activeQuickStartState } = React.useContext(QuickStartContext);
|
|
2157
2176
|
const taskNumber = activeQuickStartState === null || activeQuickStartState === void 0 ? void 0 : activeQuickStartState.taskNumber;
|
|
2158
2177
|
useScrollTopOnTaskNumberChange(contentRef, taskNumber);
|
|
2159
2178
|
const nextQuickStarts = quickStarts.filter((qs) => { var _a; return (_a = quickStart === null || quickStart === void 0 ? void 0 : quickStart.spec.nextQuickStart) === null || _a === void 0 ? void 0 : _a.includes(qs.metadata.name); });
|
|
@@ -2293,6 +2312,115 @@ const QuickStartDrawer = (_a) => {
|
|
|
2293
2312
|
React.createElement(QuickStartCloseModal, { isOpen: modalOpen, onConfirm: onModalConfirm, onCancel: onModalCancel })));
|
|
2294
2313
|
};
|
|
2295
2314
|
|
|
2315
|
+
const HelpTopicContextDefaults = {
|
|
2316
|
+
helpTopics: [],
|
|
2317
|
+
setHelpTopics: () => { },
|
|
2318
|
+
activeHelpTopic: null,
|
|
2319
|
+
setActiveHelpTopicByName: () => { },
|
|
2320
|
+
filteredHelpTopics: [],
|
|
2321
|
+
setFilteredHelpTopics: () => { },
|
|
2322
|
+
loading: false,
|
|
2323
|
+
};
|
|
2324
|
+
const HelpTopicContext = React__default.createContext(HelpTopicContextDefaults);
|
|
2325
|
+
const useValuesForHelpTopicContext = (value = {}) => {
|
|
2326
|
+
const combinedValue = Object.assign(Object.assign({}, HelpTopicContextDefaults), value);
|
|
2327
|
+
const [loading, setLoading] = React__default.useState(combinedValue.loading);
|
|
2328
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
2329
|
+
const [helpTopics, setHelpTopics] = React__default.useState(combinedValue.helpTopics || []);
|
|
2330
|
+
const [activeHelpTopic, setActiveHelpTopic] = React__default.useState(combinedValue.activeHelpTopic || null);
|
|
2331
|
+
const setActiveHelpTopicByName = React__default.useCallback((helpTopicName) => {
|
|
2332
|
+
const topic = helpTopics.find((t) => {
|
|
2333
|
+
return t.name === helpTopicName;
|
|
2334
|
+
});
|
|
2335
|
+
if (!helpTopicName) {
|
|
2336
|
+
setActiveHelpTopic(null);
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2339
|
+
setActiveHelpTopic(topic);
|
|
2340
|
+
}, [helpTopics]);
|
|
2341
|
+
const [filteredHelpTopics, setFilteredHelpTopics] = React__default.useState(combinedValue.filteredHelpTopics || []);
|
|
2342
|
+
return {
|
|
2343
|
+
helpTopics,
|
|
2344
|
+
setHelpTopics,
|
|
2345
|
+
activeHelpTopic,
|
|
2346
|
+
setActiveHelpTopicByName,
|
|
2347
|
+
filteredHelpTopics,
|
|
2348
|
+
setFilteredHelpTopics,
|
|
2349
|
+
loading,
|
|
2350
|
+
setLoading,
|
|
2351
|
+
};
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2354
|
+
const HelpTopicPanelContent = (_a) => {
|
|
2355
|
+
var _b, _c;
|
|
2356
|
+
var { activeHelpTopic = null, filteredHelpTopics = [], isResizable = true, onClose } = _a, props = __rest(_a, ["activeHelpTopic", "filteredHelpTopics", "isResizable", "onClose"]);
|
|
2357
|
+
const { setActiveHelpTopicByName } = React.useContext(HelpTopicContext);
|
|
2358
|
+
const [isHelpTopicMenuOpen, setIsHelpTopicMenuOpen] = React.useState(false);
|
|
2359
|
+
const toggleHelpTopicMenu = () => {
|
|
2360
|
+
setIsHelpTopicMenuOpen(!isHelpTopicMenuOpen);
|
|
2361
|
+
};
|
|
2362
|
+
const onSelectHelpTopic = (event) => {
|
|
2363
|
+
const topicName = event.currentTarget.id;
|
|
2364
|
+
setActiveHelpTopicByName(topicName);
|
|
2365
|
+
toggleHelpTopicMenu();
|
|
2366
|
+
};
|
|
2367
|
+
const menuItems = filteredHelpTopics.length > 0 &&
|
|
2368
|
+
filteredHelpTopics.map((topic) => {
|
|
2369
|
+
return (React.createElement(OptionsMenuItem, { key: topic.name, onSelect: onSelectHelpTopic, id: topic.name }, topic.title));
|
|
2370
|
+
});
|
|
2371
|
+
const paddingContainer = (children) => React.createElement("div", { style: { padding: '24px' } }, children);
|
|
2372
|
+
const panelBodyItems = (React.createElement(React.Fragment, null,
|
|
2373
|
+
paddingContainer(React.createElement(QuickStartMarkdownView, { content: activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.content })),
|
|
2374
|
+
((_b = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _b === void 0 ? void 0 : _b.length) && React.createElement(Divider, null),
|
|
2375
|
+
paddingContainer(React.createElement(Stack, { hasGutter: true }, (_c = activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.links) === null || _c === void 0 ? void 0 : _c.map(({ href, text, newTab, isExternal }, index) => {
|
|
2376
|
+
return (React.createElement(StackItem, { key: index },
|
|
2377
|
+
React.createElement(Button, { component: "a", href: href, target: newTab ? '_blank' : '', rel: "noopener noreferrer", variant: "link", "aria-label": `Open documentation in new window`, isInline: true, icon: isExternal ? React.createElement(ExternalLinkAltIcon, null) : null, iconPosition: "right", style: { fontSize: 'inherit' } }, text || href)));
|
|
2378
|
+
})))));
|
|
2379
|
+
const content = (React.createElement(DrawerPanelContent, Object.assign({ isResizable: isResizable, className: "pfext-quick-start__base" }, props),
|
|
2380
|
+
React.createElement("div", null,
|
|
2381
|
+
React.createElement(DrawerHead, null,
|
|
2382
|
+
React.createElement("div", { className: "pfext-quick-start-panel-content__title" },
|
|
2383
|
+
menuItems && (React.createElement(OptionsMenu, { id: 'helptopics', isPlain: true, isOpen: isHelpTopicMenuOpen, toggle: React.createElement(OptionsMenuToggle, { style: { paddingLeft: '0px' }, onToggle: toggleHelpTopicMenu, toggleTemplate: React.createElement(BarsIcon, null) }), menuItems: menuItems })),
|
|
2384
|
+
React.createElement(Title, { headingLevel: "h1", size: "xl", className: "pfext-quick-start-panel-content__name", style: { marginRight: 'var(--pf-global--spacer--md)' } }, activeHelpTopic === null || activeHelpTopic === void 0 ? void 0 : activeHelpTopic.title)),
|
|
2385
|
+
React.createElement(DrawerActions, null,
|
|
2386
|
+
React.createElement(DrawerCloseButton, { onClick: onClose, className: "pfext-quick-start-panel-content__close-button", "data-testid": "qs-drawer-close" }))),
|
|
2387
|
+
React.createElement(Divider, null),
|
|
2388
|
+
React.createElement(DrawerPanelBody, { hasNoPadding: true, className: "pfext-quick-start-panel-content__body", "data-test": "content" }, panelBodyItems))));
|
|
2389
|
+
return content;
|
|
2390
|
+
};
|
|
2391
|
+
|
|
2392
|
+
const HelpTopicContainer = (_a) => {
|
|
2393
|
+
var { helpTopics, children, resourceBundle, language, loading = false, markdown, contextProps } = _a, props = __rest(_a, ["helpTopics", "children", "resourceBundle", "language", "loading", "markdown", "contextProps"]);
|
|
2394
|
+
const valuesForHelpTopicContext = useValuesForHelpTopicContext(Object.assign({ helpTopics,
|
|
2395
|
+
language, resourceBundle: Object.assign({}, resourceBundle), loading,
|
|
2396
|
+
markdown }, contextProps));
|
|
2397
|
+
React.useEffect(() => {
|
|
2398
|
+
if (loading !== valuesForHelpTopicContext.loading) {
|
|
2399
|
+
valuesForHelpTopicContext.setLoading(loading);
|
|
2400
|
+
}
|
|
2401
|
+
}, [loading, valuesForHelpTopicContext]);
|
|
2402
|
+
React.useEffect(() => {
|
|
2403
|
+
if (helpTopics &&
|
|
2404
|
+
JSON.stringify(helpTopics) !== JSON.stringify(valuesForHelpTopicContext.helpTopics)) {
|
|
2405
|
+
valuesForHelpTopicContext.setHelpTopics(helpTopics);
|
|
2406
|
+
}
|
|
2407
|
+
}, [helpTopics, valuesForHelpTopicContext]);
|
|
2408
|
+
const drawerProps = Object.assign({}, props);
|
|
2409
|
+
return (React.createElement(HelpTopicContext.Provider, { value: valuesForHelpTopicContext },
|
|
2410
|
+
React.createElement(HelpTopicDrawer, Object.assign({}, drawerProps), children)));
|
|
2411
|
+
};
|
|
2412
|
+
const HelpTopicDrawer = (_a) => {
|
|
2413
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
2414
|
+
const { activeHelpTopic, filteredHelpTopics, setActiveHelpTopicByName } = React.useContext(HelpTopicContext);
|
|
2415
|
+
const onClose = () => {
|
|
2416
|
+
setActiveHelpTopicByName('');
|
|
2417
|
+
};
|
|
2418
|
+
const panelContent = (React.createElement(HelpTopicPanelContent, { activeHelpTopic: activeHelpTopic, filteredHelpTopics: filteredHelpTopics, onClose: onClose }));
|
|
2419
|
+
return (React.createElement(React.Fragment, null,
|
|
2420
|
+
React.createElement(Drawer, Object.assign({ isExpanded: !!activeHelpTopic, isInline: true }, props), children ? (React.createElement(DrawerContent, { panelContent: panelContent },
|
|
2421
|
+
React.createElement(DrawerContentBody, { className: "pfext-quick-start-drawer__body" }, children))) : (React.createElement("div", { className: "pf-c-drawer__main" }, panelContent)))));
|
|
2422
|
+
};
|
|
2423
|
+
|
|
2296
2424
|
const useLocalStorage = (key, initialValue) => {
|
|
2297
2425
|
// State to store our value
|
|
2298
2426
|
// Pass initial state function to useState so logic is only executed once
|
|
@@ -2330,5 +2458,5 @@ const useLocalStorage = (key, initialValue) => {
|
|
|
2330
2458
|
return [storedValue, setValue];
|
|
2331
2459
|
};
|
|
2332
2460
|
|
|
2333
|
-
export { Box, CamelCaseWrap, EmptyBox, Loading, LoadingBox, QUICKSTART_ID_FILTER_KEY, QUICKSTART_SEARCH_FILTER_KEY, QUICKSTART_STATUS_FILTER_KEY, QUICKSTART_TASKS_INITIAL_STATES, QUICK_START_NAME, QuickStartCatalog, QuickStartCatalogEmptyState, QuickStartCatalogFilter, QuickStartCatalogFilterCount, QuickStartCatalogFilterCountWrapper, QuickStartCatalogFilterSearch, QuickStartCatalogFilterSearchWrapper, QuickStartCatalogFilterSelect, QuickStartCatalogFilterStatusWrapper, QuickStartCatalogHeader, QuickStartCatalogPage, QuickStartCatalogSection, QuickStartCatalogToolbar, QuickStartCloseModal, QuickStartContainer, QuickStartContext, QuickStartContextDefaults, QuickStartContextProvider, QuickStartDrawer, QuickStartPanelContent, QuickStartStatus, QuickStartTaskStatus, QuickStartTile, QuickStartTileDescription, QuickStartTileFooter, QuickStartTileFooterExternal, QuickStartTileHeader, camelize, clearFilterParams, equalsIgnoreOrder, filterQuickStarts, getDefaultQuickStartState, getDisabledQuickStarts, getQuickStartByName, getQuickStartStatus, getQuickStartStatusCount, getResource, getTaskStatusKey, history, isDisabledQuickStart, removeQueryArgument, setQueryArgument, useLocalStorage, useValuesForQuickStartContext };
|
|
2461
|
+
export { Box, CamelCaseWrap, EmptyBox, HELP_TOPIC_NAME_KEY, HelpTopicContainer, HelpTopicContext, HelpTopicContextDefaults, HelpTopicDrawer, Loading, LoadingBox, QUICKSTART_ID_FILTER_KEY, QUICKSTART_SEARCH_FILTER_KEY, QUICKSTART_STATUS_FILTER_KEY, QUICKSTART_TASKS_INITIAL_STATES, QUICK_START_NAME, QuickStartCatalog, QuickStartCatalogEmptyState, QuickStartCatalogFilter, QuickStartCatalogFilterCount, QuickStartCatalogFilterCountWrapper, QuickStartCatalogFilterSearch, QuickStartCatalogFilterSearchWrapper, QuickStartCatalogFilterSelect, QuickStartCatalogFilterStatusWrapper, QuickStartCatalogHeader, QuickStartCatalogPage, QuickStartCatalogSection, QuickStartCatalogToolbar, QuickStartCloseModal, QuickStartContainer, QuickStartContext, QuickStartContextDefaults, QuickStartContextProvider, QuickStartDrawer, QuickStartPanelContent, QuickStartStatus, QuickStartTaskStatus, QuickStartTile, QuickStartTileDescription, QuickStartTileFooter, QuickStartTileFooterExternal, QuickStartTileHeader, camelize, clearFilterParams, equalsIgnoreOrder, filterQuickStarts, getDefaultQuickStartState, getDisabledQuickStarts, getQuickStartByName, getQuickStartStatus, getQuickStartStatusCount, getResource, getTaskStatusKey, history, isDisabledQuickStart, removeQueryArgument, setQueryArgument, useLocalStorage, useValuesForHelpTopicContext, useValuesForQuickStartContext };
|
|
2334
2462
|
//# sourceMappingURL=index.es.js.map
|