fix: backend edit format
This commit is contained in:
@@ -57,10 +57,7 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
const onOk = () => {
|
||||
if (activeKey === 'yaml') {
|
||||
const content = editorRef.current?.getContent();
|
||||
const valid = editorRef.current?.validate();
|
||||
if (valid) {
|
||||
onSubmitYaml({ content: content });
|
||||
}
|
||||
onSubmitYaml({ content: content });
|
||||
} else {
|
||||
formRef.current?.submit();
|
||||
}
|
||||
@@ -104,30 +101,40 @@ const AddModal: React.FC<AddModalProps> = (props) => {
|
||||
);
|
||||
|
||||
const builtInVersions = Object.keys(
|
||||
values.build_in_version_configs || {}
|
||||
values.built_in_version_configs || {}
|
||||
).map((key) => ({
|
||||
version_no: key,
|
||||
image_name: values.build_in_version_configs?.[key]?.image_name,
|
||||
run_command: values.build_in_version_configs?.[key]?.run_command,
|
||||
image_name: values.built_in_version_configs?.[key]?.image_name,
|
||||
run_command: values.built_in_version_configs?.[key]?.run_command,
|
||||
is_default: key === values.default_version,
|
||||
build_in_frameworks:
|
||||
values.build_in_version_configs?.[key]?.build_in_frameworks || [],
|
||||
built_in_frameworks:
|
||||
values.built_in_version_configs?.[key]?.built_in_frameworks || [],
|
||||
is_built_in: true
|
||||
}));
|
||||
|
||||
return {
|
||||
...values,
|
||||
version_configs: versionConfigs,
|
||||
build_in_version_configs: builtInVersions
|
||||
built_in_version_configs: builtInVersions
|
||||
};
|
||||
};
|
||||
|
||||
// built-in backend does not allow to edit default_version
|
||||
const initYamlContent = (values: any) => {
|
||||
const copyValues = structuredClone(values);
|
||||
copyValues.version_configs = _.mapValues(
|
||||
copyValues.version_configs || {},
|
||||
(v: any) => {
|
||||
return _.omit(v, ['built_in_frameworks']);
|
||||
}
|
||||
);
|
||||
|
||||
if (currentData?.is_built_in) {
|
||||
return json2Yaml(_.pick(values, backendFields));
|
||||
return json2Yaml(_.pick(copyValues, backendFields));
|
||||
}
|
||||
return json2Yaml(_.pick(values, [...backendFields, 'default_version']));
|
||||
return json2Yaml(
|
||||
_.pick(copyValues, [...backendFields, 'default_version'])
|
||||
);
|
||||
};
|
||||
|
||||
if (action === PageAction.EDIT && open) {
|
||||
|
||||
@@ -20,8 +20,8 @@ const VersionInfoModal: React.FC<VersionInfoModalProps> = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (open && currentData) {
|
||||
// add is_built_in field to build_in_version_configs
|
||||
const builtInVersions = currentData.build_in_version_configs || {};
|
||||
// add is_built_in field to built_in_version_configs
|
||||
const builtInVersions = currentData.built_in_version_configs || {};
|
||||
|
||||
for (const key in builtInVersions) {
|
||||
if (builtInVersions?.hasOwnProperty(key)) {
|
||||
@@ -41,7 +41,7 @@ const VersionInfoModal: React.FC<VersionInfoModalProps> = ({
|
||||
run_command: value.run_command,
|
||||
is_default: key === currentData.default_version,
|
||||
availableFrameworks: [
|
||||
...(value.build_in_frameworks || []),
|
||||
...(value.built_in_frameworks || []),
|
||||
...(value.custom_framework ? [value.custom_framework] : [])
|
||||
],
|
||||
is_built_in: value.is_built_in || false
|
||||
|
||||
Reference in New Issue
Block a user