Skip to content

Commit 37c4f35

Browse files
authored
Merge pull request #641 from Keith-CY/network-status-nav-to-networks-setting
feat(neuron-ui): nav to the networks setting on clicking on the netwo…
2 parents 2d5c24e + 8f07e61 commit 37c4f35

File tree

1 file changed

+27
-17
lines changed
  • packages/neuron-ui/src/containers/Footer

1 file changed

+27
-17
lines changed

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

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
import React, { useContext } from 'react'
1+
import React, { useCallback, useContext } from 'react'
22
import { createPortal } from 'react-dom'
33
import { RouteComponentProps } from 'react-router-dom'
44
import { useTranslation } from 'react-i18next'
55
import { Stack, getTheme, Text, ProgressIndicator } from 'office-ui-fabric-react'
66
import { Alert as AlertIcon, Nodes as ConnectIcon } from 'grommet-icons'
77

88
import { StateWithDispatch } from 'states/stateProvider/reducer'
9-
import { ConnectStatus, FULL_SCREENS } from 'utils/const'
9+
import { ConnectStatus, FULL_SCREENS, Routes } from 'utils/const'
1010
import { NeuronWalletContext } from 'states/stateProvider'
1111

1212
const theme = getTheme()
13+
const stackStyles = {
14+
root: [
15+
{
16+
width: '100%',
17+
background: theme.palette.neutralLighter,
18+
},
19+
],
20+
}
21+
const stackItemStyles = {
22+
root: [theme.fonts.small],
23+
}
1324

1425
// TODO: Listen to sync progress report and update
1526
const SyncStatus = () => {
@@ -34,27 +45,24 @@ const NetworkStatus = ({ name, online }: { name: string; online: boolean }) => {
3445
}
3546

3647
// Status bar
37-
const Footer = ({ location: { pathname } }: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
48+
const Footer = ({
49+
history,
50+
location: { pathname },
51+
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
3852
const {
3953
chain: { networkID, connectStatus },
4054
settings: { networks },
4155
} = useContext(NeuronWalletContext)
56+
const [t] = useTranslation()
57+
58+
const goToNetworksSetting = useCallback(() => {
59+
history.push(Routes.SettingsNetworks)
60+
}, [history])
4261

4362
if (FULL_SCREENS.find(url => pathname.startsWith(url))) {
4463
return null
4564
}
4665
const currentNetwork = networks.find(network => network.id === networkID)
47-
const stackStyles = {
48-
root: [
49-
{
50-
width: '100%',
51-
background: theme.palette.neutralLighter,
52-
},
53-
],
54-
}
55-
const stackItemStyles = {
56-
root: [theme.fonts.small],
57-
}
5866

5967
return (
6068
<Stack
@@ -69,11 +77,13 @@ const Footer = ({ location: { pathname } }: React.PropsWithoutRef<StateWithDispa
6977
<SyncStatus />
7078
</Stack.Item>
7179

72-
<Stack.Item styles={stackItemStyles}>
80+
<Stack styles={stackItemStyles} onClick={goToNetworksSetting}>
7381
{currentNetwork ? (
7482
<NetworkStatus online={connectStatus === ConnectStatus.Online} name={currentNetwork.name} />
75-
) : null}
76-
</Stack.Item>
83+
) : (
84+
<Text>{t('settings.setting-tabs.network')}</Text>
85+
)}
86+
</Stack>
7787
</Stack>
7888
)
7989
}

0 commit comments

Comments
 (0)