fix: lint

pull/4372/head
James Elliott 2022-11-13 10:18:57 +11:00
parent 9b66bb4fe2
commit bbc9e6422e
No known key found for this signature in database
GPG Key ID: 0F1C4A096E857E49
5 changed files with 120 additions and 66 deletions

View File

@ -1,8 +1,8 @@
import { WebauthnDevice } from "@root/models/Webauthn"; import { WebauthnDevice } from "@root/models/Webauthn";
import { WebauthnDevicesPath } from "./Api"; import { WebauthnDevicesPath } from "./Api";
import { Get } from "./Client"; import { Get } from "./Client";
// getWebauthnDevices returns the list of webauthn devices for the authenticated user. // getWebauthnDevices returns the list of webauthn devices for the authenticated user.
export async function getWebauthnDevices(): Promise<WebauthnDevice[]> { export async function getWebauthnDevices(): Promise<WebauthnDevice[]> {
return Get<WebauthnDevice[]>(WebauthnDevicesPath); return Get<WebauthnDevice[]>(WebauthnDevicesPath);

View File

@ -1,28 +1,36 @@
import { Button, Dialog, DialogActions, DialogContent, DialogContentText, DialogProps, DialogTitle, TextField } from "@mui/material";
import React from "react"; import React from "react";
interface Props extends DialogProps {}; import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogContentText,
DialogProps,
DialogTitle,
TextField,
} from "@mui/material";
interface Props extends DialogProps {}
export default function AddSecurityKeyDialog(props: Props) { export default function AddSecurityKeyDialog(props: Props) {
const handleAddClick = () => { const handleAddClick = () => {
if (props.onClose) { if (props.onClose) {
props.onClose({}, "backdropClick"); props.onClose({}, "backdropClick");
} }
} };
const handleCancelClick = () => { const handleCancelClick = () => {
if (props.onClose) { if (props.onClose) {
props.onClose({}, "backdropClick"); props.onClose({}, "backdropClick");
} }
} };
return ( return (
<Dialog {...props}> <Dialog {...props}>
<DialogTitle>Add new Security Key</DialogTitle> <DialogTitle>Add new Security Key</DialogTitle>
<DialogContent> <DialogContent>
<DialogContentText> <DialogContentText>Provide the details for the new security key.</DialogContentText>
Provide the details for the new security key.
</DialogContentText>
<TextField <TextField
autoFocus autoFocus
margin="dense" margin="dense"

View File

@ -1,11 +1,36 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { AppBar, Box, Button, Drawer, Grid, IconButton, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Paper, Stack, Switch, Table, TableBody, TableCell, TableHead, TableRow, Toolbar, Tooltip, Typography } from "@mui/material"; import DeleteIcon from "@mui/icons-material/Delete";
import SystemSecurityUpdateGoodIcon from '@mui/icons-material/SystemSecurityUpdateGood'; import EditIcon from "@mui/icons-material/Edit";
import DeleteIcon from '@mui/icons-material/Delete'; import SystemSecurityUpdateGoodIcon from "@mui/icons-material/SystemSecurityUpdateGood";
import EditIcon from '@mui/icons-material/Edit'; import {
import { getWebauthnDevices } from "@root/services/UserWebauthnDevices"; AppBar,
Box,
Button,
Drawer,
Grid,
IconButton,
List,
ListItem,
ListItemButton,
ListItemIcon,
ListItemText,
Paper,
Stack,
Switch,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Toolbar,
Tooltip,
Typography,
} from "@mui/material";
import { WebauthnDevice } from "@root/models/Webauthn"; import { WebauthnDevice } from "@root/models/Webauthn";
import { getWebauthnDevices } from "@root/services/UserWebauthnDevices";
import AddSecurityKeyDialog from "./AddSecurityDialog"; import AddSecurityKeyDialog from "./AddSecurityDialog";
interface Props {} interface Props {}
@ -20,19 +45,19 @@ export default function SettingsView(props: Props) {
(async function () { (async function () {
const devices = await getWebauthnDevices(); const devices = await getWebauthnDevices();
setWebauthnDevices(devices); setWebauthnDevices(devices);
})() })();
}, []); }, []);
const handleKeyClose = () => { const handleKeyClose = () => {
setAddKeyOpen(false); setAddKeyOpen(false);
} };
const handleAddKeyButtonClick = () => { const handleAddKeyButtonClick = () => {
setAddKeyOpen(true); setAddKeyOpen(true);
} };
return ( return (
<Box sx={{ display: 'flex' }}> <Box sx={{ display: "flex" }}>
<AppBar position="fixed" sx={{ zIndex: (theme) => theme.zIndex.drawer + 1 }}> <AppBar position="fixed" sx={{ zIndex: (theme) => theme.zIndex.drawer + 1 }}>
<Toolbar variant="dense"> <Toolbar variant="dense">
<Typography style={{ flexGrow: 1 }}>Settings</Typography> <Typography style={{ flexGrow: 1 }}>Settings</Typography>
@ -43,11 +68,11 @@ export default function SettingsView(props: Props) {
sx={{ sx={{
width: drawerWidth, width: drawerWidth,
flexShrink: 0, flexShrink: 0,
[`& .MuiDrawer-paper`]: { width: drawerWidth, boxSizing: 'border-box' }, [`& .MuiDrawer-paper`]: { width: drawerWidth, boxSizing: "border-box" },
}} }}
> >
<Toolbar variant="dense" /> <Toolbar variant="dense" />
<Box sx={{ overflow: 'auto' }}> <Box sx={{ overflow: "auto" }}>
<List> <List>
<ListItem disablePadding> <ListItem disablePadding>
<ListItemButton selected={true}> <ListItemButton selected={true}>
@ -67,7 +92,9 @@ export default function SettingsView(props: Props) {
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>
<Stack spacing={1} direction="row"> <Stack spacing={1} direction="row">
<Button color="primary" variant="contained" onClick={handleAddKeyButtonClick}>Add</Button> <Button color="primary" variant="contained" onClick={handleAddKeyButtonClick}>
Add
</Button>
</Stack> </Stack>
</Grid> </Grid>
<Grid item xs={12}> <Grid item xs={12}>
@ -83,15 +110,26 @@ export default function SettingsView(props: Props) {
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{webauthnDevices ? webauthnDevices.map((x, idx) => { {webauthnDevices
? webauthnDevices.map((x, idx) => {
return ( return (
<TableRow key={x.description}> <TableRow key={x.description}>
<TableCell>{x.description}</TableCell> <TableCell>{x.description}</TableCell>
<TableCell><Switch defaultChecked={false} size="small" /></TableCell> <TableCell>
<TableCell><Typography>{(false) ? "<ADATE>" : "Not enabled"}</Typography></TableCell> <Switch defaultChecked={false} size="small" />
</TableCell>
<TableCell>
<Typography>{false ? "<ADATE>" : "Not enabled"}</Typography>
</TableCell>
<TableCell> <TableCell>
<Tooltip title={x.public_key}> <Tooltip title={x.public_key}>
<div style={{overflow: "hidden", textOverflow: "ellipsis", width: '300px'}}> <div
style={{
overflow: "hidden",
textOverflow: "ellipsis",
width: "300px",
}}
>
<Typography noWrap>{x.public_key}</Typography> <Typography noWrap>{x.public_key}</Typography>
</div> </div>
</Tooltip> </Tooltip>
@ -107,8 +145,9 @@ export default function SettingsView(props: Props) {
</Stack> </Stack>
</TableCell> </TableCell>
</TableRow> </TableRow>
) );
}) : null} })
: null}
</TableBody> </TableBody>
</Table> </Table>
</Paper> </Paper>

View File

@ -58,6 +58,13 @@ export default defineConfig(({ mode }) => {
port: 3000, port: 3000,
open: false, open: false,
}, },
plugins: [/* eslintPlugin({ cache: false }) */, htmlPlugin(), istanbulPlugin, react(), svgr(), tsconfigPaths()], plugins: [
,
/* eslintPlugin({ cache: false }) */ htmlPlugin(),
istanbulPlugin,
react(),
svgr(),
tsconfigPaths(),
],
}; };
}); });