diff --git a/web/app/components/plugins/marketplace/index.tsx b/web/app/components/plugins/marketplace/index.tsx index e85411c1ed..d8843ce97c 100644 --- a/web/app/components/plugins/marketplace/index.tsx +++ b/web/app/components/plugins/marketplace/index.tsx @@ -1,18 +1,35 @@ +import type { Plugin } from '../types' import { MarketplaceContextProvider } from './context' import Description from './description' import IntersectionLine from './intersection-line' import SearchBox from './search-box' import PluginTypeSwitch from './plugin-type-switch' -import List from './list' +import ListWrapper from './list/list-wrapper' +import type { MarketplaceCollection } from './types' + +const Marketplace = async () => { + const marketplaceCollectionsData = await globalThis.fetch('https://marketplace.dify.dev/api/v1/collections') + const marketplaceCollectionsDataJson = await marketplaceCollectionsData.json() + const marketplaceCollections = marketplaceCollectionsDataJson.data.collections + const marketplaceCollectionPluginsMap = {} as Record + await Promise.all(marketplaceCollections.map(async (collection: MarketplaceCollection) => { + const marketplaceCollectionPluginsData = await globalThis.fetch(`https://marketplace.dify.dev/api/v1/collections/${collection.name}/plugins`) + const marketplaceCollectionPluginsDataJson = await marketplaceCollectionPluginsData.json() + const plugins = marketplaceCollectionPluginsDataJson.data.plugins + + marketplaceCollectionPluginsMap[collection.name] = plugins + })) -const Marketplace = () => { return ( - + ) } diff --git a/web/app/components/plugins/marketplace/list/index.tsx b/web/app/components/plugins/marketplace/list/index.tsx index a805522b43..604211fb5b 100644 --- a/web/app/components/plugins/marketplace/list/index.tsx +++ b/web/app/components/plugins/marketplace/list/index.tsx @@ -1,197 +1,50 @@ 'use client' +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 { toolNotion } from '@/app/components/plugins/card/card-mock' -const List = () => { +interface ListProps { + marketplaceCollections: MarketplaceCollection[] + marketplaceCollectionPluginsMap: Record + plugins?: Plugin[] +} +const List = ({ + marketplaceCollections, + marketplaceCollectionPluginsMap, + plugins, +}: ListProps) => { return (
-
-
Featured
-
Our top picks to get you started
-
- - } + { + !plugins && ( + - + ) + } + { + plugins && ( +
+ { + plugins.map(plugin => ( + + } + /> + )) } - /> - - } - /> - - } - /> - - } - /> -
-
-
-
Popular
-
Explore the library and discover the incredible work of our community
-
- - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> - - } - /> -
-
+
+ ) + }
) } diff --git a/web/app/components/plugins/marketplace/list/list-with-collection.tsx b/web/app/components/plugins/marketplace/list/list-with-collection.tsx new file mode 100644 index 0000000000..9009b7a799 --- /dev/null +++ b/web/app/components/plugins/marketplace/list/list-with-collection.tsx @@ -0,0 +1,48 @@ +'use client' +import type { MarketplaceCollection } from '../types' +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' + +interface ListWithCollectionProps { + marketplaceCollections: MarketplaceCollection[] + marketplaceCollectionPluginsMap: Record +} +const ListWithCollection = ({ + marketplaceCollections, + marketplaceCollectionPluginsMap, +}: ListWithCollectionProps) => { + return ( + <> + { + marketplaceCollections.map(collection => ( +
+
{collection.name}
+
{collection.description}
+
+ { + marketplaceCollectionPluginsMap[collection.name].map(plugin => ( + + } + /> + )) + } +
+
+ )) + } + + ) +} + +export default ListWithCollection diff --git a/web/app/components/plugins/marketplace/list/list-wrapper.tsx b/web/app/components/plugins/marketplace/list/list-wrapper.tsx new file mode 100644 index 0000000000..0de2fa2c06 --- /dev/null +++ b/web/app/components/plugins/marketplace/list/list-wrapper.tsx @@ -0,0 +1,22 @@ +'use client' +import type { Plugin } from '../../types' +import type { MarketplaceCollection } from '../types' +import List from './index' + +interface ListWrapperProps { + marketplaceCollections: MarketplaceCollection[] + marketplaceCollectionPluginsMap: Record +} +const ListWrapper = ({ + marketplaceCollections, + marketplaceCollectionPluginsMap, +}: ListWrapperProps) => { + return ( + + ) +} + +export default ListWrapper