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
-44
View File
@@ -259,7 +259,6 @@ body {
}
.ant-pro-sider .ant-layout-sider-children {
// background-color: var(--color-fill-sider);
border-right: 1px solid var(--ant-color-split);
}
}
@@ -330,20 +329,7 @@ body {
}
.ant-menu {
.ant-menu-item {
// color: var(--ant-color-text) !important;
&:active {
// background-color: var(--ant-menu-item-selected-bg);
}
}
.ant-menu-item:not(.ant-menu-item-selected) {
// color: var(--ant-color-text);
}
.ant-menu-item.ant-menu-item-selected {
// color: var(--ant-color-primary) !important;
font-weight: 400;
}
@@ -361,38 +347,11 @@ body {
.ant-menu-item-only-child {
height: 40px;
line-height: 40px;
// color: var(--ant-color-text);
.anticon {
font-size: var(--font-size-middle);
}
}
.new-icon {
position: relative;
bottom: 3px;
display: flex;
color: #fff;
width: 36px;
height: 15px;
margin-left: 5px;
justify-content: center;
align-items: center;
background-color: var(--ant-orange-5);
border-radius: 8px 8px 8px 0;
transform: scale(0.9);
.text {
transform: scale(0.8);
line-height: 1em;
}
}
}
}
.ant-menu {
.ant-menu-submenu-title {
// color: var(--ant-color-text) !important;
}
}
@@ -400,7 +359,6 @@ body {
.user-avatar.ant-menu-submenu {
.ant-menu-submenu-title {
padding-left: 10px;
// color: var(--ant-color-text) !important;
}
}
@@ -409,7 +367,6 @@ body {
display: flex;
justify-content: center;
align-items: center;
// color: var(--ant-color-text) !important;
padding-inline: unset !important;
width: 100%;
margin-inline: 0 !important;
@@ -436,7 +393,6 @@ body {
display: flex;
justify-content: flex-start;
align-items: center;
// color: var(--ant-color-text) !important;
}
}
+22 -2
View File
@@ -22,6 +22,26 @@ import { useMemo } from 'react';
import styled from 'styled-components';
import { DEFAULT_ENTER_PAGE } from '../config/settings';
const NewLabel = styled.span`
position: relative;
bottom: 3px;
display: flex;
color: #fff;
width: 36px;
height: 15px;
margin-left: 5px;
justify-content: center;
align-items: center;
background-color: var(--ant-orange-5);
border-radius: 8px 8px 8px 0;
transform: scale(0.9);
.text {
transform: scale(0.8);
line-height: 1em;
}
`;
const IconWrapper = styled.span`
cursor: pointer;
display: flex;
@@ -173,11 +193,11 @@ export const ExtraContent = () => {
<>
<a className="m-l-8">{item.label}</a>
{showUpgrade && (
<span className="new-icon">
<NewLabel>
<span className="text">
{intl.formatMessage({ id: 'common.text.new' })}
</span>
</span>
</NewLabel>
)}
</>
) : (
-1
View File
@@ -339,7 +339,6 @@ export default (props: any) => {
};
const menuItemRender = (menuItemProps, defaultDom) => {
console.log('defaultdom==========', menuItemProps, defaultDom);
if (menuItemProps.isUrl || menuItemProps.children) {
return defaultDom;
}
+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;