add empty view if logs disabled
This commit is contained in:
1 parent
9a541dac21
commit
e2362ca809
3 files changed
+22
-4
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
// Components
|
// Components
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { BaseBox } from "@/Components/design-elements";
|
import { BaseBox, EmptyState } from "@/Components/design-elements";
|
||||||
import { Button } from "@/Components/inputs";
|
import { Button } from "@/Components/inputs";
|
||||||
import { HeaderLogs } from "@/Pages/Docker/ContainerDetails/Components/HeaderLogs";
|
import { HeaderLogs } from "@/Pages/Docker/ContainerDetails/Components/HeaderLogs";
|
||||||
import { RowLog } from "@/Pages/Docker/ContainerDetails/Components/RowLog";
|
import { RowLog } from "@/Pages/Docker/ContainerDetails/Components/RowLog";
|
||||||
@@ -32,6 +32,7 @@ import { flattenDockerLogs } from "@/Utils/MonitorUtils";
|
|||||||
interface TabLogsProps {
|
interface TabLogsProps {
|
||||||
monitorId?: string;
|
monitorId?: string;
|
||||||
containerName?: string;
|
containerName?: string;
|
||||||
|
enabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SCROLL_PIN_THRESHOLD_PX = 8;
|
const SCROLL_PIN_THRESHOLD_PX = 8;
|
||||||
@@ -45,7 +46,7 @@ const fetchLogs = async (url: string, params: { before?: string; after?: string
|
|||||||
return res.data.data;
|
return res.data.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TabLogs = ({ monitorId, containerName }: TabLogsProps) => {
|
export const TabLogs = ({ monitorId, containerName, enabled }: TabLogsProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { toastError } = useToast();
|
const { toastError } = useToast();
|
||||||
@@ -58,7 +59,7 @@ export const TabLogs = ({ monitorId, containerName }: TabLogsProps) => {
|
|||||||
const [lastUpdatedAt, setLastUpdatedAt] = useState<number | null>(null);
|
const [lastUpdatedAt, setLastUpdatedAt] = useState<number | null>(null);
|
||||||
|
|
||||||
const logsUrl =
|
const logsUrl =
|
||||||
monitorId && containerName
|
enabled && monitorId && containerName
|
||||||
? `/monitors/docker/details/${encodeURIComponent(monitorId)}/containers/${encodeURIComponent(containerName)}/logs`
|
? `/monitors/docker/details/${encodeURIComponent(monitorId)}/containers/${encodeURIComponent(containerName)}/logs`
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
@@ -167,6 +168,17 @@ export const TabLogs = ({ monitorId, containerName }: TabLogsProps) => {
|
|||||||
}
|
}
|
||||||
}, [logsUrl, oldestCursor, loadingOlder, t, toastError]);
|
}, [logsUrl, oldestCursor, loadingOlder, t, toastError]);
|
||||||
|
|
||||||
|
if (!enabled) {
|
||||||
|
return (
|
||||||
|
<EmptyState
|
||||||
|
title={t("pages.docker.container.logs.disabled.title")}
|
||||||
|
description={t("pages.docker.container.logs.disabled.description")}
|
||||||
|
actionText={t("pages.docker.container.logs.disabled.action")}
|
||||||
|
actionTo={`/docker/configure/${monitorId}`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap={LAYOUT.MD}>
|
<Stack gap={LAYOUT.MD}>
|
||||||
<HeaderLogs
|
<HeaderLogs
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ const DockerDetailsPage = ({ open = "logs" }: DockerContainerDetailsProps) => {
|
|||||||
<TabLogs
|
<TabLogs
|
||||||
monitorId={monitorId}
|
monitorId={monitorId}
|
||||||
containerName={containerName}
|
containerName={containerName}
|
||||||
|
enabled={monitor.dockerLogsEnabled ?? false}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</BasePage>
|
</BasePage>
|
||||||
|
|||||||
@@ -976,7 +976,12 @@
|
|||||||
"loadingOlder": "Loading...",
|
"loadingOlder": "Loading...",
|
||||||
"noOlder": "Beginning of retained logs",
|
"noOlder": "Beginning of retained logs",
|
||||||
"loadError": "Could not load logs",
|
"loadError": "Could not load logs",
|
||||||
"loadOlderError": "Could not load older logs"
|
"loadOlderError": "Could not load older logs",
|
||||||
|
"disabled": {
|
||||||
|
"title": "Log collection is off for this host",
|
||||||
|
"description": "Turn on container logs in the monitor settings to start collecting.",
|
||||||
|
"action": "Configure monitor"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"host": {
|
"host": {
|
||||||
|
|||||||
Reference in new issue
Block a user