Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 91 additions & 31 deletions react/src/components/ComputeSessionNodeItems/SessionActionButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({

const userInfo = useCurrentUserInfo();
const isOwner = userInfo[0]?.uuid === session?.user_id;
// The session row's access_key is set when the session was created.
// If the current keypair is different, manager APIs return 403
// ("Only admins can perform operations on behalf of other users.")
// for any per-session action — disable the buttons upfront instead.
const isAccessKeyMismatch =
!!session?.access_key &&
!!baiClient._config.accessKey &&
session.access_key !== baiClient._config.accessKey;
Comment thread
yomybaby marked this conversation as resolved.

// Only swap to the mismatch tooltip when switching access keys would
// actually unblock the user — i.e. they own the session. For non-owners
// the button is already disabled for a different reason and the mismatch
// copy ("Switch to that access key to manage this session") would be
// misleading.
const resolveTooltip = (defaultTitle: string) =>
isAccessKeyMismatch && isOwner
Comment thread
yomybaby marked this conversation as resolved.
Outdated
? t('session.AccessKeyMismatchTooltip')
: defaultTitle;

const hiddenButtons = React.useMemo(
() => new Set(hiddenButtonKeys ?? []),
Expand Down Expand Up @@ -181,26 +199,33 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
title={
isButtonTitleMode
? undefined
: t('session.ExecuteSpecificApp', {
appName: 'Jupyter Notebook',
})
: resolveTooltip(
t('session.ExecuteSpecificApp', {
appName: 'Jupyter Notebook',
}),
)
}
>
<Button
size={size}
type={'primary'}
disabled={
!isAppSupported(session) || !isActive(session) || !isOwner
!isAppSupported(session) ||
!isActive(session) ||
!isOwner ||
isAccessKeyMismatch
}
icon={<BAIJupyterIcon />}
onClick={() => {
launchApp();
}}
title={
isButtonTitleMode
? t('session.ExecuteSpecificApp', {
appName: 'Jupyter Notebook',
})
? resolveTooltip(
t('session.ExecuteSpecificApp', {
appName: 'Jupyter Notebook',
}),
)
: undefined
}
/>
Expand All @@ -211,26 +236,33 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
title={
isButtonTitleMode
? undefined
: t('session.ExecuteSpecificApp', {
appName: 'File browser',
})
: resolveTooltip(
t('session.ExecuteSpecificApp', {
appName: 'File browser',
}),
)
}
>
<Button
size={size}
type={'primary'}
disabled={
!isAppSupported(session) || !isActive(session) || !isOwner
!isAppSupported(session) ||
!isActive(session) ||
!isOwner ||
isAccessKeyMismatch
}
icon={<BAIFileBrowserIcon />}
onClick={() => {
launchApp();
}}
title={
isButtonTitleMode
? t('session.ExecuteSpecificApp', {
appName: 'File browser',
})
? resolveTooltip(
t('session.ExecuteSpecificApp', {
appName: 'File browser',
}),
)
: undefined
}
/>
Expand All @@ -241,31 +273,40 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
{isVisible('appLauncher') && (
<>
<Tooltip
title={isButtonTitleMode ? undefined : t('session.SeeAppDialog')}
title={
isButtonTitleMode
? undefined
: resolveTooltip(t('session.SeeAppDialog'))
}
>
<Button
size={size}
type={primaryAppOption ? undefined : 'primary'}
disabled={
!isAppSupported(session) || !isActive(session) || !isOwner
!isAppSupported(session) ||
!isActive(session) ||
!isOwner ||
isAccessKeyMismatch
}
icon={<BAIAppIcon />}
onClick={() => {
onAction?.('appLauncher');
setOpenAppLauncherModal(true);
}}
title={
isButtonTitleMode ? t('session.SeeAppDialog') : undefined
isButtonTitleMode
? resolveTooltip(t('session.SeeAppDialog'))
: undefined
}
/>
</Tooltip>
</>
)}
{isVisible('sftp') && (
<Tooltip title={t('data.explorer.RunSSH/SFTPserver')}>
<Tooltip title={resolveTooltip(t('data.explorer.RunSSH/SFTPserver'))}>
<Button
type="primary"
disabled={!isActive(session) || !isOwner}
disabled={!isActive(session) || !isOwner || isAccessKeyMismatch}
size={size}
icon={<BAISftpIcon />}
onClick={() => {
Expand All @@ -278,13 +319,18 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
<>
<Tooltip
title={
isButtonTitleMode ? undefined : t('session.ExecuteTerminalApp')
isButtonTitleMode
? undefined
: resolveTooltip(t('session.ExecuteTerminalApp'))
}
>
<Button
size={size}
disabled={
!isAppSupported(session) || !isActive(session) || !isOwner
!isAppSupported(session) ||
!isActive(session) ||
!isOwner ||
isAccessKeyMismatch
}
icon={<BAITerminalAppIcon />}
onClick={() => {
Expand All @@ -293,7 +339,7 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
}}
title={
isButtonTitleMode
? t('session.ExecuteTerminalApp')
? resolveTooltip(t('session.ExecuteTerminalApp'))
: undefined
}
/>
Expand All @@ -303,18 +349,23 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
{isVisible('logs') && (
<Tooltip
title={
isButtonTitleMode ? undefined : t('session.SeeContainerLogs')
isButtonTitleMode
? undefined
: resolveTooltip(t('session.SeeContainerLogs'))
}
>
<Button
size={size}
disabled={isAccessKeyMismatch}
Comment thread
yomybaby marked this conversation as resolved.
Outdated
icon={<BAISessionLogIcon />}
onClick={() => {
onAction?.('logs');
setOpenLogModal(true);
}}
title={
isButtonTitleMode ? t('session.SeeContainerLogs') : undefined
isButtonTitleMode
? resolveTooltip(t('session.SeeContainerLogs'))
: undefined
}
/>
</Tooltip>
Expand All @@ -324,20 +375,22 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
title={
isButtonTitleMode
? undefined
: t('session.RequestContainerCommit')
: resolveTooltip(t('session.RequestContainerCommit'))
}
>
<Button
size={size}
disabled={session?.status !== 'RUNNING' || !isOwner}
disabled={
session?.status !== 'RUNNING' || !isOwner || isAccessKeyMismatch
}
icon={<BAIContainerCommitIcon />}
onClick={() => {
onAction?.('containerCommit');
setOpenContainerCommitModal(true);
}}
title={
isButtonTitleMode
? t('session.RequestContainerCommit')
? resolveTooltip(t('session.RequestContainerCommit'))
: undefined
}
/>
Expand All @@ -346,16 +399,21 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
{isVisible('terminate') && (
<Tooltip
title={
isButtonTitleMode ? undefined : t('session.TerminateSession')
isButtonTitleMode
? undefined
: resolveTooltip(t('session.TerminateSession'))
}
>
<Button
size={size}
disabled={!isActive(session)}
disabled={!isActive(session) || isAccessKeyMismatch}
Comment thread
yomybaby marked this conversation as resolved.
Outdated
icon={
<BAITerminateIcon
style={{
color: isActive(session) ? token.colorError : undefined,
color:
isActive(session) && !isAccessKeyMismatch
? token.colorError
: undefined,
}}
/>
}
Expand All @@ -364,7 +422,9 @@ const SessionActionButtons: React.FC<SessionActionButtonsProps> = ({
setOpenTerminateModal(true);
}}
title={
isButtonTitleMode ? t('session.TerminateSession') : undefined
isButtonTitleMode
? resolveTooltip(t('session.TerminateSession'))
: undefined
}
/>
</Tooltip>
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,7 @@
"PendingSessions": "Ausstehende Sitzungen"
},
"session": {
"AccessKeyMismatchTooltip": "Diese Sitzung wurde mit einem anderen Zugriffsschlüssel erstellt. Wechseln Sie zu diesem Zugriffsschlüssel, um diese Sitzung zu verwalten.",
"ActiveSessions": "Aktive Sitzungen",
"Agent": "Agent",
"AgentId": "Agenten -ID",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@
"PendingSessions": "Εκκρεμείς συνεδρίες"
},
"session": {
"AccessKeyMismatchTooltip": "Αυτή η συνεδρία δημιουργήθηκε με διαφορετικό κλειδί πρόσβασης. Μεταβείτε σε εκείνο το κλειδί πρόσβασης για να διαχειριστείτε αυτή τη συνεδρία.",
"ActiveSessions": "Ενεργές συνεδρίες",
"Agent": "Μέσο",
"AgentId": "Αναγνωριστικό πράκτορα",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2513,6 +2513,7 @@
"PendingSessions": "Pending Sessions"
},
"session": {
"AccessKeyMismatchTooltip": "This session was created under a different access key. Switch to that access key to manage this session.",
"ActiveSessions": "Active Sessions",
"Agent": "Agent",
"AgentId": "Agent ID",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@
"PendingSessions": "Sesiones pendientes"
},
"session": {
"AccessKeyMismatchTooltip": "Esta sesión se creó con una clave de acceso diferente. Cambia a esa clave de acceso para gestionar esta sesión.",
"ActiveSessions": "Sesiones activas",
"Agent": "Agente",
"AgentId": "ID de agente",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@
"PendingSessions": "Vireillä olevat istunnot"
},
"session": {
"AccessKeyMismatchTooltip": "Tämä istunto luotiin eri käyttöavaimella. Vaihda kyseiseen käyttöavaimeen hallitaksesi tätä istuntoa.",
"ActiveSessions": "Aktiiviset istunnot",
"Agent": "Agentti",
"AgentId": "Agenttitunnus",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,7 @@
"PendingSessions": "Séances en attente"
},
"session": {
"AccessKeyMismatchTooltip": "Cette session a été créée avec une clé d’accès différente. Passez à cette clé d’accès pour gérer cette session.",
"ActiveSessions": "Sessions actives",
"Agent": "Agent",
"AgentId": "ID d'agent",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -2488,6 +2488,7 @@
"PendingSessions": "Sesi yang tertunda"
},
"session": {
"AccessKeyMismatchTooltip": "Sesi ini dibuat dengan kunci akses yang berbeda. Beralihlah ke kunci akses tersebut untuk mengelola sesi ini.",
"ActiveSessions": "Sesi aktif",
"Agent": "Agen",
"AgentId": "ID Agen",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@
"PendingSessions": "Sessioni in sospeso"
},
"session": {
"AccessKeyMismatchTooltip": "Questa sessione è stata creata con una chiave di accesso diversa. Passa a quella chiave di accesso per gestire questa sessione.",
"ActiveSessions": "Sessioni attive",
"Agent": "Agente",
"AgentId": "ID agente",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,7 @@
"PendingSessions": "保留中のセッション"
},
"session": {
"AccessKeyMismatchTooltip": "このセッションは別のアクセスキーで作成されました。このセッションを操作するには、そのアクセスキーに切り替えてください。",
"ActiveSessions": "アクティブセッション",
"Agent": "エージェント",
"AgentId": "エージェントID",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,7 @@
"PendingSessions": "대기 세션"
},
"session": {
"AccessKeyMismatchTooltip": "이 세션은 다른 액세스 키로 생성되었습니다. 이 세션을 관리하려면 해당 액세스 키로 전환하세요.",
"ActiveSessions": "활성 세션",
"Agent": "실행 노드",
"AgentId": "에이전트 ID",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/mn.json
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,7 @@
"PendingSessions": "Хүлээгдэж буй хуралдаанууд"
},
"session": {
"AccessKeyMismatchTooltip": "Энэ сешн өөр нэвтрэх түлхүүрээр үүсгэгдсэн. Энэ сешнийг удирдахын тулд тухайн нэвтрэх түлхүүр рүү шилжинэ үү.",
"ActiveSessions": "Идэвхтэй сешнүүд",
"Agent": "Агент",
"AgentId": "Хийнний ID",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@
"PendingSessions": "Sesi yang belum selesai"
},
"session": {
"AccessKeyMismatchTooltip": "Sesi ini dicipta dengan kunci akses yang berbeza. Tukar ke kunci akses tersebut untuk mengurus sesi ini.",
"ActiveSessions": "Sesi aktif",
"Agent": "Ejen",
"AgentId": "Id ejen",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,7 @@
"PendingSessions": "Oczekujące sesje"
},
"session": {
"AccessKeyMismatchTooltip": "Ta sesja została utworzona przy użyciu innego klucza dostępu. Przełącz się na ten klucz dostępu, aby zarządzać sesją.",
"ActiveSessions": "Aktywne sesje",
"Agent": "Agent",
"AgentId": "Identyfikator agenta",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@
"PendingSessions": "Sessões pendentes"
},
"session": {
"AccessKeyMismatchTooltip": "Esta sessão foi criada com uma chave de acesso diferente. Mude para essa chave de acesso para gerenciar esta sessão.",
"ActiveSessions": "Sessões ativas",
"Agent": "Agente",
"AgentId": "ID do agente",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,7 @@
"PendingSessions": "Sessões pendentes"
},
"session": {
"AccessKeyMismatchTooltip": "Esta sessão foi criada com uma chave de acesso diferente. Mude para essa chave de acesso para gerir esta sessão.",
"ActiveSessions": "Sessões ativas",
"Agent": "Agente",
"AgentId": "ID do agente",
Expand Down
1 change: 1 addition & 0 deletions resources/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@
"PendingSessions": "В ожидании сессий"
},
"session": {
"AccessKeyMismatchTooltip": "Эта сессия создана с использованием другого ключа доступа. Переключитесь на этот ключ доступа, чтобы управлять сессией.",
"ActiveSessions": "Активные сеансы",
"Agent": "Агент",
"AgentId": "Идентификатор агента",
Expand Down
Loading
Loading