dify/web/app/components/plugins/marketplace/index.tsx

63 lines
2.1 KiB
TypeScript
Raw Normal View History

2024-10-12 18:02:24 +08:00
import { MarketplaceContextProvider } from './context'
import Description from './description'
import IntersectionLine from './intersection-line'
2024-10-31 18:54:13 +08:00
import SearchBoxWrapper from './search-box/search-box-wrapper'
2024-10-12 18:02:24 +08:00
import PluginTypeSwitch from './plugin-type-switch'
2024-10-28 11:50:26 +08:00
import ListWrapper from './list/list-wrapper'
import type { SearchParams } from './types'
2024-10-29 14:44:30 +08:00
import { getMarketplaceCollectionsAndPlugins } from './utils'
2024-11-08 18:21:39 +08:00
import { TanstackQueryIniter } from '@/context/query-client'
2024-10-28 11:50:26 +08:00
2024-10-30 11:06:54 +08:00
type MarketplaceProps = {
locale: string
2024-10-30 11:06:54 +08:00
showInstallButton?: boolean
2024-11-27 16:14:15 +08:00
shouldExclude?: boolean
searchParams?: SearchParams
2024-12-03 18:02:57 +08:00
pluginTypeSwitchClassName?: string
2024-12-05 14:54:04 +08:00
intersectionContainerId?: string
scrollContainerId?: string
2024-10-30 11:06:54 +08:00
}
const Marketplace = async ({
2024-11-06 11:55:19 +08:00
locale,
2024-10-30 11:06:54 +08:00
showInstallButton = true,
2024-11-27 16:14:15 +08:00
shouldExclude,
searchParams,
2024-12-03 18:02:57 +08:00
pluginTypeSwitchClassName,
2024-12-05 14:54:04 +08:00
intersectionContainerId,
scrollContainerId,
2024-10-30 11:06:54 +08:00
}: MarketplaceProps) => {
2024-11-27 16:14:15 +08:00
let marketplaceCollections: any = []
let marketplaceCollectionPluginsMap = {}
if (!shouldExclude) {
const marketplaceCollectionsAndPluginsData = await getMarketplaceCollectionsAndPlugins()
marketplaceCollections = marketplaceCollectionsAndPluginsData.marketplaceCollections
marketplaceCollectionPluginsMap = marketplaceCollectionsAndPluginsData.marketplaceCollectionPluginsMap
}
2024-10-08 17:57:46 +08:00
return (
2024-11-08 18:21:39 +08:00
<TanstackQueryIniter>
2024-12-05 14:54:04 +08:00
<MarketplaceContextProvider
searchParams={searchParams}
shouldExclude={shouldExclude}
scrollContainerId={scrollContainerId}
>
2024-11-08 18:21:39 +08:00
<Description locale={locale} />
2024-12-05 14:54:04 +08:00
<IntersectionLine intersectionContainerId={intersectionContainerId} />
2024-11-08 18:21:39 +08:00
<SearchBoxWrapper locale={locale} />
2024-12-03 18:02:57 +08:00
<PluginTypeSwitch
locale={locale}
className={pluginTypeSwitchClassName}
/>
2024-11-08 18:21:39 +08:00
<ListWrapper
locale={locale}
marketplaceCollections={marketplaceCollections}
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap}
showInstallButton={showInstallButton}
/>
</MarketplaceContextProvider>
</TanstackQueryIniter>
2024-10-08 17:57:46 +08:00
)
}
2024-10-11 16:15:24 +08:00
export default Marketplace