Skip to content

Commit

Permalink
feat(neuron-ui): add a guide link to run a ckb mainnet node.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Nov 14, 2019
1 parent ad5fd4b commit 89aa04c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
}
}

.guide {
margin-left: 20px;
color: rgb(0, 90, 158);

&:hover {
text-decoration: underline;
}
}

@keyframes autoDismiss {
from {
transform: translateX(110%)
Expand All @@ -33,4 +42,5 @@
100% {
transform: translateX(110%)
}

}
11 changes: 11 additions & 0 deletions packages/neuron-ui/src/containers/Notification/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { createPortal } from 'react-dom'
import { RouteComponentProps } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { Stack, MessageBar, MessageBarType, IconButton, Panel, PanelType, Text } from 'office-ui-fabric-react'
import { openExternal } from 'services/remote'
import { NeuronWalletContext } from 'states/stateProvider'
import { StateWithDispatch, StateDispatch } from 'states/stateProvider/reducer'
import {
toggleAllNotificationVisibility,
toggleTopAlertVisibility,
dismissNotification,
} from 'states/stateProvider/actionCreators'
import { ErrorCode, RUN_NODE_GUIDE_URL } from 'utils/const'
import styles from './Notification.module.scss'

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

const onGuideLinkClick = useCallback(() => {
openExternal(RUN_NODE_GUIDE_URL)
}, [])

return (
<div>
{showTopAlert && notification ? (
Expand All @@ -102,6 +108,11 @@ export const NoticeContent = ({ dispatch }: React.PropsWithoutRef<StateWithDispa
{notification.code
? t(`messages.codes.${notification.code}`, notification.meta)
: notification.content || t('messages.unknown-error')}
{notification.code === ErrorCode.NodeDisconnected ? (
<Text as="span" variant="xSmall" className={styles.guide} onClick={onGuideLinkClick}>
{t('messages.run-ckb-guide')}
</Text>
) : null}
</MessageBar>
) : null}

Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
},
"mainnet-address-required": "Please enter a mainnet address",
"testnet-address-required": "Please enter a testnet address",
"run-ckb-guide": "How to run a CKB Mainnet Node?",
"codes": {
"-3": "",
"100": "Amount is not enough",
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
},
"mainnet-address-required": "请输入主网地址",
"testnet-address-required": "请输出测试网地址",
"run-ckb-guide": "如何运行一个 CKB 主网节点?",
"codes": {
"-3": "",
"100": "余额不足",
Expand Down
2 changes: 2 additions & 0 deletions packages/neuron-ui/src/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const SHANNON_CKB_RATIO = 1e8
export const MEDIUM_FEE_RATE = 6000
export const WITHDRAW_EPOCHS = 180

export const RUN_NODE_GUIDE_URL = 'https://docs.nervos.org/references/neuron-wallet-guide.html#1-run-a-ckb-mainnet-node'

export enum ConnectionStatus {
Online = 'online',
Offline = 'offline',
Expand Down

0 comments on commit 89aa04c

Please sign in to comment.