Skip to content

Commit ccc9ed8

Browse files
committed
MRVA: Add webview button to export results
1 parent 141f538 commit ccc9ed8

File tree

4 files changed

+50
-6
lines changed

4 files changed

+50
-6
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ export type FromRemoteQueriesMessage =
394394
| OpenFileMsg
395395
| OpenVirtualFileMsg
396396
| RemoteQueryDownloadAnalysisResultsMessage
397-
| RemoteQueryDownloadAllAnalysesResultsMessage;
397+
| RemoteQueryDownloadAllAnalysesResultsMessage
398+
| RemoteQueryExportResultsMessage;
398399

399400
export type ToRemoteQueriesMessage =
400401
| SetRemoteQueryResultMessage
@@ -429,3 +430,6 @@ export interface RemoteQueryDownloadAllAnalysesResultsMessage {
429430
analysisSummaries: AnalysisSummary[];
430431
}
431432

433+
export interface RemoteQueryExportResultsMessage {
434+
t: 'remoteQueryExportResults';
435+
}

extensions/ql-vscode/src/remote-queries/remote-queries-interface.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
window as Window,
55
ViewColumn,
66
Uri,
7-
workspace
7+
workspace,
8+
commands
89
} from 'vscode';
910
import * as path from 'path';
1011

@@ -210,6 +211,9 @@ export class RemoteQueriesInterfaceManager {
210211
case 'remoteQueryDownloadAllAnalysesResults':
211212
await this.downloadAllAnalysesResults(msg);
212213
break;
214+
case 'remoteQueryExportResults':
215+
await await commands.executeCommand('codeQL.exportVariantAnalysisResults');
216+
break;
213217
default:
214218
assertNever(msg);
215219
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as React from 'react';
2+
import styled from 'styled-components';
3+
4+
const Button = styled.a`
5+
color: var(--vscode-button-foreground);
6+
background-color: var(--vscode-button-background);
7+
&:hover {
8+
color: var(--vscode-button-foreground);
9+
text-decoration: none;
10+
background-color: var(--vscode-button-hoverBackground);
11+
}
12+
cursor: pointer;
13+
padding: 5px 10px;
14+
`;
15+
16+
const ExportButton = ({ text, onClick }: { text: string, onClick: () => void }) => (
17+
<Button className="monaco-button monaco-text-button" onClick={onClick}>
18+
{text}
19+
</Button>
20+
);
21+
22+
export default ExportButton;

extensions/ql-vscode/src/remote-queries/view/RemoteQueries.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import { useEffect, useState } from 'react';
33
import * as Rdom from 'react-dom';
4-
import { Flash, ThemeProvider } from '@primer/react';
4+
import { Box, Flash, ThemeProvider } from '@primer/react';
55
import { ToRemoteQueriesMessage } from '../../pure/interface-types';
66
import { AnalysisSummary, RemoteQueryResult } from '../shared/remote-query-result';
77
import { MAX_RAW_RESULTS } from '../shared/result-limits';
@@ -20,6 +20,7 @@ import { AlertIcon, CodeSquareIcon, FileCodeIcon, RepoIcon, TerminalIcon } from
2020
import AnalysisAlertResult from './AnalysisAlertResult';
2121
import RawResultsTable from './RawResultsTable';
2222
import RepositoriesSearch from './RepositoriesSearch';
23+
import ExportButton from './ExportButton';
2324

2425
const numOfReposInContractedMode = 10;
2526

@@ -238,6 +239,12 @@ const AnalysesResultsTitle = ({ totalAnalysesResults, totalResults }: { totalAna
238239
return <SectionTitle>{totalAnalysesResults}/{totalResults} results</SectionTitle>;
239240
};
240241

242+
const exportResults = () => {
243+
vscode.postMessage({
244+
t: 'remoteQueryExportResults',
245+
});
246+
};
247+
241248
const AnalysesResultsDescription = ({
242249
queryResult,
243250
analysesResults,
@@ -313,9 +320,16 @@ const AnalysesResults = ({
313320
return (
314321
<>
315322
<VerticalSpace size={2} />
316-
<AnalysesResultsTitle
317-
totalAnalysesResults={totalAnalysesResults}
318-
totalResults={totalResults} />
323+
<Box display="flex">
324+
<Box flexGrow={1}>
325+
<AnalysesResultsTitle
326+
totalAnalysesResults={totalAnalysesResults}
327+
totalResults={totalResults} />
328+
</Box>
329+
<Box>
330+
<ExportButton text="Export all" onClick={() => exportResults()}></ExportButton>
331+
</Box>
332+
</Box>
319333
<AnalysesResultsDescription
320334
queryResult={queryResult}
321335
analysesResults={analysesResults} />

0 commit comments

Comments
 (0)