mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
fix: plugin task
This commit is contained in:
parent
601d267b7a
commit
c6d1b7869d
|
@ -1,19 +1,12 @@
|
|||
import { useCallback } from 'react'
|
||||
import { apiPrefix } from '@/config'
|
||||
import { fetchWorkspaces } from '@/service/common'
|
||||
|
||||
let tenantId: string | null | undefined = null
|
||||
import { useSelector } from '@/context/app-context'
|
||||
|
||||
const useGetIcon = () => {
|
||||
const getIconUrl = async (fileName: string) => {
|
||||
if (!tenantId) {
|
||||
const { workspaces } = await fetchWorkspaces({
|
||||
url: '/workspaces',
|
||||
params: {},
|
||||
})
|
||||
tenantId = workspaces.find(v => v.current)?.id
|
||||
}
|
||||
return `${apiPrefix}/workspaces/current/plugin/icon?tenant_id=${tenantId}&filename=${fileName}`
|
||||
}
|
||||
const currentWorkspace = useSelector(s => s.currentWorkspace)
|
||||
const getIconUrl = useCallback((fileName: string) => {
|
||||
return `${apiPrefix}/workspaces/current/plugin/icon?tenant_id=${currentWorkspace.id}&filename=${fileName}`
|
||||
}, [currentWorkspace.id])
|
||||
|
||||
return {
|
||||
getIconUrl,
|
||||
|
|
|
@ -20,6 +20,7 @@ import ProgressCircle from '@/app/components/base/progress-bar/progress-circle'
|
|||
import CardIcon from '@/app/components/plugins/card/base/card-icon'
|
||||
import cn from '@/utils/classnames'
|
||||
import { useGetLanguage } from '@/context/i18n'
|
||||
import useGetIcon from '@/app/components/plugins/install-plugin/base/use-get-icon'
|
||||
|
||||
const PluginTasks = () => {
|
||||
const { t } = useTranslation()
|
||||
|
@ -32,6 +33,7 @@ const PluginTasks = () => {
|
|||
totalPluginsLength,
|
||||
handleClearErrorPlugin,
|
||||
} = usePluginTaskStatus()
|
||||
const { getIconUrl } = useGetIcon()
|
||||
|
||||
const isInstalling = runningPlugins.length > 0 && errorPlugins.length === 0 && successPlugins.length === 0
|
||||
const isInstallingWithError = errorPlugins.length > 0 && errorPlugins.length < totalPluginsLength
|
||||
|
@ -123,7 +125,8 @@ const PluginTasks = () => {
|
|||
<div className='relative flex items-center justify-center mr-2 w-6 h-6 rounded-md border-[0.5px] border-components-panel-border-subtle bg-background-default-dodge'>
|
||||
<RiErrorWarningFill className='absolute -right-0.5 -bottom-0.5 w-3 h-3 text-text-destructive' />
|
||||
<CardIcon
|
||||
src={errorPlugin.icon}
|
||||
size='tiny'
|
||||
src={getIconUrl(errorPlugin.icon)}
|
||||
/>
|
||||
</div>
|
||||
<div className='grow system-md-regular text-text-secondary truncate'>
|
||||
|
|
|
@ -120,7 +120,7 @@ export const useMutationPluginsFromMarketplace = () => {
|
|||
|
||||
const usePluginTaskListKey = [NAME_SPACE, 'pluginTaskList']
|
||||
export const usePluginTaskList = () => {
|
||||
const [enabled, setEnabled] = useState(false)
|
||||
const [enabled, setEnabled] = useState(true)
|
||||
const {
|
||||
data,
|
||||
isFetched,
|
||||
|
@ -137,7 +137,7 @@ export const usePluginTaskList = () => {
|
|||
|
||||
return currentData
|
||||
},
|
||||
refetchInterval: 5000,
|
||||
// refetchInterval: 5000,
|
||||
enabled,
|
||||
})
|
||||
const handleRefetch = useCallback(() => {
|
||||
|
@ -157,7 +157,7 @@ export const usePluginTaskList = () => {
|
|||
export const useMutationClearTaskPlugin = () => {
|
||||
return useMutation({
|
||||
mutationFn: ({ taskId, pluginId }: { taskId: string; pluginId: string }) => {
|
||||
return post<{ success: boolean }>(`/workspaces/current/plugin/task/${taskId}/delete/${pluginId}`)
|
||||
return post<{ success: boolean }>(`/workspaces/current/plugin/tasks/${taskId}/delete/${pluginId}`)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user