diff --git a/src/components/KillButton/index.tsx b/src/components/KillButton/index.tsx
index e9dd637..5297e7b 100644
--- a/src/components/KillButton/index.tsx
+++ b/src/components/KillButton/index.tsx
@@ -32,20 +32,24 @@ export default function KillButton(props: KillButtonProps) {
const [open, setOpen] = useState(false);
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;
+ console.log("session", sessionData);
- if (loggedUser?.toLowerCase() != props.payload["--owner"].toLowerCase()) {
- // logged user and owner of the job should be equal (case insensitive)
+ if (!isAdmin &&
+ username.toLowerCase() != props.payload["--owner"].toLowerCase()
+ ) {
return null
}
const toggleDialog = () => {
setOpen(!open);
};
-
+
return (
-
+
- { (mutation.isError) ?
: null }
- { (mutation.isSuccess) ?
: null }
-
+ {(mutation.isError) ?
: null}
+ {(mutation.isSuccess) ?
: null}
+
);
};
-function KillButtonDialog({mutation, open, handleClose, payload}: KillButtonDialogProps) {
+function KillButtonDialog({ mutation, open, handleClose, payload }: KillButtonDialogProps) {
return (
:
(mutation.isLoading) ? (
-
-
+
+
Killing run...
- ) :
- (mutation.isError) ? (
-
-
- Failed!
-
-
-
- {mutation.error?.response?.data?.detail}
+ ) :
+ (mutation.isError) ? (
+
+
+ Failed!
-
-
- ) :
-
-
- Are you sure you want to kill this run/job?
-
-
-
+
+
+ {mutation.error?.response?.data?.detail}
+
+
+
+ ) :
+
+
+ Are you sure you want to kill this run/job?
+
+
+
}
- )
+ )
}
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,
}
}