fix: yaml editor do not update when upload same file

This commit is contained in:
jialin
2025-11-13 16:53:11 +08:00
parent b61c0d6dee
commit aee9566bbb
13 changed files with 42 additions and 98 deletions
+1 -9
View File
@@ -5,7 +5,7 @@ import SegmentLine from '@/components/segment-line';
import { PageAction } from '@/config';
import { PageActionType } from '@/config/types';
import { useIntl } from '@umijs/max';
import { Segmented, Tabs } from 'antd';
import { Tabs } from 'antd';
import _ from 'lodash';
import React, { useEffect, useId, useRef, useState } from 'react';
import styled from 'styled-components';
@@ -25,14 +25,6 @@ const ModalFooterStyle = {
justifyContent: 'flex-end'
};
const SegmentedInner = styled(Segmented)`
width: 100%;
border-radius: 0;
.ant-segmented-item {
flex: 1;
}
`;
const SegmentedHeader = styled.div`
margin: 16px 24px;
border-bottom: 1px solid var(--ant-color-split);
@@ -67,6 +67,10 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
);
const [error, setError] = useState<string>('');
const setContent = (val: string) => {
editorRef.current?.setValue?.(val);
};
const beforeUpload = (file: RcFile) => {
const isYaml =
file.type === 'application/x-yaml' ||
@@ -81,6 +85,7 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
const content = e.target?.result;
if (typeof content === 'string') {
setFileContent(content);
setContent(content);
} else {
message.error('Failed to read file content!');
}
@@ -150,9 +155,7 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
getContent: () => {
return getContent();
},
setContent: (val: string) => {
editorRef.current?.setValue?.(val);
},
setContent: setContent,
validate() {
return validate();
}
@@ -73,7 +73,6 @@ const ViewerEditor: React.FC<ViewerProps> = forwardRef((props, ref) => {
const handleEditorDidMount = (editor: any, monaco: any) => {
editorRef.current = editor;
monacoRef.current = monaco;
const uri = monaco.Uri.parse(path);
};
const formatCode = () => {
+1 -1
View File
@@ -3,7 +3,7 @@
"properties": {
"backend_name": {
"type": "string",
"pattern": "^-custom$",
"pattern": "^.+-custom$",
"description": "backend name",
"severity": "error"
},
@@ -184,7 +184,6 @@ const ClusterCreate = () => {
}
return formKeys.map((key) => {
console.log('renderForms key========', key, formValues);
const FormComponent = moduleRegistry[key];
return FormComponent ? (
<FormComponent
+1 -2
View File
@@ -196,6 +196,7 @@ export async function queryModelScopeModels(
Criterion: [...(tagsCriterion || []), ...(tasksCriterion || [])]
}
: {};
const res = await fetch(setProxyUrl(`${MODEL_SCOPE_LIST_MODEL_API}`), {
method: 'PUT',
signal: config?.signal,
@@ -212,7 +213,6 @@ export async function queryModelScopeModels(
});
if (!res.ok) {
throw new Error('Network response was not ok');
return null;
}
return res.json();
}
@@ -246,7 +246,6 @@ export async function queryModelScopeModelFiles(
if (!res.ok) {
throw new Error('Network response was not ok');
return null;
}
return res.json();
@@ -122,6 +122,7 @@ const ApiAccessInfo = ({ open, data, onClose }: ApiAccessInfoProps) => {
const handleClose = () => {
onClose();
};
return (
<ScrollerModal
open={open}
+6 -34
View File
@@ -12,7 +12,6 @@ import { CatalogItem as CatalogItemType } from '../config/types';
import '../style/catalog-item.less';
import { categoryConfig } from './model-tag';
const COLORS = ['blue', 'purple', 'orange'];
interface CatalogItemProps {
activeId: number;
data: CatalogItemType;
@@ -26,32 +25,6 @@ const CatalogItem: React.FC<CatalogItemProps> = (props) => {
onClick(data);
}, [data, onClick]);
const handleOnError = (e: any) => {
e.target.src = fallbackImg;
};
const renderTag = useCallback((sItem: any) => {
return (
<ThemeTag
key={sItem}
className="tag-item"
opacity={0.7}
style={{
marginRight: 0,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
padding: '2px 6px',
borderRadius: 4,
fontSize: 12,
height: 22
}}
>
{sItem.label}
</ThemeTag>
);
}, []);
const description = useMemo(() => {
return (
<Typography.Paragraph
@@ -86,13 +59,12 @@ const CatalogItem: React.FC<CatalogItemProps> = (props) => {
>
<div className="content">
<div className="title">
<div className="img">
<img
src={data.icon || fallbackImg}
alt=""
onError={handleOnError}
/>
</div>
<div
className="img"
style={{
backgroundImage: `url(${data.icon}),url(${fallbackImg})`
}}
></div>
<AutoTooltip ghost>{data.name}</AutoTooltip>
</div>
</div>
+1
View File
@@ -116,6 +116,7 @@ const Models: React.FC = () => {
cancelToken: axiosToken.token
});
// if the current page is beyond total page, fetch again
if (
!res.items.length &&
params.page > res.pagination.totalPage &&
@@ -19,6 +19,9 @@
height: 32px;
border-radius: var(--ant-border-radius);
overflow: hidden;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
img {
height: 32px;