|
1 | | -import groupBy from 'lodash/groupBy'; |
2 | | -import mapValues from 'lodash/mapValues'; |
3 | | -import React from 'react'; |
4 | | -import { Tab, TabList, TabPanel, Tabs } from 'react-tabs'; |
5 | | -import 'react-tabs/style/react-tabs.css'; |
6 | | -import Collapsible from './Collapsible'; |
7 | | - |
8 | | -export default function ScannerExamples({ examples: allExamples }) { |
9 | | - const exampleGroups = mapValues( |
10 | | - groupBy(allExamples, ({ scanTarget }) => scanTarget), |
11 | | - (examples) => { |
12 | | - /* We are reversing to ensure that the right text ist displayed for the right file */ |
13 | | - return examples.reverse(); |
14 | | - } |
15 | | - ); |
| 1 | +import React from "react"; |
| 2 | +import { Tab, TabList, TabPanel, Tabs } from "react-tabs"; |
| 3 | +import "react-tabs/style/react-tabs.css"; |
| 4 | +import Collapsible from "./Collapsible"; |
16 | 5 |
|
| 6 | +export default function ScannerExamples({ examples }) { |
17 | 7 | return ( |
18 | 8 | <div className="container-fluid"> |
19 | 9 | <h2 className="title">Examples</h2> |
20 | 10 |
|
21 | | - {Object.entries(exampleGroups).map(([targetName, examples]) => { |
| 11 | + {examples.map(({ name, description, scan, findings }) => { |
22 | 12 | return ( |
23 | | - <Tabs key={targetName}> |
| 13 | + <Tabs key={name}> |
24 | 14 | <Collapsible |
25 | 15 | overflowWhenOpen="visible" |
26 | 16 | lazyRender={true} |
27 | 17 | transitionTime={150} |
28 | 18 | transitionCloseTime={50} |
29 | | - trigger={targetName} |
| 19 | + trigger={name} |
30 | 20 | triggerTagName="h3" |
31 | 21 | > |
| 22 | + {description && ( |
| 23 | + <div |
| 24 | + dangerouslySetInnerHTML={{ |
| 25 | + __html: description, |
| 26 | + }} |
| 27 | + ></div> |
| 28 | + )} |
32 | 29 | <TabList> |
33 | | - {examples.map(({ fileName }) => ( |
34 | | - <Tab key={fileName}>{fileName.split('.')[0]}</Tab> |
35 | | - ))} |
| 30 | + {scan && <Tab key={"scan"}>Scan</Tab>} |
| 31 | + {findings && <Tab key={"findings"}>Findings</Tab>} |
36 | 32 | </TabList> |
37 | | - |
38 | | - {examples.map(({ fileName, content }) => ( |
39 | | - <TabPanel key={fileName}> |
| 33 | + {scan && ( |
| 34 | + <TabPanel key={"scan"}> |
| 35 | + <deckgo-highlight-code theme="cobalt"> |
| 36 | + <code slot="code">{scan}</code> |
| 37 | + </deckgo-highlight-code> |
| 38 | + </TabPanel> |
| 39 | + )} |
| 40 | + {findings && ( |
| 41 | + <TabPanel key={"findings"}> |
40 | 42 | <deckgo-highlight-code theme="cobalt"> |
41 | | - <code slot="code">{content}</code> |
| 43 | + <code slot="code">{findings}</code> |
42 | 44 | </deckgo-highlight-code> |
43 | 45 | </TabPanel> |
44 | | - ))} |
| 46 | + )} |
45 | 47 | </Collapsible> |
46 | 48 | </Tabs> |
47 | 49 | ); |
|
0 commit comments