Skip to content

Commit 8dfcf8b

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Add 'View Autofixes' button to variant analysis view
1 parent ac2dea7 commit 8dfcf8b

File tree

8 files changed

+56
-0
lines changed

8 files changed

+56
-0
lines changed

extensions/ql-vscode/src/common/interface-types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,11 @@ interface OpenQueryTextMessage {
527527
t: "openQueryText";
528528
}
529529

530+
interface ViewAutofixesMessage {
531+
t: "viewAutofixes";
532+
filterSort?: RepositoriesFilterSortStateWithIds;
533+
}
534+
530535
interface CopyRepositoryListMessage {
531536
t: "copyRepositoryList";
532537
filterSort?: RepositoriesFilterSortStateWithIds;
@@ -561,6 +566,7 @@ export type FromVariantAnalysisMessage =
561566
| RequestRepositoryResultsMessage
562567
| OpenQueryFileMessage
563568
| OpenQueryTextMessage
569+
| ViewAutofixesMessage
564570
| CopyRepositoryListMessage
565571
| ExportResultsMessage
566572
| OpenLogsMessage

extensions/ql-vscode/src/variant-analysis/variant-analysis-manager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,10 @@ export class VariantAnalysisManager
967967
);
968968
}
969969

970+
public async viewAutofixes() {
971+
// TODO
972+
}
973+
970974
public async copyRepoListToClipboard(
971975
variantAnalysisId: number,
972976
filterSort: RepositoriesFilterSortStateWithIds = defaultFilterSortState,

extensions/ql-vscode/src/variant-analysis/variant-analysis-view-manager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ export interface VariantAnalysisViewManager<
3434
variantAnalysisId: number,
3535
filterSort?: RepositoriesFilterSortStateWithIds,
3636
): Promise<void>;
37+
viewAutofixes(
38+
variantAnalysisId: number,
39+
filterSort?: RepositoriesFilterSortStateWithIds,
40+
): Promise<void>;
3741
}

extensions/ql-vscode/src/variant-analysis/variant-analysis-view.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ export class VariantAnalysisView
135135
case "openQueryText":
136136
await this.manager.openQueryText(this.variantAnalysisId);
137137
break;
138+
case "viewAutofixes":
139+
await this.manager.viewAutofixes(
140+
this.variantAnalysisId,
141+
msg.filterSort,
142+
);
143+
break;
138144
case "copyRepositoryList":
139145
await this.manager.copyRepoListToClipboard(
140146
this.variantAnalysisId,

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysis.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ export function VariantAnalysis({
105105
}
106106
}, []);
107107

