Refactor service status response: migrate bangui_version into version field
This commit is contained in:
@@ -70,7 +70,7 @@ const useStyles = makeStyles({
|
||||
*/
|
||||
export function ServerStatusBar(): React.JSX.Element {
|
||||
const styles = useStyles();
|
||||
const { status, banguiVersion, loading, error, refresh } = useServerStatus();
|
||||
const { status, loading, error, refresh } = useServerStatus();
|
||||
|
||||
const cardStyles = useCardStyles();
|
||||
|
||||
@@ -98,21 +98,13 @@ export function ServerStatusBar(): React.JSX.Element {
|
||||
{/* Version */}
|
||||
{/* ---------------------------------------------------------------- */}
|
||||
{status?.version != null && (
|
||||
<Tooltip content="fail2ban daemon version" relationship="description">
|
||||
<Tooltip content="BanGUI version" relationship="description">
|
||||
<Text size={200} className={styles.statValue}>
|
||||
v{status.version}
|
||||
</Text>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{banguiVersion != null && (
|
||||
<Tooltip content="BanGUI version" relationship="description">
|
||||
<Badge appearance="filled" size="small">
|
||||
BanGUI v{banguiVersion}
|
||||
</Badge>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{/* ---------------------------------------------------------------- */}
|
||||
{/* Stats (only when online) */}
|
||||
{/* ---------------------------------------------------------------- */}
|
||||
|
||||
@@ -41,7 +41,6 @@ describe("ServerStatusBar", () => {
|
||||
it("shows a spinner while the initial load is in progress", () => {
|
||||
mockedUseServerStatus.mockReturnValue({
|
||||
status: null,
|
||||
banguiVersion: null,
|
||||
loading: true,
|
||||
error: null,
|
||||
refresh: vi.fn(),
|
||||
@@ -60,7 +59,6 @@ describe("ServerStatusBar", () => {
|
||||
total_bans: 10,
|
||||
total_failures: 5,
|
||||
},
|
||||
banguiVersion: "1.1.0",
|
||||
loading: false,
|
||||
error: null,
|
||||
refresh: vi.fn(),
|
||||
@@ -78,7 +76,6 @@ describe("ServerStatusBar", () => {
|
||||
total_bans: 0,
|
||||
total_failures: 0,
|
||||
},
|
||||
banguiVersion: "1.1.0",
|
||||
loading: false,
|
||||
error: null,
|
||||
refresh: vi.fn(),
|
||||
@@ -96,7 +93,6 @@ describe("ServerStatusBar", () => {
|
||||
total_bans: 0,
|
||||
total_failures: 0,
|
||||
},
|
||||
banguiVersion: "1.2.3",
|
||||
loading: false,
|
||||
error: null,
|
||||
refresh: vi.fn(),
|
||||
@@ -105,7 +101,7 @@ describe("ServerStatusBar", () => {
|
||||
expect(screen.getByText("v1.2.3")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders a BanGUI version badge", () => {
|
||||
it("does not render a separate BanGUI version badge", () => {
|
||||
mockedUseServerStatus.mockReturnValue({
|
||||
status: {
|
||||
online: true,
|
||||
@@ -114,13 +110,12 @@ describe("ServerStatusBar", () => {
|
||||
total_bans: 0,
|
||||
total_failures: 0,
|
||||
},
|
||||
banguiVersion: "9.9.9",
|
||||
loading: false,
|
||||
error: null,
|
||||
refresh: vi.fn(),
|
||||
});
|
||||
renderBar();
|
||||
expect(screen.getByText("BanGUI v9.9.9")).toBeInTheDocument();
|
||||
expect(screen.queryByText("BanGUI v9.9.9")).toBeNull();
|
||||
});
|
||||
|
||||
it("does not render the version element when version is null", () => {
|
||||
@@ -132,7 +127,6 @@ describe("ServerStatusBar", () => {
|
||||
total_bans: 0,
|
||||
total_failures: 0,
|
||||
},
|
||||
banguiVersion: "1.2.3",
|
||||
loading: false,
|
||||
error: null,
|
||||
refresh: vi.fn(),
|
||||
@@ -151,7 +145,6 @@ describe("ServerStatusBar", () => {
|
||||
total_bans: 21,
|
||||
total_failures: 99,
|
||||
},
|
||||
banguiVersion: "1.0.0",
|
||||
loading: false,
|
||||
error: null,
|
||||
refresh: vi.fn(),
|
||||
@@ -167,7 +160,6 @@ describe("ServerStatusBar", () => {
|
||||
it("renders an error message when the status fetch fails", () => {
|
||||
mockedUseServerStatus.mockReturnValue({
|
||||
status: null,
|
||||
banguiVersion: null,
|
||||
loading: false,
|
||||
error: "Network error",
|
||||
refresh: vi.fn(),
|
||||
|
||||
@@ -352,12 +352,6 @@ export function ServerHealthSection(): React.JSX.Element {
|
||||
<Text className={styles.statValue}>{status.version}</Text>
|
||||
</div>
|
||||
)}
|
||||
{status.bangui_version && (
|
||||
<div className={styles.statCard}>
|
||||
<Text className={styles.statLabel}>BanGUI</Text>
|
||||
<Text className={styles.statValue}>{status.bangui_version}</Text>
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.statCard}>
|
||||
<Text className={styles.statLabel}>Active Jails</Text>
|
||||
<Text className={styles.statValue}>{status.jail_count}</Text>
|
||||
|
||||
@@ -15,11 +15,10 @@ describe("ServerHealthSection", () => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("shows the BanGUI version in the service health panel", async () => {
|
||||
it("shows the version in the service health panel", async () => {
|
||||
mockedFetchServiceStatus.mockResolvedValue({
|
||||
online: true,
|
||||
version: "1.2.3",
|
||||
bangui_version: "1.2.3",
|
||||
jail_count: 2,
|
||||
total_bans: 5,
|
||||
total_failures: 1,
|
||||
@@ -41,11 +40,11 @@ describe("ServerHealthSection", () => {
|
||||
</FluentProvider>,
|
||||
);
|
||||
|
||||
// The service health panel should render and include the BanGUI version.
|
||||
const banGuiLabel = await screen.findByText("BanGUI");
|
||||
expect(banGuiLabel).toBeInTheDocument();
|
||||
// The service health panel should render and include the version.
|
||||
const versionLabel = await screen.findByText("Version");
|
||||
expect(versionLabel).toBeInTheDocument();
|
||||
|
||||
const banGuiCard = banGuiLabel.closest("div");
|
||||
expect(banGuiCard).toHaveTextContent("1.2.3");
|
||||
const versionCard = versionLabel.closest("div");
|
||||
expect(versionCard).toHaveTextContent("1.2.3");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user