diff --git a/web/app/components/plugins/marketplace/index.tsx b/web/app/components/plugins/marketplace/index.tsx index 300aad9e7c..d9f0920893 100644 --- a/web/app/components/plugins/marketplace/index.tsx +++ b/web/app/components/plugins/marketplace/index.tsx @@ -6,7 +6,12 @@ import PluginTypeSwitch from './plugin-type-switch' import ListWrapper from './list/list-wrapper' import { getMarketplaceCollectionsAndPlugins } from './utils' -const Marketplace = async () => { +type MarketplaceProps = { + showInstallButton?: boolean +} +const Marketplace = async ({ + showInstallButton = true, +}: MarketplaceProps) => { const { marketplaceCollections, marketplaceCollectionPluginsMap } = await getMarketplaceCollectionsAndPlugins() return ( @@ -18,6 +23,7 @@ const Marketplace = async () => { ) diff --git a/web/app/components/plugins/marketplace/list/card-wrapper.tsx b/web/app/components/plugins/marketplace/list/card-wrapper.tsx new file mode 100644 index 0000000000..d9eaa55a16 --- /dev/null +++ b/web/app/components/plugins/marketplace/list/card-wrapper.tsx @@ -0,0 +1,50 @@ +'use client' +import { RiArrowRightUpLine } from '@remixicon/react' +import Card from '@/app/components/plugins/card' +import CardMoreInfo from '@/app/components/plugins/card/card-more-info' +import type { Plugin } from '@/app/components/plugins/types' +import Button from '@/app/components/base/button' + +type CardWrapperProps = { + plugin: Plugin + showInstallButton?: boolean +} +const CardWrapper = ({ + plugin, + showInstallButton, +}: CardWrapperProps) => { + return ( +
+ + } + /> + { + showInstallButton && ( +
+ + +
+ ) + } +
+ ) +} + +export default CardWrapper diff --git a/web/app/components/plugins/marketplace/list/index.tsx b/web/app/components/plugins/marketplace/list/index.tsx index 6f268839ec..0d03e8073d 100644 --- a/web/app/components/plugins/marketplace/list/index.tsx +++ b/web/app/components/plugins/marketplace/list/index.tsx @@ -2,18 +2,19 @@ import type { Plugin } from '../../types' import type { MarketplaceCollection } from '../types' import ListWithCollection from './list-with-collection' -import Card from '@/app/components/plugins/card' -import CardMoreInfo from '@/app/components/plugins/card/card-more-info' +import CardWrapper from './card-wrapper' type ListProps = { marketplaceCollections: MarketplaceCollection[] marketplaceCollectionPluginsMap: Record plugins?: Plugin[] + showInstallButton?: boolean } const List = ({ marketplaceCollections, marketplaceCollectionPluginsMap, plugins, + showInstallButton, }: ListProps) => { return ( <> @@ -22,6 +23,7 @@ const List = ({ ) } @@ -30,15 +32,10 @@ const List = ({
{ plugins.map(plugin => ( - - } + plugin={plugin} + showInstallButton={showInstallButton} /> )) } diff --git a/web/app/components/plugins/marketplace/list/list-with-collection.tsx b/web/app/components/plugins/marketplace/list/list-with-collection.tsx index 944b72a0e0..6d56380c52 100644 --- a/web/app/components/plugins/marketplace/list/list-with-collection.tsx +++ b/web/app/components/plugins/marketplace/list/list-with-collection.tsx @@ -1,16 +1,17 @@ 'use client' import type { MarketplaceCollection } from '../types' +import CardWrapper from './card-wrapper' import type { Plugin } from '@/app/components/plugins/types' -import Card from '@/app/components/plugins/card' -import CardMoreInfo from '@/app/components/plugins/card/card-more-info' type ListWithCollectionProps = { marketplaceCollections: MarketplaceCollection[] marketplaceCollectionPluginsMap: Record + showInstallButton?: boolean } const ListWithCollection = ({ marketplaceCollections, marketplaceCollectionPluginsMap, + showInstallButton, }: ListWithCollectionProps) => { return ( <> @@ -25,15 +26,10 @@ const ListWithCollection = ({
{ marketplaceCollectionPluginsMap[collection.name].map(plugin => ( - - } + plugin={plugin} + 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 c4b5c854c7..c8c6a30823 100644 --- a/web/app/components/plugins/marketplace/list/list-wrapper.tsx +++ b/web/app/components/plugins/marketplace/list/list-wrapper.tsx @@ -8,10 +8,12 @@ import SortDropdown from '../sort-dropdown' type ListWrapperProps = { marketplaceCollections: MarketplaceCollection[] marketplaceCollectionPluginsMap: Record + showInstallButton?: boolean } const ListWrapper = ({ marketplaceCollections, marketplaceCollectionPluginsMap, + showInstallButton, }: ListWrapperProps) => { const plugins = useMarketplaceContext(s => s.plugins) @@ -26,6 +28,7 @@ const ListWrapper = ({ marketplaceCollections={marketplaceCollections} marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap} plugins={plugins} + showInstallButton={showInstallButton} />
) diff --git a/web/app/components/plugins/marketplace/utils.ts b/web/app/components/plugins/marketplace/utils.ts index 558a07736f..88ca1da0fa 100644 --- a/web/app/components/plugins/marketplace/utils.ts +++ b/web/app/components/plugins/marketplace/utils.ts @@ -15,7 +15,12 @@ export const getMarketplaceCollectionsAndPlugins = async () => { await Promise.all(marketplaceCollections.map(async (collection: MarketplaceCollection) => { const marketplaceCollectionPluginsData = await globalThis.fetch(`${MARKETPLACE_API_PREFIX}/collections/${collection.name}/plugins`) const marketplaceCollectionPluginsDataJson = await marketplaceCollectionPluginsData.json() - const plugins = marketplaceCollectionPluginsDataJson.data.plugins + const plugins = marketplaceCollectionPluginsDataJson.data.plugins.map((plugin: Plugin) => { + return { + ...plugin, + icon: `${MARKETPLACE_API_PREFIX}/plugins/${plugin.org}/${plugin.name}/icon`, + } + }) marketplaceCollectionPluginsMap[collection.name] = plugins })) @@ -54,7 +59,12 @@ export const getMarketplacePlugins = async (query: PluginsSearchParams) => { }, ) const marketplacePluginsDataJson = await marketplacePluginsData.json() - marketplacePlugins = marketplacePluginsDataJson.data.plugins + marketplacePlugins = marketplacePluginsDataJson.data.plugins.map((plugin: Plugin) => { + return { + ...plugin, + icon: `${MARKETPLACE_API_PREFIX}/plugins/${plugin.org}/${plugin.name}/icon`, + } + }) } // eslint-disable-next-line unused-imports/no-unused-vars catch (e) { diff --git a/web/app/components/tools/marketplace/index.tsx b/web/app/components/tools/marketplace/index.tsx index aeed373489..64ec83f460 100644 --- a/web/app/components/tools/marketplace/index.tsx +++ b/web/app/components/tools/marketplace/index.tsx @@ -55,6 +55,7 @@ const Marketplace = ({ ) }