diff --git a/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx b/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx index a6bffaafe4..23e64f1ab6 100644 --- a/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx +++ b/web/app/components/plugins/marketplace/search-box/search-box-wrapper.tsx @@ -24,10 +24,12 @@ import SearchDropdown from './search-dropdown' type SearchBoxWrapperProps = { wrapperClassName?: string inputClassName?: string + includeSource?: boolean } const SearchBoxWrapper = ({ wrapperClassName, inputClassName, + includeSource = true, }: SearchBoxWrapperProps) => { const { t } = useTranslation() const [searchText, handleSearchTextChange] = useSearchText() @@ -126,6 +128,7 @@ const SearchBoxWrapper = ({ plugins={dropdownPlugins} templates={dropdownTemplates} creators={dropdownCreators} + includeSource={includeSource} onShowAll={handleSubmit} isLoading={dropdownQuery.isLoading} /> diff --git a/web/app/components/plugins/marketplace/search-box/search-dropdown/index.tsx b/web/app/components/plugins/marketplace/search-box/search-dropdown/index.tsx index aa4cb3a47d..b75a516af8 100644 --- a/web/app/components/plugins/marketplace/search-box/search-dropdown/index.tsx +++ b/web/app/components/plugins/marketplace/search-box/search-dropdown/index.tsx @@ -69,11 +69,35 @@ const ItemMeta = ({ items }: { items: (React.ReactNode | string)[] }) => ( ) +const getSearchParamsString = (params?: Record) => { + const searchParams = new URLSearchParams() + if (params) { + Object.keys(params).forEach((key) => { + const value = params[key] + if (value !== undefined && value !== null) + searchParams.append(key, value) + }) + } + return searchParams.toString() +} + +const getDropdownMarketplaceUrl = ( + path: string, + params: Record | undefined, + includeSource: boolean, +) => { + if (includeSource) + return getMarketplaceUrl(path, params) + const query = getSearchParamsString(params) + return query ? `${path}?${query}` : path +} + type SearchDropdownProps = { query: string plugins: Plugin[] templates: Template[] creators: Creator[] + includeSource?: boolean onShowAll: () => void isLoading?: boolean } @@ -83,6 +107,7 @@ const SearchDropdown = ({ plugins, templates, creators, + includeSource = true, onShowAll, isLoading = false, }: SearchDropdownProps) => { @@ -100,6 +125,7 @@ const SearchDropdown = ({ , ) @@ -122,6 +148,7 @@ const SearchDropdown = ({ , ) @@ -166,8 +193,9 @@ const SearchDropdown = ({ /* ---------- Templates Section ---------- */ -function TemplatesSection({ templates, t }: { +function TemplatesSection({ templates, includeSource, t }: { templates: Template[] + includeSource: boolean t: ReturnType['t'] }) { return ( @@ -180,7 +208,11 @@ function TemplatesSection({ templates, t }: { return ( ['t'] }) { return ( @@ -275,7 +308,7 @@ function CreatorsSection({ creators, t }: {