Skip to content

Commit b872e69

Browse files
committed
feature/1.7-MCP
1 parent 54c88e1 commit b872e69

5 files changed

Lines changed: 59 additions & 48 deletions

File tree

frontend/packages/common/src/const/type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export type MatchItem = {
8181
export type EntityItem = {
8282
id: string
8383
name: string
84+
isSubscribed: boolean
8485
}
8586

8687
export type DynamicMenuItem = {

frontend/packages/common/src/contexts/GlobalStateContext.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,31 @@ const mockData = [
9999
icon: 'ic:baseline-bar-chart',
100100
children: [
101101
{
102-
name: '运行视图',
103-
key: 'analytics',
104-
path: '/analytics',
105-
icon: 'ic:baseline-bar-chart',
102+
name: '总览',
103+
key: 'analyticsTotal',
104+
path: '/analytics/total',
105+
icon: 'material-symbols:bar-chart',
106+
access: 'system.analysis.run_view.view'
107+
},
108+
{
109+
name: '服务',
110+
key: 'analyticsSubscriber',
111+
path: '/analytics/subscriber/list',
112+
icon: 'ic:baseline-blinds-closed',
113+
access: 'system.analysis.run_view.view'
114+
},
115+
{
116+
name: '消费者',
117+
key: 'analyticsProvider',
118+
path: '/analytics/provider/list',
119+
icon: 'ic:baseline-apps',
120+
access: 'system.analysis.run_view.view'
121+
},
122+
{
123+
name: 'API',
124+
key: 'analyticsApi',
125+
path: '/analytics/api/list',
126+
icon: 'gravity-ui:plug-connection',
106127
access: 'system.analysis.run_view.view'
107128
}
108129
],

frontend/packages/dashboard/src/pages/DashboardTabPage.tsx

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,16 @@ import { RouterParams } from '@common/const/type'
77

88
export default function DashboardTabPage() {
99
const { dashboardType } = useParams<RouterParams>()
10-
const [activeKey, setActiveKey] = useState<string>('total')
1110
const navigateTo = useNavigate()
1211

1312
useEffect(() => {
14-
setActiveKey(dashboardType || 'total')
13+
const activeKey = dashboardType || 'total'
14+
navigateTo(`/analytics/${activeKey === 'total' ? activeKey : `${activeKey}/list`}`)
1515
}, [dashboardType])
1616

17-
const monitorTabItems: TabsProps['items'] = [
18-
{
19-
label: $t('监控总览'),
20-
key: 'total',
21-
children: <DashboardTotal />
22-
},
23-
{
24-
label: $t('服务被调用统计'),
25-
key: 'subscriber',
26-
children: <Outlet />
27-
},
28-
{
29-
label: $t('消费者调用统计'),
30-
key: 'provider',
31-
children: <Outlet />
32-
},
33-
{
34-
label: $t('API 调用统计'),
35-
key: 'api',
36-
children: <Outlet />
37-
}
38-
]
39-
4017
return (
4118
<>
42-
<Tabs
43-
activeKey={activeKey}
44-
onChange={(val) => {
45-
setActiveKey(val)
46-
navigateTo(`/analytics/${val === 'total' ? val : `${val}/list`}`)
47-
}}
48-
items={monitorTabItems}
49-
className="h-full overflow-hidden mt-[6px] [&>.ant-tabs-content-holder]:overflow-auto [&>.ant-tabs-content-holder]:pr-PAGE_INSIDE_X [&>.ant-tabs-content-holder>.ant-tabs-content]:h-full [&>.ant-tabs-content-holder>.ant-tabs-content>.ant-tabs-tabpane]:h-full"
50-
size="small"
51-
tabBarStyle={{ paddingLeft: '10px', marginTop: '0px', marginBottom: '0px' }}
52-
/>
19+
<Outlet />
5320
</>
5421
)
5522
}

frontend/packages/market/src/pages/serviceHub/ApplyServiceModal.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import WithPermission from '@common/components/aoplatform/WithPermission'
22
import { BasicResponse, RESPONSE_TIPS, STATUS_CODE } from '@common/const/const'
33
import { useFetch } from '@common/hooks/http'
44
import { $t } from '@common/locales'
5-
import { App, Col, Form, Input, Row, Select } from 'antd'
5+
import { App, Col, Form, Input, Row, Select, Tooltip } from 'antd'
66
import { forwardRef, useEffect, useImperativeHandle } from 'react'
77
import { ApplyServiceHandle, ApplyServiceProps } from '../../const/serviceHub/type'
88

@@ -77,6 +77,16 @@ export const ApplyServiceModal = forwardRef<ApplyServiceHandle, ApplyServiceProp
7777
placeholder={$t('搜索或选择消费者')}
7878
mode="multiple"
7979
options={mySystemOptionList?.filter((x) => x.value !== entity.id)}
80+
optionRender={(option) => {
81+
if (option.data.disabled) {
82+
return (
83+
<Tooltip title={$t('该消费者已订阅')}>
84+
<div>{option.data.label}</div>
85+
</Tooltip>
86+
)
87+
}
88+
return <div>{option.data.label}</div>
89+
}}
8090
/>
8191
</Form.Item>
8292
{entity.approvalType === 'manual' && (

frontend/packages/market/src/pages/serviceHub/ServiceHubDetail.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,28 @@ servers:
235235

236236
const getMySelectList = () => {
237237
setMySystemOptionList([])
238-
fetchData<BasicResponse<{ app: EntityItem[] }>>('apps/can_subscribe', { method: 'GET' }).then((response) => {
238+
fetchData<BasicResponse<{ app: EntityItem[] }>>('apps/can_subscribe', {
239+
method: 'GET',
240+
eoParams: { service: serviceId },
241+
eoTransformKeys: ['is_subscribed']
242+
}).then((response) => {
239243
const { code, data, msg } = response
240244
if (code === STATUS_CODE.SUCCESS) {
241245
setMySystemOptionList(
242-
data.app?.map((x: EntityItem) => {
243-
return {
244-
label: x.name,
245-
value: x.id
246-
}
247-
})
246+
data.app
247+
?.sort((a: EntityItem, b: EntityItem) => {
248+
// 已订阅的排在后面
249+
if (a.isSubscribed && !b.isSubscribed) return 1
250+
if (!a.isSubscribed && b.isSubscribed) return -1
251+
return 0
252+
})
253+
.map((x: EntityItem) => {
254+
return {
255+
label: x.name,
256+
value: x.id,
257+
disabled: x.isSubscribed // 已订阅的设为禁用
258+
}
259+
})
248260
)
249261
} else {
250262
message.error(msg || $t(RESPONSE_TIPS.error))

0 commit comments

Comments
 (0)