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
|
import React from 'react';
import { useRouteMatch, useHistory, Redirect } from 'react-router-dom';
import { Segment, Tab, Menu, Icon } from 'semantic-ui-react';
import './System.css';
import Info from './Info';
import Logs from './Logs';
import Options from './Options';
import Shares from './Shares';
import { Switch } from '../Shared';
import Data from './Data';
const System = ({ state = {}, options = {} }) => {
const { params: { tab }, ...route } = useRouteMatch();
const history = useHistory();
const panes = [
{
route: 'info',
menuItem: (<Menu.Item key='info'>
<Switch
pending={((state?.pendingRestart ?? false) || (state?.pendingReconnect ?? false))
&& <Icon name='exclamation circle' color='yellow'/>}
>
<Icon name='info circle'/>
</Switch>
Info
</Menu.Item>),
render: () => <Tab.Pane><Info state={state}/></Tab.Pane>,
},
{
route: 'options',
menuItem: {
key: 'options',
icon: 'options',
content: 'Options',
},
render: () => <Tab.Pane className='full-height'><Options options={options} /></Tab.Pane>,
},
{
route: 'shares',
menuItem: (<Menu.Item key='shares'>
<Switch
scanPending={(state?.shares?.scanPending ?? false) && <Icon name='exclamation circle' color='yellow'/>}
>
<Icon name='share external'/>
</Switch>
Shares
</Menu.Item>),
render: () => <Tab.Pane><Shares state={state.shares}/></Tab.Pane>,
},
{
route: 'data',
menuItem: {
key: 'data',
icon: 'database',
content: 'Data',
},
render: () => <Tab.Pane className='full-height'><Data/></Tab.Pane>,
},
{
route: 'logs',
menuItem: {
key: 'logs',
icon: 'file outline',
content: 'Logs',
},
render: () => <Tab.Pane><Logs/></Tab.Pane>,
},
];
const activeIndex = panes.findIndex(pane => pane.route === tab);
const onTabChange = (e, { activeIndex }) => {
history.push(panes[activeIndex].route);
};
if (tab === undefined) {
return <Redirect to={`${route.url}/${panes[0].route}`}/>;
}
return (
<div className='system'>
<Segment raised>
<Tab
activeIndex={activeIndex > -1 ? activeIndex : 0}
panes={panes}
onTabChange={onTabChange}
/>
</Segment>
</div>
);
};
export default System;
|