chore: remove

pull/198/head
金伟强 3 years ago
parent d5585a7284
commit 41a069f86b

@ -38,12 +38,12 @@ const ItemOperation: FC<IItemOperationProps> = ({
}}> }}>
<div className={cn(s.actionItem, 'hover:bg-gray-50 group')} onClick={togglePin}> <div className={cn(s.actionItem, 'hover:bg-gray-50 group')} onClick={togglePin}>
{PinIcon} {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> </div>
{isShowDelete && ( {isShowDelete && (
<div className={cn(s.actionItem, s.deleteActionItem, 'hover:bg-gray-50 group')} onClick={onDelete} > <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'} /> <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> </div>
)} )}

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

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

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

Loading…
Cancel
Save