108+
const viewAutofixes = useCallback(() => {
109+
vscode.postMessage({
110+
t: "viewAutofixes",
111+
filterSort: {
112+
...filterSortState,
113+
repositoryIds: selectedRepositoryIds,
114+
},
115+
});
116+
sendTelemetry("variant-analysis-view-autofixes");
117+
}, [filterSortState, selectedRepositoryIds]);
118+
108119
const copyRepositoryList = useCallback(() => {
109120
vscode.postMessage({
110121
t: "copyRepositoryList",
@@ -148,6 +159,7 @@ export function VariantAnalysis({
148159
onOpenQueryFileClick={openQueryFile}
149160
onViewQueryTextClick={openQueryText}
150161
onStopQueryClick={stopQuery}
162+
onViewAutofixesClick={viewAutofixes}
151163
onCopyRepositoryListClick={copyRepositoryList}
152164
onExportResultsClick={exportResults}
153165
onViewLogsClick={onViewLogsClick}

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisActions.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ export type VariantAnalysisActionsProps = {
99
stopQueryDisabled?: boolean;
1010

1111
showResultActions?: boolean;
12+
onViewAutofixesClick: () => void;
1213
onCopyRepositoryListClick: () => void;
1314
onExportResultsClick: () => void;
15+
viewAutofixesDisabled?: boolean;
1416
copyRepositoryListDisabled?: boolean;
1517
exportResultsDisabled?: boolean;
1618

@@ -55,8 +57,10 @@ export const VariantAnalysisActions = ({
5557
onStopQueryClick,
5658
stopQueryDisabled,
5759
showResultActions,
60+
onViewAutofixesClick,
5861
onCopyRepositoryListClick,
5962
onExportResultsClick,
63+
viewAutofixesDisabled,
6064
copyRepositoryListDisabled,
6165
exportResultsDisabled,
6266
hasSelectedRepositories,
@@ -66,6 +70,19 @@ export const VariantAnalysisActions = ({
6670
<Container>
6771
{showResultActions && (
6872
<>
73+
<Button
74+
secondary
75+
onClick={onViewAutofixesClick}
76+
disabled={viewAutofixesDisabled}
77+
>
78+
{chooseText({
79+
hasSelectedRepositories,
80+
hasFilteredRepositories,
81+
normalText: "View Autofixes",
82+
selectedText: "View Autofixes for selected results",
83+
filteredText: "View Autofixes for filtered results",
84+
})}
85+
</Button>
6986
<Button
7087
secondary
7188
onClick={onCopyRepositoryListClick}

extensions/ql-vscode/src/view/variant-analysis/VariantAnalysisHeader.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type VariantAnalysisHeaderProps = {
3434

3535
onStopQueryClick: () => void;
3636

37+
onViewAutofixesClick: () => void;
3738
onCopyRepositoryListClick: () => void;
3839
onExportResultsClick: () => void;
3940

@@ -82,6 +83,7 @@ export const VariantAnalysisHeader = ({
8283
onOpenQueryFileClick,
8384
onViewQueryTextClick,
8485
onStopQueryClick,
86+
onViewAutofixesClick,
8587
onCopyRepositoryListClick,
8688
onExportResultsClick,
8789
onViewLogsClick,
@@ -150,11 +152,13 @@ export const VariantAnalysisHeader = ({
150152
variantAnalysisStatus={variantAnalysis.status}
151153
showResultActions={(resultCount ?? 0) > 0}
152154
onStopQueryClick={onStopQueryClick}
155+
onViewAutofixesClick={onViewAutofixesClick}
153156
onCopyRepositoryListClick={onCopyRepositoryListClick}
154157
onExportResultsClick={onExportResultsClick}
155158
stopQueryDisabled={!variantAnalysis.actionsWorkflowRunId}
156159
exportResultsDisabled={!hasDownloadedRepos}
157160
copyRepositoryListDisabled={!hasReposWithResults}
161+
viewAutofixesDisabled={!hasReposWithResults}
158162
hasFilteredRepositories={
159163
variantAnalysis.scannedRepos?.length !==
160164
filteredRepositories?.length

extensions/ql-vscode/src/view/variant-analysis/__tests__/VariantAnalysisActions.spec.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import { VariantAnalysisActions } from "../VariantAnalysisActions";
66

77
describe(VariantAnalysisActions.name, () => {
88
const onStopQueryClick = jest.fn();
9+
const onViewAutofixesClick = jest.fn();
910
const onCopyRepositoryListClick = jest.fn();
1011
const onExportResultsClick = jest.fn();
1112

1213
afterEach(() => {
1314
onStopQueryClick.mockReset();
15+
onViewAutofixesClick.mockReset();
1416
onCopyRepositoryListClick.mockReset();
1517
onExportResultsClick.mockReset();
1618
});
@@ -22,6 +24,7 @@ describe(VariantAnalysisActions.name, () => {
2224
reactRender(
2325
<VariantAnalysisActions
2426
onStopQueryClick={onStopQueryClick}
27+
onViewAutofixesClick={onViewAutofixesClick}
2528
onCopyRepositoryListClick={onCopyRepositoryListClick}
2629
onExportResultsClick={onExportResultsClick}
2730
{...props}

0 commit comments

Comments
 (0)