Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors |
Adrià Vilanova Martínez | 535e731 | 2021-10-17 00:48:12 +0200 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 5 | import React from 'react'; |
Adrià Vilanova Martínez | 535e731 | 2021-10-17 00:48:12 +0200 | [diff] [blame] | 6 | import { makeStyles, withStyles } from '@material-ui/styles'; |
| 7 | import { blue, yellow, red, grey } from '@material-ui/core/colors'; |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 8 | import FormControlLabel from '@material-ui/core/FormControlLabel'; |
Adrià Vilanova Martínez | 535e731 | 2021-10-17 00:48:12 +0200 | [diff] [blame] | 9 | import Checkbox, { CheckboxProps } from '@material-ui/core/Checkbox'; |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 10 | import SelectMenu from './SelectMenu.tsx'; |
Adrià Vilanova Martínez | 535e731 | 2021-10-17 00:48:12 +0200 | [diff] [blame] | 11 | import { RadioDescription } from './RadioDescription/RadioDescription.tsx'; |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 12 | import {GetCategoriesByPersona} from './IssueWizardUtils.tsx'; |
| 13 | import {ISSUE_WIZARD_QUESTIONS} from './IssueWizardConfig.ts'; |
| 14 | import DotMobileStepper from './DotMobileStepper.tsx'; |
| 15 | import {IssueWizardPersona} from './IssueWizardTypes.tsx'; |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 16 | |
| 17 | const CustomCheckbox = withStyles({ |
| 18 | root: { |
| 19 | color: blue[400], |
| 20 | '&$checked': { |
| 21 | color: blue[600], |
| 22 | }, |
| 23 | }, |
| 24 | checked: {}, |
| 25 | })((props: CheckboxProps) => <Checkbox color="default" {...props} />); |
| 26 | |
| 27 | const useStyles = makeStyles({ |
| 28 | pad: { |
| 29 | margin: '10px, 20px', |
| 30 | display: 'inline-block', |
| 31 | }, |
| 32 | flex: { |
| 33 | display: 'flex', |
| 34 | }, |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 35 | warningBox: { |
| 36 | minHeight: '10vh', |
| 37 | borderStyle: 'solid', |
| 38 | borderWidth: '2px', |
| 39 | borderColor: yellow[800], |
| 40 | borderRadius: '8px', |
| 41 | background: yellow[50], |
| 42 | padding: '0px 20px 1em', |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 43 | margin: '1rem 0' |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 44 | }, |
| 45 | warningHeader: { |
| 46 | color: yellow[800], |
| 47 | fontSize: '16px', |
| 48 | fontWeight: '500', |
| 49 | }, |
Adrià Vilanova Martínez | 535e731 | 2021-10-17 00:48:12 +0200 | [diff] [blame] | 50 | star: { |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 51 | color: red[700], |
| 52 | marginRight: '8px', |
| 53 | fontSize: '16px', |
| 54 | display: 'inline-block', |
| 55 | }, |
| 56 | header: { |
| 57 | color: grey[900], |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 58 | fontSize: '1.5rem', |
| 59 | margin: '1rem 0', |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 60 | }, |
| 61 | subheader: { |
| 62 | color: grey[700], |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 63 | fontSize: '1.125rem', |
| 64 | margin: '1rem 0', |
| 65 | }, |
| 66 | alertDetail: { |
| 67 | fontSize: '16px', |
| 68 | }, |
| 69 | link: { |
| 70 | fontSize: '20px', |
| 71 | fontWeight: 'bolder', |
| 72 | textDecoration: 'underline', |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 73 | }, |
| 74 | red: { |
| 75 | color: red[600], |
| 76 | }, |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 77 | line: { |
| 78 | color: grey[200], |
| 79 | marginTop: '1.5rem', |
| 80 | minWidth: '360px', |
| 81 | } |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 82 | }); |
| 83 | |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 84 | type Props = { |
| 85 | userPersona: IssueWizardPersona, |
| 86 | setUserPersona: Function, |
| 87 | category: string, |
| 88 | setCategory: Function, |
| 89 | setActiveStep: Function, |
| 90 | }; |
| 91 | |
| 92 | export default function LandingStep(props: Props) { |
| 93 | |
| 94 | const {userPersona, setUserPersona, category, setCategory, setActiveStep} = props; |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 95 | const classes = useStyles(); |
| 96 | |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 97 | const categoriesByPersonaMap = GetCategoriesByPersona(ISSUE_WIZARD_QUESTIONS); |
| 98 | |
| 99 | const [categoryList, setCategoryList] = React.useState(categoriesByPersonaMap.get(userPersona)); |
| 100 | const [checkExisting, setCheckExisting] = React.useState(false); |
| 101 | |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 102 | const handleCheckChange = (event: React.ChangeEvent<HTMLInputElement>) => { |
| 103 | setCheckExisting(event.target.checked); |
| 104 | }; |
| 105 | |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 106 | const onSelectUserPersona = (userPersona: string) => { |
| 107 | setUserPersona(userPersona); |
| 108 | setCategoryList(categoriesByPersonaMap.get(userPersona)); |
| 109 | setCategory(''); |
| 110 | } |
| 111 | |
| 112 | const contributorAlert = () => { |
| 113 | return ( |
| 114 | <div> |
| 115 | <div className={classes.subheader}> |
| 116 | Prefer to file an issue manually? |
| 117 | </div> |
| 118 | <div className={classes.alertDetail}> |
| 119 | It's usually best to work through this short wizard so that your issue is given the labels needed for the right team to see it. |
| 120 | Otherwise it might take longer for your issue to be triaged and resolved. |
| 121 | </div> |
| 122 | <div className={classes.alertDetail}> |
| 123 | However, if you are a Chromium contributor and none of the other options apply, you may use the |
| 124 | <a className={classes.link} href="entry"> regular issue entry form</a>. |
| 125 | </div> |
| 126 | </div> |
| 127 | ); |
| 128 | } |
| 129 | |
| 130 | const nextEnabled = (userPersona != IssueWizardPersona.Contributor) && checkExisting && (category != ''); |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 131 | return ( |
| 132 | <> |
| 133 | <p className={classes.header}>Report an issue with Chromium</p> |
| 134 | <p className={classes.subheader}> |
| 135 | We want you to enter the best possible issue report so that the project team members |
| 136 | can act on it effectively. The following steps will help route your issue to the correct |
| 137 | people. |
| 138 | </p> |
| 139 | <p className={classes.subheader}> |
| 140 | Please select your following role: <span className={classes.red}>*</span> |
| 141 | </p> |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 142 | <RadioDescription selectedRadio={userPersona} onClickRadio={onSelectUserPersona} /> |
| 143 | { userPersona === IssueWizardPersona.Contributor ? contributorAlert() : |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 144 | <div> |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 145 | <div className={classes.subheader}> |
| 146 | Which of the following best describes the issue that you are reporting? <span className={classes.red}>*</span> |
| 147 | </div> |
| 148 | <SelectMenu optionsList={categoryList} selectedOption={category} setOption={setCategory} /> |
| 149 | <div className={classes.warningBox}> |
| 150 | <p className={classes.warningHeader}> <span className={classes.star}>*</span>Avoid duplicate issue reports:</p> |
| 151 | <div> |
| 152 | <FormControlLabel className={classes.pad} |
| 153 | control={ |
| 154 | <CustomCheckbox |
| 155 | checked={checkExisting} |
| 156 | onChange={handleCheckChange} |
| 157 | name="warningCheck" |
| 158 | /> |
| 159 | } |
| 160 | label={ |
| 161 | <span>By checking this box, I'm acknowledging that I have searched for <a href="/p/chromium/issues/list" target="_blank">existing issues</a> that already report this problem.</span> |
| 162 | } |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 163 | /> |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 164 | </div> |
| 165 | </div> |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 166 | </div> |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 167 | } |
| 168 | { userPersona === IssueWizardPersona.Contributor ? null : |
| 169 | <DotMobileStepper nextEnabled={nextEnabled} activeStep={0} setActiveStep={setActiveStep}/> |
| 170 | } |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 171 | </> |
| 172 | ); |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 173 | } |