From 5ba0b857389baa376dcf05daa639c38f0c17a104 Mon Sep 17 00:00:00 2001
From: AkaraChen
Date: Fri, 3 Jan 2025 10:35:06 +0800
Subject: [PATCH] feat: install plugin button
---
.../components/agent-strategy-selector.tsx | 6 +++---
.../components/install-plugin-button.tsx | 18 ++++++++++++-----
.../workflow/nodes/agent/use-config.ts | 20 ++++++++++++++-----
web/service/use-plugins.ts | 5 +++--
web/service/use-strategy.ts | 4 +++-
5 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx b/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx
index dddaf1fd40..685f3386b4 100644
--- a/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx
+++ b/web/app/components/workflow/nodes/_base/components/agent-strategy-selector.tsx
@@ -83,7 +83,7 @@ export const AgentStrategySelector = memo((props: AgentStrategySelectorProps) =>
if (!list) return []
return list.filter(tool => tool.name.toLowerCase().includes(query.toLowerCase()))
}, [query, list])
- const isShowError = (['plugin-not-found', 'strategy-not-found'] as Array).includes(strategyStatus)
+ const showError = (['plugin-not-found', 'strategy-not-found'] as Array).includes(strategyStatus)
const icon = list?.find(
coll => coll.tools?.find(tool => tool.name === value?.agent_strategy_name),
)?.icon as string | undefined
@@ -105,8 +105,8 @@ export const AgentStrategySelector = memo((props: AgentStrategySelectorProps) =>
{value?.agent_strategy_label || t('workflow.nodes.agent.strategy.selectTip')}
{value &&
- {strategyStatus === 'plugin-not-found' && e.stopPropagation()} size={'small'} />}
- {isShowError ? : }
+ {strategyStatus === 'plugin-not-found' && e.stopPropagation()} size={'small'} uniqueIdentifier={value.plugin_unique_identifier} />}
+ {showError ? : }
}
diff --git a/web/app/components/workflow/nodes/_base/components/install-plugin-button.tsx b/web/app/components/workflow/nodes/_base/components/install-plugin-button.tsx
index 992dfc05e4..f6a3334378 100644
--- a/web/app/components/workflow/nodes/_base/components/install-plugin-button.tsx
+++ b/web/app/components/workflow/nodes/_base/components/install-plugin-button.tsx
@@ -1,6 +1,6 @@
import Button from '@/app/components/base/button'
import { RiInstallLine, RiLoader2Line } from '@remixicon/react'
-import type { ComponentProps } from 'react'
+import type { ComponentProps, MouseEventHandler } from 'react'
import classNames from '@/utils/classnames'
import { useTranslation } from 'react-i18next'
import { useCheckInstalled, useInstallPackageFromMarketPlace } from '@/service/use-plugins'
@@ -21,13 +21,21 @@ export const InstallPluginButton = (props: InstallPluginButtonProps) => {
manifest.refetch()
},
})
- const handleInstall = () => {
+ const handleInstall: MouseEventHandler = (e) => {
+ e.stopPropagation()
install.mutate(uniqueIdentifier)
}
+ const isLoading = manifest.isLoading || install.isPending
if (!manifest.data) return null
if (manifest.data.plugins.some(plugin => plugin.id === uniqueIdentifier)) return null
- return