|
|
|
@ -1,6 +1,6 @@
|
|
|
|
'use client'
|
|
|
|
'use client'
|
|
|
|
import type { FC } from 'react'
|
|
|
|
import type { FC } from 'react'
|
|
|
|
import React, { useMemo } from 'react'
|
|
|
|
import React, { useEffect } from 'react'
|
|
|
|
// import { RiInformation2Line } from '@remixicon/react'
|
|
|
|
// import { RiInformation2Line } from '@remixicon/react'
|
|
|
|
import type { Plugin, PluginManifestInMarket } from '../../../types'
|
|
|
|
import type { Plugin, PluginManifestInMarket } from '../../../types'
|
|
|
|
import Card from '../../../card'
|
|
|
|
import Card from '../../../card'
|
|
|
|
@ -8,10 +8,10 @@ import { pluginManifestInMarketToPluginProps } from '../../utils'
|
|
|
|
import Button from '@/app/components/base/button'
|
|
|
|
import Button from '@/app/components/base/button'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { RiLoader2Line } from '@remixicon/react'
|
|
|
|
import { RiLoader2Line } from '@remixicon/react'
|
|
|
|
import Badge, { BadgeState } from '@/app/components/base/badge/index'
|
|
|
|
|
|
|
|
import { useInstallPackageFromMarketPlace, useUpdatePackageFromMarketPlace } from '@/service/use-plugins'
|
|
|
|
import { useInstallPackageFromMarketPlace, useUpdatePackageFromMarketPlace } from '@/service/use-plugins'
|
|
|
|
import checkTaskStatus from '../../base/check-task-status'
|
|
|
|
import checkTaskStatus from '../../base/check-task-status'
|
|
|
|
import useCheckInstalled from '@/app/components/plugins/install-plugin/hooks/use-check-installed'
|
|
|
|
import useCheckInstalled from '@/app/components/plugins/install-plugin/hooks/use-check-installed'
|
|
|
|
|
|
|
|
import Version from '../../base/version'
|
|
|
|
|
|
|
|
|
|
|
|
const i18nPrefix = 'plugin.installModal'
|
|
|
|
const i18nPrefix = 'plugin.installModal'
|
|
|
|
|
|
|
|
|
|
|
|
@ -35,7 +35,7 @@ const Installed: FC<Props> = ({
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const toInstallVersion = payload.version || payload.latest_version
|
|
|
|
const toInstallVersion = payload.version || payload.latest_version
|
|
|
|
const pluginId = (payload as Plugin).plugin_id
|
|
|
|
const pluginId = (payload as Plugin).plugin_id
|
|
|
|
const { installedInfo } = useCheckInstalled({
|
|
|
|
const { installedInfo, isLoading } = useCheckInstalled({
|
|
|
|
pluginIds: [pluginId],
|
|
|
|
pluginIds: [pluginId],
|
|
|
|
enabled: !!pluginId,
|
|
|
|
enabled: !!pluginId,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
@ -51,6 +51,11 @@ const Installed: FC<Props> = ({
|
|
|
|
stop,
|
|
|
|
stop,
|
|
|
|
} = checkTaskStatus()
|
|
|
|
} = checkTaskStatus()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if (hasInstalled && toInstallVersion === installedVersion)
|
|
|
|
|
|
|
|
onInstalled()
|
|
|
|
|
|
|
|
}, [hasInstalled, toInstallVersion, installedVersion])
|
|
|
|
|
|
|
|
|
|
|
|
const handleCancel = () => {
|
|
|
|
const handleCancel = () => {
|
|
|
|
stop()
|
|
|
|
stop()
|
|
|
|
onCancel()
|
|
|
|
onCancel()
|
|
|
|
@ -103,26 +108,6 @@ const Installed: FC<Props> = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const versionInfo = useMemo(() => {
|
|
|
|
|
|
|
|
return (<>{
|
|
|
|
|
|
|
|
!installedVersion
|
|
|
|
|
|
|
|
? (
|
|
|
|
|
|
|
|
<Badge className='mx-1' size="s" state={BadgeState.Default}>{ }</Badge>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
<Badge className='mx-1' size="s" state={BadgeState.Warning}>
|
|
|
|
|
|
|
|
{`${installedVersion} -> ${toInstallVersion}`}
|
|
|
|
|
|
|
|
</Badge>
|
|
|
|
|
|
|
|
{/* <div className='flex px-0.5 justify-center items-center gap-0.5'>
|
|
|
|
|
|
|
|
<div className='text-text-warning system-xs-medium'>Used in 3 apps</div>
|
|
|
|
|
|
|
|
<RiInformation2Line className='w-4 h-4 text-text-tertiary' />
|
|
|
|
|
|
|
|
</div> */}
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}</>)
|
|
|
|
|
|
|
|
}, [installedVersion, payload])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<div className='flex flex-col px-6 py-3 justify-center items-start gap-4 self-stretch'>
|
|
|
|
<div className='flex flex-col px-6 py-3 justify-center items-start gap-4 self-stretch'>
|
|
|
|
@ -133,7 +118,11 @@ const Installed: FC<Props> = ({
|
|
|
|
<Card
|
|
|
|
<Card
|
|
|
|
className='w-full'
|
|
|
|
className='w-full'
|
|
|
|
payload={pluginManifestInMarketToPluginProps(payload as PluginManifestInMarket)}
|
|
|
|
payload={pluginManifestInMarketToPluginProps(payload as PluginManifestInMarket)}
|
|
|
|
titleLeft={versionInfo}
|
|
|
|
titleLeft={!isLoading && <Version
|
|
|
|
|
|
|
|
hasInstalled={hasInstalled}
|
|
|
|
|
|
|
|
installedVersion={installedVersion}
|
|
|
|
|
|
|
|
toInstallVersion={toInstallVersion}
|
|
|
|
|
|
|
|
/>}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@ -147,7 +136,7 @@ const Installed: FC<Props> = ({
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
variant='primary'
|
|
|
|
variant='primary'
|
|
|
|
className='min-w-[72px] flex space-x-0.5'
|
|
|
|
className='min-w-[72px] flex space-x-0.5'
|
|
|
|
disabled={isInstalling}
|
|
|
|
disabled={isInstalling || isLoading}
|
|
|
|
onClick={handleInstall}
|
|
|
|
onClick={handleInstall}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{isInstalling && <RiLoader2Line className='w-4 h-4 animate-spin-slow' />}
|
|
|
|
{isInstalling && <RiLoader2Line className='w-4 h-4 animate-spin-slow' />}
|
|
|
|
|