Show a message on tokens list route when no token was created yet
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-05-30 11:35:00 +02:00
parent fa03ae885f
commit ec9492c933

View File

@@ -10,6 +10,7 @@ import {
TableContainer, TableContainer,
TableHead, TableHead,
TableRow, TableRow,
Typography,
} from "@mui/material"; } from "@mui/material";
import React from "react"; import React from "react";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
@@ -58,70 +59,78 @@ export function TokensListRouteInner(p: {
</RouterLink> </RouterLink>
} }
> >
<TableContainer component={Paper}> {p.list.length > 0 && (
<Table> <TableContainer component={Paper}>
<TableHead> <Table>
<TableRow> <TableHead>
<TableCell>Name</TableCell> <TableRow>
<TableCell>Description</TableCell> <TableCell>Name</TableCell>
<TableCell>Created</TableCell> <TableCell>Description</TableCell>
<TableCell>Updated</TableCell> <TableCell>Created</TableCell>
<TableCell>Last used</TableCell> <TableCell>Updated</TableCell>
<TableCell>IP restriction</TableCell> <TableCell>Last used</TableCell>
<TableCell>Max inactivity</TableCell> <TableCell>IP restriction</TableCell>
<TableCell>Rights</TableCell> <TableCell>Max inactivity</TableCell>
<TableCell>Actions</TableCell> <TableCell>Rights</TableCell>
</TableRow> <TableCell>Actions</TableCell>
</TableHead> </TableRow>
<TableBody> </TableHead>
{p.list.map((t) => { <TableBody>
return ( {p.list.map((t) => {
<TableRow return (
key={t.id} <TableRow
hover key={t.id}
onDoubleClick={() => navigate(APITokenURL(t))} hover
style={{ backgroundColor: ExpiredAPIToken(t) ? "red" : "" }} onDoubleClick={() => navigate(APITokenURL(t))}
> style={{ backgroundColor: ExpiredAPIToken(t) ? "red" : "" }}
<TableCell> >
{t.name} {ExpiredAPIToken(t) && <i>(Expired)</i>} <TableCell>
</TableCell> {t.name} {ExpiredAPIToken(t) && <i>(Expired)</i>}
<TableCell>{t.description}</TableCell> </TableCell>
<TableCell> <TableCell>{t.description}</TableCell>
<TimeWidget time={t.created} /> <TableCell>
</TableCell> <TimeWidget time={t.created} />
<TableCell> </TableCell>
<TimeWidget time={t.updated} /> <TableCell>
</TableCell> <TimeWidget time={t.updated} />
<TableCell> </TableCell>
<TimeWidget time={t.last_used} /> <TableCell>
</TableCell> <TimeWidget time={t.last_used} />
<TableCell>{t.ip_restriction}</TableCell> </TableCell>
<TableCell> <TableCell>{t.ip_restriction}</TableCell>
{t.max_inactivity && timeDiff(0, t.max_inactivity)} <TableCell>
</TableCell> {t.max_inactivity && timeDiff(0, t.max_inactivity)}
<TableCell> </TableCell>
{t.rights.map((r, n) => { <TableCell>
return ( {t.rights.map((r, n) => {
<div key={n}> return (
{r.verb} {r.path} <div key={n}>
</div> {r.verb} {r.path}
); </div>
})} );
</TableCell> })}
</TableCell>
<TableCell> <TableCell>
<RouterLink to={APITokenURL(t)}> <RouterLink to={APITokenURL(t)}>
<IconButton> <IconButton>
<VisibilityIcon /> <VisibilityIcon />
</IconButton> </IconButton>
</RouterLink> </RouterLink>
</TableCell> </TableCell>
</TableRow> </TableRow>
); );
})} })}
</TableBody> </TableBody>
</Table> </Table>
</TableContainer> </TableContainer>
)}
{p.list.length === 0 && (
<Typography style={{ textAlign: "center" }}>
No API token created yet.
</Typography>
)}
</VirtWebRouteContainer> </VirtWebRouteContainer>
); );
} }