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 { .ant-pro-sider .ant-layout-sider-children {
// background-color: var(--color-fill-sider);
border-right: 1px solid var(--ant-color-split); border-right: 1px solid var(--ant-color-split);
} }
} }
@@ -330,20 +329,7 @@ body {
} }
.ant-menu { .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 { .ant-menu-item.ant-menu-item-selected {
// color: var(--ant-color-primary) !important;
font-weight: 400; font-weight: 400;
} }
@@ -361,38 +347,11 @@ body {
.ant-menu-item-only-child { .ant-menu-item-only-child {
height: 40px; height: 40px;
line-height: 40px; line-height: 40px;
// color: var(--ant-color-text);
.anticon { .anticon {
font-size: var(--font-size-middle); 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 { .user-avatar.ant-menu-submenu {
.ant-menu-submenu-title { .ant-menu-submenu-title {
padding-left: 10px; padding-left: 10px;
// color: var(--ant-color-text) !important;
} }
} }
@@ -409,7 +367,6 @@ body {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
// color: var(--ant-color-text) !important;
padding-inline: unset !important; padding-inline: unset !important;
width: 100%; width: 100%;
margin-inline: 0 !important; margin-inline: 0 !important;
@@ -436,7 +393,6 @@ body {
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
align-items: center; 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 styled from 'styled-components';
import { DEFAULT_ENTER_PAGE } from '../config/settings'; 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` const IconWrapper = styled.span`
cursor: pointer; cursor: pointer;
display: flex; display: flex;
@@ -173,11 +193,11 @@ export const ExtraContent = () => {
<> <>
<a className="m-l-8">{item.label}</a> <a className="m-l-8">{item.label}</a>
{showUpgrade && ( {showUpgrade && (
<span className="new-icon"> <NewLabel>
<span className="text"> <span className="text">
{intl.formatMessage({ id: 'common.text.new' })} {intl.formatMessage({ id: 'common.text.new' })}
</span> </span>
</span> </NewLabel>
)} )}
</> </>
) : ( ) : (
-1
View File
@@ -339,7 +339,6 @@ export default (props: any) => {
}; };
const menuItemRender = (menuItemProps, defaultDom) => { const menuItemRender = (menuItemProps, defaultDom) => {
console.log('defaultdom==========', menuItemProps, defaultDom);
if (menuItemProps.isUrl || menuItemProps.children) { if (menuItemProps.isUrl || menuItemProps.children) {
return defaultDom; return defaultDom;
} }
+1 -9
View File
@@ -5,7 +5,7 @@ import SegmentLine from '@/components/segment-line';
import { PageAction } from '@/config'; import { PageAction } from '@/config';
import { PageActionType } from '@/config/types'; import { PageActionType } from '@/config/types';
import { useIntl } from '@umijs/max'; import { useIntl } from '@umijs/max';
import { Segmented, Tabs } from 'antd'; import { Tabs } from 'antd';
import _ from 'lodash'; import _ from 'lodash';
import React, { useEffect, useId, useRef, useState } from 'react'; import React, { useEffect, useId, useRef, useState } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
@@ -25,14 +25,6 @@ const ModalFooterStyle = {
justifyContent: 'flex-end' justifyContent: 'flex-end'
}; };
const SegmentedInner = styled(Segmented)`
width: 100%;
border-radius: 0;
.ant-segmented-item {
flex: 1;
}
`;
const SegmentedHeader = styled.div` const SegmentedHeader = styled.div`
margin: 16px 24px; margin: 16px 24px;
border-bottom: 1px solid var(--ant-color-split); border-bottom: 1px solid var(--ant-color-split);
@@ -67,6 +67,10 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
); );
const [error, setError] = useState<string>(''); const [error, setError] = useState<string>('');
const setContent = (val: string) => {
editorRef.current?.setValue?.(val);
};
const beforeUpload = (file: RcFile) => { const beforeUpload = (file: RcFile) => {
const isYaml = const isYaml =
file.type === 'application/x-yaml' || file.type === 'application/x-yaml' ||
@@ -81,6 +85,7 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
const content = e.target?.result; const content = e.target?.result;
if (typeof content === 'string') { if (typeof content === 'string') {
setFileContent(content); setFileContent(content);
setContent(content);
} else { } else {
message.error('Failed to read file content!'); message.error('Failed to read file content!');
} }
@@ -150,9 +155,7 @@ const ImportYAML: React.FC<ImportYAMLProps> = forwardRef(
getContent: () => { getContent: () => {
return getContent(); return getContent();
}, },
setContent: (val: string) => { setContent: setContent,
editorRef.current?.setValue?.(val);
},
validate() { validate() {
return validate(); return validate();
} }
@@ -73,7 +73,6 @@ const ViewerEditor: React.FC<ViewerProps> = forwardRef((props, ref) => {
const handleEditorDidMount = (editor: any, monaco: any) => { const handleEditorDidMount = (editor: any, monaco: any) => {
editorRef.current = editor; editorRef.current = editor;
monacoRef.current = monaco; monacoRef.current = monaco;
const uri = monaco.Uri.parse(path);
}; };
const formatCode = () => { const formatCode = () => {
+1 -1
View File
@@ -3,7 +3,7 @@
"properties": { "properties": {
"backend_name": { "backend_name": {
"type": "string", "type": "string",
"pattern": "^-custom$", "pattern": "^.+-custom$",
"description": "backend name", "description": "backend name",
"severity": "error" "severity": "error"
}, },
@@ -184,7 +184,6 @@ const ClusterCreate = () => {
} }
return formKeys.map((key) => { return formKeys.map((key) => {
console.log('renderForms key========', key, formValues);
const FormComponent = moduleRegistry[key]; const FormComponent = moduleRegistry[key];
return FormComponent ? ( return FormComponent ? (
<FormComponent <FormComponent
+1 -2
View File
@@ -196,6 +196,7 @@ export async function queryModelScopeModels(
Criterion: [...(tagsCriterion || []), ...(tasksCriterion || [])] Criterion: [...(tagsCriterion || []), ...(tasksCriterion || [])]
} }
: {}; : {};
const res = await fetch(setProxyUrl(`${MODEL_SCOPE_LIST_MODEL_API}`), { const res = await fetch(setProxyUrl(`${MODEL_SCOPE_LIST_MODEL_API}`), {
method: 'PUT', method: 'PUT',
signal: config?.signal, signal: config?.signal,
@@ -212,7 +213,6 @@ export async function queryModelScopeModels(
}); });
if (!res.ok) { if (!res.ok) {
throw new Error('Network response was not ok'); throw new Error('Network response was not ok');
return null;
} }
return res.json(); return res.json();
} }
@@ -246,7 +246,6 @@ export async function queryModelScopeModelFiles(
if (!res.ok) { if (!res.ok) {
throw new Error('Network response was not ok'); throw new Error('Network response was not ok');
return null;
} }
return res.json(); return res.json();
@@ -122,6 +122,7 @@ const ApiAccessInfo = ({ open, data, onClose }: ApiAccessInfoProps) => {
const handleClose = () => { const handleClose = () => {
onClose(); onClose();
}; };
return ( return (
<ScrollerModal <ScrollerModal
open={open} open={open}
+6 -34
View File
@@ -12,7 +12,6 @@ import { CatalogItem as CatalogItemType } from '../config/types';
import '../style/catalog-item.less'; import '../style/catalog-item.less';
import { categoryConfig } from './model-tag'; import { categoryConfig } from './model-tag';
const COLORS = ['blue', 'purple', 'orange'];
interface CatalogItemProps { interface CatalogItemProps {
activeId: number; activeId: number;
data: CatalogItemType; data: CatalogItemType;
@@ -26,32 +25,6 @@ const CatalogItem: React.FC<CatalogItemProps> = (props) => {
onClick(data); onClick(data);
}, [data, onClick]); }, [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(() => { const description = useMemo(() => {
return ( return (
<Typography.Paragraph <Typography.Paragraph
@@ -86,13 +59,12 @@ const CatalogItem: React.FC<CatalogItemProps> = (props) => {
> >
<div className="content"> <div className="content">
<div className="title"> <div className="title">
<div className="img"> <div
<img className="img"
src={data.icon || fallbackImg} style={{
alt="" backgroundImage: `url(${data.icon}),url(${fallbackImg})`
onError={handleOnError} }}
/> ></div>
</div>
<AutoTooltip ghost>{data.name}</AutoTooltip> <AutoTooltip ghost>{data.name}</AutoTooltip>
</div> </div>
</div> </div>
+1
View File
@@ -116,6 +116,7 @@ const Models: React.FC = () => {
cancelToken: axiosToken.token cancelToken: axiosToken.token
}); });
// if the current page is beyond total page, fetch again
if ( if (
!res.items.length && !res.items.length &&
params.page > res.pagination.totalPage && params.page > res.pagination.totalPage &&
@@ -19,6 +19,9 @@
height: 32px; height: 32px;
border-radius: var(--ant-border-radius); border-radius: var(--ant-border-radius);
overflow: hidden; overflow: hidden;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
img { img {
height: 32px; height: 32px;