From 7b4d67d72f29f7eb4e1ac14b43459bc2c5d4e6aa Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 14 Nov 2024 15:08:58 +0800 Subject: [PATCH] app list filter --- .../app-selector/app-picker.tsx | 3 +- .../app-selector/app-trigger.tsx | 1 + .../app-selector/index.tsx | 6 +-- .../plugin-detail-panel/endpoint-modal.tsx | 2 +- .../tool-selector/tool-credentials-form.tsx | 2 +- web/service/use-apps.ts | 11 +++-- web/types/app.ts | 41 +++++++++++-------- 7 files changed, 39 insertions(+), 27 deletions(-) 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 32a0f365f0..4ede53c277 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 @@ -40,7 +40,7 @@ const AppPicker: FC = ({ const [searchText, setSearchText] = useState('') const { data: appList } = useAppFullList() const filteredAppList = useMemo(() => { - return (appList || []).filter(app => app.name.toLowerCase().includes(searchText.toLowerCase())) + return (appList?.data || []).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) { @@ -81,7 +81,6 @@ const AppPicker: FC = ({ setSearchText(e.target.value)} onClear={() => setSearchText('')} diff --git a/web/app/components/plugins/plugin-detail-panel/app-selector/app-trigger.tsx b/web/app/components/plugins/plugin-detail-panel/app-selector/app-trigger.tsx index 1a308b3d9b..2706597a86 100644 --- a/web/app/components/plugins/plugin-detail-panel/app-selector/app-trigger.tsx +++ b/web/app/components/plugins/plugin-detail-panel/app-selector/app-trigger.tsx @@ -26,6 +26,7 @@ const AppTrigger = ({ )}> {appDetail && ( = ({ onShowChange(true) } - const { data: currentApp } = useAppDetail(value?.app_id || '') + const { data: currentApp } = useAppDetail(value?.app_id || 'empty') const [isShowChooseApp, setIsShowChooseApp] = useState(false) const handleSelectApp = (app: App) => { const appValue = { @@ -74,7 +74,7 @@ const AppSelector: FC = ({ > @@ -87,7 +87,7 @@ const AppSelector: FC = ({ trigger={ } isShow={isShowChooseApp} diff --git a/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx b/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx index 704ef9dd41..f6e4a0d0bc 100644 --- a/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx +++ b/web/app/components/plugins/plugin-detail-panel/endpoint-modal.tsx @@ -73,7 +73,7 @@ const EndpointModal: FC = ({ isEditMode={true} showOnVariableMap={{}} validating={false} - inputClassName='bg-components-input-bg-normal hover:bg-state-base-hover-alt' + inputClassName='bg-components-input-bg-normal hover:bg-components-input-bg-hover' fieldMoreInfo={item => item.url ? ( = ({ isEditMode={true} showOnVariableMap={{}} validating={false} - inputClassName='bg-components-input-bg-normal hover:bg-state-base-hover-alt' + inputClassName='bg-components-input-bg-normal hover:bg-components-input-bg-hover' fieldMoreInfo={item => item.url ? ( { - return useQuery({ + return useQuery({ queryKey: useAppFullListKey, - queryFn: () => get('/apps', { params: { page: 1, limit: 100 } }), + queryFn: () => get('/apps', { params: { page: 1, limit: 100 } }), }) } @@ -21,6 +22,10 @@ export const useInvalidateAppFullList = () => { export const useAppDetail = (appID: string) => { return useQuery({ queryKey: [NAME_SPACE, 'detail', appID], - queryFn: () => get(`/apps/${appID}`), + queryFn: () => { + if (appID === 'empty') + return Promise.resolve(undefined as unknown as App) + return get(`/apps/${appID}`) + }, }) } diff --git a/web/types/app.ts b/web/types/app.ts index 93e4e20506..2f5f6254ff 100644 --- a/web/types/app.ts +++ b/web/types/app.ts @@ -48,7 +48,7 @@ export enum RETRIEVE_METHOD { keywordSearch = 'keyword_search', } -export interface VariableInput { +export type VariableInput = { key: string name: string value: string @@ -69,7 +69,7 @@ export type VariableType = typeof VariableTypes[number] /** * Prompt variable parameter */ -export interface PromptVariable { +export type PromptVariable = { /** Variable key */ key: string /** Variable name */ @@ -82,7 +82,7 @@ export interface PromptVariable { max_length?: number } -export interface TextTypeFormItem { +export type TextTypeFormItem = { default: string label: string variable: string @@ -90,7 +90,7 @@ export interface TextTypeFormItem { max_length: number } -export interface SelectTypeFormItem { +export type SelectTypeFormItem = { default: string label: string variable: string @@ -98,7 +98,7 @@ export interface SelectTypeFormItem { options: string[] } -export interface ParagraphTypeFormItem { +export type ParagraphTypeFormItem = { default: string label: string variable: string @@ -115,7 +115,7 @@ export type UserInputFormItem = { paragraph: TextTypeFormItem } -export interface AgentTool { +export type AgentTool = { provider_id: string provider_type: CollectionType provider_name: string @@ -145,7 +145,7 @@ export enum AgentStrategy { react = 'react', } -export interface CompletionParams { +export type CompletionParams = { /** Maximum number of tokens in the answer message returned by Completion */ max_tokens: number /** @@ -193,7 +193,7 @@ export interface CompletionParams { /** * Model configuration. The backend type. */ -export interface Model { +export type Model = { /** LLM provider, e.g., OPENAI */ provider: string /** Model name, e.g, gpt-3.5.turbo */ @@ -203,7 +203,7 @@ export interface Model { completion_params: CompletionParams } -export interface ModelConfig { +export type ModelConfig = { opening_statement: string suggested_questions?: string[] pre_prompt: string @@ -254,7 +254,7 @@ export type Language = typeof LanguagesSupported[number] /** * Web Application Configuration */ -export interface SiteConfig { +export type SiteConfig = { /** Application URL Identifier: `http://dify.app/{access_token}` */ access_token: string /** Public Title */ @@ -307,7 +307,7 @@ export type AppIconType = 'image' | 'emoji' /** * App */ -export interface App { +export type App = { /** App ID */ id: string /** Name */ @@ -351,16 +351,23 @@ export interface App { /** api site url */ api_base_url: string tags: Tag[] + workflow?: { + id: string + created_at: number + created_by?: string + updated_at: number + updated_by?: string + } } -export interface AppSSO { +export type AppSSO = { enable_sso: boolean } /** * App Template */ -export interface AppTemplate { +export type AppTemplate = { /** Name */ name: string /** Description */ @@ -389,7 +396,7 @@ export enum TtsAutoPlay { export const ALLOW_FILE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif'] -export interface VisionSettings { +export type VisionSettings = { enabled: boolean number_limits: number detail: Resolution @@ -397,7 +404,7 @@ export interface VisionSettings { image_file_size_limit?: number | string } -export interface ImageFile { +export type ImageFile = { type: TransferMethod _id: string fileId: string @@ -408,7 +415,7 @@ export interface ImageFile { deleted?: boolean } -export interface VisionFile { +export type VisionFile = { id?: string type: string transfer_method: TransferMethod @@ -417,7 +424,7 @@ export interface VisionFile { belongs_to?: string } -export interface RetrievalConfig { +export type RetrievalConfig = { search_method: RETRIEVE_METHOD reranking_enable: boolean reranking_model: {