diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx index bb6f8f19d8..f4e23b566b 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Form.tsx @@ -19,6 +19,7 @@ import Tooltip from '@/app/components/base/tooltip' import Radio from '@/app/components/base/radio' import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal' import ToolSelector from '@/app/components/plugins/plugin-detail-panel/tool-selector' +import AppSelector from '@/app/components/plugins/plugin-detail-panel/app-selector' type FormProps = { className?: string @@ -347,7 +348,32 @@ const Form: FC = ({ } if (formSchema.type === FormTypeEnum.appSelector) { - // TODO + const { + variable, + label, + required, + } = formSchema as (CredentialFormSchemaTextInput | CredentialFormSchemaSecretInput) + + return ( +
+
+ {label[language] || label.en_US} + { + required && ( + * + ) + } + {tooltipContent} +
+ handleFormChange(variable, item as any)} + /> + {fieldMoreInfo?.(formSchema)} + {validating && changeKey === variable && } +
+ ) } } diff --git a/web/app/components/plugins/plugin-detail-panel/app-selector/app-picker.tsx b/web/app/components/plugins/plugin-detail-panel/app-selector/app-picker.tsx index 4ede53c277..a5be6ffbdd 100644 --- a/web/app/components/plugins/plugin-detail-panel/app-selector/app-picker.tsx +++ b/web/app/components/plugins/plugin-detail-panel/app-selector/app-picker.tsx @@ -13,12 +13,10 @@ import type { } from '@floating-ui/react' import Input from '@/app/components/base/input' import AppIcon from '@/app/components/base/app-icon' -import { - useAppFullList, -} from '@/service/use-apps' import type { App } from '@/types/app' type Props = { + appList: App[] disabled: boolean trigger: React.ReactNode placement?: Placement @@ -29,6 +27,7 @@ type Props = { } const AppPicker: FC = ({ + appList, disabled, trigger, placement = 'right-start', @@ -38,9 +37,8 @@ const AppPicker: FC = ({ onSelect, }) => { const [searchText, setSearchText] = useState('') - const { data: appList } = useAppFullList() const filteredAppList = useMemo(() => { - return (appList?.data || []).filter(app => app.name.toLowerCase().includes(searchText.toLowerCase())).filter(app => (app.mode !== 'advanced-chat' && app.mode !== 'workflow') || !!app.workflow) + return (appList || []).filter(app => app.name.toLowerCase().includes(searchText.toLowerCase())).filter(app => (app.mode !== 'advanced-chat' && app.mode !== 'workflow') || !!app.workflow) }, [appList, searchText]) const getAppType = (app: App) => { switch (app.mode) { diff --git a/web/app/components/plugins/plugin-detail-panel/app-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/app-selector/index.tsx index 1cbaa85174..3c08e7abda 100644 --- a/web/app/components/plugins/plugin-detail-panel/app-selector/index.tsx +++ b/web/app/components/plugins/plugin-detail-panel/app-selector/index.tsx @@ -1,6 +1,6 @@ 'use client' import type { FC } from 'react' -import React, { useState } from 'react' +import React, { useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' import { PortalToFollowElem, @@ -11,7 +11,7 @@ import AppTrigger from '@/app/components/plugins/plugin-detail-panel/app-selecto import AppPicker from '@/app/components/plugins/plugin-detail-panel/app-selector/app-picker' // import Button from '@/app/components/base/button' -import { useAppDetail } from '@/service/use-apps' +import { useAppFullList } from '@/service/use-apps' import type { App } from '@/types/app' import type { OffsetOptions, @@ -48,7 +48,12 @@ const AppSelector: FC = ({ onShowChange(true) } - const { data: currentApp } = useAppDetail(value?.app_id || 'empty') + const { data: appList } = useAppFullList() + const currentAppInfo = useMemo(() => { + if (!appList?.data || !value) + return undefined + return appList.data.find(app => app.id === value.app_id) + }, [appList?.data, value]) const [isShowChooseApp, setIsShowChooseApp] = useState(false) const handleSelectApp = (app: App) => { const appValue = { @@ -60,6 +65,8 @@ const AppSelector: FC = ({ setIsShowChooseApp(false) } + // const { data: currentApp } = useAppDetail(value?.app_id || 'empty') + return ( <> = ({ >
-
{t('tools.toolSelector.label')}
+
{t('app.appSelector.label')}
} isShow={isShowChooseApp} onShowChange={setIsShowChooseApp} disabled={false} + appList={appList?.data || []} onSelect={handleSelectApp} />