mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
feat: plugin uninstall & plugin list filtering
This commit is contained in:
@ -1,16 +1,33 @@
|
||||
'use client'
|
||||
import { useState } from 'react'
|
||||
import type { EndpointListItem, PluginDetail } from '../types'
|
||||
import { useMemo, useState } from 'react'
|
||||
import type { EndpointListItem, InstalledPlugin, 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'
|
||||
import { usePluginPageContext } from './context'
|
||||
import { useDebounceFn } from 'ahooks'
|
||||
|
||||
const PluginsPanel = () => {
|
||||
const handleFilterChange = (filters: FilterState) => {
|
||||
//
|
||||
}
|
||||
const [filters, setFilters] = usePluginPageContext(v => [v.filters, v.setFilters])
|
||||
const pluginList = usePluginPageContext(v => v.installedPluginList) as InstalledPlugin[]
|
||||
|
||||
const { run: handleFilterChange } = useDebounceFn((filters: FilterState) => {
|
||||
setFilters(filters)
|
||||
}, { wait: 500 })
|
||||
|
||||
const filteredList = useMemo(() => {
|
||||
// todo: filter by tags
|
||||
const { categories, searchQuery } = filters
|
||||
const filteredList = pluginList.filter((plugin) => {
|
||||
return (
|
||||
(categories.length === 0 || categories.includes(plugin.declaration.category))
|
||||
&& (searchQuery === '' || plugin.plugin_id.toLowerCase().includes(searchQuery.toLowerCase()))
|
||||
)
|
||||
})
|
||||
return filteredList
|
||||
}, [pluginList, filters])
|
||||
|
||||
const [currentPluginDetail, setCurrentPluginDetail] = useState<PluginDetail | undefined>(toolNotion as any)
|
||||
const [currentPluginEndpoints, setCurrentEndpoints] = useState<EndpointListItem[]>(toolNotionEndpoints as any)
|
||||
@ -24,7 +41,7 @@ const PluginsPanel = () => {
|
||||
</div>
|
||||
<div className='flex px-12 items-start content-start gap-2 flex-grow self-stretch flex-wrap'>
|
||||
<div className='w-full'>
|
||||
<List />
|
||||
<List pluginList={filteredList} />
|
||||
</div>
|
||||
</div>
|
||||
<PluginDetailPanel
|
||||
|
||||
Reference in New Issue
Block a user