gate client side log page behind admin check
This commit is contained in:
1 parent
fd7b3e5f20
commit
533783ba3e
2 files changed
+15
No files matched your search
@@ -23,6 +23,7 @@ import {
|
|||||||
import { useTheme } from "@mui/material";
|
import { useTheme } from "@mui/material";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useToast } from "@/Hooks/UseToast";
|
import { useToast } from "@/Hooks/UseToast";
|
||||||
|
import { useIsAdmin } from "@/Hooks/useIsAdmin";
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { get } from "@/Utils/ApiClient";
|
import { get } from "@/Utils/ApiClient";
|
||||||
@@ -50,6 +51,7 @@ 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();
|
||||||
|
const isAdmin = useIsAdmin();
|
||||||
|
|
||||||
// logs is newest-first, matching the API and what flattenDockerLogs expects.
|
// logs is newest-first, matching the API and what flattenDockerLogs expects.
|
||||||
const [logs, setLogs] = useState<DockerLog[]>([]);
|
const [logs, setLogs] = useState<DockerLog[]>([]);
|
||||||
@@ -168,6 +170,15 @@ export const TabLogs = ({ monitorId, containerName, enabled }: TabLogsProps) =>
|
|||||||
}
|
}
|
||||||
}, [logsUrl, oldestCursor, loadingOlder, t, toastError]);
|
}, [logsUrl, oldestCursor, loadingOlder, t, toastError]);
|
||||||
|
|
||||||
|
if (!isAdmin) {
|
||||||
|
return (
|
||||||
|
<EmptyState
|
||||||
|
title={t("pages.docker.container.logs.forbidden.title")}
|
||||||
|
description={t("pages.docker.container.logs.forbidden.description")}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
return (
|
return (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
|
|||||||
@@ -985,6 +985,10 @@
|
|||||||
"title": "Log collection is off for this host",
|
"title": "Log collection is off for this host",
|
||||||
"description": "Turn on container logs in the monitor settings to start collecting.",
|
"description": "Turn on container logs in the monitor settings to start collecting.",
|
||||||
"action": "Configure monitor"
|
"action": "Configure monitor"
|
||||||
|
},
|
||||||
|
"forbidden": {
|
||||||
|
"title": "You don't have access to container logs",
|
||||||
|
"description": "Only administrators can view logs. Ask an administrator for access if you need to see them."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user