Skip to content

Commit ccf03cb

Browse files
committed
Fix view not taking into account download status
The variant analysis view would allow expanding the results when the repo task was completed. However, it did not take into account whether the results were actually downloaded. This will that by usign the download status when the repo task was succeeded and sending the repo states to the view on load.
1 parent 47045f2 commit ccf03cb

File tree

6 files changed

+67
-4
lines changed

6 files changed

+67
-4
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
129129
return this.variantAnalyses.get(variantAnalysisId);
130130
}
131131

132+
public async getRepoStates(variantAnalysisId: number): Promise<VariantAnalysisScannedRepositoryState[]> {
133+
return Object.values(this.repoStates.get(variantAnalysisId) ?? {});
134+
}
135+
132136
public get variantAnalysesSize(): number {
133137
return this.variantAnalyses.size;
134138
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { VariantAnalysis } from './shared/variant-analysis';
1+
import { VariantAnalysis, VariantAnalysisScannedRepositoryState } from './shared/variant-analysis';
22

33
export interface VariantAnalysisViewInterface {
44
variantAnalysisId: number;
@@ -10,4 +10,5 @@ export interface VariantAnalysisViewManager<T extends VariantAnalysisViewInterfa
1010
unregisterView(view: T): void;
1111

1212
getVariantAnalysis(variantAnalysisId: number): Promise<VariantAnalysis | undefined>;
13+
getRepoStates(variantAnalysisId: number): Promise<VariantAnalysisScannedRepositoryState[]>;
1314
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ export class VariantAnalysisView extends AbstractWebview<ToVariantAnalysisMessag
117117
t: 'setVariantAnalysis',
118118
variantAnalysis,
119119
});
120+
121+
const repoStates = await this.manager.getRepoStates(this.variantAnalysisId);
122+
if (repoStates.length === 0) {
123+
return;
124+
}
125+
126+
await this.postMessage({
127+
t: 'setRepoStates',
128+
repoStates,
129+
});
120130
}
121131

122132
private async openQueryFile(): Promise<void> {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const RepoRow = ({
111111
}
112112
}, [resultsLoaded, resultsLoading]);
113113

114-
const disabled = !status || !isCompletedAnalysisRepoStatus(status);
114+
const disabled = !status || !isCompletedAnalysisRepoStatus(status) || (status === VariantAnalysisRepoStatus.Succeeded && downloadStatus !== VariantAnalysisScannedRepositoryDownloadStatus.Succeeded);
115115
const expandableContentLoaded = status && (status !== VariantAnalysisRepoStatus.Succeeded || resultsLoaded);
116116

117117
return (

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

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import * as React from 'react';
22
import { render as reactRender, screen } from '@testing-library/react';
3-
import { VariantAnalysisRepoStatus } from '../../../remote-queries/shared/variant-analysis';
3+
import {
4+
VariantAnalysisRepoStatus,
5+
VariantAnalysisScannedRepositoryDownloadStatus
6+
} from '../../../remote-queries/shared/variant-analysis';
47
import userEvent from '@testing-library/user-event';
58
import { RepoRow, RepoRowProps } from '../RepoRow';
69

@@ -48,7 +51,7 @@ describe(RepoRow.name, () => {
4851
})).toBeDisabled();
4952
});
5053

51-
it('renders the succeeded state', () => {
54+
it('renders the succeeded state without download status', () => {
5255
render({
5356
status: VariantAnalysisRepoStatus.Succeeded,
5457
resultCount: 178,
@@ -58,6 +61,42 @@ describe(RepoRow.name, () => {
5861
name: 'Success',
5962
})).toBeInTheDocument();
6063
expect(screen.getByText('178')).toBeInTheDocument();
64+
expect(screen.getByRole<HTMLButtonElement>('button', {
65+
expanded: false
66+
})).toBeDisabled();
67+
});
68+
69+
it('renders the succeeded state with pending download status', () => {
70+
render({
71+
status: VariantAnalysisRepoStatus.Succeeded,
72+
resultCount: 178,
73+
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Pending,
74+
});
75+
76+
expect(screen.getByRole<HTMLButtonElement>('button', {
77+
expanded: false
78+
})).toBeDisabled();
79+
});
80+
81+
it('renders the succeeded state with in progress download status', () => {
82+
render({
83+
status: VariantAnalysisRepoStatus.Succeeded,
84+
resultCount: 178,
85+
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.InProgress,
86+
});
87+
88+
expect(screen.getByRole<HTMLButtonElement>('button', {
89+
expanded: false
90+
})).toBeDisabled();
91+
});
92+
93+
it('renders the succeeded state with succeeded download status', () => {
94+
render({
95+
status: VariantAnalysisRepoStatus.Succeeded,
96+
resultCount: 178,
97+
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Succeeded,
98+
});
99+
61100
expect(screen.getByRole<HTMLButtonElement>('button', {
62101
expanded: false
63102
})).toBeEnabled();
@@ -167,6 +206,7 @@ describe(RepoRow.name, () => {
167206
it('can expand the repo item when succeeded and loaded', async () => {
168207
render({
169208
status: VariantAnalysisRepoStatus.Succeeded,
209+
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Succeeded,
170210
interpretedResults: [],
171211
});
172212

@@ -182,6 +222,7 @@ describe(RepoRow.name, () => {
182222
it('can expand the repo item when succeeded and not loaded', async () => {
183223
const { rerender } = render({
184224
status: VariantAnalysisRepoStatus.Succeeded,
225+
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Succeeded,
185226
});
186227

187228
await userEvent.click(screen.getByRole('button', {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import userEvent from '@testing-library/user-event';
44
import {
55
VariantAnalysisQueryLanguage,
66
VariantAnalysisRepoStatus,
7+
VariantAnalysisScannedRepositoryDownloadStatus,
78
VariantAnalysisStatus
89
} from '../../../remote-queries/shared/variant-analysis';
910
import { VariantAnalysisAnalyzedRepos, VariantAnalysisAnalyzedReposProps } from '../VariantAnalysisAnalyzedRepos';
@@ -80,6 +81,12 @@ describe(VariantAnalysisAnalyzedRepos.name, () => {
8081

8182
it('renders the interpreted result for a succeeded repo', async () => {
8283
render({
84+
repositoryStates: [
85+
{
86+
repositoryId: 2,
87+
downloadStatus: VariantAnalysisScannedRepositoryDownloadStatus.Succeeded,
88+
}
89+
],
8390
repositoryResults: [
8491
{
8592
variantAnalysisId: 1,

0 commit comments

Comments
 (0)