- New EmptyState + EmptyStateIllustration components: stacked-cards SVG with grid background, theme-aware light/dark palette. - Variants: default (centered with title + description), compact (horizontal, in-section), fullscreen (vertically centers in viewport). - Wired into Checks, Incidents, Logs (Logs+Queue tabs), Notifications, Maintenance, Status pages, and Team tab — each with i18n title + description and a fullscreen layout when truly empty. - Table.EmptyView now wraps the EmptyState in a divider-bordered card so short messages no longer look orphaned. - Incidents Option-A short-circuit: when summary.total === 0, replace the whole page chrome with EmptyState; otherwise keep filters + cards. - Fallback.tsx (BaseFallback / EmptyFallback / EmptyMonitorFallback / ErrorFallback) refactored to delegate to EmptyState.
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { BasePageWithStates } from "@/Components/design-elements";
|
|
import { HeaderCreate } from "@/Components/common";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useGet } from "@/Hooks/UseApi";
|
|
import { MaintenanceWindowTable } from "./MaintenanceWindowTable";
|
|
import { useState } from "react";
|
|
import { useSelector } from "react-redux";
|
|
import type { RootState } from "@/Types/state";
|
|
import type { MaintenanceWindow } from "@/Types/MaintenanceWindow";
|
|
import { useIsAdmin } from "@/Hooks/useIsAdmin";
|
|
|
|
interface MaintenanceWindowsResponse {
|
|
maintenanceWindows: MaintenanceWindow[];
|
|
maintenanceWindowCount: number;
|
|
}
|
|
|
|
const MaintenanceWindowPage = () => {
|
|
const { t } = useTranslation();
|
|
const isAdmin = useIsAdmin();
|
|
const [page, setPage] = useState(0);
|
|
const rowsPerPage = useSelector(
|
|
(state: RootState) => state?.ui?.maintenance?.rowsPerPage ?? 5
|
|
);
|
|
|
|
const { data, isLoading, isValidating, error, refetch } =
|
|
useGet<MaintenanceWindowsResponse>(
|
|
`/maintenance-window/team?page=${page}&rowsPerPage=${rowsPerPage}`
|
|
);
|
|
|
|
const maintenanceWindows = data?.maintenanceWindows ?? [];
|
|
const maintenanceWindowCount = data?.maintenanceWindowCount ?? 0;
|
|
|
|
return (
|
|
<BasePageWithStates
|
|
headerKey="maintenanceWindow"
|
|
page={t("pages.maintenanceWindow.fallback.title")}
|
|
totalCount={maintenanceWindowCount}
|
|
description={t("pages.maintenanceWindow.fallback.description")}
|
|
loading={isLoading}
|
|
error={!!error}
|
|
actionButtonText={t("pages.maintenanceWindow.fallback.actionButton")}
|
|
actionLink="/maintenance/create"
|
|
>
|
|
<HeaderCreate
|
|
path="/maintenance/create"
|
|
isLoading={isLoading || isValidating}
|
|
isAdmin={isAdmin}
|
|
/>
|
|
<MaintenanceWindowTable
|
|
maintenanceWindows={maintenanceWindows}
|
|
maintenanceWindowCount={maintenanceWindowCount}
|
|
page={page}
|
|
setPage={setPage}
|
|
refetch={refetch}
|
|
/>
|
|
</BasePageWithStates>
|
|
);
|
|
};
|
|
|
|
export default MaintenanceWindowPage;
|