From b83dc5ab99f95138743179d8b7878f33f2a77cde Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Thu, 7 Nov 2024 15:37:22 +0800 Subject: [PATCH 1/2] fix: marketplace --- .../plugins/marketplace/context.tsx | 24 +++++++-- .../plugins/marketplace/description/index.tsx | 4 +- .../plugins/marketplace/empty/index.tsx | 2 +- .../components/plugins/marketplace/index.tsx | 54 ------------------- .../plugins/marketplace/list/list-wrapper.tsx | 2 +- .../marketplace/plugin-type-switch.tsx | 2 +- .../plugins/marketplace/search-box/index.tsx | 2 +- .../search-box/search-box-wrapper.tsx | 2 +- 8 files changed, 28 insertions(+), 64 deletions(-) diff --git a/web/app/components/plugins/marketplace/context.tsx b/web/app/components/plugins/marketplace/context.tsx index 692b3eb5a5..0c87e32919 100644 --- a/web/app/components/plugins/marketplace/context.tsx +++ b/web/app/components/plugins/marketplace/context.tsx @@ -100,6 +100,15 @@ export const MarketplaceContextProvider = ({ setSearchPluginText(text) searchPluginTextRef.current = text + if (!searchPluginTextRef.current && !filterPluginTagsRef.current.length) { + queryMarketplaceCollectionsAndPlugins({ + category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current, + }) + setPlugins(undefined) + + return + } + queryPluginsWithDebounced({ query: text, category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current, @@ -107,12 +116,21 @@ export const MarketplaceContextProvider = ({ sortBy: sortRef.current.sortBy, sortOrder: sortRef.current.sortOrder, }) - }, [queryPluginsWithDebounced]) + }, [queryPluginsWithDebounced, queryMarketplaceCollectionsAndPlugins, setPlugins]) const handleFilterPluginTagsChange = useCallback((tags: string[]) => { setFilterPluginTags(tags) filterPluginTagsRef.current = tags + if (!searchPluginTextRef.current && !filterPluginTagsRef.current.length) { + queryMarketplaceCollectionsAndPlugins({ + category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current, + }) + setPlugins(undefined) + + return + } + queryPlugins({ query: searchPluginTextRef.current, category: activePluginTypeRef.current === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : activePluginTypeRef.current, @@ -120,7 +138,7 @@ export const MarketplaceContextProvider = ({ sortBy: sortRef.current.sortBy, sortOrder: sortRef.current.sortOrder, }) - }, [queryPlugins]) + }, [queryPlugins, setPlugins, queryMarketplaceCollectionsAndPlugins]) const handleActivePluginTypeChange = useCallback((type: string) => { setActivePluginType(type) @@ -130,7 +148,7 @@ export const MarketplaceContextProvider = ({ queryMarketplaceCollectionsAndPlugins({ category: type === PLUGIN_TYPE_SEARCH_MAP.all ? undefined : type, }) - setPlugins([]) + setPlugins(undefined) return } diff --git a/web/app/components/plugins/marketplace/description/index.tsx b/web/app/components/plugins/marketplace/description/index.tsx index 403478dfc7..3b0454c3c6 100644 --- a/web/app/components/plugins/marketplace/description/index.tsx +++ b/web/app/components/plugins/marketplace/description/index.tsx @@ -14,10 +14,10 @@ const Description = async ({ return ( <> -

+

Empower your AI development

-

+

Discover {t('category.models')} diff --git a/web/app/components/plugins/marketplace/empty/index.tsx b/web/app/components/plugins/marketplace/empty/index.tsx index a6e71c9eee..cc3957d3ff 100644 --- a/web/app/components/plugins/marketplace/empty/index.tsx +++ b/web/app/components/plugins/marketplace/empty/index.tsx @@ -4,7 +4,7 @@ import Line from './line' const Empty = () => { return (
{ Array.from({ length: 16 }).map((_, index) => ( diff --git a/web/app/components/plugins/marketplace/index.tsx b/web/app/components/plugins/marketplace/index.tsx index 2cd77dc038..742df86ea0 100644 --- a/web/app/components/plugins/marketplace/index.tsx +++ b/web/app/components/plugins/marketplace/index.tsx @@ -28,60 +28,6 @@ const Marketplace = async ({ marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap} showInstallButton={showInstallButton} /> - - - - - - - - - ) } diff --git a/web/app/components/plugins/marketplace/list/list-wrapper.tsx b/web/app/components/plugins/marketplace/list/list-wrapper.tsx index 443b9ef516..50f4c5d244 100644 --- a/web/app/components/plugins/marketplace/list/list-wrapper.tsx +++ b/web/app/components/plugins/marketplace/list/list-wrapper.tsx @@ -22,7 +22,7 @@ const ListWrapper = ({ const marketplaceCollectionPluginsMapFromClient = useMarketplaceContext(v => v.marketplaceCollectionPluginsMapFromClient) return ( -
+
{ plugins && (
diff --git a/web/app/components/plugins/marketplace/plugin-type-switch.tsx b/web/app/components/plugins/marketplace/plugin-type-switch.tsx index c1469cf6bf..6a44524a0c 100644 --- a/web/app/components/plugins/marketplace/plugin-type-switch.tsx +++ b/web/app/components/plugins/marketplace/plugin-type-switch.tsx @@ -57,7 +57,7 @@ const PluginTypeSwitch = ({ return (
{ options.map(option => ( diff --git a/web/app/components/plugins/marketplace/search-box/index.tsx b/web/app/components/plugins/marketplace/search-box/index.tsx index d37f96f58c..513f8b98ad 100644 --- a/web/app/components/plugins/marketplace/search-box/index.tsx +++ b/web/app/components/plugins/marketplace/search-box/index.tsx @@ -41,7 +41,7 @@ const SearchBox = ({ />
-
+
Date: Thu, 7 Nov 2024 15:47:07 +0800 Subject: [PATCH 2/2] build: update `react-hook-form` --- web/package.json | 6 +++--- web/pnpm-lock.yaml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/package.json b/web/package.json index 350db63944..3cabe91e9b 100644 --- a/web/package.json +++ b/web/package.json @@ -31,7 +31,7 @@ "@formatjs/intl-localematcher": "^0.5.6", "@headlessui/react": "^1.7.13", "@heroicons/react": "^2.0.16", - "@hookform/resolvers": "^3.3.4", + "@hookform/resolvers": "^3.9.0", "@lexical/react": "^0.18.0", "@mdx-js/loader": "^3.1.0", "@mdx-js/react": "^3.1.0", @@ -82,7 +82,7 @@ "react-easy-crop": "^5.1.0", "react-error-boundary": "^4.1.2", "react-headless-pagination": "^1.1.6", - "react-hook-form": "^7.51.4", + "react-hook-form": "^7.53.1", "react-i18next": "^15.1.0", "react-infinite-scroll-component": "^6.1.0", "react-multi-email": "^1.0.25", @@ -110,7 +110,7 @@ "tailwind-merge": "^2.4.0", "use-context-selector": "^2.0.0", "uuid": "^10.0.0", - "zod": "^3.23.6", + "zod": "^3.23.8", "zundo": "^2.1.0", "zustand": "^4.5.2" }, diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 6c8df6e203..3d8776a052 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -35,7 +35,7 @@ importers: specifier: ^2.0.16 version: 2.1.5(react@18.2.0) '@hookform/resolvers': - specifier: ^3.3.4 + specifier: ^3.9.0 version: 3.9.0(react-hook-form@7.53.1(react@18.2.0)) '@lexical/react': specifier: ^0.18.0 @@ -188,7 +188,7 @@ importers: specifier: ^1.1.6 version: 1.1.6(react@18.2.0) react-hook-form: - specifier: ^7.51.4 + specifier: ^7.53.1 version: 7.53.1(react@18.2.0) react-i18next: specifier: ^15.1.0 @@ -272,7 +272,7 @@ importers: specifier: ^10.0.0 version: 10.0.0 zod: - specifier: ^3.23.6 + specifier: ^3.23.8 version: 3.23.8 zundo: specifier: ^2.1.0