blob: 3b0b96d247763a79795c4cebe5c0088c19189bf8 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001// Copyright 2021 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import React from 'react';
6import {createTheme, Theme} from '@material-ui/core/styles';
7import {makeStyles} from '@material-ui/styles';
8import MenuItem from '@material-ui/core/MenuItem';
9import TextField from '@material-ui/core/TextField';
10
11const CATEGORIES = [
12 {
13 value: 'UI',
14 label: 'UI',
15 },
16 {
17 value: 'Accessibility',
18 label: 'Accessibility',
19 },
20 {
21 value: 'Network/Downloading',
22 label: 'Network/Downloading',
23 },
24 {
25 value: 'Audio/Video',
26 label: 'Audio/Video',
27 },
28 {
29 value: 'Content',
30 label: 'Content',
31 },
32 {
33 value: 'Apps',
34 label: 'Apps',
35 },
36 {
37 value: 'Extensions/Themes',
38 label: 'Extensions/Themes',
39 },
40 {
41 value: 'Webstore',
42 label: 'Webstore',
43 },
44 {
45 value: 'Sync',
46 label: 'Sync',
47 },
48 {
49 value: 'Enterprise',
50 label: 'Enterprise',
51 },
52 {
53 value: 'Installation',
54 label: 'Installation',
55 },
56 {
57 value: 'Crashes',
58 label: 'Crashes',
59 },
60 {
61 value: 'Security',
62 label: 'Security',
63 },
64 {
65 value: 'Other',
66 label: 'Other',
67 },
68];
69
70const theme: Theme = createTheme();
71
72const useStyles = makeStyles((theme: Theme) => ({
73 container: {
74 display: 'flex',
75 flexWrap: 'wrap',
76 maxWidth: '65%',
77 },
78 textField: {
79 marginLeft: theme.spacing(1),
80 marginRight: theme.spacing(1),
81 },
82 menu: {
83 width: '100%',
84 minWidth: '300px',
85 },
86}), {defaultTheme: theme});
87
88/**
89 * Select menu component that is located on the landing step if the
90 * Issue Wizard. The menu is used for the user to indicate the category
91 * of their bug when filing an issue.
92 *
93 * @return ReactElement.
94 */
95export default function SelectMenu({option, setOption}: {option: string, setOption: Function}) {
96 const classes = useStyles();
97 const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => {
98 setOption(event.target.value as string);
99 };
100
101 return (
102 <form className={classes.container} noValidate autoComplete="off">
103 <TextField
104 id="outlined-select-category"
105 select
106 label=''
107 className={classes.textField}
108 value={option}
109 onChange={handleChange}
110 InputLabelProps={{shrink: false}}
111 SelectProps={{
112 MenuProps: {
113 className: classes.menu,
114 },
115 }}
116 margin="normal"
117 variant="outlined"
118 fullWidth={true}
119 >
120 {CATEGORIES.map(option => (
121 <MenuItem
122 className={classes.menu}
123 key={option.value}
124 value={option.value}
125 data-testid="select-menu-item"
126 >
127 {option.label}
128 </MenuItem>
129 ))}
130 </TextField>
131 </form>
132 );
133}