From 2d50003a3d57402b1d6adb203fcb217dc2b56d03 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Fri, 10 May 2024 17:09:23 +0530 Subject: [PATCH] KillButton: disable when user is not admin Read "isUserAdmin" from useSession and disable "Kill as Admin" button if isUserAdmin is false Signed-off-by: Vallari Agrawal --- src/components/KillButton/index.tsx | 10 ++++++++-- src/lib/teuthologyAPI.d.ts | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/KillButton/index.tsx b/src/components/KillButton/index.tsx index 71a5442..d9d330b 100644 --- a/src/components/KillButton/index.tsx +++ b/src/components/KillButton/index.tsx @@ -8,6 +8,7 @@ import DialogContent from '@mui/material/DialogContent'; import Dialog from '@mui/material/Dialog'; import Paper from "@mui/material/Paper"; import Typography from "@mui/material/Typography"; +import Tooltip from '@mui/material/Tooltip'; import { KillRunPayload } from "../../lib/teuthologyAPI.d"; import { useSession } from "../../lib/teuthologyAPI"; @@ -32,7 +33,7 @@ export default function KillButton(props: KillButtonProps) { const mutation: UseMutationResult = props.mutation; const sessionQuery = useSession(); const loggedUser = sessionQuery.data?.session?.username; - + const isUserAdmin = sessionQuery.data?.session?.isUserAdmin; const owner = props.payload["--owner"].toLowerCase() const isOwner = (loggedUser?.toLowerCase() == owner) || (`scheduled_${loggedUser?.toLowerCase()}@teuthology` == owner) @@ -49,16 +50,21 @@ export default function KillButton(props: KillButtonProps) { return (
+ + + +