Skip to content

Commit

Permalink
smal fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagobcx committed Nov 7, 2023
1 parent c1351c2 commit 520754f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/utils/common/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const messages = {
loadingResults: "Loading results",
triageNotAvailableSca: "Triage not available for SCA.",
triageSubmitedSuccess: "Feedback submited successfully! Results refreshed.",
triageError: (error) => `Triage Error | ${error}`,
triageError: (error) => `Triage ${error}`,
triageNoChange: "Make a change before submiting",
triageUpdateState: (state) => `Updating state to ${state}`,
triageUpdateSeverity: (severity) => `Updating severity to ${severity}`,
Expand Down
58 changes: 27 additions & 31 deletions src/utils/triage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,27 @@ export async function updateResults(
throw new Error(messages.fileNotFound);
}

try {
const resultHash = result.getResultHash();
resultsProvider.loadedResults.forEach((element: AstResult, index: number) => {
// Update the result in the array
if (element.data.resultHash === resultHash || element.id === resultHash) {
resultsProvider.loadedResults[index].severity = result.severity;
resultsProvider.loadedResults[index].state = result.state;
resultsProvider.loadedResults[index].status = result.status;
return;
}
});

// Update
const projectId = getFromState(context, constants.projectIdKey).id;
await cx.triageUpdate(
projectId,
result.similarityId,
result.type,
result.state,
comment,
result.severity
);
} catch (error) {
throw new Error(error);
}
// Update on cxOne
const projectId = getFromState(context, constants.projectIdKey).id;
await cx.triageUpdate(
projectId,
result.similarityId,
result.type,
result.state,
comment,
result.severity
);
// Update local results
const resultHash = result.getResultHash();
resultsProvider.loadedResults.forEach((element: AstResult, index: number) => {
// Update the result in the array
if (element.data.resultHash === resultHash || element.id === resultHash) {
resultsProvider.loadedResults[index].severity = result.severity;
resultsProvider.loadedResults[index].state = result.state;
resultsProvider.loadedResults[index].status = result.status;
return;
}
});
}

export async function triageSubmit(
Expand Down Expand Up @@ -93,12 +89,6 @@ export async function triageSubmit(
vscode.window.showErrorMessage(messages.triageNoChange);
return;
}

detailsDetachedView?.setResult(result);
detailsDetachedView.setLoad(false);
// Update webview html
detailsPanel.webview.html =
await detailsDetachedView.getDetailsWebviewContent(detailsPanel?.webview);
// Change the results locally
try {
await updateResults(result, context, data.comment, resultsProvider);
Expand All @@ -115,7 +105,13 @@ export async function triageSubmit(
);
} catch (error) {
vscode.window.showErrorMessage(messages.triageError(error));
return;
}
detailsDetachedView?.setResult(result);
detailsDetachedView.setLoad(false);
// Update webview html
detailsPanel.webview.html =
await detailsDetachedView.getDetailsWebviewContent(detailsPanel?.webview);
}

export async function getChanges(
Expand Down
2 changes: 1 addition & 1 deletion src/views/resultsView/astResultsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AstResultsProvider extends ResultsProvider {
}
// Case we come from triage we must update the state to load results from the correct place
else {
updateState(this.context, "ast-result-triage", { id: false, name: "ast-result-triage" });
updateState(this.context, constants.triageUpdate, { id: false, name: constants.triageUpdate });
}

// if there are results loaded, the tree needs to be recreated
Expand Down

0 comments on commit 520754f

Please sign in to comment.