2024-10-29 10:51:41 +08:00
|
|
|
import { RiArrowUpDoubleLine } from '@remixicon/react'
|
2024-11-06 11:55:19 +08:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2024-10-29 10:51:41 +08:00
|
|
|
import { useMarketplace } from './hooks'
|
|
|
|
import List from '@/app/components/plugins/marketplace/list'
|
2024-10-29 14:44:30 +08:00
|
|
|
import Loading from '@/app/components/base/loading'
|
2024-11-06 11:55:19 +08:00
|
|
|
import { getLocaleOnClient } from '@/i18n'
|
2024-10-29 10:51:41 +08:00
|
|
|
|
|
|
|
type MarketplaceProps = {
|
2024-10-31 15:41:02 +08:00
|
|
|
searchPluginText: string
|
|
|
|
filterPluginTags: string[]
|
2024-10-29 10:51:41 +08:00
|
|
|
onMarketplaceScroll: () => void
|
|
|
|
}
|
|
|
|
const Marketplace = ({
|
2024-10-31 15:41:02 +08:00
|
|
|
searchPluginText,
|
|
|
|
filterPluginTags,
|
2024-10-29 10:51:41 +08:00
|
|
|
onMarketplaceScroll,
|
|
|
|
}: MarketplaceProps) => {
|
2024-11-06 11:55:19 +08:00
|
|
|
const locale = getLocaleOnClient()
|
|
|
|
const { t } = useTranslation()
|
2024-10-29 14:44:30 +08:00
|
|
|
const {
|
|
|
|
isLoading,
|
|
|
|
marketplaceCollections,
|
|
|
|
marketplaceCollectionPluginsMap,
|
2024-10-31 15:41:02 +08:00
|
|
|
plugins,
|
|
|
|
} = useMarketplace(searchPluginText, filterPluginTags)
|
2024-10-29 14:44:30 +08:00
|
|
|
|
2024-10-29 10:51:41 +08:00
|
|
|
return (
|
|
|
|
<div className='shrink-0 sticky -bottom-[442px] h-[530px] overflow-y-auto px-12 py-2 pt-0 bg-background-default-subtle'>
|
|
|
|
<RiArrowUpDoubleLine
|
|
|
|
className='absolute top-2 left-1/2 -translate-x-1/2 w-4 h-4 text-text-quaternary cursor-pointer'
|
|
|
|
onClick={() => onMarketplaceScroll()}
|
|
|
|
/>
|
|
|
|
<div className='sticky top-0 pt-5 pb-3 bg-background-default-subtle z-10'>
|
|
|
|
<div className='title-2xl-semi-bold bg-gradient-to-r from-[rgba(11,165,236,0.95)] to-[rgba(21,90,239,0.95)] bg-clip-text text-transparent'>More from Marketplace</div>
|
|
|
|
<div className='flex items-center text-center body-md-regular text-text-tertiary'>
|
|
|
|
Discover
|
|
|
|
<span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
|
2024-11-06 11:55:19 +08:00
|
|
|
{t('plugin.category.models')}
|
2024-10-29 10:51:41 +08:00
|
|
|
</span>
|
|
|
|
,
|
|
|
|
<span className="relative ml-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
|
2024-11-06 11:55:19 +08:00
|
|
|
{t('plugin.category.tools')}
|
2024-10-29 10:51:41 +08:00
|
|
|
</span>
|
|
|
|
,
|
|
|
|
<span className="relative ml-1 mr-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
|
2024-11-06 11:55:19 +08:00
|
|
|
{t('plugin.category.extensions')}
|
2024-10-29 10:51:41 +08:00
|
|
|
</span>
|
|
|
|
and
|
|
|
|
<span className="relative ml-1 mr-1 body-md-medium text-text-secondary after:content-[''] after:absolute after:left-0 after:bottom-[1.5px] after:w-full after:h-2 after:bg-text-text-selected">
|
2024-11-06 11:55:19 +08:00
|
|
|
{t('plugin.category.bundles')}
|
2024-10-29 10:51:41 +08:00
|
|
|
</span>
|
|
|
|
in Dify Marketplace
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-10-29 14:44:30 +08:00
|
|
|
{
|
|
|
|
isLoading && (
|
|
|
|
<div className='absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2'>
|
|
|
|
<Loading />
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
!isLoading && (
|
|
|
|
<List
|
2024-10-31 18:31:17 +08:00
|
|
|
marketplaceCollections={marketplaceCollections || []}
|
|
|
|
marketplaceCollectionPluginsMap={marketplaceCollectionPluginsMap || {}}
|
2024-10-31 15:41:02 +08:00
|
|
|
plugins={plugins}
|
2024-10-30 11:06:54 +08:00
|
|
|
showInstallButton
|
2024-11-06 11:55:19 +08:00
|
|
|
locale={locale}
|
2024-10-29 14:44:30 +08:00
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
2024-10-29 10:51:41 +08:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Marketplace
|