Skip to content

Commit 89aa04c

Browse files
committed
feat(neuron-ui): add a guide link to run a ckb mainnet node.
1 parent ad5fd4b commit 89aa04c

5 files changed

Lines changed: 25 additions & 0 deletions

File tree

packages/neuron-ui/src/containers/Notification/Notification.module.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@
1818
}
1919
}
2020

21+
.guide {
22+
margin-left: 20px;
23+
color: rgb(0, 90, 158);
24+
25+
&:hover {
26+
text-decoration: underline;
27+
}
28+
}
29+
2130
@keyframes autoDismiss {
2231
from {
2332
transform: translateX(110%)
@@ -33,4 +42,5 @@
3342
100% {
3443
transform: translateX(110%)
3544
}
45+
3646
}

packages/neuron-ui/src/containers/Notification/index.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { createPortal } from 'react-dom'
33
import { RouteComponentProps } from 'react-router-dom'
44
import { useTranslation } from 'react-i18next'
55
import { Stack, MessageBar, MessageBarType, IconButton, Panel, PanelType, Text } from 'office-ui-fabric-react'
6+
import { openExternal } from 'services/remote'
67
import { NeuronWalletContext } from 'states/stateProvider'
78
import { StateWithDispatch, StateDispatch } from 'states/stateProvider/reducer'
89
import {
910
toggleAllNotificationVisibility,
1011
toggleTopAlertVisibility,
1112
dismissNotification,
1213
} from 'states/stateProvider/actionCreators'
14+
import { ErrorCode, RUN_NODE_GUIDE_URL } from 'utils/const'
1315
import styles from './Notification.module.scss'
1416

1517
const notificationType = (type: 'success' | 'warning' | 'alert') => {
@@ -81,6 +83,10 @@ export const NoticeContent = ({ dispatch }: React.PropsWithoutRef<StateWithDispa
8183
[dispatch]
8284
)
8385

86+
const onGuideLinkClick = useCallback(() => {
87+
openExternal(RUN_NODE_GUIDE_URL)
88+
}, [])
89+
8490
return (
8591
<div>
8692
{showTopAlert && notification ? (
@@ -102,6 +108,11 @@ export const NoticeContent = ({ dispatch }: React.PropsWithoutRef<StateWithDispa
102108
{notification.code
103109
? t(`messages.codes.${notification.code}`, notification.meta)
104110
: notification.content || t('messages.unknown-error')}
111+
{notification.code === ErrorCode.NodeDisconnected ? (
112+
<Text as="span" variant="xSmall" className={styles.guide} onClick={onGuideLinkClick}>
113+
{t('messages.run-ckb-guide')}
114+
</Text>
115+
) : null}
105116
</MessageBar>
106117
) : null}
107118

packages/neuron-ui/src/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
},
276276
"mainnet-address-required": "Please enter a mainnet address",
277277
"testnet-address-required": "Please enter a testnet address",
278+
"run-ckb-guide": "How to run a CKB Mainnet Node?",
278279
"codes": {
279280
"-3": "",
280281
"100": "Amount is not enough",

packages/neuron-ui/src/locales/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
},
276276
"mainnet-address-required": "请输入主网地址",
277277
"testnet-address-required": "请输出测试网地址",
278+
"run-ckb-guide": "如何运行一个 CKB 主网节点?",
278279
"codes": {
279280
"-3": "",
280281
"100": "余额不足",

packages/neuron-ui/src/utils/const.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export const SHANNON_CKB_RATIO = 1e8
1919
export const MEDIUM_FEE_RATE = 6000
2020
export const WITHDRAW_EPOCHS = 180
2121

22+
export const RUN_NODE_GUIDE_URL = 'https://docs.nervos.org/references/neuron-wallet-guide.html#1-run-a-ckb-mainnet-node'
23+
2224
export enum ConnectionStatus {
2325
Online = 'online',
2426
Offline = 'offline',

0 commit comments

Comments
 (0)