Skip to content

Commit

Permalink
fix: set session detail panel version compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ironAiken2 committed Feb 5, 2025
1 parent 51122ce commit 719095d
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 28 deletions.
20 changes: 13 additions & 7 deletions react/src/components/SessionDetailAndContainerLogOpenerLegacy.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useSuspendedBackendaiClient } from '../hooks';
import ContainerLogModalWithLazyQueryLoader from './ComputeSessionNodeItems/ContainerLogModalWithLazyQueryLoader';
import SessionDetailDrawer from './SessionDetailDrawer';
import { useState, useEffect, useTransition } from 'react';
Expand All @@ -8,6 +9,7 @@ const SessionDetailAndContainerLogOpenerLegacy = () => {
const [containerLogModalSessionId, setContainerLogModalSessionId] =
useState<string>();
const [isPendingLogModalOpen, startLogModalOpenTransition] = useTransition();
const baiClient = useSuspendedBackendaiClient();

useEffect(() => {
const handler = (e: any) => {
Expand All @@ -21,15 +23,19 @@ const SessionDetailAndContainerLogOpenerLegacy = () => {
};
}, [startLogModalOpenTransition, setContainerLogModalSessionId]);

const supportSessionDetailPanel = baiClient?.supports('session-node');

return (
<>
<SessionDetailDrawer
open={!sessionId}
sessionId={sessionId || undefined}
onClose={() => {
setSessionId(null, 'replaceIn');
}}
/>
{supportSessionDetailPanel ? (
<SessionDetailDrawer
open={!sessionId}
sessionId={sessionId || undefined}
onClose={() => {
setSessionId(null, 'replaceIn');
}}
/>
) : null}
<ContainerLogModalWithLazyQueryLoader
open={!!containerLogModalSessionId || isPendingLogModalOpen}
loading={isPendingLogModalOpen}
Expand Down
40 changes: 21 additions & 19 deletions react/src/components/SessionDetailContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,25 +232,27 @@ const SessionDetailContent: React.FC<{
)}
</Descriptions.Item>
<Descriptions.Item label={t('session.launcher.MountedFolders')}>
{_.map(
_.zip(legacy_session?.mounts, session?.vfolder_mounts),
(mountInfo) => {
const [name, id] = mountInfo;
return (
<Button
key={id}
type="link"
size="small"
icon={<FolderOutlined />}
onClick={() => {
open(id ?? '');
}}
>
{name}
</Button>
);
},
)}
{baiClient.supports('vfolder-mounts')
? _.map(
_.zip(legacy_session?.mounts, session?.vfolder_mounts),
(mountInfo) => {
const [name, id] = mountInfo;
return (
<Button
key={id}
type="link"
size="small"
icon={<FolderOutlined />}
onClick={() => {
open(id ?? '');
}}
>
{name}
</Button>
);
},
)
: legacy_session?.mounts?.join(', ')}
</Descriptions.Item>
<Descriptions.Item label={t('session.launcher.ResourceAllocation')}>
<Flex gap={'sm'} wrap="wrap">
Expand Down
4 changes: 3 additions & 1 deletion react/src/pages/EndpointDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,16 @@ const EndpointDetailPage: React.FC<EndpointDetailPageProps> = () => {
title: t('modelService.SessionId'),
dataIndex: 'session',
render: (sessionId) => {
return (
return baiClient.supports('session-node') ? (
<Typography.Link
onClick={() => {
setSelectedSessionId(sessionId);
}}
>
{sessionId}
</Typography.Link>
) : (
<Typography.Text>{sessionId}</Typography.Text>
);
},
},
Expand Down
7 changes: 6 additions & 1 deletion src/components/backend-ai-session-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3117,9 +3117,11 @@ export default class BackendAISessionList extends BackendAIPage {
white-space: pre-wrap;
white-space-collapse: collapse;
word-break: break-all;
}
#session-name-field[data-allow-detail-panel='true'] {
cursor: pointer;
}
#session-name-field:hover {
#session-name-field[data-allow-detail-panel='true']:hover {
text-decoration: underline;
color: var(--token-colorLink);
}
Expand Down Expand Up @@ -3147,6 +3149,9 @@ export default class BackendAISessionList extends BackendAIPage {
<div class="horizontal center center-justified layout">
<pre
id="session-name-field"
data-allow-detail-panel=${globalThis.backendaiclient.supports(
'session-node',
)}
@click="${() => this.triggerOpenSessionDetailDrawer(rowData)}"
@keyup="${() => {}}"
>
Expand Down
3 changes: 3 additions & 0 deletions src/lib/backend.ai-client-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@ class Client {
if (this.isManagerVersionCompatibleWith(['25.1.0', '24.09.6', '24.03.12'])) {
this._features['vfolder-id-based'] = true;
}
if (this.isManagerVersionCompatibleWith(['25.1.1', '24.09.6'])) {
this._features['vfolder-mounts'] = true;
}
}

/**
Expand Down

0 comments on commit 719095d

Please sign in to comment.