From 01d198016d2f379d31f4457a5efe62c0c9eea8a8 Mon Sep 17 00:00:00 2001 From: agatha197 Date: Tue, 5 Nov 2024 23:26:58 +0900 Subject: [PATCH] refactor: parsing image data in session launcher for before 24.12 --- .../ImageEnvironmentSelectFormItems.tsx | 57 ++++-------- react/src/pages/SessionLauncherPage.tsx | 86 ++++++++++++------- 2 files changed, 74 insertions(+), 69 deletions(-) diff --git a/react/src/components/ImageEnvironmentSelectFormItems.tsx b/react/src/components/ImageEnvironmentSelectFormItems.tsx index 91e5b320a..f88114e07 100644 --- a/react/src/components/ImageEnvironmentSelectFormItems.tsx +++ b/react/src/components/ImageEnvironmentSelectFormItems.tsx @@ -10,6 +10,7 @@ import Flex from './Flex'; // @ts-ignore import cssRaw from './ImageEnvironmentSelectFormItems.css?raw'; import ImageMetaIcon from './ImageMetaIcon'; +import { ImageTags } from './ImageTags'; import TextHighlighter from './TextHighlighter'; import { ImageEnvironmentSelectFormItemsQuery, @@ -98,7 +99,8 @@ const ImageEnvironmentSelectFormItems: React.FC< const [environmentSearch, setEnvironmentSearch] = useState(''); const [versionSearch, setVersionSearch] = useState(''); const { t } = useTranslation(); - const [metadata, { getImageMeta, tagAlias }] = useBackendAIImageMetaData(); + const [metadata, { getBaseVersion, getImageMeta, tagAlias }] = + useBackendAIImageMetaData(); const { token } = theme.useToken(); const { isDarkMode } = useThemeMode(); @@ -584,25 +586,11 @@ const ImageEnvironmentSelectFormItems: React.FC< paddingLeft: token.paddingSM, }} > - {supportExtendedImageInfo ? ( - <> - {t('session.launcher.Version')} - - {t('session.launcher.Architecture')} - - {t('session.launcher.Tags')} - - ) : ( - <> - {t('session.launcher.Version')} - - {t('session.launcher.Base')} - - {t('session.launcher.Architecture')} - - {t('session.launcher.Requirements')} - - )} + {t('session.launcher.Version')} + + {t('session.launcher.Architecture')} + + {t('session.launcher.Tags')} {menu} @@ -796,29 +784,22 @@ const ImageEnvironmentSelectFormItems: React.FC< - {version} - - - - {metadataTagAlias} + {getBaseVersion(getImageFullName(image) || '')} {image?.architecture} - - - {requirementTags || '-'} + + + } + /> )} diff --git a/react/src/pages/SessionLauncherPage.tsx b/react/src/pages/SessionLauncherPage.tsx index f2b465859..dccfa01c8 100644 --- a/react/src/pages/SessionLauncherPage.tsx +++ b/react/src/pages/SessionLauncherPage.tsx @@ -11,7 +11,7 @@ import ImageEnvironmentSelectFormItems, { ImageEnvironmentFormInput, } from '../components/ImageEnvironmentSelectFormItems'; import ImageMetaIcon from '../components/ImageMetaIcon'; -import SessionKernelTags from '../components/ImageTags'; +import { ImageTags } from '../components/ImageTags'; import { mainContentDivRefState } from '../components/MainLayout/MainLayout'; import PortSelectFormItem, { PortSelectFormValues, @@ -41,6 +41,7 @@ import { generateRandomString, getImageFullName, iSizeToSize, + preserveDotStartCase, } from '../helper'; import { useBackendAIImageMetaData, @@ -188,7 +189,8 @@ const SessionLauncherPage = () => { const currentUserRole = useCurrentUserRole(); const [currentGlobalResourceGroup, setCurrentGlobalResourceGroup] = useCurrentResourceGroupState(); - const [, { tagAlias }] = useBackendAIImageMetaData(); + const [, { getBaseVersion, getBaseImage, tagAlias }] = + useBackendAIImageMetaData(); const supportExtendedImageInfo = baiClient?.supports('extended-image-info') ?? false; @@ -1392,7 +1394,15 @@ const SessionLauncherPage = () => { }, )?.value : tag.value; - return ( + const aliasedTag = tagAlias( + tag.key + tagValue, + ); + return _.isEqual( + aliasedTag, + preserveDotStartCase( + tag.key + tagValue, + ), + ) ? ( { }, ]} /> + ) : ( + + {aliasedTag} + ); }, )} @@ -1463,36 +1482,41 @@ const SessionLauncherPage = () => { ) : ( <> - + {tagAlias( + getBaseImage( + form.getFieldValue('environments') + ?.version, + ), + )} + + + + {getBaseVersion( + form.getFieldValue('environments') + ?.version, + )} + + + + { form.getFieldValue('environments') - ?.version + ?.image?.architecture + } + + + } - /> - {form.getFieldValue('environments') - ?.customizedTag ? ( - - ) : null} - )}