diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-task-list.tsx b/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-task-list.tsx index cc2eed1dbb..be678df42f 100644 --- a/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-task-list.tsx +++ b/web/app/components/plugins/plugin-page/plugin-tasks/components/plugin-task-list.tsx @@ -15,6 +15,7 @@ type PluginTaskListProps = { onClearAll: () => void onClearErrors: () => void onClearSingle: (taskId: string, pluginId: string) => void + onStopAll: () => void } const PluginTaskList: FC = ({ @@ -25,6 +26,7 @@ const PluginTaskList: FC = ({ onClearAll, onClearErrors, onClearSingle, + onStopAll, }) => { const { t } = useTranslation() const language = useGetLanguage() @@ -43,6 +45,16 @@ const PluginTaskList: FC = ({ } defaultStatusText={t('task.installingHint', { ns: 'plugin' })} + headerAction={( + + )} /> )} diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/hooks.ts b/web/app/components/plugins/plugin-page/plugin-tasks/hooks.ts index e780072904..00f2cbbb27 100644 --- a/web/app/components/plugins/plugin-page/plugin-tasks/hooks.ts +++ b/web/app/components/plugins/plugin-page/plugin-tasks/hooks.ts @@ -5,6 +5,7 @@ import { import { TaskStatus } from '@/app/components/plugins/types' import { useMutationClearTaskPlugin, + useMutationStopAllTaskPlugins, usePluginTaskList, } from '@/service/use-plugins' @@ -14,6 +15,7 @@ export const usePluginTaskStatus = () => { handleRefetch, } = usePluginTaskList() const { mutateAsync } = useMutationClearTaskPlugin() + const { mutateAsync: mutateStopAllAsync } = useMutationStopAllTaskPlugins() const allPlugins = pluginTasks.map(task => task.plugins.map((plugin) => { return { ...plugin, @@ -40,6 +42,11 @@ export const usePluginTaskStatus = () => { }) handleRefetch() }, [mutateAsync, handleRefetch]) + + const handleStopAllPlugins = useCallback(async () => { + await mutateStopAllAsync() + handleRefetch() + }, [mutateStopAllAsync, handleRefetch]) const totalPluginsLength = allPlugins.length const runningPluginsLength = runningPlugins.length const errorPluginsLength = errorPlugins.length @@ -65,5 +72,6 @@ export const usePluginTaskStatus = () => { isSuccess, isFailed, handleClearErrorPlugin, + handleStopAllPlugins, } } diff --git a/web/app/components/plugins/plugin-page/plugin-tasks/index.tsx b/web/app/components/plugins/plugin-page/plugin-tasks/index.tsx index 00fcb7e072..775eee2e0a 100644 --- a/web/app/components/plugins/plugin-page/plugin-tasks/index.tsx +++ b/web/app/components/plugins/plugin-page/plugin-tasks/index.tsx @@ -31,6 +31,7 @@ const PluginTasks = () => { isSuccess, isFailed, handleClearErrorPlugin, + handleStopAllPlugins, } = usePluginTaskStatus() const { getIconUrl } = useGetIcon() const canOpenMenu = isFailed || isInstalling || isInstallingWithSuccess || isInstallingWithError || isSuccess @@ -81,6 +82,12 @@ const PluginTasks = () => { [clearPluginsAndClose, errorPlugins], ) + + const handleStopAll = useCallback(async () => { + await handleStopAllPlugins() + setOpen(false) + }, [handleStopAllPlugins]) + const handleClearSingle = useCallback( (taskId: string, pluginId: string) => clearPluginsAndClose([{ taskId, plugin_unique_identifier: pluginId }]), [clearPluginsAndClose], @@ -127,6 +134,7 @@ const PluginTasks = () => { onClearAll={handleClearAll} onClearErrors={handleClearErrors} onClearSingle={handleClearSingle} + onStopAll={handleStopAll} /> diff --git a/web/i18n/en-US/plugin.json b/web/i18n/en-US/plugin.json index 85f8b3bbbd..4f7cc3033f 100644 --- a/web/i18n/en-US/plugin.json +++ b/web/i18n/en-US/plugin.json @@ -248,6 +248,7 @@ "task.installingWithError": "Installing {{installingLength}} plugins, {{successLength}} success, {{errorLength}} failed", "task.installingWithSuccess": "Installing {{installingLength}} plugins, {{successLength}} success.", "task.runningPlugins": "Installing Plugins", + "task.stopAll": "Stop all", "task.successPlugins": "Successfully Installed Plugins", "upgrade.close": "Close", "upgrade.description": "About to install the following plugin", @@ -256,4 +257,4 @@ "upgrade.upgrade": "Install", "upgrade.upgrading": "Installing...", "upgrade.usedInApps": "Used in {{num}} apps" -} +} \ No newline at end of file diff --git a/web/i18n/zh-Hans/plugin.json b/web/i18n/zh-Hans/plugin.json index 5d640b5723..3f0f2de238 100644 --- a/web/i18n/zh-Hans/plugin.json +++ b/web/i18n/zh-Hans/plugin.json @@ -248,6 +248,7 @@ "task.installingWithError": "{{installingLength}} 个插件安装中,{{successLength}} 安装成功,{{errorLength}} 安装失败", "task.installingWithSuccess": "{{installingLength}} 个插件安装中,{{successLength}} 安装成功", "task.runningPlugins": "正在安装的插件", + "task.stopAll": "停止所有", "task.successPlugins": "安装成功的插件", "upgrade.close": "关闭", "upgrade.description": "即将安装以下插件", diff --git a/web/i18n/zh-Hant/plugin.json b/web/i18n/zh-Hant/plugin.json index 4e7d577aaa..2af4fe5c6f 100644 --- a/web/i18n/zh-Hant/plugin.json +++ b/web/i18n/zh-Hant/plugin.json @@ -248,6 +248,7 @@ "task.installingWithError": "安裝 {{installingLength}} 個插件,{{successLength}} 成功,{{errorLength}} 失敗", "task.installingWithSuccess": "安裝 {{installingLength}} 個插件,{{successLength}} 成功。", "task.runningPlugins": "Installing Plugins", + "task.stopAll": "停止所有", "task.successPlugins": "Successfully Installed Plugins", "upgrade.close": "關閉", "upgrade.description": "即將安裝以下插件", diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts index 6004ecde56..0f12c941c5 100644 --- a/web/service/use-plugins.ts +++ b/web/service/use-plugins.ts @@ -560,6 +560,14 @@ export const useMutationClearTaskPlugin = () => { }) } +export const useMutationStopAllTaskPlugins = () => { + return useMutation({ + mutationFn: () => { + return post<{ success: boolean }>('/workspaces/current/plugin/tasks/delete_all') + }, + }) +} + export const usePluginManifestInfo = (pluginUID: string) => { return useQuery({ enabled: !!pluginUID,