Skip to content

Commit

Permalink
[WINDUP-3842] - Source code window not in sync with the Issues report…
Browse files Browse the repository at this point in the history
…ed (#1652)

* Match selected hint with ruleId and Issue description

* Select first minor line

* Format import
  • Loading branch information
carlosthe19916 committed Apr 28, 2023
1 parent 69c51fa commit ce8c230
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
Expand Up @@ -27,7 +27,7 @@ import { getMarkdown } from "@app/utils/rule-utils";

interface IIssueOverviewProps {
issue: IssueDto;
onShowFile: (fileId: string) => void;
onShowFile: (fileId: string, issueDescription?: string) => void;
}

export const IssueOverview: React.FC<IIssueOverviewProps> = ({
Expand Down Expand Up @@ -56,7 +56,12 @@ export const IssueOverview: React.FC<IIssueOverviewProps> = ({
<FileLink
fileId={file.fileId}
defaultText={file.fileName}
onClick={() => onShowFile(file.fileId)}
onClick={() =>
onShowFile(
file.fileId,
affectedFile.description
)
}
/>
</Td>
<Td dataLabel="Incidents found" width={10}>
Expand Down
Expand Up @@ -33,6 +33,7 @@ import {
} from "@patternfly/react-table";
import { useDebounce } from "usehooks-ts";

import { HintDto } from "@app/api/file";
import { compareByCategoryFn, compareByEffortFn } from "@app/api/issues";
import { ALL_APPLICATIONS_ID } from "@app/Constants";
import { IssueProcessed } from "@app/models/api-enriched";
Expand Down Expand Up @@ -66,6 +67,7 @@ const areRowsEquals = (a: TableData, b: TableData) => {
interface SelectedFile {
fileId: string;
ruleId: string;
issueDescription?: string;
}

//
Expand Down Expand Up @@ -417,10 +419,11 @@ export const IssuesTable: React.FC<IIssuesTableProps> = ({ applicationId }) => {
<div className="pf-u-m-sm">
<IssueOverview
issue={item}
onShowFile={(file) =>
onShowFile={(file, issueDescription) =>
openFileModal("showFile", {
fileId: file,
ruleId: item.ruleId,
issueDescription: issueDescription,
})
}
/>
Expand Down Expand Up @@ -760,9 +763,19 @@ export const IssuesTable: React.FC<IIssuesTableProps> = ({ applicationId }) => {
{fileModalMappedFile && (
<FileEditor
file={fileModalMappedFile}
hintToFocus={fileModalMappedFile.hints.find(
(f) => f.ruleId === fileModalData?.ruleId
)}
hintToFocus={fileModalMappedFile.hints
.filter((hint) => {
return (
hint.ruleId === fileModalData?.ruleId &&
hint.content === fileModalData.issueDescription
);
})
.reduce((prev, current) => {
if (!prev) {
return current;
}
return current.line < prev.line ? current : prev;
}, undefined as HintDto | undefined)}
/>
)}
</Modal>
Expand Down

0 comments on commit ce8c230

Please sign in to comment.