Skip to content

Commit 59f2dd5

Browse files
committed
feat(neuron-ui): add a guide bubble in connection status
1 parent a078e76 commit 59f2dd5

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

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

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import React, { useCallback, useContext } from 'react'
1+
import React, { useCallback, useContext, useState, useEffect } from 'react'
22
import { createPortal } from 'react-dom'
33
import { RouteComponentProps } from 'react-router-dom'
44
import { useTranslation } from 'react-i18next'
5-
import { Stack, getTheme, Text, ProgressIndicator, Icon, TooltipHost } from 'office-ui-fabric-react'
5+
import { Stack, getTheme, Text, ProgressIndicator, Icon, TooltipHost, TeachingBubble } from 'office-ui-fabric-react'
66

7+
import { openExternal } from 'services/remote'
78
import { StateWithDispatch } from 'states/stateProvider/reducer'
8-
import { ConnectionStatus, FULL_SCREENS, Routes } from 'utils/const'
99
import { NeuronWalletContext } from 'states/stateProvider'
10+
import { ConnectionStatus, FULL_SCREENS, RUN_NODE_GUIDE_URL, Routes } from 'utils/const'
1011

1112
const theme = getTheme()
1213
const stackStyles = {
@@ -55,7 +56,7 @@ export const SyncStatus = ({
5556

5657
export const NetworkStatus = ({ name, online }: { name: string; online: boolean }) => {
5758
return (
58-
<Stack horizontal verticalAlign="center" tokens={{ childrenGap: 5 }} styles={stackItemStyles}>
59+
<Stack id="network-status" horizontal verticalAlign="center" tokens={{ childrenGap: 5 }} styles={stackItemStyles}>
5960
<Icon
6061
iconName={online ? 'Connected' : 'Disconnected'}
6162
styles={{ root: { display: 'flex', alignItems: 'center' } }}
@@ -75,6 +76,23 @@ const Footer = ({
7576
settings: { networks = [] },
7677
} = useContext(NeuronWalletContext)
7778
const [t] = useTranslation()
79+
const [showGuide, setShowGuide] = useState(false)
80+
81+
useEffect(() => {
82+
if (connectionStatus !== ConnectionStatus.Online) {
83+
setShowGuide(true)
84+
} else {
85+
setShowGuide(false)
86+
}
87+
}, [connectionStatus, setShowGuide])
88+
89+
const onDismissGuide = useCallback(() => {
90+
setShowGuide(false)
91+
}, [setShowGuide])
92+
93+
const onGuideLinkClick = useCallback(() => {
94+
openExternal(RUN_NODE_GUIDE_URL)
95+
}, [])
7896

7997
const goToNetworksSetting = useCallback(() => {
8098
history.push(Routes.SettingsNetworks)
@@ -106,6 +124,27 @@ const Footer = ({
106124
) : (
107125
<Text>{t('settings.setting-tabs.network')}</Text>
108126
)}
127+
{showGuide ? (
128+
<TeachingBubble
129+
target="#network-status"
130+
headline={t('messages.run-ckb-guide')}
131+
hasSmallHeadline
132+
primaryButtonProps={{
133+
children: t('common.open'),
134+
onClick: onGuideLinkClick,
135+
}}
136+
onDismiss={onDismissGuide}
137+
styles={{
138+
subText: {
139+
fontSize: '14px',
140+
},
141+
}}
142+
>
143+
<Text as="span" variant="xSmall">
144+
{t('messages.view-the-run-node-doc')}
145+
</Text>
146+
</TeachingBubble>
147+
) : null}
109148
</Stack>
110149
</Stack>
111150
)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
"common": {
235235
"or": "or",
236236
"confirm": "Confirm",
237+
"open": "Open",
237238
"cancel": "Cancel",
238239
"save": "Save",
239240
"toggle": {
@@ -258,6 +259,7 @@
258259
"update-network-successfully": "The network was updated",
259260
"addr-copied": "Address has been copied to the clipboard",
260261
"qrcode-copied": "QR Code has been copied to the clipboard",
262+
"view-the-run-node-doc": "View the guide in browser",
261263
"fields": {
262264
"wallet": "Wallet",
263265
"name": "Name",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
"common": {
235235
"or": "",
236236
"confirm": "确认",
237+
"open": "打开",
237238
"cancel": "取消",
238239
"save": "保存",
239240
"toggle": {
@@ -258,6 +259,7 @@
258259
"update-network-successfully": "已更新节点信息",
259260
"addr-copied": "已复制地址到剪贴板",
260261
"qrcode-copied": "已复制二维码到剪贴板",
262+
"view-the-run-node-doc": "打开浏览器查看文档",
261263
"fields": {
262264
"wallet": "钱包",
263265
"name": "名称",

0 commit comments

Comments
 (0)