From 71976f91922484b360f2061ac589e572b9402e7e Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Fri, 10 Jan 2025 14:03:00 +0800 Subject: [PATCH] fix: marketplace serach bundle (#12581) --- web/app/components/plugins/marketplace/hooks.ts | 2 +- web/app/components/plugins/marketplace/utils.ts | 3 +++ web/app/components/plugins/types.ts | 1 + web/service/use-plugins.ts | 3 ++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web/app/components/plugins/marketplace/hooks.ts b/web/app/components/plugins/marketplace/hooks.ts index 8f811d1b3e..83a6709a47 100644 --- a/web/app/components/plugins/marketplace/hooks.ts +++ b/web/app/components/plugins/marketplace/hooks.ts @@ -72,7 +72,7 @@ export const useMarketplacePlugins = () => { const handleUpdatePlugins = useCallback((pluginsSearchParams: PluginsSearchParams) => { mutateAsync(pluginsSearchParams).then((res) => { const currentPage = pluginsSearchParams.page || 1 - const resPlugins = res.data.plugins + const resPlugins = res.data.bundles || res.data.plugins if (currentPage > 1) { setPrevPlugins(prevPlugins => [...(prevPlugins || []), ...resPlugins.map((plugin) => { return getFormattedPlugin(plugin) diff --git a/web/app/components/plugins/marketplace/utils.ts b/web/app/components/plugins/marketplace/utils.ts index 78d4437681..0c00a98d6d 100644 --- a/web/app/components/plugins/marketplace/utils.ts +++ b/web/app/components/plugins/marketplace/utils.ts @@ -110,6 +110,9 @@ export const getMarketplaceListCondition = (pluginType: string) => { if (pluginType === PluginType.extension) return 'category=endpoint' + if (pluginType === 'bundle') + return 'type=bundle' + return '' } diff --git a/web/app/components/plugins/types.ts b/web/app/components/plugins/types.ts index 15da9991a6..e9f7884257 100644 --- a/web/app/components/plugins/types.ts +++ b/web/app/components/plugins/types.ts @@ -320,6 +320,7 @@ export type UninstallPluginResponse = { export type PluginsFromMarketplaceResponse = { plugins: Plugin[] + bundles?: Plugin[] total: number } export type PluginsFromMarketplaceByInfoResponse = { diff --git a/web/service/use-plugins.ts b/web/service/use-plugins.ts index 66e55c6431..1673b5fff8 100644 --- a/web/service/use-plugins.ts +++ b/web/service/use-plugins.ts @@ -305,7 +305,8 @@ export const useMutationPluginsFromMarketplace = () => { page = 1, pageSize = 40, } = pluginsSearchParams - return postMarketplace<{ data: PluginsFromMarketplaceResponse }>('/plugins/search/basic', { + const pluginOrBundle = type === 'bundle' ? 'bundles' : 'plugins' + return postMarketplace<{ data: PluginsFromMarketplaceResponse }>(`/${pluginOrBundle}/search/basic`, { body: { page, page_size: pageSize,