import AddIcon from "@mui/icons-material/Add"; import DeleteIcon from "@mui/icons-material/Delete"; import { IconButton, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip, Typography, } from "@mui/material"; import { ServerApi } from "../../api/ServerApi"; import { APIToken } from "../../api/TokensApi"; import { SelectInput } from "../forms/SelectInput"; import { TextInput } from "../forms/TextInput"; export function TokenRawRightsEditor(p: { token: APIToken; editable: boolean; onChange?: () => void; }): React.ReactElement { const addRule = () => { p.token.rights.push({ path: "/api/", verb: "GET" }); p.onChange?.(); }; const deleteRule = (id: number) => { p.token.rights.splice(id, 1); p.onChange?.(); }; return (
Raw rights
{p.editable && ( )}
Verb URI {p.editable && Actions} {p.token.rights.map((r, num) => ( { r.verb = v as any; p.onChange?.(); }} options={[ { value: "GET" }, { value: "POST" }, { value: "PATCH" }, { value: "PUT" }, { value: "DELETE" }, ]} /> { r.path = v ?? ""; p.onChange?.(); }} checkValue={(v) => v.startsWith("/api/")} size={ServerApi.Config.constraints.api_token_right_path_size} /> {p.editable && ( deleteRule(num)}> )} ))}
); }