app list filter

This commit is contained in:
JzoNg 2024-11-14 15:08:58 +08:00
parent 7446244147
commit 7b4d67d72f
7 changed files with 39 additions and 27 deletions

View File

@ -40,7 +40,7 @@ const AppPicker: FC<Props> = ({
const [searchText, setSearchText] = useState('') const [searchText, setSearchText] = useState('')
const { data: appList } = useAppFullList() const { data: appList } = useAppFullList()
const filteredAppList = useMemo(() => { 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]) }, [appList, searchText])
const getAppType = (app: App) => { const getAppType = (app: App) => {
switch (app.mode) { switch (app.mode) {
@ -81,7 +81,6 @@ const AppPicker: FC<Props> = ({
<Input <Input
showLeftIcon showLeftIcon
showClearIcon showClearIcon
// wrapperClassName='w-[200px]'
value={searchText} value={searchText}
onChange={e => setSearchText(e.target.value)} onChange={e => setSearchText(e.target.value)}
onClear={() => setSearchText('')} onClear={() => setSearchText('')}

View File

@ -26,6 +26,7 @@ const AppTrigger = ({
)}> )}>
{appDetail && ( {appDetail && (
<AppIcon <AppIcon
className='mr-2'
size='xs' size='xs'
iconType={appDetail.icon_type} iconType={appDetail.icon_type}
icon={appDetail.icon} icon={appDetail.icon}

View File

@ -48,7 +48,7 @@ const AppSelector: FC<Props> = ({
onShowChange(true) onShowChange(true)
} }
const { data: currentApp } = useAppDetail(value?.app_id || '') const { data: currentApp } = useAppDetail(value?.app_id || 'empty')
const [isShowChooseApp, setIsShowChooseApp] = useState(false) const [isShowChooseApp, setIsShowChooseApp] = useState(false)
const handleSelectApp = (app: App) => { const handleSelectApp = (app: App) => {
const appValue = { const appValue = {
@ -74,7 +74,7 @@ const AppSelector: FC<Props> = ({
> >
<AppTrigger <AppTrigger
open={isShow} open={isShow}
appDetail={undefined} appDetail={currentApp}
/> />
</PortalToFollowElemTrigger> </PortalToFollowElemTrigger>
<PortalToFollowElemContent className='z-[1000]'> <PortalToFollowElemContent className='z-[1000]'>
@ -87,7 +87,7 @@ const AppSelector: FC<Props> = ({
trigger={ trigger={
<AppTrigger <AppTrigger
open={isShowChooseApp} open={isShowChooseApp}
appDetail={undefined} appDetail={currentApp}
/> />
} }
isShow={isShowChooseApp} isShow={isShowChooseApp}

View File

@ -73,7 +73,7 @@ const EndpointModal: FC<Props> = ({
isEditMode={true} isEditMode={true}
showOnVariableMap={{}} showOnVariableMap={{}}
validating={false} 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 fieldMoreInfo={item => item.url
? (<a ? (<a
href={item.url} href={item.url}

View File

@ -67,7 +67,7 @@ const ToolCredentialForm: FC<Props> = ({
isEditMode={true} isEditMode={true}
showOnVariableMap={{}} showOnVariableMap={{}}
validating={false} 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 fieldMoreInfo={item => item.url
? (<a ? (<a
href={item.url} href={item.url}

View File

@ -1,5 +1,6 @@
import { get } from './base' import { get } from './base'
import type { App } from '@/types/app' import type { App } from '@/types/app'
import type { AppListResponse } from '@/models/app'
import { useInvalid } from './use-base' import { useInvalid } from './use-base'
import { useQuery } from '@tanstack/react-query' import { useQuery } from '@tanstack/react-query'
@ -8,9 +9,9 @@ const NAME_SPACE = 'apps'
// TODO paging for list // TODO paging for list
const useAppFullListKey = [NAME_SPACE, 'full-list'] const useAppFullListKey = [NAME_SPACE, 'full-list']
export const useAppFullList = () => { export const useAppFullList = () => {
return useQuery<App[]>({ return useQuery<AppListResponse>({
queryKey: useAppFullListKey, queryKey: useAppFullListKey,
queryFn: () => get<App[]>('/apps', { params: { page: 1, limit: 100 } }), queryFn: () => get<AppListResponse>('/apps', { params: { page: 1, limit: 100 } }),
}) })
} }
@ -21,6 +22,10 @@ export const useInvalidateAppFullList = () => {
export const useAppDetail = (appID: string) => { export const useAppDetail = (appID: string) => {
return useQuery<App>({ return useQuery<App>({
queryKey: [NAME_SPACE, 'detail', appID], queryKey: [NAME_SPACE, 'detail', appID],
queryFn: () => get<App>(`/apps/${appID}`), queryFn: () => {
if (appID === 'empty')
return Promise.resolve(undefined as unknown as App)
return get<App>(`/apps/${appID}`)
},
}) })
} }

View File

@ -48,7 +48,7 @@ export enum RETRIEVE_METHOD {
keywordSearch = 'keyword_search', keywordSearch = 'keyword_search',
} }
export interface VariableInput { export type VariableInput = {
key: string key: string
name: string name: string
value: string value: string
@ -69,7 +69,7 @@ export type VariableType = typeof VariableTypes[number]
/** /**
* Prompt variable parameter * Prompt variable parameter
*/ */
export interface PromptVariable { export type PromptVariable = {
/** Variable key */ /** Variable key */
key: string key: string
/** Variable name */ /** Variable name */
@ -82,7 +82,7 @@ export interface PromptVariable {
max_length?: number max_length?: number
} }
export interface TextTypeFormItem { export type TextTypeFormItem = {
default: string default: string
label: string label: string
variable: string variable: string
@ -90,7 +90,7 @@ export interface TextTypeFormItem {
max_length: number max_length: number
} }
export interface SelectTypeFormItem { export type SelectTypeFormItem = {
default: string default: string
label: string label: string
variable: string variable: string
@ -98,7 +98,7 @@ export interface SelectTypeFormItem {
options: string[] options: string[]
} }
export interface ParagraphTypeFormItem { export type ParagraphTypeFormItem = {
default: string default: string
label: string label: string
variable: string variable: string
@ -115,7 +115,7 @@ export type UserInputFormItem = {
paragraph: TextTypeFormItem paragraph: TextTypeFormItem
} }
export interface AgentTool { export type AgentTool = {
provider_id: string provider_id: string
provider_type: CollectionType provider_type: CollectionType
provider_name: string provider_name: string
@ -145,7 +145,7 @@ export enum AgentStrategy {
react = 'react', react = 'react',
} }
export interface CompletionParams { export type CompletionParams = {
/** Maximum number of tokens in the answer message returned by Completion */ /** Maximum number of tokens in the answer message returned by Completion */
max_tokens: number max_tokens: number
/** /**
@ -193,7 +193,7 @@ export interface CompletionParams {
/** /**
* Model configuration. The backend type. * Model configuration. The backend type.
*/ */
export interface Model { export type Model = {
/** LLM provider, e.g., OPENAI */ /** LLM provider, e.g., OPENAI */
provider: string provider: string
/** Model name, e.g, gpt-3.5.turbo */ /** Model name, e.g, gpt-3.5.turbo */
@ -203,7 +203,7 @@ export interface Model {
completion_params: CompletionParams completion_params: CompletionParams
} }
export interface ModelConfig { export type ModelConfig = {
opening_statement: string opening_statement: string
suggested_questions?: string[] suggested_questions?: string[]
pre_prompt: string pre_prompt: string
@ -254,7 +254,7 @@ export type Language = typeof LanguagesSupported[number]
/** /**
* Web Application Configuration * Web Application Configuration
*/ */
export interface SiteConfig { export type SiteConfig = {
/** Application URL Identifier: `http://dify.app/{access_token}` */ /** Application URL Identifier: `http://dify.app/{access_token}` */
access_token: string access_token: string
/** Public Title */ /** Public Title */
@ -307,7 +307,7 @@ export type AppIconType = 'image' | 'emoji'
/** /**
* App * App
*/ */
export interface App { export type App = {
/** App ID */ /** App ID */
id: string id: string
/** Name */ /** Name */
@ -351,16 +351,23 @@ export interface App {
/** api site url */ /** api site url */
api_base_url: string api_base_url: string
tags: Tag[] 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 enable_sso: boolean
} }
/** /**
* App Template * App Template
*/ */
export interface AppTemplate { export type AppTemplate = {
/** Name */ /** Name */
name: string name: string
/** Description */ /** Description */
@ -389,7 +396,7 @@ export enum TtsAutoPlay {
export const ALLOW_FILE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif'] export const ALLOW_FILE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'webp', 'gif']
export interface VisionSettings { export type VisionSettings = {
enabled: boolean enabled: boolean
number_limits: number number_limits: number
detail: Resolution detail: Resolution
@ -397,7 +404,7 @@ export interface VisionSettings {
image_file_size_limit?: number | string image_file_size_limit?: number | string
} }
export interface ImageFile { export type ImageFile = {
type: TransferMethod type: TransferMethod
_id: string _id: string
fileId: string fileId: string
@ -408,7 +415,7 @@ export interface ImageFile {
deleted?: boolean deleted?: boolean
} }
export interface VisionFile { export type VisionFile = {
id?: string id?: string
type: string type: string
transfer_method: TransferMethod transfer_method: TransferMethod
@ -417,7 +424,7 @@ export interface VisionFile {
belongs_to?: string belongs_to?: string
} }
export interface RetrievalConfig { export type RetrievalConfig = {
search_method: RETRIEVE_METHOD search_method: RETRIEVE_METHOD
reranking_enable: boolean reranking_enable: boolean
reranking_model: { reranking_model: {