chore: remove

This commit is contained in:
金伟强 2023-05-19 19:26:29 +08:00
parent d5585a7284
commit 41a069f86b
4 changed files with 43 additions and 21 deletions

View File

@ -38,12 +38,12 @@ const ItemOperation: FC<IItemOperationProps> = ({
}}>
<div className={cn(s.actionItem, 'hover:bg-gray-50 group')} onClick={togglePin}>
{PinIcon}
<span className={s.actionName}>{isPinned ? t('explore.sideBar.action.unpin') : t('explore.sideBar.action.pin')}</span>
<span className={s.actionName}>{isPinned ? t('explore.sidebar.action.unpin') : t('explore.sidebar.action.pin')}</span>
</div>
{isShowDelete && (
<div className={cn(s.actionItem, s.deleteActionItem, 'hover:bg-gray-50 group')} onClick={onDelete} >
<TrashIcon className={'w-4 h-4 stroke-current text-gray-500 stroke-2 group-hover:text-red-500'} />
<span className={cn(s.actionName, 'group-hover:text-red-500')}>{t('explore.sideBar.action.delete')}</span>
<span className={cn(s.actionName, 'group-hover:text-red-500')}>{t('explore.sidebar.action.delete')}</span>
</div>
)}

View File

@ -1,5 +1,5 @@
'use client'
import React, { FC, useEffect } from 'react'
import React, { FC, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useContext } from 'use-context-selector'
import ExploreContext from '@/context/explore-context'
@ -9,6 +9,7 @@ import Link from 'next/link'
import Item from './app-nav-item'
import { fetchInstalledAppList as doFetchInstalledAppList, uninstallApp, updatePinStatus } from '@/service/explore'
import Toast from '../../base/toast'
import Confirm from '@/app/components/base/confirm'
const SelectedDiscoveryIcon = () => (
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
@ -37,12 +38,16 @@ const SideBar: FC<{
const {installed_apps} : any = await doFetchInstalledAppList()
setInstalledApps(installed_apps)
}
const handleDelete = async (id: string) => {
const [showConfirm, setShowConfirm] = useState(false)
const [currId, setCurrId] = useState('')
const handleDelete = async () => {
const id = currId
await uninstallApp(id)
setShowConfirm(false)
Toast.notify({
type: 'success',
message: t('common.api.Removed')
message: t('common.api.remove')
})
fetchInstalledAppList()
}
@ -96,13 +101,26 @@ const SideBar: FC<{
isPinned={is_pinned}
togglePin={() => handleUpdatePinStatus(id, !is_pinned)}
uninstallable={uninstallable}
onDelete={handleDelete}
onDelete={(id) => {
setCurrId(id)
setShowConfirm(true)
}}
/>
)
})}
</div>
</div>
)}
{showConfirm && (
<Confirm
title={t('explore.sidebar.delete.title')}
content={t('explore.sidebar.delete.content')}
isShow={showConfirm}
onClose={() => setShowConfirm(false)}
onConfirm={handleDelete}
onCancel={() => setShowConfirm(false)}
/>
)}
</div>
)
}

View File

@ -2,6 +2,15 @@ const translation = {
sidebar: {
discovery: 'Discovery',
workspace: 'Workspace',
action: {
pin: 'Pin',
unpin: 'Unpin',
delete: 'Delete',
},
delete: {
title: 'Delete app',
content: 'Are you sure you want to delete this app?',
}
},
apps: {
title: 'Explore Apps by Dify',
@ -17,13 +26,6 @@ const translation = {
subTitle: 'App icon & name',
nameRequired: 'App name is required',
},
sideBar: {
action: {
pin: 'Pin',
unpin: 'Unpin',
delete: 'Delete',
}
}
}
export default translation

View File

@ -2,6 +2,15 @@ const translation = {
sidebar: {
discovery: '发现',
workspace: '工作区',
action: {
pin: '置顶',
unpin: '取消置顶',
delete: '删除',
},
delete: {
title: '删除程序',
content: '您确定要删除此程序吗?',
}
},
apps: {
title: '探索 Dify 的应用',
@ -17,13 +26,6 @@ const translation = {
subTitle: '应用程序图标和名称',
nameRequired: '应用程序名称不能为空',
},
sideBar: {
action: {
pin: '置顶',
unpin: '取消置顶',
delete: '删除',
}
}
}
export default translation