Skip to content

Commit 349d1d3

Browse files
committed
feat: add show more expandable for long descriptions
Signed-off-by: Ruben Romero Montes <[email protected]>
1 parent 1d09832 commit 349d1d3

File tree

6 files changed

+1314
-1163
lines changed

6 files changed

+1314
-1163
lines changed

src/main/resources/freemarker/templates/generated/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/freemarker/templates/generated/vendor.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/resources/freemarker/templates/generated/vendor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/src/components/VulnerabilityRow.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { usePrivateIssueHelper } from "../hooks/usePrivateDataHelper";
88
import { hasRemediations, VulnerabilityItem } from "../api/report";
99
import { useAppContext } from '../App';
1010
import { VulnerabilityIdLink } from './VulnerabilityIdLink';
11+
import { VulnerabilityTitle } from './VulnerabilityTitle';
1112

1213
interface VulnerabilityRowProps {
1314
item: VulnerabilityItem;
@@ -42,7 +43,7 @@ export const VulnerabilityRow: React.FC<VulnerabilityRowProps> = ({item, provide
4243
<p key={index}><VulnerabilityIdLink id={id}/></p>
4344
))}
4445
</Td>
45-
<Td>{item.vulnerability.title}</Td>
46+
<Td><VulnerabilityTitle title={item.vulnerability.title}/></Td>
4647
<Td noPadding>
4748
<VulnerabilitySeverityLabel vulnerability={item.vulnerability}/>
4849
</Td>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ExpandableSection, ExpandableSectionVariant } from '@patternfly/react-core';
2+
import React from 'react';
3+
4+
export const VulnerabilityTitle = ({ title }: { title: string }) => {
5+
6+
const [isExpanded, setIsExpanded] = React.useState(false);
7+
const onToggle = (_event: React.MouseEvent, isExpanded: boolean) => {
8+
setIsExpanded(isExpanded);
9+
};
10+
11+
return (
12+
<ExpandableSection
13+
variant={ExpandableSectionVariant.truncate}
14+
toggleText={isExpanded ? "Show less" : "Show more"}
15+
onToggle={onToggle}
16+
isExpanded={isExpanded}>
17+
{title}
18+
</ExpandableSection>
19+
);
20+
};

0 commit comments

Comments
 (0)