Skip to content

Commit

Permalink
feat: hide ignore buttons when FF is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Catalina Oyaneder committed Jul 23, 2024
1 parent b23e2eb commit e37bf24
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export class CodeSuggestionWebviewProvider

private mapToModel(issue: Issue<CodeIssueData>): Suggestion {
const parsedDetails = marked.parse(issue.additionalData.text) as string;
const showInlineIgnoresButton = configuration.getFeatureFlag(FEATURE_FLAGS.snykCodeInlineIgnore);

return {
id: issue.id,
Expand All @@ -208,6 +209,7 @@ export class CodeSuggestionWebviewProvider
text: parsedDetails,
hasAIFix: issue.additionalData.hasAIFix,
filePath: issue.filePath,
showInlineIgnoresButton,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ declare const acquireVsCodeApi: any;
noExamplesElem: document.getElementById('info-no-examples') as HTMLElement,
exNumElem: document.getElementById('example-number') as HTMLElement,
exNum2Elem: document.getElementById('example-number2') as HTMLElement,

footerInlineIgnoresButtons: document.querySelector('.suggestion-actions') as HTMLElement,
};

function navigateToUrl(url: string) {
Expand Down Expand Up @@ -629,11 +631,14 @@ declare const acquireVsCodeApi: any;
* @param {Suggestion} suggestion - The suggestion object containing the details to be displayed.
*/
function showSuggestionMeta(suggestion: Suggestion) {
const { metaElem } = elements;
const { metaElem, footerInlineIgnoresButtons } = elements;

// Clear previously metadata.
metaElem.querySelectorAll('.suggestion-meta').forEach(element => element.remove());

// Hide the inline ignores button if the feature flag is disabled.
footerInlineIgnoresButtons.style.display = suggestion?.showInlineIgnoresButton ? 'block' : 'none';

// Append issue type: 'Vulnerability' or 'Issue'.
const issueTypeElement = document.createElement('span');
issueTypeElement.className = 'suggestion-meta';
Expand Down
1 change: 1 addition & 0 deletions src/snyk/snykCode/views/suggestion/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Suggestion = {
rows: Point;
hasAIFix?: boolean;
filePath: string;
showInlineIgnoresButton: boolean;
};

export type OpenLocalMessage = {
Expand Down

0 comments on commit e37bf24

Please sign in to comment.