Skip to content

Commit c38a01e

Browse files
authored
Add a dropdown for choosing MRVA result format (#2743)
1 parent ac0dfa5 commit c38a01e

3 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as React from "react";
2+
import { useState } from "react";
3+
4+
import { Meta } from "@storybook/react";
5+
6+
import { RepositoriesResultFormat as RepositoriesResultFormatComponent } from "../../view/variant-analysis/RepositoriesResultFormat";
7+
import { ResultFormat } from "../../variant-analysis/shared/variant-analysis-result-format";
8+
9+
export default {
10+
title: "Variant Analysis/Repositories Result Format",
11+
component: RepositoriesResultFormatComponent,
12+
argTypes: {
13+
value: {
14+
control: {
15+
disable: true,
16+
},
17+
},
18+
},
19+
} as Meta<typeof RepositoriesResultFormatComponent>;
20+
21+
export const RepositoriesResultFormat = () => {
22+
const [value, setValue] = useState(ResultFormat.Alerts);
23+
24+
return (
25+
<RepositoriesResultFormatComponent value={value} onChange={setValue} />
26+
);
27+
};
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: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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}>
37+
{ResultFormat.Alerts}
38+
</VSCodeOption>
39+
<VSCodeOption value={ResultFormat.RawResults}>
40+
{ResultFormat.RawResults}
41+
</VSCodeOption>
42+
</Dropdown>
43+
);
44+
};

0 commit comments

Comments
 (0)