From c5f6ace5bf1bb65abbe9eaf2c44f03c248265150 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Tue, 9 Apr 2024 14:31:52 -0600 Subject: [PATCH] allow admins to kill any run --- src/components/KillButton/index.tsx | 9 ++++++++- src/lib/teuthologyAPI.d.ts | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/KillButton/index.tsx b/src/components/KillButton/index.tsx index e9dd637..bb4ca3a 100644 --- a/src/components/KillButton/index.tsx +++ b/src/components/KillButton/index.tsx @@ -33,8 +33,15 @@ export default function KillButton(props: KillButtonProps) { const mutation: UseMutationResult = props.mutation; const sessionQuery = useSession(); const loggedUser = sessionQuery.data?.session?.username; + const sessionData = sessionQuery.data?.session; + const username = sessionData?.username; + const isAdmin = sessionData? sessionData.role == "admin" : false; - if (loggedUser?.toLowerCase() != props.payload["--owner"].toLowerCase()) { + if ( + username && + username.toLowerCase() != props.payload["--owner"].toLowerCase() || + isAdmin + ) { // logged user and owner of the job should be equal (case insensitive) return null } diff --git a/src/lib/teuthologyAPI.d.ts b/src/lib/teuthologyAPI.d.ts index 9404c2e..db55726 100644 --- a/src/lib/teuthologyAPI.d.ts +++ b/src/lib/teuthologyAPI.d.ts @@ -2,7 +2,10 @@ export type Session = { session: { id: int, - username: string + role: string, + state: string, + username: string, + access_token: string, } }