diff --git a/web/app/components/plugins/marketplace/constants.ts b/web/app/components/plugins/marketplace/constants.ts index e9f9bfdc0a..3952200c28 100644 --- a/web/app/components/plugins/marketplace/constants.ts +++ b/web/app/components/plugins/marketplace/constants.ts @@ -15,7 +15,7 @@ export const SCROLL_BOTTOM_THRESHOLD = 100 export const CATEGORY_ALL = 'all' export const PLUGIN_TYPE_SEARCH_MAP = { - all: CATEGORY_ALL, + [CATEGORY_ALL]: CATEGORY_ALL, model: PluginCategoryEnum.model, tool: PluginCategoryEnum.tool, agent: PluginCategoryEnum.agent, @@ -38,7 +38,7 @@ export const PLUGIN_CATEGORY_WITH_COLLECTIONS = new Set( ) export const TEMPLATE_CATEGORY_MAP = { - all: CATEGORY_ALL, + [CATEGORY_ALL]: CATEGORY_ALL, marketing: 'marketing', sales: 'sales', support: 'support', diff --git a/web/app/components/plugins/marketplace/list/list-top-info.tsx b/web/app/components/plugins/marketplace/list/list-top-info.tsx index 1dfd177c81..4dfee39c34 100644 --- a/web/app/components/plugins/marketplace/list/list-top-info.tsx +++ b/web/app/components/plugins/marketplace/list/list-top-info.tsx @@ -4,20 +4,18 @@ import { useTranslation } from '#i18n' import { useActivePluginCategory, useActiveTemplateCategory, + useCreationType, useFilterPluginTags, } from '../atoms' import { usePluginCategoryText, useTemplateCategoryText } from '../category-switch/category-text' import { CATEGORY_ALL, - TEMPLATE_CATEGORY_MAP, } from '../constants' +import { CREATION_TYPE } from '../search-params' import SortDropdown from '../sort-dropdown' -type ListTopInfoProps = { - variant: 'plugins' | 'templates' -} - -const ListTopInfo = ({ variant }: ListTopInfoProps) => { +const ListTopInfo = () => { + const [creationType] = useCreationType() const { t } = useTranslation() const [filterPluginTags] = useFilterPluginTags() const [activePluginCategory] = useActivePluginCategory() @@ -25,7 +23,9 @@ const ListTopInfo = ({ variant }: ListTopInfoProps) => { const getPluginCategoryText = usePluginCategoryText() const getTemplateCategoryText = useTemplateCategoryText() - const hasTags = variant === 'plugins' && filterPluginTags.length > 0 + const isPluginsView = creationType === CREATION_TYPE.plugins + + const hasTags = isPluginsView && filterPluginTags.length > 0 if (hasTags) { return ( @@ -38,26 +38,20 @@ const ListTopInfo = ({ variant }: ListTopInfoProps) => { ) } - const isPlugins = variant === 'plugins' - const isAllCategory = isPlugins + const isAllCategory = isPluginsView ? activePluginCategory === CATEGORY_ALL - : activeTemplateCategory === TEMPLATE_CATEGORY_MAP.all + : activeTemplateCategory === CATEGORY_ALL - const categoryText = isPlugins + const categoryText = isPluginsView ? getPluginCategoryText(activePluginCategory) : getTemplateCategoryText(activeTemplateCategory) - const title = isPlugins - ? isAllCategory - ? t('marketplace.listTopInfo.pluginsTitleAll', { ns: 'plugin' }) - : t('marketplace.listTopInfo.pluginsTitleByCategory', { ns: 'plugin', category: categoryText }) - : isAllCategory - ? t('marketplace.listTopInfo.templatesTitleAll', { ns: 'plugin' }) - : t('marketplace.listTopInfo.templatesTitleByCategory', { ns: 'plugin', category: categoryText }) - - const subtitleKey = isPlugins - ? 'marketplace.listTopInfo.pluginsSubtitle' - : 'marketplace.listTopInfo.templatesSubtitle' + const title = t( + `marketplace.listTopInfo.${creationType}${isAllCategory ? 'TitleAll' : 'TitleByCategory'}`, + isAllCategory + ? { ns: 'plugin' } + : { ns: 'plugin', category: categoryText }, + ) return (
@@ -66,7 +60,7 @@ const ListTopInfo = ({ variant }: ListTopInfoProps) => { {title}

- {t(subtitleKey, { ns: 'plugin' })} + {t(`marketplace.listTopInfo.${creationType}Subtitle`, { ns: 'plugin' })}

diff --git a/web/app/components/plugins/marketplace/list/list-wrapper.tsx b/web/app/components/plugins/marketplace/list/list-wrapper.tsx index e2cd82bd9b..c7eb04efa6 100644 --- a/web/app/components/plugins/marketplace/list/list-wrapper.tsx +++ b/web/app/components/plugins/marketplace/list/list-wrapper.tsx @@ -1,6 +1,7 @@ 'use client' import Loading from '@/app/components/base/loading' +import { useMarketplaceSearchMode } from '../atoms' import { isPluginsData, useMarketplaceData } from '../state' import FlatList from './flat-list' import ListTopInfo from './list-top-info' @@ -13,16 +14,14 @@ type ListWrapperProps = { const ListWrapper = ({ showInstallButton }: ListWrapperProps) => { const marketplaceData = useMarketplaceData() const { isLoading, page, isFetchingNextPage } = marketplaceData + const isSearchMode = useMarketplaceSearchMode() const renderContent = () => { if (isPluginsData(marketplaceData)) { const { pluginCollections, pluginCollectionPluginsMap, plugins } = marketplaceData return plugins !== undefined ? ( - <> - - - + ) : ( { const { templateCollections, templateCollectionTemplatesMap, templates } = marketplaceData return templates !== undefined ? ( - <> - - - + ) : ( { style={{ scrollbarGutter: 'stable' }} className="relative flex grow flex-col bg-background-default-subtle px-12 py-2" > - {isLoading && page === 1 && ( -
- -
- )} - {(!isLoading || page > 1) && renderContent()} + {isSearchMode && } +
+ {isLoading && page === 1 && ( +
+ +
+ )} + {(!isLoading || page > 1) && renderContent()} +
{isFetchingNextPage && } )