Skip to content

Commit

Permalink
fix: hide AI fix div if no fixes [IDE-753] (#555)
Browse files Browse the repository at this point in the history
* fix: hide AI fix div if no fixes

* chore: update CHANGELOG
  • Loading branch information
ShawkyZ authored Nov 5, 2024
1 parent fcdcad8 commit edffa9f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [2.19.2]
- Update download endpoint to downloads.snyk.io.
- Send correct FixId to AI Fix endpoint.
- Hide AI Fix div if no fixes found.

## [2.19.1]
- Adjust OSS panel font size.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ declare const acquireVsCodeApi: any;
const diffTopElem = document.getElementById('diff-top') as HTMLElement;
const diffElem = document.getElementById('diff') as HTMLElement;
const noDiffsElem = document.getElementById('info-no-diffs') as HTMLElement;

if (noDiffsElem) {
noDiffsElem.innerText = "We couldn't determine any fixes for this issue.";
}
const diffNumElem = document.getElementById('diff-number') as HTMLElement;
const diffNum2Elem = document.getElementById('diff-number2') as HTMLElement;

Expand All @@ -292,11 +294,20 @@ declare const acquireVsCodeApi: any;
}

function showCurrentDiff() {
if (!suggestion?.diffs?.length) {
toggleElement(noDiffsElem, 'show');
toggleElement(diffTopElem, 'hide');
toggleElement(diffElem, 'hide');
toggleElement(applyFixButton, 'hide');
return;
}

if (!suggestion?.diffs?.length || diffSelectedIndex < 0 || diffSelectedIndex >= suggestion.diffs.length) return;

toggleElement(noDiffsElem, 'hide');
toggleElement(diffTopElem, 'show');
toggleElement(diffElem, 'show');
toggleElement(applyFixButton, 'show');

diffNumElem.innerText = suggestion.diffs.length.toString();
diffNum2Elem.innerText = suggestion.diffs.length.toString();
Expand Down

0 comments on commit edffa9f

Please sign in to comment.