diff --git a/web/app/components/plugins/plugin-detail-panel/detail-header.tsx b/web/app/components/plugins/plugin-detail-panel/detail-header.tsx
index 182cf2d925..686d8c4572 100644
--- a/web/app/components/plugins/plugin-detail-panel/detail-header.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/detail-header.tsx
@@ -1,6 +1,5 @@
import React, { useMemo } from 'react'
import { useTranslation } from 'react-i18next'
-import { useContext } from 'use-context-selector'
import { useBoolean } from 'ahooks'
import {
RiBugLine,
@@ -23,7 +22,8 @@ import Confirm from '@/app/components/base/confirm'
import Tooltip from '@/app/components/base/tooltip'
import { BoxSparkleFill } from '@/app/components/base/icons/src/vender/plugin'
import { Github } from '@/app/components/base/icons/src/public/common'
-import I18n from '@/context/i18n'
+import { useGetLanguage } from '@/context/i18n'
+import { API_PREFIX, MARKETPLACE_URL_PREFIX } from '@/config'
import cn from '@/utils/classnames'
const i18nPrefix = 'plugin.action'
@@ -40,15 +40,22 @@ const DetailHeader = ({
onDelete,
}: Props) => {
const { t } = useTranslation()
- const { locale } = useContext(I18n)
+ const locale = useGetLanguage()
+ const {
+ source,
+ tenant_id,
+ version,
+ latest_version,
+ meta,
+ } = detail
+ const { author, name, label, description, icon, verified } = detail.declaration
+ // Only plugin installed from GitHub need to check if it's the new version
const hasNewVersion = useMemo(() => {
- if (!detail)
- return false
- return false
- // return pluginDetail.latest_version !== pluginDetail.version
- }, [detail])
+ return source === PluginSource.github && latest_version !== version
+ }, [source, latest_version, version])
+ // #plugin TODO# update plugin
const handleUpdate = () => {}
const [isShowPluginInfo, {
@@ -61,19 +68,20 @@ const DetailHeader = ({
setFalse: hideDeleteConfirm,
}] = useBoolean(false)
+ // #plugin TODO# used in apps
const usedInApps = 3
return (
-
+
-
- {detail.declaration.verified && }
+
+ {verified && }
{hasNewVersion && (
@@ -81,32 +89,31 @@ const DetailHeader = ({
)}
-
+
ยท
{detail.source === PluginSource.marketplace && (
-
+
)}
{detail.source === PluginSource.github && (
-
+
)}
{detail.source === PluginSource.local && (
-
+
)}
{detail.source === PluginSource.debugging && (
-
+
)}
@@ -115,19 +122,21 @@ const DetailHeader = ({
-
+
{isShowPluginInfo && (
)}
@@ -137,7 +146,7 @@ const DetailHeader = ({
title={t(`${i18nPrefix}.delete`)}
content={
- {t(`${i18nPrefix}.deleteContentLeft`)}{detail.declaration.label[locale]}{t(`${i18nPrefix}.deleteContentRight`)}
+ {t(`${i18nPrefix}.deleteContentLeft`)}{label[locale]}{t(`${i18nPrefix}.deleteContentRight`)}
{usedInApps > 0 && t(`${i18nPrefix}.usedInApps`, { num: usedInApps })}
}
diff --git a/web/app/components/plugins/plugin-detail-panel/operation-dropdown.tsx b/web/app/components/plugins/plugin-detail-panel/operation-dropdown.tsx
index e8186d1958..b23b29d462 100644
--- a/web/app/components/plugins/plugin-detail-panel/operation-dropdown.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/operation-dropdown.tsx
@@ -14,12 +14,16 @@ import cn from '@/utils/classnames'
type Props = {
onInfo: () => void
+ onCheckVersion: () => void
onRemove: () => void
+ detailUrl: string
}
const OperationDropdown: FC
= ({
onInfo,
+ onCheckVersion,
onRemove,
+ detailUrl,
}) => {
const { t } = useTranslation()
const [open, doSetOpen] = useState(false)
@@ -44,22 +48,40 @@ const OperationDropdown: FC = ({
}}
>
-
-
-
+
-
{t('plugin.detailPanel.operation.info')}
- {/* ##plugin TODO## check update */}
-
{t('plugin.detailPanel.operation.checkUpdate')}
- {/* ##plugin TODO## router action */}
-
-
{t('plugin.detailPanel.operation.viewDetail')}
+
{
+ onInfo()
+ handleTrigger()
+ }}
+ className='px-3 py-1.5 rounded-lg text-text-secondary system-md-regular cursor-pointer hover:bg-state-base-hover'
+ >{t('plugin.detailPanel.operation.info')}
+
{
+ onCheckVersion()
+ handleTrigger()
+ }}
+ className='px-3 py-1.5 rounded-lg text-text-secondary system-md-regular cursor-pointer hover:bg-state-base-hover'
+ >{t('plugin.detailPanel.operation.checkUpdate')}
+
+ {t('plugin.detailPanel.operation.viewDetail')}
-
+
-
{t('plugin.detailPanel.operation.remove')}
+
{
+ onRemove()
+ handleTrigger()
+ }}
+ className='px-3 py-1.5 rounded-lg text-text-secondary system-md-regular cursor-pointer hover:text-text-destructive hover:bg-state-destructive-hover'
+ >{t('plugin.detailPanel.operation.remove')}