-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I thought I'd use a <Select> component for choosing the issuer/subject name attribute, but I can't get it to recognize a click on any but the first item in the dropdown list.
- Loading branch information
1 parent
05afd8d
commit 1f26236
Showing
6 changed files
with
641 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import FormControl from '@mui/material/FormControl'; | ||
import FormHelperText from '@mui/material/FormHelperText'; | ||
import Grid from '@mui/material/Grid'; | ||
import InputLabel from '@mui/material/InputLabel'; | ||
import MenuItem from '@mui/material/ListItem'; | ||
import Select from '@mui/material/Select'; | ||
import Typography from '@mui/material/Typography'; | ||
import React, { useId, useState } from 'react'; | ||
import TextField from '../components/TextField'; | ||
|
||
interface Props { | ||
label: string; | ||
data: string | undefined; | ||
onChange: (a: string | undefined) => void; | ||
disabled: boolean; | ||
} | ||
|
||
const CertFilter: React.FC<Props> = ({ label, data, onChange, disabled }) => { | ||
const [dataAttribute, dataValue] = (data || '').split('=', 2); | ||
const attribute = dataAttribute || ''; | ||
const value = dataValue || ''; | ||
|
||
const selectLabelId = useId(); | ||
const selectId = useId(); | ||
const setAttribute = (newAttribute: string) => { | ||
onChange(!!newAttribute ? (newAttribute + '=' + value) : undefined); | ||
} | ||
const setValue = (newValue: string) => { | ||
onChange(attribute + '=' + newValue); | ||
} | ||
|
||
return ( | ||
<> | ||
<Typography sx={{ pt: 1, pb: 0.5 }}>{label}</Typography> | ||
<Grid container spacing={2}> | ||
<Grid item xs={4}> | ||
<FormControl size="small" fullWidth disabled={disabled}> | ||
<InputLabel id={selectLabelId}>Attribute</InputLabel> | ||
<Select | ||
labelId={selectLabelId} | ||
id={selectId} | ||
label="Attribute" | ||
renderValue={(selected) => selected} | ||
> | ||
<MenuItem value="" sx={{ fontStyle: 'italic'}}>None</MenuItem> | ||
<MenuItem value="CN">CN (Common Name)</MenuItem> | ||
<MenuItem value="O">O (Organization Name)</MenuItem> | ||
<MenuItem value="OU">OU (Organizational Unit Name)</MenuItem> | ||
<MenuItem value="C">C (Country Name)</MenuItem> | ||
<MenuItem value="ST">ST (State or Province Name)</MenuItem> | ||
<MenuItem value="L">L (Locality Name)</MenuItem> | ||
</Select> | ||
</FormControl> | ||
</Grid> | ||
<Grid item xs={8}> | ||
{ attribute === '' | ||
? <Typography sx={{ py: 1, fontStyle: 'italic', color: 'text.secondary' }}> | ||
No filter | ||
</Typography> | ||
: <TextField | ||
fullWidth | ||
label="Value" | ||
value={value} | ||
onChange={(evt): void => setValue(evt.target.value)} | ||
/> } | ||
</Grid> | ||
</Grid> | ||
<FormHelperText> | ||
Limits the search to certificates where the {label} has a particular | ||
attribute value (exact match). | ||
</FormHelperText> | ||
</> | ||
); | ||
}; | ||
|
||
export default CertFilter; |
Oops, something went wrong.