feat: handle import from marketplace
This commit is contained in:
parent
8d8d5b5235
commit
2cb7b73ee7
@ -111,7 +111,9 @@ const PluginPage = ({
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{canManagement && (
|
{canManagement && (
|
||||||
<InstallPluginDropdown />
|
<InstallPluginDropdown
|
||||||
|
onSwitchToMarketplaceTab={() => setActiveTab('discover')}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{
|
{
|
||||||
canDebugger && (
|
canDebugger && (
|
||||||
|
@ -6,7 +6,6 @@ import Button from '@/app/components/base/button'
|
|||||||
import { MagicBox } from '@/app/components/base/icons/src/vender/solid/mediaAndDevices'
|
import { MagicBox } from '@/app/components/base/icons/src/vender/solid/mediaAndDevices'
|
||||||
import { FileZip } from '@/app/components/base/icons/src/vender/solid/files'
|
import { FileZip } from '@/app/components/base/icons/src/vender/solid/files'
|
||||||
import { Github } from '@/app/components/base/icons/src/vender/solid/general'
|
import { Github } from '@/app/components/base/icons/src/vender/solid/general'
|
||||||
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
|
|
||||||
import InstallFromGitHub from '@/app/components/plugins/install-plugin/install-from-github'
|
import InstallFromGitHub from '@/app/components/plugins/install-plugin/install-from-github'
|
||||||
import InstallFromLocalPackage from '@/app/components/plugins/install-plugin/install-from-local-package'
|
import InstallFromLocalPackage from '@/app/components/plugins/install-plugin/install-from-local-package'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
@ -17,7 +16,12 @@ import {
|
|||||||
} from '@/app/components/base/portal-to-follow-elem'
|
} from '@/app/components/base/portal-to-follow-elem'
|
||||||
import { useSelector as useAppContextSelector } from '@/context/app-context'
|
import { useSelector as useAppContextSelector } from '@/context/app-context'
|
||||||
|
|
||||||
const InstallPluginDropdown = () => {
|
type Props = {
|
||||||
|
onSwitchToMarketplaceTab: () => void
|
||||||
|
}
|
||||||
|
const InstallPluginDropdown = ({
|
||||||
|
onSwitchToMarketplaceTab,
|
||||||
|
}: Props) => {
|
||||||
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)
|
||||||
@ -53,7 +57,7 @@ const InstallPluginDropdown = () => {
|
|||||||
<PortalToFollowElemContent className='z-[1002]'>
|
<PortalToFollowElemContent className='z-[1002]'>
|
||||||
<div className='flex flex-col p-1 pb-2 items-start w-[200px] bg-components-panel-bg-blur border border-components-panel-border rounded-xl shadows-shadow-lg'>
|
<div className='flex flex-col p-1 pb-2 items-start w-[200px] bg-components-panel-bg-blur border border-components-panel-border rounded-xl shadows-shadow-lg'>
|
||||||
<span className='flex pt-1 pb-0.5 pl-2 pr-3 items-start self-stretch text-text-tertiary system-xs-medium-uppercase'>
|
<span className='flex pt-1 pb-0.5 pl-2 pr-3 items-start self-stretch text-text-tertiary system-xs-medium-uppercase'>
|
||||||
Install Form
|
Install From
|
||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
type='file'
|
type='file'
|
||||||
@ -65,7 +69,7 @@ const InstallPluginDropdown = () => {
|
|||||||
<div className='p-1 w-full'>
|
<div className='p-1 w-full'>
|
||||||
{[
|
{[
|
||||||
...(
|
...(
|
||||||
enable_marketplace
|
(enable_marketplace || true)
|
||||||
? [{ icon: MagicBox, text: 'Marketplace', action: 'marketplace' }]
|
? [{ icon: MagicBox, text: 'Marketplace', action: 'marketplace' }]
|
||||||
: []
|
: []
|
||||||
),
|
),
|
||||||
@ -79,6 +83,10 @@ const InstallPluginDropdown = () => {
|
|||||||
if (action === 'local') {
|
if (action === 'local') {
|
||||||
fileInputRef.current?.click()
|
fileInputRef.current?.click()
|
||||||
}
|
}
|
||||||
|
else if (action === 'marketplace') {
|
||||||
|
onSwitchToMarketplaceTab()
|
||||||
|
setIsMenuOpen(false)
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
setSelectedAction(action)
|
setSelectedAction(action)
|
||||||
setIsMenuOpen(false)
|
setIsMenuOpen(false)
|
||||||
@ -93,7 +101,6 @@ const InstallPluginDropdown = () => {
|
|||||||
</div>
|
</div>
|
||||||
</PortalToFollowElemContent>
|
</PortalToFollowElemContent>
|
||||||
</div>
|
</div>
|
||||||
{selectedAction === 'marketplace' && <InstallFromMarketplace onClose={() => setSelectedAction(null)} />}
|
|
||||||
{selectedAction === 'github' && <InstallFromGitHub onClose={() => setSelectedAction(null)} />}
|
{selectedAction === 'github' && <InstallFromGitHub onClose={() => setSelectedAction(null)} />}
|
||||||
{selectedAction === 'local' && selectedFile
|
{selectedAction === 'local' && selectedFile
|
||||||
&& (<InstallFromLocalPackage
|
&& (<InstallFromLocalPackage
|
||||||
|
Loading…
Reference in New Issue
Block a user