@@ -4,7 +4,7 @@ import { PageActionType } from '@/config/types';
44import { createAxiosToken } from '@/hooks/use-chunk-request' ;
55import { ClusterStatusValueMap } from '@/pages/cluster-management/config' ;
66import { useIntl } from '@umijs/max' ;
7- import { Button } from 'antd' ;
7+ import { Button , message } from 'antd' ;
88import _ from 'lodash' ;
99import React , { useEffect , useMemo , useRef , useState } from 'react' ;
1010import styled from 'styled-components' ;
@@ -96,13 +96,16 @@ const AddModal: React.FC<AddModalProps> = (props) => {
9696 const selectSpecRef = useRef < CatalogSpec > ( { } as CatalogSpec ) ;
9797 const specListRef = useRef < any [ ] > ( [ ] ) ;
9898 const noCompatibleGPUsRef = useRef < boolean > ( false ) ;
99- const [ noCompatibleGPUs , setNoCompatibleGPUs ] = useState < boolean > ( false ) ;
10099
101100 const handleSumit = ( ) => {
102101 form . current ?. submit ?.( ) ;
103102 } ;
104103
105104 const handleSubmitAnyway = async ( ) => {
105+ if ( noCompatibleGPUsRef . current ) {
106+ message . error ( intl . formatMessage ( { id : 'models.catalog.nogpus.tips' } ) ) ;
107+ return ;
108+ }
106109 submitAnyway . current = true ;
107110 form . current ?. submit ?.( ) ;
108111 } ;
@@ -266,7 +269,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
266269 // If no avaliable gpus for the model, show warning message
267270 if ( ! res . items . length ) {
268271 noCompatibleGPUsRef . current = true ;
269- setNoCompatibleGPUs ( true ) ;
270272 setWarningStatus ( {
271273 show : true ,
272274 type : 'warning' ,
@@ -275,7 +277,6 @@ const AddModal: React.FC<AddModalProps> = (props) => {
275277 return ;
276278 }
277279 noCompatibleGPUsRef . current = false ;
278- setNoCompatibleGPUs ( false ) ;
279280 handleCheckCompatibility ( allValues ) ;
280281 } catch ( error ) {
281282 // ignore
@@ -394,11 +395,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
394395 showOkBtn = { ! showExtraButton }
395396 extra = {
396397 showExtraButton && (
397- < Button
398- type = "primary"
399- onClick = { handleSubmitAnyway }
400- disabled = { noCompatibleGPUs }
401- >
398+ < Button type = "primary" onClick = { handleSubmitAnyway } >
402399 { intl . formatMessage ( {
403400 id : 'models.form.submit.anyway'
404401 } ) }
0 commit comments