Skip to content

Commit

Permalink
🐛 Use violation id instead of description for key
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 committed Jan 21, 2025
1 parent 7356808 commit 4781812
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions shared/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ export interface Link {
export type Category = "potential" | "optional" | "mandatory";

export interface Violation {
id: string;
description: string;
category?: Category;
labels?: string[];
incidents: Incident[];
links?: Link[];
extras?: unknown;
effort?: number;
}

Expand Down
4 changes: 4 additions & 0 deletions vscode/src/analysis/__tests__/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const FOO: RuleSet = {
violations: {
"foo-01": {
description: "foo-01 description",
id: "foo-01",
category: "mandatory",
labels: ["konveyor.io/target=foo", "konveyor.io/target=bar"],
incidents: [
Expand Down Expand Up @@ -37,6 +38,7 @@ export const BAR: RuleSet = {
violations: {
"bar-01": {
description: "bar-01 description",
id: "bar-01",
category: "mandatory",
labels: ["konveyor.io/target=foo", "konveyor.io/target=bar"],
incidents: [
Expand All @@ -57,6 +59,7 @@ export const BAR: RuleSet = {
},
"bar-02": {
description: "bar-02 description",
id: "bar-02",
category: "mandatory",
labels: ["konveyor.io/target=foo", "konveyor.io/target=bar"],
incidents: [
Expand Down Expand Up @@ -86,6 +89,7 @@ export const DISCOVERY: RuleSet = {
insights: {
"discover-java-files": {
description: "Java source files",
id: "discover-java-files",
labels: [
"konveyor.io/include=always",
"konveyor.io/target=discovery",
Expand Down
11 changes: 3 additions & 8 deletions webview-ui/src/components/ViolationIncidentsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,12 @@ const ViolationIncidentsList: React.FC<ViolationIncidentsListProps> = ({
}
return text.slice(0, maxLength) + "...";
};
const isExpanded = expandedViolations.has(violation.description);
const isExpanded = expandedViolations.has(violation.id);
const highestSeverity = getHighestSeverity(violation.incidents);
const truncatedDescription = truncateText(violation.description, 100);

return (
<Card
isExpanded={isExpanded}
isCompact
key={violation.description}
style={{ marginBottom: "10px" }}
>
<Card isExpanded={isExpanded} isCompact key={violation.id} style={{ marginBottom: "10px" }}>
<CardHeader
actions={{
actions: (
Expand All @@ -167,7 +162,7 @@ const ViolationIncidentsList: React.FC<ViolationIncidentsListProps> = ({
/>
),
}}
onExpand={() => toggleViolation(violation.description)}
onExpand={() => toggleViolation(violation.id)}
>
<Content style={{ marginBottom: "5px" }}>{truncatedDescription}</Content>
<Flex>
Expand Down

0 comments on commit 4781812

Please sign in to comment.