11import React , { useCallback , useMemo , useState } from 'react'
2- import { Attention , Consume , DetailIcon , EyesClose , EyesOpen , LockCell , UnLock , Consolidate } from 'widgets/Icons/icon'
2+ import {
3+ Attention ,
4+ Consume ,
5+ DetailIcon ,
6+ EyesClose ,
7+ EyesOpen ,
8+ LockCell ,
9+ UnLock ,
10+ Consolidate ,
11+ Recycle ,
12+ } from 'widgets/Icons/icon'
313import PageContainer from 'components/PageContainer'
414import { useTranslation } from 'react-i18next'
515import Breadcrum from 'widgets/Breadcrum'
@@ -14,6 +24,7 @@ import {
1424 LockScriptCategory ,
1525 getLockTimestamp ,
1626 isMainnet as isMainnetUtil ,
27+ TypeScriptCategory ,
1728} from 'utils'
1829import { HIDE_BALANCE } from 'utils/const'
1930import Tooltip from 'widgets/Tooltip'
@@ -27,6 +38,7 @@ import { computeScriptHash } from '@ckb-lumos/lumos/utils'
2738import Hardware from 'widgets/Icons/Hardware.png'
2839import Button from 'widgets/Button'
2940import Alert from 'widgets/Alert'
41+ import RecycleUDTCellDialog from 'components/RecycleUDTCellDialog'
3042import { Actions , useAction , useHardWallet , useLiveCells , usePassword , useSelect } from './hooks'
3143import styles from './cellManagement.module.scss'
3244
@@ -183,39 +195,51 @@ const getColumns = ({
183195 dataIndex : 'action' ,
184196 title : t ( 'cell-manage.table.head.action' ) ,
185197 render ( _ , index , item ) {
186- const { locked, lockedReason } = item
198+ const { locked, lockedReason, lockScriptType, typeScriptType } = item
199+ const showRecycleAction =
200+ lockScriptType === LockScriptCategory . ANYONE_CAN_PAY &&
201+ typeScriptType &&
202+ [ TypeScriptCategory . SUDT , TypeScriptCategory . XUDT ] . includes ( typeScriptType )
187203 return (
188204 < div className = { styles . actions } >
189205 < Tooltip tip = { t ( 'history.detail' ) } showTriangle placement = "top" >
190206 < DetailIcon onClick = { onAction } data-action = { Actions . View } data-index = { index } />
191207 </ Tooltip >
192- { locked ? (
193- < Tooltip tip = { t ( 'cell-manage.unlock' ) } showTriangle placement = "top" >
194- < UnLock
195- data-disabled = { ! ! lockedReason }
196- onClick = { lockedReason ? undefined : onAction }
197- data-action = { Actions . Unlock }
198- data-index = { index }
199- />
208+ { showRecycleAction ? (
209+ < Tooltip tip = { t ( 'cell-manage.recycle' ) } showTriangle placement = "top" >
210+ < Recycle onClick = { onAction } data-action = { Actions . Recycle } data-index = { index } />
200211 </ Tooltip >
201212 ) : (
202- < Tooltip tip = { t ( 'cell-manage.lock' ) } showTriangle placement = "top" >
203- < LockCell
204- data-disabled = { ! ! lockedReason }
205- onClick = { lockedReason ? undefined : onAction }
206- data-action = { Actions . Lock }
207- data-index = { index }
208- />
209- </ Tooltip >
213+ < div className = { styles . actions } >
214+ { locked ? (
215+ < Tooltip tip = { t ( 'cell-manage.unlock' ) } showTriangle placement = "top" >
216+ < UnLock
217+ data-disabled = { ! ! lockedReason }
218+ onClick = { lockedReason ? undefined : onAction }
219+ data-action = { Actions . Unlock }
220+ data-index = { index }
221+ />
222+ </ Tooltip >
223+ ) : (
224+ < Tooltip tip = { t ( 'cell-manage.lock' ) } showTriangle placement = "top" >
225+ < LockCell
226+ data-disabled = { ! ! lockedReason }
227+ onClick = { lockedReason ? undefined : onAction }
228+ data-action = { Actions . Lock }
229+ data-index = { index }
230+ />
231+ </ Tooltip >
232+ ) }
233+ < Tooltip tip = { t ( 'cell-manage.consume' ) } showTriangle placement = "top" >
234+ < Consume
235+ data-disabled = { ! ! locked }
236+ onClick = { locked ? undefined : onAction }
237+ data-action = { Actions . Consume }
238+ data-index = { index }
239+ />
240+ </ Tooltip >
241+ </ div >
210242 ) }
211- < Tooltip tip = { t ( 'cell-manage.consume' ) } showTriangle placement = "top" >
212- < Consume
213- data-disabled = { ! ! locked }
214- onClick = { locked ? undefined : onAction }
215- data-action = { Actions . Consume }
216- data-index = { index }
217- />
218- </ Tooltip >
219243 </ div >
220244 )
221245 } ,
@@ -245,7 +269,9 @@ const CellManagement = () => {
245269 direction : SortType . Decrease ,
246270 }
247271 : undefined
248- const { liveCells, updateLiveCell, onSorted, updateLiveCellsLockStatus } = useLiveCells ( { initSortInfo } )
272+ const { liveCells, updateLiveCell, onSorted, updateLiveCellsLockStatus, fetchLiveCells } = useLiveCells ( {
273+ initSortInfo,
274+ } )
249275 const { pageNo, pageSize, onPageChange } = usePagination ( )
250276 const currentPageLiveCells = useMemo ( ( ) => {
251277 return liveCells . slice ( pageSize * ( pageNo - 1 ) , pageSize * pageNo )
@@ -363,6 +389,17 @@ const CellManagement = () => {
363389 onCancel = { onActionCancel }
364390 isMainnet = { isMainnet }
365391 />
392+ { action === Actions . Recycle && operateCells [ 0 ] && (
393+ < RecycleUDTCellDialog
394+ data = { {
395+ tokenID : operateCells [ 0 ] . type . args ,
396+ lockArgs : operateCells [ 0 ] . lock . args ,
397+ outpoint : operateCells [ 0 ] . outPoint ,
398+ } }
399+ onClose = { onActionCancel }
400+ onConfirm = { fetchLiveCells }
401+ />
402+ ) }
366403 { wallet . device ? (
367404 < Dialog
368405 show = { action === Actions . Lock || action === Actions . Unlock }
0 commit comments