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);