Add ignore-self toggle to Jail Detail page
Implements the missing UI control for POST /api/jails/{name}/ignoreself:
- Add jailIgnoreSelf endpoint constant to endpoints.ts
- Add toggleIgnoreSelf(name, on) API function to jails.ts
- Expose toggleIgnoreSelf action from useJailDetail hook
- Replace read-only 'ignore self' badge with a Fluent Switch in
IgnoreListSection to allow enabling/disabling the flag per jail
- Add 5 vitest tests for checked/unchecked state and toggle behaviour
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
setJailIdle,
|
||||
startJail,
|
||||
stopJail,
|
||||
toggleIgnoreSelf as toggleIgnoreSelfApi,
|
||||
unbanAllBans,
|
||||
unbanIp,
|
||||
} from "../api/jails";
|
||||
@@ -150,6 +151,8 @@ export interface UseJailDetailResult {
|
||||
addIp: (ip: string) => Promise<void>;
|
||||
/** Remove an IP from the ignore list. */
|
||||
removeIp: (ip: string) => Promise<void>;
|
||||
/** Enable or disable the ignoreself option for this jail. */
|
||||
toggleIgnoreSelf: (on: boolean) => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,6 +211,11 @@ export function useJailDetail(name: string): UseJailDetailResult {
|
||||
load();
|
||||
};
|
||||
|
||||
const toggleIgnoreSelf = async (on: boolean): Promise<void> => {
|
||||
await toggleIgnoreSelfApi(name, on);
|
||||
load();
|
||||
};
|
||||
|
||||
return {
|
||||
jail,
|
||||
ignoreList,
|
||||
@@ -217,6 +225,7 @@ export function useJailDetail(name: string): UseJailDetailResult {
|
||||
refresh: load,
|
||||
addIp,
|
||||
removeIp,
|
||||
toggleIgnoreSelf,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user