fix: built-in backend versions endwith -custom

This commit is contained in:
jialin
2025-10-27 16:09:09 +08:00
parent 61065ee0b7
commit 697f1f9c25
15 changed files with 96 additions and 48 deletions
+3 -1
View File
@@ -56,7 +56,9 @@ const AddModal: React.FC<AddModalProps> = (props) => {
const onOk = () => {
if (activeKey === 'yaml') {
const content = editorRef.current?.getContent();
onSubmitYaml({ content: content });
if (content) {
onSubmitYaml({ content: content });
}
} else {
formRef.current?.submit();
}
+22 -2
View File
@@ -12,7 +12,7 @@ import React, {
useState
} from 'react';
import styled from 'styled-components';
import { yamlTemplate } from '../config';
import { yaml2Json, yamlTemplate } from '../config';
import YamlEditor from './yaml-editor';
const { Text } = Typography;
@@ -98,6 +98,26 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
return markers.length === 0;
};
const getContent = () => {
try {
const content = editorRef.current?.getValue();
if (actionStatus.isBuiltIn) {
const jsonData = yaml2Json(content);
const exsistingVersions = Object.keys(jsonData.version_configs || {});
const invalidVersion = exsistingVersions.find(
(v) => !v.endsWith('-custom')
);
if (invalidVersion) {
setError(intl.formatMessage({ id: 'backend.version.no.tips' }));
return false;
}
}
return content;
} catch (error) {
return false;
}
};
const renderHeader = () => {
return (
<Header>
@@ -119,7 +139,7 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
useImperativeHandle(ref, () => ({
getContent: () => {
return editorRef.current?.getValue();
return getContent();
},
setContent: (val: string) => {
editorRef.current?.setValue?.(val);
@@ -23,7 +23,7 @@
"version_configs": {
"type": "object",
"patternProperties": {
"^[a-zA-Z0-9._-]+$": {
"-custom$": {
"type": "object",
"properties": {
"image_name": {
+26 -3
View File
@@ -12,11 +12,14 @@ import styled from 'styled-components';
import { frameworks } from '../config';
import { ListItem } from '../config/types';
// version must be endwith '-custom'
const pattern = /-custom$/;
const Box = styled.div`
display: grid;
grid-template-columns: 150px 1fr;
grid-template-columns: 180px 1fr;
gap: 16px;
align-items: center;
`;
const Label = styled.span`
@@ -152,6 +155,10 @@ const VersionsForm: React.FC<AddModalProps> = ({
}
}, [currentData?.default_version]);
const handleVersionChange = (e: React.ChangeEvent<HTMLInputElement>) => {
console.log('Version changed:', e.target.value);
};
return (
<>
<Title>
@@ -273,11 +280,27 @@ const VersionsForm: React.FC<AddModalProps> = ({
{
required: true,
message: getRuleMessage(`input`, 'backend.version')
}
},
currentData?.is_built_in
? {
pattern: pattern,
message: intl.formatMessage({
id: 'backend.version.rules.builtin'
})
}
: {}
]}
>
<SealInput.Input
trim
description={
currentData?.is_built_in
? intl.formatMessage({
id: 'backend.version.no.tips'
})
: ''
}
onChange={handleVersionChange}
label={intl.formatMessage({ id: 'backend.version' })}
required
></SealInput.Input>
+1 -1
View File
@@ -84,7 +84,7 @@ const BackendFields: React.FC = () => {
{
backend: backendLabelMap[backend],
version: backendParamsTips?.version
? `(${intl.formatMessage({ id: 'common.help.eg' })} ${backendParamsTips?.version})`
? `(${intl.formatMessage({ id: 'common.help.eg' }, { content: '' })} ${backendParamsTips?.version})`
: '',
link: backendParamsTips?.releases && (
<span
-4
View File
@@ -95,8 +95,6 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
const [activeKey, setActiveKey] = React.useState<string[]>([]);
const scheduleType = Form.useWatch('scheduleType', form);
const [target, setTarget] = React.useState<string>('basic');
const performanceRef = React.useRef<HTMLDivElement>(null);
const advanceRef = React.useRef<HTMLDivElement>(null);
const segmentOptions = [
{
@@ -153,8 +151,6 @@ const DataForm: React.FC<DataFormProps> = forwardRef((props, ref) => {
// voxbox is not support multi gpu
const updateGPUSelector = (backend: string) => {
const gpuids = form.getFieldValue(['gpu_selector', 'gpu_ids']) || [];
const gpusPerReplicas =
form.getFieldValue(['gpu_selector', 'gpus_per_replica']) || null;
if (backend === backendOptionsMap.voxBox && gpuids.length > 0) {
return {