Skip to content

Commit

Permalink
allow admins to kill any run
Browse files Browse the repository at this point in the history
  • Loading branch information
zmc committed Apr 9, 2024
1 parent 33c4f36 commit c5f6ace
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/components/KillButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/teuthologyAPI.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
export type Session = {
session: {
id: int,
username: string
role: string,
state: string,
username: string,
access_token: string,
}
}

Expand Down

0 comments on commit c5f6ace

Please sign in to comment.