-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathMain.tsx
169 lines (166 loc) · 4.81 KB
/
Main.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import { GitHub, ReceiptLongOutlined, SyncAltOutlined } from '@mui/icons-material';
import { AppBar, Box, Button, Hidden, IconButton, Toolbar, Typography } from '@mui/material';
import { contracts } from '@wormhole-foundation/sdk-base';
import { NavLink, Route, Switch, useLocation } from 'react-router-dom';
import { useCurrentEnvironment } from '../contexts/NetworkContext';
import useChainHeartbeats from '../hooks/useChainHeartbeats';
import useGetGuardianSet from '../hooks/useGetGuardianSet';
import useHeartbeats from '../hooks/useHeartbeats';
import useLatestRelease from '../hooks/useLatestRelease';
import WormholeStatsIcon from '../icons/WormholeStatsIcon';
import Alerts from './Alerts';
import Contracts from './Contracts';
import Home from './Home';
import NTTMetrics from './NTTMetrics';
import NetworkSelector from './NetworkSelector';
import Settings from './Settings';
import FTMetrics from './FTMetrics';
function NavButton(props: any) {
// fix for Invalid value for prop `navigate` on <a> tag
const { navigate, ...rest } = props;
return <Button {...rest} />;
}
function NavLinks() {
const { search } = useLocation();
return (
<>
<NavLink
to={`/${search}`}
exact
component={NavButton}
color="inherit"
activeStyle={{ borderBottom: '2px solid', paddingBottom: 4 }}
style={{ marginLeft: -8, textTransform: 'none', borderRadius: 0, minWidth: 0 }}
>
<Box display="flex" alignItems="center">
<WormholeStatsIcon />
</Box>
<Hidden mdDown>
<Typography variant="h6" sx={{ pl: 0.75 }}>
Dashboard
</Typography>
</Hidden>
</NavLink>
<NavLink
to={`/contracts${search}`}
exact
component={NavButton}
color="inherit"
activeStyle={{ borderBottom: '2px solid', paddingBottom: 4 }}
style={{
paddingRight: 8,
marginLeft: 8,
textTransform: 'none',
borderRadius: 0,
minWidth: 0,
}}
>
<Hidden mdUp>
<ReceiptLongOutlined />
</Hidden>
<Hidden mdDown>
<Typography variant="h6">Contracts</Typography>
</Hidden>
</NavLink>
<NavLink
to={`/ntt-metrics${search}`}
exact
component={NavButton}
color="inherit"
activeStyle={{ borderBottom: '2px solid', paddingBottom: 4 }}
style={{
paddingRight: 8,
marginLeft: 8,
textTransform: 'none',
borderRadius: 0,
minWidth: 0,
}}
>
<Hidden mdUp>
<SyncAltOutlined />
</Hidden>
<Hidden mdDown>
<Typography variant="h6">NTT</Typography>
</Hidden>
</NavLink>
<NavLink
to={`/ft-metrics${search}`}
exact
component={NavButton}
color="inherit"
activeStyle={{ borderBottom: '2px solid', paddingBottom: 4 }}
style={{
paddingRight: 8,
marginLeft: 8,
textTransform: 'none',
borderRadius: 0,
minWidth: 0,
}}
>
<Hidden mdUp>
<SyncAltOutlined />
</Hidden>
<Hidden mdDown>
<Typography variant="h6">FT</Typography>
</Hidden>
</NavLink>
</>
);
}
function Main() {
const env = useCurrentEnvironment();
const [, currentGuardianSet] = useGetGuardianSet(
'Ethereum',
contracts.coreBridge(env, 'Ethereum')
);
const heartbeats = useHeartbeats(currentGuardianSet);
const chainIdsToHeartbeats = useChainHeartbeats(heartbeats);
const latestRelease = useLatestRelease();
return (
<>
<AppBar position="static">
<Toolbar variant="dense" sx={{ minHeight: 40 }}>
<NavLinks />
<Box flexGrow={1} />
<Hidden smDown>
<Alerts
heartbeats={heartbeats}
chainIdsToHeartbeats={chainIdsToHeartbeats}
latestRelease={latestRelease}
/>
</Hidden>
<NetworkSelector />
<IconButton
sx={{ ml: 1 }}
href="https://github.com/wormhole-foundation/wormhole-dashboard"
target="_blank"
rel="noopener noreferrer"
color="inherit"
>
<GitHub />
</IconButton>
<Settings />
</Toolbar>
</AppBar>
<Switch>
<Route path="/ntt-metrics">
<NTTMetrics />
</Route>
<Route path="/contracts">
<Contracts />
</Route>
<Route path="/ft-metrics">
<FTMetrics />
</Route>
<Route path="/">
<Home
heartbeats={heartbeats}
chainIdsToHeartbeats={chainIdsToHeartbeats}
latestRelease={latestRelease}
/>
</Route>
</Switch>
</>
);
}
export default Main;