From a21ee7fff8a303ee7c4ba5b2dc1f68ed83f317dd Mon Sep 17 00:00:00 2001 From: yanguoyu <841185308@qq.com> Date: Fri, 12 Jan 2024 16:29:17 +0800 Subject: [PATCH] fix: Disable unlock when there is no ckb. --- .../src/components/NervosDAO/index.tsx | 1 + .../NervosDAORecord/daoRecordRow.module.scss | 5 +++ .../src/components/NervosDAORecord/index.tsx | 41 +++++++++++++++---- packages/neuron-ui/src/locales/en.json | 3 +- packages/neuron-ui/src/locales/fr.json | 3 +- packages/neuron-ui/src/locales/zh-tw.json | 3 +- packages/neuron-ui/src/locales/zh.json | 3 +- .../src/controllers/app/index.ts | 2 + 8 files changed, 48 insertions(+), 13 deletions(-) diff --git a/packages/neuron-ui/src/components/NervosDAO/index.tsx b/packages/neuron-ui/src/components/NervosDAO/index.tsx index 0246117032..a551011577 100644 --- a/packages/neuron-ui/src/components/NervosDAO/index.tsx +++ b/packages/neuron-ui/src/components/NervosDAO/index.tsx @@ -179,6 +179,7 @@ const NervosDAO = () => { genesisBlockTimestamp, connectionStatus, isPrivacyMode, + hasCkbBalance: !!wallet.balance && wallet.balance !== '0', } return })} diff --git a/packages/neuron-ui/src/components/NervosDAORecord/daoRecordRow.module.scss b/packages/neuron-ui/src/components/NervosDAORecord/daoRecordRow.module.scss index a8ae72a98c..c533d52c3f 100644 --- a/packages/neuron-ui/src/components/NervosDAORecord/daoRecordRow.module.scss +++ b/packages/neuron-ui/src/components/NervosDAORecord/daoRecordRow.module.scss @@ -249,5 +249,10 @@ line-height: 56px; padding: 0; } + + .tip { + width: 220px; + white-space: normal; + } } } diff --git a/packages/neuron-ui/src/components/NervosDAORecord/index.tsx b/packages/neuron-ui/src/components/NervosDAORecord/index.tsx index 2dc5dca037..eab1433cac 100644 --- a/packages/neuron-ui/src/components/NervosDAORecord/index.tsx +++ b/packages/neuron-ui/src/components/NervosDAORecord/index.tsx @@ -19,6 +19,7 @@ import { Clock } from 'widgets/Icons/icon' import { Link } from 'react-router-dom' import { HIDE_BALANCE } from 'utils/const' +import Tooltip from 'widgets/Tooltip' import styles from './daoRecordRow.module.scss' import hooks from './hooks' @@ -42,6 +43,7 @@ export interface DAORecordProps extends State.NervosDAORecord { tipBlockTimestamp: number // tip block timestamp, used to calculate apc, dovetails with current epoch genesisBlockTimestamp: number | undefined // genesis block timestamp, used to calculate apc isPrivacyMode?: boolean + hasCkbBalance?: boolean } export const DAORecord = ({ @@ -62,6 +64,7 @@ export const DAORecord = ({ withdrawInfo, unlockInfo, isPrivacyMode, + hasCkbBalance, }: DAORecordProps) => { const [t] = useTranslation() const [withdrawEpoch, setWithdrawEpoch] = useState('') @@ -143,8 +146,11 @@ export const DAORecord = ({ const compensatedPeriod = withdrawInfo?.timestamp && depositInfo?.timestamp ? +withdrawInfo.timestamp - +depositInfo.timestamp : undefined + const isWithdrawnDisabled = CellStatus.Deposited === cellStatus && !hasCkbBalance const isActionAvailable = - connectionStatus === 'online' && [CellStatus.Deposited, CellStatus.Unlockable].includes(cellStatus) + connectionStatus === 'online' && + [CellStatus.Deposited, CellStatus.Unlockable].includes(cellStatus) && + !isWithdrawnDisabled const depositOutPointKey = depositOutPoint ? `${depositOutPoint.txHash}-${depositOutPoint.index}` @@ -277,14 +283,31 @@ export const DAORecord = ({
-
} + placement="top" + tipClassName={styles.tip} + > +