Add filtering and sorting to exported results
This adds filtering (based on search and selected repositories) and sorting to exporting results. This is done in the same way as for copying the repository list, so the changes are fairly minimal.
This commit is contained in:
@@ -1008,8 +1008,8 @@ async function activateWithInstalledDistribution(
|
||||
);
|
||||
|
||||
ctx.subscriptions.push(
|
||||
commandRunner('codeQL.exportVariantAnalysisResults', async (variantAnalysisId: number) => {
|
||||
await exportVariantAnalysisResults(ctx, variantAnalysisManager, variantAnalysisId);
|
||||
commandRunner('codeQL.exportVariantAnalysisResults', async (variantAnalysisId: number, filterSort?: RepositoriesFilterSortStateWithIds) => {
|
||||
await exportVariantAnalysisResults(ctx, variantAnalysisManager, variantAnalysisId, filterSort);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -480,6 +480,7 @@ export interface CopyRepositoryListMessage {
|
||||
|
||||
export interface ExportResultsMessage {
|
||||
t: 'exportResults';
|
||||
filterSort?: RepositoriesFilterSortStateWithIds;
|
||||
}
|
||||
|
||||
export interface OpenLogsMessage {
|
||||
|
||||
@@ -24,6 +24,10 @@ import {
|
||||
VariantAnalysisScannedRepository,
|
||||
VariantAnalysisScannedRepositoryResult
|
||||
} from './shared/variant-analysis';
|
||||
import {
|
||||
filterAndSortRepositoriesWithResults,
|
||||
RepositoriesFilterSortStateWithIds,
|
||||
} from '../pure/variant-analysis-filter-sort';
|
||||
|
||||
/**
|
||||
* Exports the results of the currently-selected remote query or variant analysis.
|
||||
@@ -98,6 +102,7 @@ export async function exportVariantAnalysisResults(
|
||||
ctx: ExtensionContext,
|
||||
variantAnalysisManager: VariantAnalysisManager,
|
||||
variantAnalysisId: number,
|
||||
filterSort?: RepositoriesFilterSortStateWithIds,
|
||||
): Promise<void> {
|
||||
const variantAnalysis = await variantAnalysisManager.getVariantAnalysis(variantAnalysisId);
|
||||
if (!variantAnalysis) {
|
||||
@@ -117,7 +122,9 @@ export async function exportVariantAnalysisResults(
|
||||
return;
|
||||
}
|
||||
|
||||
for (const repo of variantAnalysis.scannedRepos) {
|
||||
const repositories = filterAndSortRepositoriesWithResults(variantAnalysis.scannedRepos, filterSort);
|
||||
|
||||
for (const repo of repositories) {
|
||||
if (repo.resultCount == 0) {
|
||||
yield [repo, {
|
||||
variantAnalysisId: variantAnalysis.id,
|
||||
|
||||
@@ -107,7 +107,7 @@ export class VariantAnalysisView extends AbstractWebview<ToVariantAnalysisMessag
|
||||
void commands.executeCommand('codeQL.copyVariantAnalysisRepoList', this.variantAnalysisId, msg.filterSort);
|
||||
break;
|
||||
case 'exportResults':
|
||||
void commands.executeCommand('codeQL.exportVariantAnalysisResults', this.variantAnalysisId);
|
||||
void commands.executeCommand('codeQL.exportVariantAnalysisResults', this.variantAnalysisId, msg.filterSort);
|
||||
break;
|
||||
case 'openLogs':
|
||||
await this.openLogs();
|
||||
|
||||
@@ -37,12 +37,6 @@ const stopQuery = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const exportResults = () => {
|
||||
vscode.postMessage({
|
||||
t: 'exportResults',
|
||||
});
|
||||
};
|
||||
|
||||
const openLogs = () => {
|
||||
vscode.postMessage({
|
||||
t: 'openLogs',
|
||||
@@ -104,6 +98,16 @@ export function VariantAnalysis({
|
||||
});
|
||||
}, [filterSortState, selectedRepositoryIds]);
|
||||
|
||||
const exportResults = useCallback(() => {
|
||||
vscode.postMessage({
|
||||
t: 'exportResults',
|
||||
filterSort: {
|
||||
...filterSortState,
|
||||
repositoryIds: selectedRepositoryIds,
|
||||
},
|
||||
});
|
||||
}, [filterSortState, selectedRepositoryIds]);
|
||||
|
||||
if (variantAnalysis?.actionsWorkflowRunId === undefined) {
|
||||
return <VariantAnalysisLoading />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user