From 9a905e83f75c0263ab9ec227c950e82f7981c7e4 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 28 Mar 2025 11:35:51 +0100 Subject: [PATCH] WIP ESLint fixes --- virtweb_frontend/eslint.config.js | 1 + virtweb_frontend/src/App.tsx | 8 ++++---- virtweb_frontend/src/api/ApiClient.ts | 12 +++++------ virtweb_frontend/src/api/NWFilterApi.ts | 4 ++-- virtweb_frontend/src/api/NetworksApi.ts | 2 +- virtweb_frontend/src/api/TokensApi.ts | 2 +- .../hooks/providers/AlertDialogProvider.tsx | 4 ++-- .../hooks/providers/ConfirmDialogProvider.tsx | 12 +++++------ .../providers/LoadingMessageProvider.tsx | 10 +++++----- .../src/hooks/providers/SnackbarProvider.tsx | 6 +++--- virtweb_frontend/src/index.tsx | 2 +- .../src/routes/EditAPITokenRoute.tsx | 2 +- .../src/routes/EditNWFilterRoute.tsx | 2 +- .../src/routes/EditNetworkRoute.tsx | 2 +- virtweb_frontend/src/routes/EditVMRoute.tsx | 2 +- virtweb_frontend/src/routes/IsoFilesRoute.tsx | 4 ++-- .../src/routes/NetworkFiltersListRoute.tsx | 2 +- virtweb_frontend/src/routes/SysInfoRoute.tsx | 2 +- virtweb_frontend/src/routes/VMListRoute.tsx | 12 +++++------ virtweb_frontend/src/routes/VNCRoute.tsx | 6 +++--- .../src/routes/auth/LoginRoute.tsx | 6 +++--- virtweb_frontend/src/widgets/AsyncWidget.tsx | 2 +- .../src/widgets/ConfigImportExportButtons.tsx | 4 ++-- virtweb_frontend/src/widgets/TabsWidget.tsx | 2 +- .../src/widgets/forms/CheckboxInput.tsx | 2 +- .../src/widgets/forms/IPInput.tsx | 6 +++--- .../src/widgets/forms/MACInput.tsx | 2 +- .../src/widgets/forms/NWFConnStateInput.tsx | 2 +- .../widgets/forms/NWFilterPriorityInput.tsx | 2 +- .../src/widgets/forms/NWFilterRules.tsx | 6 +++--- .../widgets/forms/NetDHCPHostReservations.tsx | 4 ++-- .../src/widgets/forms/PortInput.tsx | 2 +- .../src/widgets/forms/RadioGroupInput.tsx | 2 +- .../src/widgets/forms/SelectInput.tsx | 2 +- .../src/widgets/net/NetworkDetails.tsx | 20 +++++++++---------- .../src/widgets/net/NetworkStatusWidget.tsx | 4 ++-- .../widgets/tokens/TokenRawRightsEditor.tsx | 2 +- .../src/widgets/tokens/TokenRightsEditor.tsx | 10 +++++----- .../src/widgets/vms/VMDetails.tsx | 2 +- .../src/widgets/vms/VMStatusWidget.tsx | 4 ++-- 40 files changed, 92 insertions(+), 91 deletions(-) diff --git a/virtweb_frontend/eslint.config.js b/virtweb_frontend/eslint.config.js index cf66efa..1fd4d8a 100644 --- a/virtweb_frontend/eslint.config.js +++ b/virtweb_frontend/eslint.config.js @@ -38,6 +38,7 @@ export default tseslint.config( ], ...reactX.configs["recommended-typescript"].rules, ...reactDom.configs.recommended.rules, + "@typescript-eslint/no-non-null-assertion": "off" }, } ); diff --git a/virtweb_frontend/src/App.tsx b/virtweb_frontend/src/App.tsx index 8e7cd81..1873c3c 100644 --- a/virtweb_frontend/src/App.tsx +++ b/virtweb_frontend/src/App.tsx @@ -51,7 +51,7 @@ export function App() { const context: AuthContext = { signedIn: signedIn, - setSignedIn: (s) => setSignedIn(s), + setSignedIn: (s) => { setSignedIn(s); }, }; const router = createBrowserRouter( @@ -97,12 +97,12 @@ export function App() { ); return ( - + - + ); } export function useAuth(): AuthContext { - return React.useContext(AuthContextK)!; + return React.use(AuthContextK)!; } diff --git a/virtweb_frontend/src/api/ApiClient.ts b/virtweb_frontend/src/api/ApiClient.ts index 177ac86..49df36b 100644 --- a/virtweb_frontend/src/api/ApiClient.ts +++ b/virtweb_frontend/src/api/ApiClient.ts @@ -44,7 +44,7 @@ export class APIClient { */ static async exec(args: RequestParams): Promise { let body: string | undefined | FormData = undefined; - let headers: any = {}; + const headers: any = {}; // JSON request if (args.jsonData) { @@ -67,17 +67,17 @@ export class APIClient { const res: XMLHttpRequest = await new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.upload.addEventListener("progress", (e) => - args.upProgress!(e.loaded / e.total) + { args.upProgress!(e.loaded / e.total); } ); - xhr.addEventListener("load", () => resolve(xhr)); + xhr.addEventListener("load", () => { resolve(xhr); }); xhr.addEventListener("error", () => - reject(new Error("File upload failed")) + { reject(new Error("File upload failed")); } ); xhr.addEventListener("abort", () => - reject(new Error("File upload aborted")) + { reject(new Error("File upload aborted")); } ); xhr.addEventListener("timeout", () => - reject(new Error("File upload timeout")) + { reject(new Error("File upload timeout")); } ); xhr.open(args.method, url, true); xhr.withCredentials = true; diff --git a/virtweb_frontend/src/api/NWFilterApi.ts b/virtweb_frontend/src/api/NWFilterApi.ts index 220c228..4aa9b04 100644 --- a/virtweb_frontend/src/api/NWFilterApi.ts +++ b/virtweb_frontend/src/api/NWFilterApi.ts @@ -140,7 +140,7 @@ export interface NWFilter { rules: NWFilterRule[]; } -export function NWFilterURL(n: NWFilter, edit: boolean = false): string { +export function NWFilterURL(n: NWFilter, edit = false): string { return `/nwfilter/${n.uuid}${edit ? "/edit" : ""}`; } @@ -221,7 +221,7 @@ export class NWFilterApi { static async Delete(n: NWFilter): Promise { await APIClient.exec({ method: "DELETE", - uri: `/nwfilter/${n.uuid}`, + uri: `/nwfilter/${n.uuid!}`, }); } } diff --git a/virtweb_frontend/src/api/NetworksApi.ts b/virtweb_frontend/src/api/NetworksApi.ts index 109e3ff..ace4268 100644 --- a/virtweb_frontend/src/api/NetworksApi.ts +++ b/virtweb_frontend/src/api/NetworksApi.ts @@ -53,7 +53,7 @@ export interface NetworkInfo { export type NetworkStatus = "Started" | "Stopped"; -export function NetworkURL(n: NetworkInfo, edit: boolean = false): string { +export function NetworkURL(n: NetworkInfo, edit = false): string { return `/net/${n.uuid}${edit ? "/edit" : ""}`; } diff --git a/virtweb_frontend/src/api/TokensApi.ts b/virtweb_frontend/src/api/TokensApi.ts index daf27a4..b2a4ab4 100644 --- a/virtweb_frontend/src/api/TokensApi.ts +++ b/virtweb_frontend/src/api/TokensApi.ts @@ -20,7 +20,7 @@ export interface APIToken { max_inactivity?: number; } -export function APITokenURL(t: APIToken, edit: boolean = false): string { +export function APITokenURL(t: APIToken, edit = false): string { return `/token/${t.id}${edit ? "/edit" : ""}`; } diff --git a/virtweb_frontend/src/hooks/providers/AlertDialogProvider.tsx b/virtweb_frontend/src/hooks/providers/AlertDialogProvider.tsx index 520e56e..0510bd6 100644 --- a/virtweb_frontend/src/hooks/providers/AlertDialogProvider.tsx +++ b/virtweb_frontend/src/hooks/providers/AlertDialogProvider.tsx @@ -39,7 +39,7 @@ export function AlertDialogProvider(p: PropsWithChildren): React.ReactElement { return ( <> - {p.children} + {p.children} - + {p.children} - + handleClose(false)} + onClose={() => { handleClose(false); }} aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > @@ -76,10 +76,10 @@ export function ConfirmDialogProvider( - - @@ -89,5 +89,5 @@ export function ConfirmDialogProvider( } export function useConfirm(): ConfirmContext { - return React.useContext(ConfirmContextK)!; + return React.use(ConfirmContextK)!; } diff --git a/virtweb_frontend/src/hooks/providers/LoadingMessageProvider.tsx b/virtweb_frontend/src/hooks/providers/LoadingMessageProvider.tsx index 6c0c826..01acab9 100644 --- a/virtweb_frontend/src/hooks/providers/LoadingMessageProvider.tsx +++ b/virtweb_frontend/src/hooks/providers/LoadingMessageProvider.tsx @@ -6,10 +6,10 @@ import { } from "@mui/material"; import React, { PropsWithChildren } from "react"; -type LoadingMessageContext = { +interface LoadingMessageContext { show: (message: string) => void; hide: () => void; -}; +} const LoadingMessageContextK = React.createContext(null); @@ -34,9 +34,9 @@ export function LoadingMessageProvider( return ( <> - + {p.children} - + @@ -60,5 +60,5 @@ export function LoadingMessageProvider( } export function useLoadingMessage(): LoadingMessageContext { - return React.useContext(LoadingMessageContextK)!; + return React.use(LoadingMessageContextK)!; } diff --git a/virtweb_frontend/src/hooks/providers/SnackbarProvider.tsx b/virtweb_frontend/src/hooks/providers/SnackbarProvider.tsx index 203b3c9..935c00b 100644 --- a/virtweb_frontend/src/hooks/providers/SnackbarProvider.tsx +++ b/virtweb_frontend/src/hooks/providers/SnackbarProvider.tsx @@ -24,9 +24,9 @@ export function SnackbarProvider(p: PropsWithChildren): React.ReactElement { return ( <> - + {p.children} - + diff --git a/virtweb_frontend/src/routes/EditAPITokenRoute.tsx b/virtweb_frontend/src/routes/EditAPITokenRoute.tsx index 7063028..068dd28 100644 --- a/virtweb_frontend/src/routes/EditAPITokenRoute.tsx +++ b/virtweb_frontend/src/routes/EditAPITokenRoute.tsx @@ -116,7 +116,7 @@ function EditApiTokenRouteInner(p: { const [changed, setChanged] = React.useState(false); const [, updateState] = React.useState(); - const forceUpdate = React.useCallback(() => updateState({}), []); + const forceUpdate = React.useCallback(() => { updateState({}); }, []); const valueChanged = () => { setChanged(true); diff --git a/virtweb_frontend/src/routes/EditNWFilterRoute.tsx b/virtweb_frontend/src/routes/EditNWFilterRoute.tsx index 7eb729d..72408fc 100644 --- a/virtweb_frontend/src/routes/EditNWFilterRoute.tsx +++ b/virtweb_frontend/src/routes/EditNWFilterRoute.tsx @@ -99,7 +99,7 @@ function EditNetworkFilterRouteInner(p: { const [changed, setChanged] = React.useState(false); const [, updateState] = React.useState(); - const forceUpdate = React.useCallback(() => updateState({}), []); + const forceUpdate = React.useCallback(() => { updateState({}); }, []); const valueChanged = () => { setChanged(true); diff --git a/virtweb_frontend/src/routes/EditNetworkRoute.tsx b/virtweb_frontend/src/routes/EditNetworkRoute.tsx index 8ca60cd..a946de8 100644 --- a/virtweb_frontend/src/routes/EditNetworkRoute.tsx +++ b/virtweb_frontend/src/routes/EditNetworkRoute.tsx @@ -97,7 +97,7 @@ function EditNetworkRouteInner(p: { const [changed, setChanged] = React.useState(false); const [, updateState] = React.useState(); - const forceUpdate = React.useCallback(() => updateState({}), []); + const forceUpdate = React.useCallback(() => { updateState({}); }, []); const valueChanged = () => { setChanged(true); diff --git a/virtweb_frontend/src/routes/EditVMRoute.tsx b/virtweb_frontend/src/routes/EditVMRoute.tsx index 8a5b420..6d1e401 100644 --- a/virtweb_frontend/src/routes/EditVMRoute.tsx +++ b/virtweb_frontend/src/routes/EditVMRoute.tsx @@ -103,7 +103,7 @@ function EditVMInner(p: { const [changed, setChanged] = React.useState(false); const [, updateState] = React.useState(); - const forceUpdate = React.useCallback(() => updateState({}), []); + const forceUpdate = React.useCallback(() => { updateState({}); }, []); const valueChanged = () => { setChanged(true); diff --git a/virtweb_frontend/src/routes/IsoFilesRoute.tsx b/virtweb_frontend/src/routes/IsoFilesRoute.tsx index 0a8306e..894ab54 100644 --- a/virtweb_frontend/src/routes/IsoFilesRoute.tsx +++ b/virtweb_frontend/src/routes/IsoFilesRoute.tsx @@ -166,14 +166,14 @@ function UploadIsoFileFromUrlCard(p: { label="URL" value={url} style={{ flex: 3 }} - onChange={(e) => setURL(e.target.value)} + onChange={(e) => { setURL(e.target.value); }} /> setFilename(e.target.value)} + onChange={(e) => { setFilename(e.target.value); }} /> {url !== "" && actualFileName !== "" && ( diff --git a/virtweb_frontend/src/routes/NetworkFiltersListRoute.tsx b/virtweb_frontend/src/routes/NetworkFiltersListRoute.tsx index 45403e3..77d6845 100644 --- a/virtweb_frontend/src/routes/NetworkFiltersListRoute.tsx +++ b/virtweb_frontend/src/routes/NetworkFiltersListRoute.tsx @@ -78,7 +78,7 @@ function NetworkFiltersListRouteInner(p: { size="small" value={visibleFilters} exclusive - onChange={(_ev, v) => setVisibleFilters(v)} + onChange={(_ev, v) => { setVisibleFilters(v); }} aria-label="visible filters" > All diff --git a/virtweb_frontend/src/routes/SysInfoRoute.tsx b/virtweb_frontend/src/routes/SysInfoRoute.tsx index e73d676..08c4c50 100644 --- a/virtweb_frontend/src/routes/SysInfoRoute.tsx +++ b/virtweb_frontend/src/routes/SysInfoRoute.tsx @@ -236,7 +236,7 @@ export function SysInfoRouteInner(p: { function SysInfoDetailsTable(p: { label: string; icon: React.ReactElement; - entries: Array<{ label: string; value: string | number }>; + entries: { label: string; value: string | number }[]; }): React.ReactElement { return ( >(); + const [groups, setGroups] = React.useState<(string | undefined)[]>(); const [list, setList] = React.useState(); const loadKey = React.useRef(1); const load = async () => { - const groups: Array = await GroupApi.GetList(); + const groups: (string | undefined)[] = await GroupApi.GetList(); const list = await VMApi.GetList(); if (list.find((v) => !v.group) !== undefined) groups.push(undefined); @@ -70,7 +70,7 @@ export function VMListRoute(): React.ReactElement { } function VMListWidget(p: { - groups: Array; + groups: (string | undefined)[]; list: VMInfo[]; onReload: () => void; }): React.ReactElement { @@ -125,9 +125,9 @@ function VMListWidget(p: { > toggleHiddenGroup(g)} + onClick={() => { toggleHiddenGroup(g); }} > - {!hiddenGroups?.has(g) ? ( + {!hiddenGroups.has(g) ? ( ) : ( @@ -157,7 +157,7 @@ function VMListWidget(p: { updateVMState(row, s)} + onChange={(s) => { updateVMState(row, s); }} /> diff --git a/virtweb_frontend/src/routes/VNCRoute.tsx b/virtweb_frontend/src/routes/VNCRoute.tsx index a969b7e..7e33933 100644 --- a/virtweb_frontend/src/routes/VNCRoute.tsx +++ b/virtweb_frontend/src/routes/VNCRoute.tsx @@ -91,7 +91,7 @@ function VNCInner(p: { vm: VMInfo }): React.ReactElement { connect(false); if (vncRef.current) { - vncRef.current.onfullscreenchange = () => setCounter(counter + 1); + vncRef.current.onfullscreenchange = () => { setCounter(counter + 1); }; } }); @@ -140,10 +140,10 @@ function VNCInner(p: { vm: VMInfo }): React.ReactElement { ref={vncScreenRef} url={token.url} onDisconnect={() => { - console.info("VNC disconnected " + token?.url); + console.info("VNC disconnected " + token.url); disconnected(); }} - onConnect={() => setConnected(true)} + onConnect={() => { setConnected(true); }} /> diff --git a/virtweb_frontend/src/routes/auth/LoginRoute.tsx b/virtweb_frontend/src/routes/auth/LoginRoute.tsx index fd2d148..6389a5b 100644 --- a/virtweb_frontend/src/routes/auth/LoginRoute.tsx +++ b/virtweb_frontend/src/routes/auth/LoginRoute.tsx @@ -36,7 +36,7 @@ export function LoginRoute(): React.ReactElement { const canSubmit = username.length > 0 && password.length > 0; const [showPassword, setShowPassword] = React.useState(false); - const handleClickShowPassword = () => setShowPassword((show) => !show); + const handleClickShowPassword = () => { setShowPassword((show) => !show); }; const handleMouseDownPassword = ( event: React.MouseEvent @@ -105,7 +105,7 @@ export function LoginRoute(): React.ReactElement { label="Username" name="username" value={username} - onChange={(e) => setUsername(e.target.value)} + onChange={(e) => { setUsername(e.target.value); }} autoComplete="username" autoFocus /> @@ -120,7 +120,7 @@ export function LoginRoute(): React.ReactElement { type={showPassword ? "text" : "password"} id="password" value={password} - onChange={(e) => setPassword(e.target.value)} + onChange={(e) => { setPassword(e.target.value); }} autoComplete="current-password" endAdornment={ diff --git a/virtweb_frontend/src/widgets/AsyncWidget.tsx b/virtweb_frontend/src/widgets/AsyncWidget.tsx index 18d24b8..d7424bb 100644 --- a/virtweb_frontend/src/widgets/AsyncWidget.tsx +++ b/virtweb_frontend/src/widgets/AsyncWidget.tsx @@ -67,7 +67,7 @@ export function AsyncWidget(p: { - {p.errAdditionalElement && p.errAdditionalElement()} + {p.errAdditionalElement?.()} ) ); diff --git a/virtweb_frontend/src/widgets/ConfigImportExportButtons.tsx b/virtweb_frontend/src/widgets/ConfigImportExportButtons.tsx index d51df88..f966c58 100644 --- a/virtweb_frontend/src/widgets/ConfigImportExportButtons.tsx +++ b/virtweb_frontend/src/widgets/ConfigImportExportButtons.tsx @@ -32,13 +32,13 @@ export function ConfigImportExportButtons(p: { // Wait for a file to be chosen await new Promise((res, _rej) => - fileEl.addEventListener("change", () => res(null)) + { fileEl.addEventListener("change", () => { res(null); }); } ); if ((fileEl.files?.length ?? 0) === 0) return null; // Import conf - let file = fileEl.files![0]; + const file = fileEl.files![0]; const content = await file.text(); p.importConf?.(JSON.parse(content)); } catch (e) { diff --git a/virtweb_frontend/src/widgets/TabsWidget.tsx b/virtweb_frontend/src/widgets/TabsWidget.tsx index 5411eaa..9148662 100644 --- a/virtweb_frontend/src/widgets/TabsWidget.tsx +++ b/virtweb_frontend/src/widgets/TabsWidget.tsx @@ -24,7 +24,7 @@ export function TabsWidget(p: { updateActiveTab(newVal)} + onChange={(_ev, newVal) => { updateActiveTab(newVal); }} > {activeOptions.map((o, index) => ( diff --git a/virtweb_frontend/src/widgets/forms/CheckboxInput.tsx b/virtweb_frontend/src/widgets/forms/CheckboxInput.tsx index 2d320fb..837fb39 100644 --- a/virtweb_frontend/src/widgets/forms/CheckboxInput.tsx +++ b/virtweb_frontend/src/widgets/forms/CheckboxInput.tsx @@ -17,7 +17,7 @@ export function CheckboxInput(p: { p.onValueChange(e.target.checked)} + onChange={(e) => { p.onValueChange(e.target.checked); }} /> } label={p.label} diff --git a/virtweb_frontend/src/widgets/forms/IPInput.tsx b/virtweb_frontend/src/widgets/forms/IPInput.tsx index 90df36a..46a4d02 100644 --- a/virtweb_frontend/src/widgets/forms/IPInput.tsx +++ b/virtweb_frontend/src/widgets/forms/IPInput.tsx @@ -44,7 +44,7 @@ export function IPInputWithMask(p: { return; } - const split = v?.split("/"); + const split = v.split("/"); const ip = p.version === 4 ? sanitizeIpV4(split[0]) : sanitizeIpV6(split[0]); let mask = undefined; @@ -69,7 +69,7 @@ export function IPInputWithMask(p: { function sanitizeIpV4(s: string | undefined): string | undefined { if (s === "" || s === undefined) return s; - let split = s.split("."); + const split = s.split("."); if (split.length > 4) split.splice(4); let needAnotherIteration = false; @@ -106,7 +106,7 @@ function sanitizeIpV6(s: string | undefined): string | undefined { const num = parseInt(e, 16); if (isNaN(num)) return "0"; - let s = num.toString(16); + const s = num.toString(16); if (num > 0xffff) { needAnotherIteration = true; return s.slice(0, 4) + ":" + s.slice(4); diff --git a/virtweb_frontend/src/widgets/forms/MACInput.tsx b/virtweb_frontend/src/widgets/forms/MACInput.tsx index 56bc5fa..6a121c0 100644 --- a/virtweb_frontend/src/widgets/forms/MACInput.tsx +++ b/virtweb_frontend/src/widgets/forms/MACInput.tsx @@ -32,7 +32,7 @@ function sanitizeMacAddress(s: string | undefined): string | undefined { const num = parseInt(e, 16); if (isNaN(num)) return "0"; - let s = num.toString(16).padStart(2, "0"); + const s = num.toString(16).padStart(2, "0"); if (num > 0xff) { needAnotherIteration = true; return s.slice(0, 2) + ":" + s.slice(2); diff --git a/virtweb_frontend/src/widgets/forms/NWFConnStateInput.tsx b/virtweb_frontend/src/widgets/forms/NWFConnStateInput.tsx index 1aa3a39..fd49bba 100644 --- a/virtweb_frontend/src/widgets/forms/NWFConnStateInput.tsx +++ b/virtweb_frontend/src/widgets/forms/NWFConnStateInput.tsx @@ -12,7 +12,7 @@ export function NWFConnStateInput(p: { label="Connection state" value={p.value} onValueChange={(s) => { - p.onChange?.(s as any); + p.onChange(s as any); }} options={[ { label: "None", value: undefined }, diff --git a/virtweb_frontend/src/widgets/forms/NWFilterPriorityInput.tsx b/virtweb_frontend/src/widgets/forms/NWFilterPriorityInput.tsx index 22336ec..90e17bb 100644 --- a/virtweb_frontend/src/widgets/forms/NWFilterPriorityInput.tsx +++ b/virtweb_frontend/src/widgets/forms/NWFilterPriorityInput.tsx @@ -13,7 +13,7 @@ export function NWFilterPriorityInput(p: { value={p.value?.toString()} type="number" onValueChange={(v) => { - p.onChange?.(v && v !== "" ? Number(v) : undefined); + p.onChange(v && v !== "" ? Number(v) : undefined); }} size={ServerApi.Config.constraints.nwfilter_priority} helperText="A lower priority value is accessed before one with a higher value" diff --git a/virtweb_frontend/src/widgets/forms/NWFilterRules.tsx b/virtweb_frontend/src/widgets/forms/NWFilterRules.tsx index 8ea8907..a0cedb0 100644 --- a/virtweb_frontend/src/widgets/forms/NWFilterRules.tsx +++ b/virtweb_frontend/src/widgets/forms/NWFilterRules.tsx @@ -66,9 +66,9 @@ export function NWFilterRules(p: { deleteRule(n); }} onGoDown={ - n < p.rules.length - 1 ? () => swapRules(n, n + 1) : undefined + n < p.rules.length - 1 ? () => { swapRules(n, n + 1); } : undefined } - onGoUp={n > 0 ? () => swapRules(n, n - 1) : undefined} + onGoUp={n > 0 ? () => { swapRules(n, n - 1); } : undefined} {...p} /> ))} @@ -153,7 +153,7 @@ function NWRuleEdit(p: { editable={p.editable} onChange={p.onChange} selector={s} - onDelete={() => deleteSelector(n)} + onDelete={() => { deleteSelector(n); }} /> ))} diff --git a/virtweb_frontend/src/widgets/forms/NetDHCPHostReservations.tsx b/virtweb_frontend/src/widgets/forms/NetDHCPHostReservations.tsx index e92750b..220cbf4 100644 --- a/virtweb_frontend/src/widgets/forms/NetDHCPHostReservations.tsx +++ b/virtweb_frontend/src/widgets/forms/NetDHCPHostReservations.tsx @@ -130,7 +130,7 @@ function HostReservationWidget(p: { value={p.host.mac} onValueChange={(v) => { p.host.mac = v!; - p.onChange?.(); + p.onChange(); }} /> )} @@ -142,7 +142,7 @@ function HostReservationWidget(p: { value={p.host.ip} onValueChange={(v) => { p.host.ip = v!; - p.onChange?.(); + p.onChange(); }} /> diff --git a/virtweb_frontend/src/widgets/forms/PortInput.tsx b/virtweb_frontend/src/widgets/forms/PortInput.tsx index cde2d72..09bdf9b 100644 --- a/virtweb_frontend/src/widgets/forms/PortInput.tsx +++ b/virtweb_frontend/src/widgets/forms/PortInput.tsx @@ -12,7 +12,7 @@ export function PortInput(p: { value={p.value?.toString() ?? ""} type="number" onValueChange={(v) => { - p.onChange?.(sanitizePort(v)); + p.onChange(sanitizePort(v)); }} checkValue={(v) => Number(v) <= 65535} /> diff --git a/virtweb_frontend/src/widgets/forms/RadioGroupInput.tsx b/virtweb_frontend/src/widgets/forms/RadioGroupInput.tsx index 6e25c9d..11cf4ba 100644 --- a/virtweb_frontend/src/widgets/forms/RadioGroupInput.tsx +++ b/virtweb_frontend/src/widgets/forms/RadioGroupInput.tsx @@ -24,7 +24,7 @@ export function RadioGroupInput(p: { p.onValueChange?.(v)} + onChange={(_ev, v) => { p.onValueChange(v); }} > {p.options.map((o) => ( p.onValueChange(e.target.value)} + onChange={(e) => { p.onValueChange(e.target.value); }} > {p.options.map((e) => ( { - if (!!p.config) { + if (p.config) { if ( !(await confirm( `Do you really want to disable IPv${p.version} on this network? Specific configuration will be deleted!` @@ -268,11 +268,11 @@ function IPSection(p: { ) return; - p.onChange?.(undefined); + p.onChange(undefined); return; } - p.onChange?.({ + p.onChange({ bridge_address: p.version === 4 ? "192.168.1.1" : "fd00::1", prefix: p.version === 4 ? 24 : 8, }); @@ -298,7 +298,7 @@ function IPSection(p: { p.config!.dhcp = undefined; } - p.onChange?.(p.config); + p.onChange(p.config); }; const toggleNAT = async (v: boolean) => { @@ -315,7 +315,7 @@ function IPSection(p: { p.config!.nat = undefined; } - p.onChange?.(p.config); + p.onChange(p.config); }; if (!p.config && !p.editable) return <>; @@ -338,10 +338,10 @@ function IPSection(p: { editable={p.editable} label="Bridge address" version={p.version} - value={p.config?.bridge_address} + value={p.config.bridge_address} onValueChange={(v) => { p.config!.bridge_address = v ?? ""; - p.onChange?.(p.config); + p.onChange(p.config); }} /> @@ -352,7 +352,7 @@ function IPSection(p: { type="number" onValueChange={(v) => { p.config!.prefix = Number(v); - p.onChange?.(p.config); + p.onChange(p.config); }} size={ p.version === 4 ? { min: 0, max: 32 } : { min: 0, max: 128 } @@ -407,7 +407,7 @@ function IPSection(p: { dhcp={p.config.dhcp} onChange={(d) => { p.config!.dhcp = d; - p.onChange?.(p.config); + p.onChange(p.config); }} /> @@ -431,7 +431,7 @@ function IPSection(p: { nat={p.config.nat} onChange={(n) => { p.config!.nat = n; - p.onChange?.(p.config); + p.onChange(p.config); }} /> )} diff --git a/virtweb_frontend/src/widgets/net/NetworkStatusWidget.tsx b/virtweb_frontend/src/widgets/net/NetworkStatusWidget.tsx index 0cdc0dd..c1bd471 100644 --- a/virtweb_frontend/src/widgets/net/NetworkStatusWidget.tsx +++ b/virtweb_frontend/src/widgets/net/NetworkStatusWidget.tsx @@ -29,13 +29,13 @@ export function NetworkStatusWidget(p: { } }; - const changedAction = () => setState(undefined); + const changedAction = () => { setState(undefined); }; React.useEffect(() => { refresh(); const i = setInterval(() => refresh(), 3000); - return () => clearInterval(i); + return () => { clearInterval(i); }; }); if (state === undefined) diff --git a/virtweb_frontend/src/widgets/tokens/TokenRawRightsEditor.tsx b/virtweb_frontend/src/widgets/tokens/TokenRawRightsEditor.tsx index 654e8a6..1bcd837 100644 --- a/virtweb_frontend/src/widgets/tokens/TokenRawRightsEditor.tsx +++ b/virtweb_frontend/src/widgets/tokens/TokenRawRightsEditor.tsx @@ -95,7 +95,7 @@ export function TokenRawRightsEditor(p: { {p.editable && ( - deleteRule(num)}> + { deleteRule(num); }}> diff --git a/virtweb_frontend/src/widgets/tokens/TokenRightsEditor.tsx b/virtweb_frontend/src/widgets/tokens/TokenRightsEditor.tsx index 46fbb8f..a5891ee 100644 --- a/virtweb_frontend/src/widgets/tokens/TokenRightsEditor.tsx +++ b/virtweb_frontend/src/widgets/tokens/TokenRightsEditor.tsx @@ -576,7 +576,7 @@ export function TokenRightsEditor(p: { right={{ verb: "GET", path: `/api/nwfilter/${v.uuid}` }} parent={{ verb: "GET", path: "/api/nwfilter/*" }} /> - {ServerApi.Config.builtin_nwfilter_rules.includes(v.name!) ? ( + {ServerApi.Config.builtin_nwfilter_rules.includes(v.name) ? ( ) : ( )} - {ServerApi.Config.builtin_nwfilter_rules.includes(v.name!) ? ( + {ServerApi.Config.builtin_nwfilter_rules.includes(v.name) ? ( ) : ( r.verb === p.parent?.verb && r.path === p.parent?.path + (r) => r.verb === p.parent?.verb && r.path === p.parent.path ) !== -1; const toggle = (a: boolean) => { @@ -804,7 +804,7 @@ function RouteRight(p: RightOpts): React.ReactElement { toggle(a)} + onChange={(_e, a) => { toggle(a); }} /> } label={p.label} @@ -814,7 +814,7 @@ function RouteRight(p: RightOpts): React.ReactElement { toggle(a)} + onChange={(_e, a) => { toggle(a); }} /> )} diff --git a/virtweb_frontend/src/widgets/vms/VMDetails.tsx b/virtweb_frontend/src/widgets/vms/VMDetails.tsx index d1fcb08..1b338af 100644 --- a/virtweb_frontend/src/widgets/vms/VMDetails.tsx +++ b/virtweb_frontend/src/widgets/vms/VMDetails.tsx @@ -222,7 +222,7 @@ function VMDetailsTabGeneral(p: DetailsInnerProps): React.ReactElement { : "Add a new group instead of using existing one" } > - setAddGroup(!addGroup)}> + { setAddGroup(!addGroup); }}> {addGroup ? : } diff --git a/virtweb_frontend/src/widgets/vms/VMStatusWidget.tsx b/virtweb_frontend/src/widgets/vms/VMStatusWidget.tsx index 20a94ca..5b4881a 100644 --- a/virtweb_frontend/src/widgets/vms/VMStatusWidget.tsx +++ b/virtweb_frontend/src/widgets/vms/VMStatusWidget.tsx @@ -31,13 +31,13 @@ export function VMStatusWidget(p: { } }; - const changedAction = () => setState(undefined); + const changedAction = () => { setState(undefined); }; React.useEffect(() => { refresh(); const i = setInterval(() => refresh(), 3000); - return () => clearInterval(i); + return () => { clearInterval(i); }; }); if (state === undefined)