feat: in tool install plugin

This commit is contained in:
Joel 2024-11-21 11:16:05 +08:00
parent 98ae34acd5
commit 000db07d29
3 changed files with 17 additions and 3 deletions

View File

@ -52,6 +52,7 @@ const InstallFromMarketplace: React.FC<InstallFromMarketplaceProps> = ({
<Modal
isShow={true}
onClose={onClose}
wrapperClassName='z-[9999]'
className='flex min-w-[560px] p-0 flex-col items-start rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadows-shadow-xl'
closable
>

View File

@ -47,7 +47,7 @@ const OperationDropdown: FC<Props> = ({
<RiMoreFill className='w-4 h-4 text-components-button-secondary-accent-text' />
</ActionButton>
</PortalToFollowElemTrigger>
<PortalToFollowElemContent className='z-50'>
<PortalToFollowElemContent className='z-[9999]'>
<div className='w-[112px] p-1 bg-components-panel-bg-blur rounded-xl border-[0.5px] border-components-panel-border shadow-lg'>
<div className='px-3 py-1.5 rounded-lg text-text-secondary system-md-regular cursor-pointer hover:bg-state-base-hover'>{t('common.operation.download')}</div>
{/* Wait marketplace */}

View File

@ -5,10 +5,12 @@ import { useContext } from 'use-context-selector'
import { useTranslation } from 'react-i18next'
import Action from './action'
import type { Plugin } from '@/app/components/plugins/types.ts'
import InstallFromMarketplace from '@/app/components/plugins/install-plugin/install-from-marketplace'
import I18n from '@/context/i18n'
import cn from '@/utils/classnames'
import { formatNumber } from '@/utils/format'
import { useBoolean } from 'ahooks'
enum ActionType {
install = 'install',
@ -28,6 +30,10 @@ const Item: FC<Props> = ({
const { locale } = useContext(I18n)
const getLocalizedText = (obj: Record<string, string> | undefined) =>
obj?.[locale] || obj?.['en-US'] || obj?.en_US || ''
const [isShowInstallModal, {
setTrue: showInstallModal,
setFalse: hideInstallModal,
}] = useBoolean(false)
return (
<div className='group/plugin flex rounded-lg py-1 pr-1 pl-3 hover:bg-state-base-hover'>
@ -47,14 +53,21 @@ const Item: FC<Props> = ({
</div>
{/* Action */}
<div className={cn(!open ? 'hidden' : 'flex', 'group-hover/plugin:flex items-center space-x-1 h-4 text-components-button-secondary-accent-text system-xs-medium')}>
<div className='px-1.5'>{t('plugin.installAction')}</div>
<div className='px-1.5 cursor-pointer' onClick={showInstallModal}>{t('plugin.installAction')}</div>
<Action
open={open}
onOpenChange={setOpen}
/>
</div>
{isShowInstallModal && (
<InstallFromMarketplace
uniqueIdentifier={payload.latest_package_identifier}
manifest={payload}
onSuccess={hideInstallModal}
onClose={hideInstallModal}
/>
)}
</div>
</div>
)
}