diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx new file mode 100644 index 0000000000..59f620a64e --- /dev/null +++ b/web/app/components/plugins/plugin-detail-panel/endpoint-card.tsx @@ -0,0 +1,60 @@ +import React from 'react' +import { useTranslation } from 'react-i18next' +import { RiLoginCircleLine } from '@remixicon/react' +import CopyBtn from '@/app/components/base/copy-btn' +import Indicator from '@/app/components/header/indicator' +import Switch from '@/app/components/base/switch' + +const EndpointCard = () => { + const { t } = useTranslation() + return ( +
+
+
+ +
Endpoint for Unreal workspace
+
+
+
Start Callback
+
+
https://extension.dify.ai/a1b2c3d4/onStart
+ +
+
+
+
Finish Callback
+
+
https://extension.dify.ai/a1b2c3d4/onFinish
+ +
+
+
+
+
+ + {t('plugin.detailPanel.serviceOk')} +
+ {/*
+ + {t('plugin.detailPanel.disabled')} +
*/} + {}} + size='sm' + /> +
+
+ ) +} + +export default EndpointCard diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx index 4dfd4bbd55..5acf1c18ab 100644 --- a/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx +++ b/web/app/components/plugins/plugin-detail-panel/endpoint-list.tsx @@ -1,65 +1,19 @@ import React from 'react' import { useTranslation } from 'react-i18next' -import { RiAddLine, RiLoginCircleLine } from '@remixicon/react' +import { RiAddLine } from '@remixicon/react' +import EndpointCard from './endpoint-card' import ActionButton from '@/app/components/base/action-button' -import CopyBtn from '@/app/components/base/copy-btn' -import Indicator from '@/app/components/header/indicator' import Tooltip from '@/app/components/base/tooltip' -import Switch from '@/app/components/base/switch' -const EndpointCard = () => { - const { t } = useTranslation() - return ( -
-
-
- -
Endpoint for Unreal workspace
-
-
-
Start Callback
-
-
https://extension.dify.ai/a1b2c3d4/onStart
- -
-
-
-
Finish Callback
-
-
https://extension.dify.ai/a1b2c3d4/onFinish
- -
-
-
-
-
- - {t('plugin.detailPanel.serviceOk')} -
- {/*
- - {t('plugin.detailPanel.disabled')} -
*/} - {}} - size='sm' - /> -
-
- ) +type Props = { + declaration: any + list: any[] } -const EndpointList = () => { +const EndpointList = ({ + declaration, + list, +}: Props) => { const { t } = useTranslation() return (
@@ -80,11 +34,13 @@ const EndpointList = () => {
-
{t('plugin.detailPanel.endpointsEmpty')}
+ {list.length === 0 && ( +
{t('plugin.detailPanel.endpointsEmpty')}
+ )}
- - - + {list.map((item, index) => ( + + ))}
) diff --git a/web/app/components/plugins/plugin-detail-panel/index.tsx b/web/app/components/plugins/plugin-detail-panel/index.tsx index 0fd9570137..17823dea23 100644 --- a/web/app/components/plugins/plugin-detail-panel/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/index.tsx @@ -2,7 +2,7 @@ import React from 'react' import type { FC } from 'react' import { useTranslation } from 'react-i18next' -import type { PluginDetail } from '../types' +import type { EndpointListItem, PluginDetail } from '../types' import DetailHeader from './detail-header' import EndpointList from './endpoint-list' import ActionList from './action-list' @@ -13,11 +13,13 @@ import cn from '@/utils/classnames' type Props = { pluginDetail: PluginDetail | undefined + endpointList: EndpointListItem[] onHide: () => void } const PluginDetailPanel: FC = ({ pluginDetail, + endpointList = [], onHide, }) => { const { t } = useTranslation() @@ -46,9 +48,14 @@ const PluginDetailPanel: FC = ({ onDelete={handleDelete} />
- - - + {!!pluginDetail.declaration.endpoint && ( + + )} + {!!pluginDetail.declaration.tool && } + {!!pluginDetail.declaration.model && }
)} diff --git a/web/app/components/plugins/plugin-detail-panel/mock.ts b/web/app/components/plugins/plugin-detail-panel/mock.ts index 7c421ce942..dd76c7bdbe 100644 --- a/web/app/components/plugins/plugin-detail-panel/mock.ts +++ b/web/app/components/plugins/plugin-detail-panel/mock.ts @@ -24,7 +24,32 @@ export const toolNotion = { created_at: '2024-10-16 16:05:33', resource: {}, plugins: {}, - tool: {}, // TODO + endpoint: { + settings: [ + { + type: 'secret-input', + name: 'api-key', + required: true, + default: null, + options: null, + label: { + 'en-US': 'API-key', + 'zh-Hans': 'API-key', + }, + help: null, + url: null, + placeholder: { + 'en-US': 'Please input your API key', + 'zh-Hans': '请输入你的 API key', + }, + }, + ], + endpoints: [ + { path: '/duck/', method: 'GET' }, + { path: '/neko', method: 'GET' }, + ], + }, + tool: null, // TODO verified: true, }, installation_id: 'jflkdsjoewingljlsadjgoijg-dkfjldajglkajglask-dlfkajdg', @@ -67,7 +92,7 @@ export const toolNotionEndpoints = [ }, }, ], - endpoint: [ + endpoints: [ { path: '/duck/', method: 'GET' }, { path: '/neko', method: 'GET' }, ], diff --git a/web/app/components/plugins/plugin-page/plugins-panel.tsx b/web/app/components/plugins/plugin-page/plugins-panel.tsx index 7bd9620177..7dd8a5e480 100644 --- a/web/app/components/plugins/plugin-page/plugins-panel.tsx +++ b/web/app/components/plugins/plugin-page/plugins-panel.tsx @@ -1,12 +1,11 @@ 'use client' import { useState } from 'react' -import type { PluginDetail } from '../types' -import PluginDetailPanel from '@/app/components/plugins/plugin-detail-panel' -import { toolNotion } from '@/app/components/plugins/plugin-detail-panel/mock' - +import type { EndpointListItem, PluginDetail } from '../types' import type { FilterState } from './filter-management' import FilterManagement from './filter-management' import List from './list' +import PluginDetailPanel from '@/app/components/plugins/plugin-detail-panel' +import { toolNotion, toolNotionEndpoints } from '@/app/components/plugins/plugin-detail-panel/mock' const PluginsPanel = () => { const handleFilterChange = (filters: FilterState) => { @@ -14,6 +13,7 @@ const PluginsPanel = () => { } const [currentPluginDetail, setCurrentPluginDetail] = useState(toolNotion as any) + const [currentPluginEndpoints, setCurrentEndpoints] = useState(toolNotionEndpoints as any) return ( <>
@@ -27,7 +27,14 @@ const PluginsPanel = () => {
- setCurrentPluginDetail(undefined)} /> + { + setCurrentPluginDetail(undefined) + setCurrentEndpoints([]) + }} + /> ) } diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index 4b3b750497..75a8e1e9a0 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -63,8 +63,8 @@ export type PluginDeclaration = { resource: any // useless in frontend plugins: any // useless in frontend verified: boolean - tool: PluginToolDeclaration endpoint: PluginEndpointDeclaration + tool: PluginToolDeclaration model: any // TODO }