mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 19:16:03 +08:00
feat: remove config
This commit is contained in:
parent
1a64c660ba
commit
fbc853af92
@ -4,11 +4,18 @@ import React from 'react'
|
|||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
import { RiDeleteBinLine, RiInformation2Line, RiLoopLeftLine } from '@remixicon/react'
|
import { RiDeleteBinLine, RiInformation2Line, RiLoopLeftLine } from '@remixicon/react'
|
||||||
import { useBoolean } from 'ahooks'
|
import { useBoolean } from 'ahooks'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import PluginInfo from '../plugin-page/plugin-info'
|
import PluginInfo from '../plugin-page/plugin-info'
|
||||||
import ActionButton from '../../base/action-button'
|
import ActionButton from '../../base/action-button'
|
||||||
|
import Tooltip from '../../base/tooltip'
|
||||||
|
import Confirm from '../../base/confirm'
|
||||||
|
|
||||||
|
const i18nPrefix = 'plugin.action'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
pluginId: string
|
pluginId: string
|
||||||
|
pluginName: string
|
||||||
|
usedInApps: number
|
||||||
isShowFetchNewVersion: boolean
|
isShowFetchNewVersion: boolean
|
||||||
isShowInfo: boolean
|
isShowInfo: boolean
|
||||||
isShowDelete: boolean
|
isShowDelete: boolean
|
||||||
@ -16,11 +23,14 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Action: FC<Props> = ({
|
const Action: FC<Props> = ({
|
||||||
|
pluginName,
|
||||||
|
usedInApps,
|
||||||
isShowFetchNewVersion,
|
isShowFetchNewVersion,
|
||||||
isShowInfo,
|
isShowInfo,
|
||||||
isShowDelete,
|
isShowDelete,
|
||||||
onDelete,
|
onDelete,
|
||||||
}) => {
|
}) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [isShowPluginInfo, {
|
const [isShowPluginInfo, {
|
||||||
setTrue: showPluginInfo,
|
setTrue: showPluginInfo,
|
||||||
@ -29,25 +39,45 @@ const Action: FC<Props> = ({
|
|||||||
|
|
||||||
const handleFetchNewVersion = () => { }
|
const handleFetchNewVersion = () => { }
|
||||||
|
|
||||||
|
const [isShowDeleteConfirm, {
|
||||||
|
setTrue: showDeleteConfirm,
|
||||||
|
setFalse: hideDeleteConfirm,
|
||||||
|
}] = useBoolean(false)
|
||||||
|
|
||||||
// const handleDelete = () => { }
|
// const handleDelete = () => { }
|
||||||
return (
|
return (
|
||||||
<div className='flex space-x-1'>
|
<div className='flex space-x-1'>
|
||||||
{isShowFetchNewVersion
|
{isShowFetchNewVersion
|
||||||
&& <ActionButton onClick={handleFetchNewVersion}>
|
&& (
|
||||||
<RiLoopLeftLine className='w-4 h-4 text-text-tertiary' />
|
<Tooltip popupContent={t(`${i18nPrefix}.checkForUpdates`)}>
|
||||||
</ActionButton>
|
<ActionButton onClick={handleFetchNewVersion}>
|
||||||
|
<RiLoopLeftLine className='w-4 h-4 text-text-tertiary' />
|
||||||
|
</ActionButton>
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isShowInfo
|
isShowInfo
|
||||||
&& <ActionButton onClick={showPluginInfo}>
|
&& (
|
||||||
<RiInformation2Line className='w-4 h-4 text-text-tertiary' />
|
<Tooltip popupContent={t(`${i18nPrefix}.pluginInfo`)}>
|
||||||
</ActionButton>
|
<ActionButton onClick={showPluginInfo}>
|
||||||
|
<RiInformation2Line className='w-4 h-4 text-text-tertiary' />
|
||||||
|
</ActionButton>
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
isShowDelete
|
isShowDelete
|
||||||
&& <ActionButton className='hover:bg-state-destructive-hover text-text-tertiary hover:text-text-destructive' onClick={onDelete}>
|
&& (
|
||||||
<RiDeleteBinLine className='w-4 h-4' />
|
<Tooltip popupContent={t(`${i18nPrefix}.delete`)}>
|
||||||
</ActionButton>
|
<ActionButton
|
||||||
|
className='hover:bg-state-destructive-hover text-text-tertiary hover:text-text-destructive'
|
||||||
|
onClick={showDeleteConfirm}
|
||||||
|
>
|
||||||
|
<RiDeleteBinLine className='w-4 h-4' />
|
||||||
|
</ActionButton>
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
{isShowPluginInfo && (
|
{isShowPluginInfo && (
|
||||||
@ -58,6 +88,22 @@ const Action: FC<Props> = ({
|
|||||||
onHide={hidePluginInfo}
|
onHide={hidePluginInfo}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{
|
||||||
|
isShowDeleteConfirm && (
|
||||||
|
<Confirm
|
||||||
|
isShow
|
||||||
|
title={t(`${i18nPrefix}.delete`)}
|
||||||
|
content={
|
||||||
|
<div>
|
||||||
|
{t(`${i18nPrefix}.deleteContentLeft`)}<span className='system-md-semibold'>{pluginName}</span>{t(`${i18nPrefix}.deleteContentRight`)}<br />
|
||||||
|
{usedInApps > 0 && t(`${i18nPrefix}.usedInApps`, { num: usedInApps })}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
onCancel={hideDeleteConfirm}
|
||||||
|
onConfirm={onDelete}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,8 @@ const PluginItem: FC<Props> = ({
|
|||||||
<Description text={payload.brief[locale]} descriptionLineRows={1}></Description>
|
<Description text={payload.brief[locale]} descriptionLineRows={1}></Description>
|
||||||
<Action
|
<Action
|
||||||
pluginId='xxx'
|
pluginId='xxx'
|
||||||
|
pluginName={label[locale]}
|
||||||
|
usedInApps={5}
|
||||||
isShowFetchNewVersion={hasNewVersion}
|
isShowFetchNewVersion={hasNewVersion}
|
||||||
isShowInfo
|
isShowInfo
|
||||||
isShowDelete
|
isShowDelete
|
||||||
|
@ -39,6 +39,14 @@ const translation = {
|
|||||||
release: 'Release',
|
release: 'Release',
|
||||||
packageName: 'Package',
|
packageName: 'Package',
|
||||||
},
|
},
|
||||||
|
action: {
|
||||||
|
checkForUpdates: 'Check for updates',
|
||||||
|
pluginInfo: 'Plugin info',
|
||||||
|
delete: 'Remove plugin',
|
||||||
|
deleteContentLeft: 'Would you like to remove ',
|
||||||
|
deleteContentRight: ' plugin?',
|
||||||
|
usedInApps: 'This plugin is being used in {{num}} apps.',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translation
|
export default translation
|
||||||
|
@ -39,6 +39,14 @@ const translation = {
|
|||||||
release: '发布版本',
|
release: '发布版本',
|
||||||
packageName: '包',
|
packageName: '包',
|
||||||
},
|
},
|
||||||
|
action: {
|
||||||
|
checkForUpdates: '检查更新',
|
||||||
|
pluginInfo: '插件信息',
|
||||||
|
delete: '移除插件',
|
||||||
|
deleteContentLeft: '是否要移除 ',
|
||||||
|
deleteContentRight: ' 插件?',
|
||||||
|
usedInApps: '此插件正在 {{num}} 个应用中使用。',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translation
|
export default translation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user