From fbc853af9239e589eaf6525ef20949a3e5a48df2 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 16 Oct 2024 15:13:19 +0800 Subject: [PATCH] feat: remove config --- .../components/plugins/plugin-item/action.tsx | 64 ++++++++++++++++--- .../components/plugins/plugin-item/index.tsx | 2 + web/i18n/en-US/plugin.ts | 8 +++ web/i18n/zh-Hans/plugin.ts | 8 +++ 4 files changed, 73 insertions(+), 9 deletions(-) diff --git a/web/app/components/plugins/plugin-item/action.tsx b/web/app/components/plugins/plugin-item/action.tsx index 59ab0e3e0f..5aae4649bb 100644 --- a/web/app/components/plugins/plugin-item/action.tsx +++ b/web/app/components/plugins/plugin-item/action.tsx @@ -4,11 +4,18 @@ import React from 'react' import { useRouter } from 'next/navigation' import { RiDeleteBinLine, RiInformation2Line, RiLoopLeftLine } from '@remixicon/react' import { useBoolean } from 'ahooks' +import { useTranslation } from 'react-i18next' import PluginInfo from '../plugin-page/plugin-info' import ActionButton from '../../base/action-button' +import Tooltip from '../../base/tooltip' +import Confirm from '../../base/confirm' + +const i18nPrefix = 'plugin.action' type Props = { pluginId: string + pluginName: string + usedInApps: number isShowFetchNewVersion: boolean isShowInfo: boolean isShowDelete: boolean @@ -16,11 +23,14 @@ type Props = { } const Action: FC = ({ + pluginName, + usedInApps, isShowFetchNewVersion, isShowInfo, isShowDelete, onDelete, }) => { + const { t } = useTranslation() const router = useRouter() const [isShowPluginInfo, { setTrue: showPluginInfo, @@ -29,25 +39,45 @@ const Action: FC = ({ const handleFetchNewVersion = () => { } + const [isShowDeleteConfirm, { + setTrue: showDeleteConfirm, + setFalse: hideDeleteConfirm, + }] = useBoolean(false) + // const handleDelete = () => { } return (
{isShowFetchNewVersion - && - - + && ( + + + + + + ) } { isShowInfo - && - - + && ( + + + + + + ) } { isShowDelete - && - - + && ( + + + + + + ) } {isShowPluginInfo && ( @@ -58,6 +88,22 @@ const Action: FC = ({ onHide={hidePluginInfo} /> )} + { + isShowDeleteConfirm && ( + + {t(`${i18nPrefix}.deleteContentLeft`)}{pluginName}{t(`${i18nPrefix}.deleteContentRight`)}
+ {usedInApps > 0 && t(`${i18nPrefix}.usedInApps`, { num: usedInApps })} +
+ } + onCancel={hideDeleteConfirm} + onConfirm={onDelete} + /> + ) + } ) } diff --git a/web/app/components/plugins/plugin-item/index.tsx b/web/app/components/plugins/plugin-item/index.tsx index d4f4159af5..452796c27b 100644 --- a/web/app/components/plugins/plugin-item/index.tsx +++ b/web/app/components/plugins/plugin-item/index.tsx @@ -52,6 +52,8 @@ const PluginItem: FC = ({