fix: anyway submit disabled when no catalog specs

This commit is contained in:
jialin
2025-12-19 20:33:25 +08:00
parent 6e16b2eb0c
commit 6738dfe0d3
@@ -96,6 +96,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
const selectSpecRef = useRef<CatalogSpec>({} as CatalogSpec); const selectSpecRef = useRef<CatalogSpec>({} as CatalogSpec);
const specListRef = useRef<any[]>([]); const specListRef = useRef<any[]>([]);
const noCompatibleGPUsRef = useRef<boolean>(false); const noCompatibleGPUsRef = useRef<boolean>(false);
const [noCompatibleGPUs, setNoCompatibleGPUs] = useState<boolean>(false);
const handleSumit = () => { const handleSumit = () => {
form.current?.submit?.(); form.current?.submit?.();
@@ -265,6 +266,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
// If no avaliable gpus for the model, show warning message // If no avaliable gpus for the model, show warning message
if (!res.items.length) { if (!res.items.length) {
noCompatibleGPUsRef.current = true; noCompatibleGPUsRef.current = true;
setNoCompatibleGPUs(true);
setWarningStatus({ setWarningStatus({
show: true, show: true,
type: 'warning', type: 'warning',
@@ -273,6 +275,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
return; return;
} }
noCompatibleGPUsRef.current = false; noCompatibleGPUsRef.current = false;
setNoCompatibleGPUs(false);
handleCheckCompatibility(allValues); handleCheckCompatibility(allValues);
} catch (error) { } catch (error) {
// ignore // ignore
@@ -391,7 +394,11 @@ const AddModal: React.FC<AddModalProps> = (props) => {
showOkBtn={!showExtraButton} showOkBtn={!showExtraButton}
extra={ extra={
showExtraButton && ( showExtraButton && (
<Button type="primary" onClick={handleSubmitAnyway}> <Button
type="primary"
onClick={handleSubmitAnyway}
disabled={noCompatibleGPUs}
>
{intl.formatMessage({ {intl.formatMessage({
id: 'models.form.submit.anyway' id: 'models.form.submit.anyway'
})} })}