diff --git a/react/src/components/SessionList.tsx b/react/src/components/SessionList.tsx index 66931034e1..dcf038e67e 100644 --- a/react/src/components/SessionList.tsx +++ b/react/src/components/SessionList.tsx @@ -1,15 +1,8 @@ import { useSuspendedBackendaiClient, useUpdatableState } from '../hooks'; -import { useBackendAIImageMetaData } from '../hooks'; -import DoubleTag from './DoubleTag'; -import Flex from './Flex'; -import ImageMetaIcon from './ImageMetaIcon'; -import ResourceNumber from './ResourceNumber'; import SessionInfoCell from './SessionListColums/SessionInfoCell'; import { SessionListQuery } from './__generated__/SessionListQuery.graphql'; -import { FolderOutlined, GroupOutlined } from '@ant-design/icons'; -import { Table, TableProps, Tag, Typography, theme } from 'antd'; +import { Table, TableProps } from 'antd'; import graphql from 'babel-plugin-relay/macro'; -import _ from 'lodash'; import React, { useDeferredValue } from 'react'; import { useTranslation } from 'react-i18next'; import { useLazyLoadQuery } from 'react-relay'; @@ -26,7 +19,6 @@ interface SessionListProps extends Omit, 'dataSource'> { filter: (item: Session) => boolean; extraFetchKey?: string; } - const SessionList: React.FC = ({ status = [], limit = 50, @@ -42,9 +34,6 @@ const SessionList: React.FC = ({ const [fetchKey, updateFetchKey] = useUpdatableState('initial-fetch'); const deferredMergedFetchKey = useDeferredValue(fetchKey + extraFetchKey); const { t } = useTranslation(); - const { token } = theme.useToken(); - const [, { getImageAliasName, getBaseVersion, getBaseImage }] = - useBackendAIImageMetaData(); if ( !baiClient.supports('avoid-hol-blocking') && @@ -86,9 +75,7 @@ const SessionList: React.FC = ({ occupied_slots access_key starts_at - scaling_group - agents - image + cluster_size @skipOnClient(if: $skipClusterSize) ...SessionInfoCellFragment } @@ -110,44 +97,15 @@ const SessionList: React.FC = ({ }, ); - const statusTagColor = { - //prepare - RESTARTING: 'blue', - PREPARING: 'blue', - PULLING: 'blue', - //running - RUNNING: 'green', - PENDING: 'green', - SCHEDULED: 'green', - //error - ERROR: 'red', - //finished return undefined - }; - - const statusInfoTagColor = { - 'idle-timeout': 'green', - 'user-requested': 'green', - scheduled: 'green', - 'self-terminated': 'green', - 'no-available-instances': 'red', - 'failed-to-start': 'red', - 'creation-failed': 'red', - }; - - const typeTagColor = { - INTERACTIVE: 'green', - BATCH: 'darkgreen', - INFERENCE: 'blue', - }; - return ( <> = ({ { title: t('session.Status'), dataIndex: 'status', - render(value, record) { - return ( - <> - {record.status_info !== '' ? ( - - ) : ( - {value} - )} - - ); - }, }, { title: t('general.Control'), }, { title: t('session.Configuration'), - dataIndex: 'mounts', - render(value, record) { - return ( - <> - {value.length > 0 ? ( - - - - {_.map(value, (mountedFolder) => { - return
{mountedFolder}
; - })} -
- ), - }} - > - {value.join(', ')} - - - ) : ( - - - No mount - - )} - - - {record.scaling_group} - - - {record.occupied_slots && - _.map( - JSON.parse(record.occupied_slots), - (value, type) => { - return ( - - ); - }, - )} - - - ); - }, }, { title: t('session.Usage'), }, { title: t('session.Reservation'), - dataIndex: 'created_at', - render(value, record) { - const localeStringDate = new Date(value).toLocaleString(); - const elapsedTime = baiClient.utils.elapsedTime( - value, - record.terminated_at, - ); - return ( - - {localeStringDate} - - - ); - }, }, { - title: t('session.EnvironmentInfo'), - render: (record) => { - return ( - - - - - {/*
to apply gap */} -
{getImageAliasName(record.image)}
- {getBaseVersion(record.image)} - - - {/*
to apply gap */} -
{getBaseImage(record.image)}
- {record.architecture} - - - - ); - }, + title: t('session.Architecture'), }, { title: t('session.SessionType'), - dataIndex: 'type', - render: (value) => { - return {value}; - }, }, - ...(baiClient.is_admin || !!baiClient._config.hideAgents - ? [ - { - title: t('session.Agent'), - dataIndex: 'agents', - render(value: string[]) { - return _.map(value, (agent) => { - return agent; - }); - }, - }, - ] - : []), + { + title: t('session.Agent'), + }, ]} // @ts-ignore dataSource={(compute_session_list?.items || []).filter(filter)} diff --git a/react/src/components/SessionListColums/SessionInfoCell.tsx b/react/src/components/SessionListColums/SessionInfoCell.tsx index 6160e54d40..c3a27b66a7 100644 --- a/react/src/components/SessionListColums/SessionInfoCell.tsx +++ b/react/src/components/SessionListColums/SessionInfoCell.tsx @@ -4,6 +4,8 @@ import { } from '../../hooks'; import { useTanMutation } from '../../hooks/reactQueryAlias'; import Flex from '../Flex'; +import ImageMetaIcon from '../ImageMetaIcon'; +import SessionKernelTag from '../SessionKernelTag'; import { SessionInfoCellFragment$key } from './__generated__/SessionInfoCellFragment.graphql'; import { EditOutlined } from '@ant-design/icons'; import { Button, Form, Input, Typography, theme } from 'antd'; @@ -88,59 +90,62 @@ const SessionInfoCell: React.FC<{ // sessions[objectKey].icon = this._getKernelIcon(session.image); // sessions[objectKey].sessionTags = this._getKernelInfo(session.image); return ( -
- {editing ? ( - - save()} - onKeyUp={(e) => { - if (e.key === 'Escape') setEditing(false); - }} - /> - - ) : ( - - - {optimisticName} - - {editable && ( - + + + + {editing ? ( + + save()} + onKeyUp={(e) => { + if (e.key === 'Escape') setEditing(false); + }} + /> + + ) : ( + <> + + {optimisticName} + + {editable && ( + + )} + )} - - )} - + + + + + ); };