diff --git a/web/src/pages/Settings.tsx b/web/src/pages/Settings.tsx index 368d4dea0..06bf65fd5 100644 --- a/web/src/pages/Settings.tsx +++ b/web/src/pages/Settings.tsx @@ -73,7 +73,11 @@ export default function Settings() { const isAdmin = useIsAdmin(); - const allowedViewsForViewer: SettingsType[] = ["ui", "debug"]; + const allowedViewsForViewer: SettingsType[] = [ + "ui", + "debug", + "notifications", + ]; const visibleSettingsViews = !isAdmin ? allowedViewsForViewer : allSettingsViews; @@ -164,7 +168,7 @@ export default function Settings() { useSearchEffect("page", (page: string) => { if (allSettingsViews.includes(page as SettingsType)) { // Restrict viewer to UI settings - if (!isAdmin && !["ui", "debug"].includes(page)) { + if (!isAdmin && !allowedViewsForViewer.includes(page as SettingsType)) { setPage("ui"); } else { setPage(page as SettingsType); @@ -200,7 +204,7 @@ export default function Settings() { onValueChange={(value: SettingsType) => { if (value) { // Restrict viewer navigation - if (!isAdmin && !["ui", "debug"].includes(value)) { + if (!isAdmin && !allowedViewsForViewer.includes(value)) { setPageToggle("ui"); } else { setPageToggle(value); diff --git a/web/src/views/settings/NotificationsSettingsView.tsx b/web/src/views/settings/NotificationsSettingsView.tsx index ab0241e24..7381c20dc 100644 --- a/web/src/views/settings/NotificationsSettingsView.tsx +++ b/web/src/views/settings/NotificationsSettingsView.tsx @@ -46,6 +46,8 @@ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { Trans, useTranslation } from "react-i18next"; import { useDateLocale } from "@/hooks/use-date-locale"; import { useDocDomain } from "@/hooks/use-doc-domain"; +import { useIsAdmin } from "@/hooks/use-is-admin"; +import { cn } from "@/lib/utils"; const NOTIFICATION_SERVICE_WORKER = "notifications-worker.js"; @@ -64,6 +66,10 @@ export default function NotificationView({ const { t } = useTranslation(["views/settings"]); const { getLocaleDocUrl } = useDocDomain(); + // roles + + const isAdmin = useIsAdmin(); + const { data: config, mutate: updateConfig } = useSWR( "config", { @@ -380,7 +386,11 @@ export default function NotificationView({
-
+
{t("notification.notificationSettings.title")} @@ -403,138 +413,151 @@ export default function NotificationView({
-
- - ( - - {t("notification.email.title")} - - - - - {t("notification.email.desc")} - - - - )} - /> + {isAdmin && ( + + + ( + + {t("notification.email.title")} + + + + + {t("notification.email.desc")} + + + + )} + /> - ( - - {allCameras && allCameras?.length > 0 ? ( - <> -
- - {t("notification.cameras.title")} - -
-
- ( + ( + + {allCameras && allCameras?.length > 0 ? ( + <> +
+ + {t("notification.cameras.title")} + +
+
+ ( + { + setChangedValue(true); + if (checked) { + form.setValue("cameras", []); + } + field.onChange(checked); + }} + /> + )} + /> + {allCameras?.map((camera) => ( { setChangedValue(true); + let newCameras; if (checked) { - form.setValue("cameras", []); + newCameras = [ + ...field.value, + camera.name, + ]; + } else { + newCameras = field.value?.filter( + (value) => value !== camera.name, + ); } - field.onChange(checked); + field.onChange(newCameras); + form.setValue("allEnabled", false); }} /> - )} - /> - {allCameras?.map((camera) => ( - { - setChangedValue(true); - let newCameras; - if (checked) { - newCameras = [ - ...field.value, - camera.name, - ]; - } else { - newCameras = field.value?.filter( - (value) => value !== camera.name, - ); - } - field.onChange(newCameras); - form.setValue("allEnabled", false); - }} - /> - ))} + ))} +
+ + ) : ( +
+ {t("notification.cameras.noCameras")}
- - ) : ( -
- {t("notification.cameras.noCameras")} -
- )} + )} - - - {t("notification.cameras.desc")} - -
- )} - /> - -
- - -
- - + /> + +
+ + +
+ + + )}
-
- - +
+ + {t("notification.deviceSpecific")}
- {notificationCameras.length > 0 && ( + {isAdmin && notificationCameras.length > 0 && (