fix: built-in backend versions endwith -custom
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user