mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 06:45:53 +08:00
enable marketplace
This commit is contained in:
parent
846555af1b
commit
1a64c660ba
@ -22,6 +22,7 @@ import TabSlider from '@/app/components/base/tab-slider'
|
|||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
import PermissionSetModal from '@/app/components/plugins/permission-setting-modal/modal'
|
import PermissionSetModal from '@/app/components/plugins/permission-setting-modal/modal'
|
||||||
|
import { useSelector as useAppContextSelector } from '@/context/app-context'
|
||||||
|
|
||||||
export type PluginPageProps = {
|
export type PluginPageProps = {
|
||||||
plugins: React.ReactNode
|
plugins: React.ReactNode
|
||||||
@ -45,12 +46,17 @@ const PluginPage = ({
|
|||||||
}] = useBoolean()
|
}] = useBoolean()
|
||||||
const [currentFile, setCurrentFile] = useState<File | null>(null)
|
const [currentFile, setCurrentFile] = useState<File | null>(null)
|
||||||
const containerRef = usePluginPageContext(v => v.containerRef)
|
const containerRef = usePluginPageContext(v => v.containerRef)
|
||||||
|
const { enable_marketplace } = useAppContextSelector(s => s.systemFeatures)
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
{ value: 'plugins', text: t('common.menus.plugins') },
|
{ value: 'plugins', text: t('common.menus.plugins') },
|
||||||
{ value: 'discover', text: 'Explore Marketplace' },
|
...(
|
||||||
|
!enable_marketplace
|
||||||
|
? [{ value: 'discover', text: 'Explore Marketplace' }]
|
||||||
|
: []
|
||||||
|
),
|
||||||
]
|
]
|
||||||
}, [t])
|
}, [t, enable_marketplace])
|
||||||
const [activeTab, setActiveTab] = useTabSearchParams({
|
const [activeTab, setActiveTab] = useTabSearchParams({
|
||||||
defaultTab: options[0].value,
|
defaultTab: options[0].value,
|
||||||
})
|
})
|
||||||
@ -137,7 +143,7 @@ const PluginPage = ({
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{
|
{
|
||||||
activeTab === 'discover' && marketplace
|
activeTab === 'discover' && !enable_marketplace && marketplace
|
||||||
}
|
}
|
||||||
|
|
||||||
{showPluginSettingModal && (
|
{showPluginSettingModal && (
|
||||||
|
@ -15,12 +15,14 @@ import {
|
|||||||
PortalToFollowElemContent,
|
PortalToFollowElemContent,
|
||||||
PortalToFollowElemTrigger,
|
PortalToFollowElemTrigger,
|
||||||
} from '@/app/components/base/portal-to-follow-elem'
|
} from '@/app/components/base/portal-to-follow-elem'
|
||||||
|
import { useSelector as useAppContextSelector } from '@/context/app-context'
|
||||||
|
|
||||||
const InstallPluginDropdown = () => {
|
const InstallPluginDropdown = () => {
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null)
|
const fileInputRef = useRef<HTMLInputElement>(null)
|
||||||
const [isMenuOpen, setIsMenuOpen] = useState(false)
|
const [isMenuOpen, setIsMenuOpen] = useState(false)
|
||||||
const [selectedAction, setSelectedAction] = useState<string | null>(null)
|
const [selectedAction, setSelectedAction] = useState<string | null>(null)
|
||||||
const [selectedFile, setSelectedFile] = useState<File | null>(null)
|
const [selectedFile, setSelectedFile] = useState<File | null>(null)
|
||||||
|
const { enable_marketplace } = useAppContextSelector(s => s.systemFeatures)
|
||||||
|
|
||||||
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const file = event.target.files?.[0]
|
const file = event.target.files?.[0]
|
||||||
@ -62,7 +64,11 @@ const InstallPluginDropdown = () => {
|
|||||||
/>
|
/>
|
||||||
<div className='p-1 w-full'>
|
<div className='p-1 w-full'>
|
||||||
{[
|
{[
|
||||||
{ icon: MagicBox, text: 'Marketplace', action: 'marketplace' },
|
...(
|
||||||
|
enable_marketplace
|
||||||
|
? [{ icon: MagicBox, text: 'Marketplace', action: 'marketplace' }]
|
||||||
|
: []
|
||||||
|
),
|
||||||
{ icon: Github, text: 'GitHub', action: 'github' },
|
{ icon: Github, text: 'GitHub', action: 'github' },
|
||||||
{ icon: FileZip, text: 'Local Package File', action: 'local' },
|
{ icon: FileZip, text: 'Local Package File', action: 'local' },
|
||||||
].map(({ icon: Icon, text, action }) => (
|
].map(({ icon: Icon, text, action }) => (
|
||||||
|
@ -19,11 +19,13 @@ import { fetchCollectionList } from '@/service/tools'
|
|||||||
import Card from '@/app/components/plugins/card'
|
import Card from '@/app/components/plugins/card'
|
||||||
import { useGetLanguage } from '@/context/i18n'
|
import { useGetLanguage } from '@/context/i18n'
|
||||||
import CardMoreInfo from '@/app/components/plugins/card/card-more-info'
|
import CardMoreInfo from '@/app/components/plugins/card/card-more-info'
|
||||||
|
import { useSelector as useAppContextSelector } from '@/context/app-context'
|
||||||
|
|
||||||
const ProviderList = () => {
|
const ProviderList = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const language = useGetLanguage()
|
const language = useGetLanguage()
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
|
const { enable_marketplace } = useAppContextSelector(s => s.systemFeatures)
|
||||||
|
|
||||||
const [activeTab, setActiveTab] = useTabSearchParams({
|
const [activeTab, setActiveTab] = useTabSearchParams({
|
||||||
defaultTab: 'builtin',
|
defaultTab: 'builtin',
|
||||||
@ -109,6 +111,7 @@ const ProviderList = () => {
|
|||||||
'border-[1.5px] border-transparent',
|
'border-[1.5px] border-transparent',
|
||||||
currentProvider?.id === collection.id && 'border-components-option-card-option-selected-border',
|
currentProvider?.id === collection.id && 'border-components-option-card-option-selected-border',
|
||||||
)}
|
)}
|
||||||
|
hideCornerMark
|
||||||
locale={language}
|
locale={language}
|
||||||
payload={{
|
payload={{
|
||||||
...collection,
|
...collection,
|
||||||
@ -116,7 +119,6 @@ const ProviderList = () => {
|
|||||||
} as any}
|
} as any}
|
||||||
footer={
|
footer={
|
||||||
<CardMoreInfo
|
<CardMoreInfo
|
||||||
downloadCount={0}
|
|
||||||
tags={collection.labels}
|
tags={collection.labels}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@ -125,9 +127,13 @@ const ProviderList = () => {
|
|||||||
))}
|
))}
|
||||||
{!filteredCollectionList.length && <div className='absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2'><Empty /></div>}
|
{!filteredCollectionList.length && <div className='absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2'><Empty /></div>}
|
||||||
</div>
|
</div>
|
||||||
<Marketplace onMarketplaceScroll={() => {
|
{
|
||||||
containerRef.current?.scrollTo({ top: containerRef.current.scrollHeight, behavior: 'smooth' })
|
!enable_marketplace && (
|
||||||
}} />
|
<Marketplace onMarketplaceScroll={() => {
|
||||||
|
containerRef.current?.scrollTo({ top: containerRef.current.scrollHeight, behavior: 'smooth' })
|
||||||
|
}} />
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<div className={cn(
|
<div className={cn(
|
||||||
'shrink-0 w-0 border-l-[0.5px] border-black/8 overflow-y-auto transition-all duration-200 ease-in-out',
|
'shrink-0 w-0 border-l-[0.5px] border-black/8 overflow-y-auto transition-all duration-200 ease-in-out',
|
||||||
|
@ -4,6 +4,7 @@ export type SystemFeatures = {
|
|||||||
sso_enforced_for_web: boolean
|
sso_enforced_for_web: boolean
|
||||||
sso_enforced_for_web_protocol: string
|
sso_enforced_for_web_protocol: string
|
||||||
enable_web_sso_switch_component: boolean
|
enable_web_sso_switch_component: boolean
|
||||||
|
enable_marketplace: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultSystemFeatures: SystemFeatures = {
|
export const defaultSystemFeatures: SystemFeatures = {
|
||||||
@ -12,4 +13,5 @@ export const defaultSystemFeatures: SystemFeatures = {
|
|||||||
sso_enforced_for_web: false,
|
sso_enforced_for_web: false,
|
||||||
sso_enforced_for_web_protocol: '',
|
sso_enforced_for_web_protocol: '',
|
||||||
enable_web_sso_switch_component: false,
|
enable_web_sso_switch_component: false,
|
||||||
|
enable_marketplace: false,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user