Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/neuron-ui/src/components/NervosDAO/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ const NervosDAO = () => {
genesisBlockTimestamp,
connectionStatus,
isPrivacyMode,
hasCkbBalance: +wallet.balance > 0,
}
return <DAORecord key={key} {...props} />
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,10 @@
line-height: 56px;
padding: 0;
}

.tip {
width: 220px;
white-space: normal;
}
}
}
41 changes: 32 additions & 9 deletions packages/neuron-ui/src/components/NervosDAORecord/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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 = ({
Expand All @@ -62,6 +64,7 @@ export const DAORecord = ({
withdrawInfo,
unlockInfo,
isPrivacyMode,
hasCkbBalance,
}: DAORecordProps) => {
const [t] = useTranslation()
const [withdrawEpoch, setWithdrawEpoch] = useState('')
Expand Down Expand Up @@ -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}`
Expand Down Expand Up @@ -277,14 +283,31 @@ export const DAORecord = ({
</div>

<div className={styles.action}>
<Button
type="primary"
data-tx-hash={txHash}
data-index={index}
onClick={onClick}
disabled={!isActionAvailable}
label={t(`nervos-dao.deposit-record.${isWithdrawn ? 'unlock' : 'withdraw'}-action-label`)}
/>
{isWithdrawnDisabled ? (
<Tooltip
tip={<div>{t('nervos-dao.deposit-record.insufficient-balance-to-unlock')}</div>}
placement="top"
tipClassName={styles.tip}
>
<Button
type="primary"
data-tx-hash={txHash}
data-index={index}
onClick={onClick}
disabled={!isActionAvailable}
label={t(`nervos-dao.deposit-record.${isWithdrawn ? 'unlock' : 'withdraw'}-action-label`)}
/>
</Tooltip>
) : (
<Button
type="primary"
data-tx-hash={txHash}
data-index={index}
onClick={onClick}
disabled={!isActionAvailable}
label={t(`nervos-dao.deposit-record.${isWithdrawn ? 'unlock' : 'withdraw'}-action-label`)}
/>
)}
</div>
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@
"compensated-period": "Compensation Period",
"days-hours": "{{days}} days {{hours}} hours",
"no-deposit": "No Deposit",
"no-completed": "No Completed"
"no-completed": "No Completed",
"insufficient-balance-to-unlock": "Balance is not enough for transaction fee to unlock the deposit"
},
"compensation-period": {
"tooltip": {
Expand Down
3 changes: 2 additions & 1 deletion packages/neuron-ui/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@
"compensated-period": "Période de compensation",
"days-hours": "{{days}} jours {{hours}} heures",
"no-deposit": "Aucun dépôt",
"no-completed": "Aucun terminé"
"no-completed": "Aucun terminé",
"insufficient-balance-to-unlock": "Le solde n'est pas suffisant pour payer les frais de transaction afin de débloquer le dépôt DAO."
},
"compensation-period": {
"tooltip": {
Expand Down
3 changes: 2 additions & 1 deletion packages/neuron-ui/src/locales/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@
"compensated-period": "補貼時間",
"days-hours": "{{days}} 天 {{hours}} 小時",
"no-deposit": "沒有存入記錄",
"no-completed": "沒有解鎖記錄"
"no-completed": "沒有解鎖記錄",
"insufficient-balance-to-unlock": "沒有足夠余額支付交易費用以解鎖 DAO 存款"
},
"compensation-period": {
"tooltip": {
Expand Down
3 changes: 2 additions & 1 deletion packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@
"compensated-period": "补贴时间",
"days-hours": "{{days}} 天 {{hours}} 小时",
"no-deposit": "没有存入记录",
"no-completed": "没有解锁记录"
"no-completed": "没有解锁记录",
"insufficient-balance-to-unlock": "没有足够余额支付交易费用以解锁 DAO 存款"
},
"compensation-period": {
"tooltip": {
Expand Down
2 changes: 2 additions & 0 deletions packages/neuron-wallet/src/controllers/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ export default class AppController {
devTools: env.isDevMode,
contextIsolation: false,
preload: path.join(__dirname, './preload.js'),
// disable webSecurity for dev, do not set webSecurity as true, because electron has default set other value when webSecurity is not set by developer
...(app.isPackaged ? {} : { webSecurity: false }),
},
})

Expand Down