From 77aa0080d9b67e176ad2e3eaf0124fc50954778c Mon Sep 17 00:00:00 2001 From: maggieyyy <61950669+maggieyyy@users.noreply.github.com> Date: Fri, 30 Aug 2024 19:38:59 +0800 Subject: [PATCH 1/2] fix:publish status & api doc --- .../src/locales/scan/newJson/en-GB.json | 1 + .../src/locales/scan/newJson/zh-CN.json | 4 +-- .../publish/SystemInsidePublishOnline.tsx | 29 ++++++++++++++++--- .../serviceHub/ServiceHubApiDocument.tsx | 6 ++-- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/frontend/packages/common/src/locales/scan/newJson/en-GB.json b/frontend/packages/common/src/locales/scan/newJson/en-GB.json index 2c63c085..f33c6e33 100644 --- a/frontend/packages/common/src/locales/scan/newJson/en-GB.json +++ b/frontend/packages/common/src/locales/scan/newJson/en-GB.json @@ -1,2 +1,3 @@ { + "K4758140d": "路由列表" } diff --git a/frontend/packages/common/src/locales/scan/newJson/zh-CN.json b/frontend/packages/common/src/locales/scan/newJson/zh-CN.json index f3239c9a..f33c6e33 100644 --- a/frontend/packages/common/src/locales/scan/newJson/zh-CN.json +++ b/frontend/packages/common/src/locales/scan/newJson/zh-CN.json @@ -1,5 +1,3 @@ { - "K71753476": "是否放行", - "K597435c5": "监控", - "Kde9d6e8e": "开启拦截后,网关会拦截所有该路径的请求,相当于防火墙禁用了特定路径的访问。" + "K4758140d": "路由列表" } diff --git a/frontend/packages/core/src/pages/system/publish/SystemInsidePublishOnline.tsx b/frontend/packages/core/src/pages/system/publish/SystemInsidePublishOnline.tsx index 20575f44..0287a8b2 100644 --- a/frontend/packages/core/src/pages/system/publish/SystemInsidePublishOnline.tsx +++ b/frontend/packages/core/src/pages/system/publish/SystemInsidePublishOnline.tsx @@ -1,10 +1,13 @@ -import { App, Table } from "antd"; +import { App, Table, Tooltip } from "antd"; import { SYSTEM_PUBLISH_ONLINE_COLUMNS } from "../../../const/system/const"; -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { useFetch } from "@common/hooks/http"; -import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from "@common/const/const"; +import { BasicResponse, RESPONSE_TIPS, STATUS_CODE, STATUS_COLOR } from "@common/const/const"; import { EntityItem } from "@common/const/type"; +import { LoadingOutlined } from "@ant-design/icons"; +import { $t } from "@common/locales"; +import { useGlobalContext } from "@common/contexts/GlobalStateContext"; type SystemInsidePublishOnlineProps = { serviceId:string @@ -23,6 +26,7 @@ export default function SystemInsidePublishOnline(props:SystemInsidePublishOnlin const [dataSource, setDataSource] = useState<[]>() const {fetchData} = useFetch() const [isStopped, setIsStopped] = useState(false); + const { state } = useGlobalContext() const getOnlineStatus = ()=>{ fetchData>('service/publish/status',{method:'GET',eoParams:{service:serviceId,team:teamId, id}, eoTransformKeys:['publish_status_list']}).then(response=>{ @@ -55,11 +59,28 @@ export default function SystemInsidePublishOnline(props:SystemInsidePublishOnlin }; }, [isStopped]); + + const translatedPublishColumns = useMemo(()=>SYSTEM_PUBLISH_ONLINE_COLUMNS.map((x)=>{ + if(x.dataIndex === 'status'){ + return {...x,title:$t(x.title), + render:(_:unknown,entity:SystemInsidePublishOnlineItems)=>{ + switch(entity.status){ + case 'done': + return {$t('成功')} + case 'error': + return {$t('失败')} {entity.error} + default: + return + } + }} + } + }),[state.language]) + return ( { useEffect(()=>{ if(!service) return setServiceName(service?.name) - setApiDocument(service.apiDoc) + setApiDocument(service?.apiDoc) },[service]) useEffect(() => { @@ -41,7 +41,7 @@ const ServiceHubApiDocument = ({service}:{service:ServiceDetailType})=>{ - { closeIcon={false} > - + */} ) } From 851c54b6afb8ddbce29f28053aac8baa04d8a9ba Mon Sep 17 00:00:00 2001 From: maggieyyy <61950669+maggieyyy@users.noreply.github.com> Date: Mon, 2 Sep 2024 13:40:50 +0800 Subject: [PATCH 2/2] fix: match type is empty --- .../aoplatform/EditableTableWithModal.tsx | 32 ++++++++++++------- .../PublishApprovalModalContent.tsx | 2 +- .../common/src/const/approval/const.tsx | 4 +-- .../packages/core/src/const/system/const.tsx | 13 ++++---- .../packages/core/src/const/system/type.ts | 3 +- .../pages/system/api/SystemInsideApiProxy.tsx | 4 +-- .../system/api/SystemInsideRouterCreate.tsx | 18 +++++------ .../system/api/SystemInsideRouterList.tsx | 6 ++-- 8 files changed, 47 insertions(+), 35 deletions(-) diff --git a/frontend/packages/common/src/components/aoplatform/EditableTableWithModal.tsx b/frontend/packages/common/src/components/aoplatform/EditableTableWithModal.tsx index e388c6f9..8cc994c9 100644 --- a/frontend/packages/common/src/components/aoplatform/EditableTableWithModal.tsx +++ b/frontend/packages/common/src/components/aoplatform/EditableTableWithModal.tsx @@ -15,6 +15,7 @@ export interface ConfigField { renderText?: (value: unknown, record: T) => string; required?: boolean; ellipsis?:boolean + unRender?:(form:FormInstance)=>boolean } interface EditableTableWithModalProps { @@ -39,6 +40,7 @@ const EditableTableWithModal = ({ const [configurations, setConfigurations] = useState(value ||[]); const [editingConfig, setEditingConfig] = useState(null); const {state} = useGlobalContext() + const [formsValue, setFormsValue] = useState>() const showModal = (config?: T) => { if (config) { @@ -111,18 +113,23 @@ const EditableTableWithModal = ({ ],[state.language, disabled, configFields]) - const formItems = configFields.map(({ title,key, component, required }) => { - return ( - - {component} - - ) + const formItems = useMemo(()=>{ + return configFields.map(({ title,key, component, required,unRender }) => { + return ( + unRender && unRender(formsValue) ? null : + + {component} + + ) + }) } - ); + ,[formsValue]) + + return ( <> @@ -142,6 +149,9 @@ const EditableTableWithModal = ({
{ + setFormsValue(form.getFieldsValue()) + })} // labelCol={{ span: 7 }} // wrapperCol={{ span: 17}} autoComplete="off"> diff --git a/frontend/packages/common/src/components/aoplatform/PublishApprovalModalContent.tsx b/frontend/packages/common/src/components/aoplatform/PublishApprovalModalContent.tsx index 022df0de..66ef75ae 100644 --- a/frontend/packages/common/src/components/aoplatform/PublishApprovalModalContent.tsx +++ b/frontend/packages/common/src/components/aoplatform/PublishApprovalModalContent.tsx @@ -195,7 +195,7 @@ export const PublishApprovalModalContent = forwardRef } - {$t('API 列表')}: + {$t('路由列表')}:
value.join(',') + render:(value)=>value?.join(', ') }, { title:('路径'), diff --git a/frontend/packages/core/src/const/system/const.tsx b/frontend/packages/core/src/const/system/const.tsx index fbdd80c6..c2d6c3c7 100644 --- a/frontend/packages/core/src/const/system/const.tsx +++ b/frontend/packages/core/src/const/system/const.tsx @@ -72,8 +72,8 @@ export const SYSTEM_I18NEXT_FOR_ENUM = { export const HTTP_METHOD = ['GET','POST','PUT','DELETE','PATCH','HEAD'] export const API_PROTOCOL = [ - {label:'HTTP',value:'http'}, - {label:'HTTPS',value:'https'} + {label:'HTTP',value:'HTTP'}, + {label:'HTTPS',value:'HTTPS'} ] @@ -259,6 +259,7 @@ export const MATCH_CONFIG:ConfigField[] = [ }, { title:('参数值'), key: 'pattern', + unRender:(formValue)=>{return formValue?.matchType === 'NULL' || formValue?.matchType==='EXIST' || formValue?.matchType === 'UNEXIST'}, component: , renderText: (value: string) => { return value @@ -278,17 +279,17 @@ export const SYSTEM_API_TABLE_COLUMNS: PageProColumns[] title:('协议'), dataIndex: 'protocols', ellipsis:true, - renderText:(value)=>value?.join(',') + renderText:(value)=>value?.join(', ') }, { title:('方法'), - dataIndex: 'method', + dataIndex: 'methods', ellipsis:true, - renderText:(value)=>value?.join(',') + renderText:(value)=>value?.join(', ') }, { title:'是否放行', - dataIndex:'isDisabled', + dataIndex:'disable', ellipsis:true, filters: true, onFilter: true, diff --git a/frontend/packages/core/src/const/system/type.ts b/frontend/packages/core/src/const/system/type.ts index ac28cb6d..9dc7636a 100644 --- a/frontend/packages/core/src/const/system/type.ts +++ b/frontend/packages/core/src/const/system/type.ts @@ -95,7 +95,7 @@ export type SystemApiProxyFieldType = { id:string; description?:string; path:string; - method:string[]; + methods:string[]; match:MatchItem[] isDisable?: boolean; service?:string; @@ -295,6 +295,7 @@ export type SystemInsideApiProxyProps = { teamId:string initProxyValue?:SystemApiProxyType value?:SystemApiProxyType + type:'add'|'edit' onChange?: (newConfigItems: SystemApiProxyType) => void; // 当配置项变化时,外部传入的回调函数 } diff --git a/frontend/packages/core/src/pages/system/api/SystemInsideApiProxy.tsx b/frontend/packages/core/src/pages/system/api/SystemInsideApiProxy.tsx index 3f51eb4c..882d9071 100644 --- a/frontend/packages/core/src/pages/system/api/SystemInsideApiProxy.tsx +++ b/frontend/packages/core/src/pages/system/api/SystemInsideApiProxy.tsx @@ -9,7 +9,7 @@ import { $t } from "@common/locales"; import { useGlobalContext } from "@common/contexts/GlobalStateContext"; const SystemInsideApiProxy = forwardRef((props,ref)=>{ - const {value, onChange, className,initProxyValue} = props + const {value, onChange, className,initProxyValue,type} = props const {state} = useGlobalContext() const [form] = Form.useForm(); @@ -51,7 +51,7 @@ const SystemInsideApiProxy = forwardRef - + diff --git a/frontend/packages/core/src/pages/system/api/SystemInsideRouterCreate.tsx b/frontend/packages/core/src/pages/system/api/SystemInsideRouterCreate.tsx index 22946b84..bf551103 100644 --- a/frontend/packages/core/src/pages/system/api/SystemInsideRouterCreate.tsx +++ b/frontend/packages/core/src/pages/system/api/SystemInsideRouterCreate.tsx @@ -25,7 +25,7 @@ const SystemInsideRouterCreate = forwardRef{ return Promise.all([proxyRef.current?.validate?.(), form.validateFields()]).then(([,formValue])=>{ const body = {...formValue,path:formValue.path.trim(),proxy:{...formValue.proxy,path:formValue.proxy.path ? (formValue.proxy.path.startsWith('/')? formValue.proxy.path: '/'+ formValue.proxy.path) : undefined}} - return fetchData>('service/router',{method: type === 'add' ? 'POST' : 'PUT',eoBody:(body), eoParams: {service:serviceId,team:teamId, ...(type === 'edit' ? {router:entity?.id}: {})},eoTransformKeys:['matchType','isDisable']}).then(response=>{ + return fetchData>('service/router',{method: type === 'add' ? 'POST' : 'PUT',eoBody:(body), eoParams: {service:serviceId,team:teamId, ...(type === 'edit' ? {router:entity?.id}: {})},eoTransformKeys:['matchType','disable']}).then(response=>{ const {code,msg} = response if(code === STATUS_CODE.SUCCESS){ message.success(msg || $t(RESPONSE_TIPS.success)) @@ -63,11 +63,11 @@ const SystemInsideRouterCreate = forwardRef{ setLoading(true) - fetchData>('service/router/detail',{method:'GET',eoParams:{service:serviceId,team:teamId, router:entity!.id}}).then(response=>{ + fetchData>('service/router/detail',{method:'GET',eoParams:{service:serviceId,team:teamId, router:entity!.id}, eoTransformKeys:['create_time','update_time','match_type','upstream_id','opt_type']}).then(response=>{ const {code,data,msg} = response if(code === STATUS_CODE.SUCCESS){ - const {isDisable, protocols, path, method, description, match, proxy} = data.router - form.setFieldsValue({isDisable, protocols, path, method, description, match,proxy + const {disable, protocols, path, methods, description, match, proxy} = data.router + form.setFieldsValue({disable, protocols, path, methods, description, match,proxy }) }else{ message.error(msg || $t(RESPONSE_TIPS.error)) @@ -85,7 +85,7 @@ const SystemInsideRouterCreate = forwardRef {$t('API 基础信息')} label={$t("拦截该接口的请求")} - name="isDisable" + name="disable" extra={$t('开启拦截后,网关会拦截所有该路径的请求,相当于防火墙禁用了特定路径的访问。')} > @@ -158,13 +158,13 @@ const SystemInsideRouterCreate = forwardRef - label={$t("请求方式")} - name="method" + name="methods" rules={[{ required: true }]} >