MCPcopy Create free account
hub / github.com/Exafunction/codeium-chrome / EditableList

Function EditableList

src/component/Options.tsx:20–124  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18} from '../storage';
19
20const EditableList = () => {
21 const [text, setText] = useState('');
22 const [open, setOpen] = useState(false);
23 const [severity, setSeverity] = useState<'success' | 'error'>('success');
24 const [message, setMessage] = useState('');
25
26 useEffect(() => {
27 (async () => {
28 const allowlist = computeAllowlist(await getStorageItem('allowlist'));
29 setText(allowlist.join('\n'));
30 })();
31 }, []);
32
33 return (
34 <>
35 <Typography variant="h6">Allowlist</Typography>
36 <Typography variant="body2">
37 Domains to allow auto-completion. Use one regex per line.
38 </Typography>
39
40 <TextField
41 variant="standard"
42 fullWidth
43 value={text}
44 multiline
45 rows={10}
46 sx={{
47 '& .MuiInputBase-root': {
48 fontSize: '0.8rem',
49 fontFamily: 'monospace',
50 },
51 }}
52 onChange={(e) => setText(e.target.value)}
53 ></TextField>
54
55 <Button
56 variant="text"
57 onClick={() => {
58 const lst = text
59 .split('\n')
60 .map((x) => x.trim())
61 .filter((x) => x !== '');
62 for (const rule of lst) {
63 try {
64 new RegExp(rule);
65 } catch (e) {
66 setSeverity('error');
67 setMessage(`Invalid regex: ${rule}`);
68 setOpen(true);
69 return;
70 }
71 }
72 setStorageItem('allowlist', { defaults: defaultAllowlist, current: lst });
73 setSeverity('success');
74 setMessage('Saved successfully');
75 setOpen(true);
76 }}
77 sx={{

Callers

nothing calls this directly

Calls 3

computeAllowlistFunction · 0.90
getStorageItemFunction · 0.90
setStorageItemFunction · 0.90

Tested by

no test coverage detected