Skip to content

Commit f30d346

Browse files
committed
Add a "result format" dropdown component
1 parent 422f6de commit f30d346

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum ResultFormat {
2+
Alerts = "Alerts",
3+
RawResults = "Raw results",
4+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import * as React from "react";
2+
import { useCallback } from "react";
3+
import { styled } from "styled-components";
4+
import { VSCodeDropdown, VSCodeOption } from "@vscode/webview-ui-toolkit/react";
5+
import { Codicon } from "../common";
6+
import { ResultFormat } from "../../variant-analysis/shared/variant-analysis-result-format";
7+
8+
const Dropdown = styled(VSCodeDropdown)`
9+
width: 100%;
10+
`;
11+
12+
type Props = {
13+
value: ResultFormat;
14+
onChange: (value: ResultFormat) => void;
15+
16+
className?: string;
17+
};
18+
19+
export const RepositoriesResultFormat = ({
20+
value,
21+
onChange,
22+
className,
23+
}: Props) => {
24+
const handleInput = useCallback(
25+
(e: InputEvent) => {
26+
const target = e.target as HTMLSelectElement;
27+
28+
onChange(target.value as ResultFormat);
29+
},
30+
[onChange],
31+
);
32+
33+
return (
34+
<Dropdown value={value} onInput={handleInput} className={className}>
35+
<Codicon name="table" label="Result format..." slot="indicator" />
36+
<VSCodeOption value={ResultFormat.Alerts}>Alerts</VSCodeOption>
37+
<VSCodeOption value={ResultFormat.RawResults}>Raw results</VSCodeOption>
38+
</Dropdown>
39+
);
40+
};

0 commit comments

Comments
 (0)