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
|
import React from 'react';
import { useRouteMatch, useHistory, Redirect } from 'react-router-dom';
import { Segment, Tab } from 'semantic-ui-react';
import './System.css';
import Info from './Info';
import Logs from './Logs';
import Options from './Options';
import Shares from './Shares';
const System = ({ state = {}, options = {} }) => {
const { params: { tab }, ...route } = useRouteMatch();
const history = useHistory();
const panes = [
{
route: 'info',
menuItem: {
key: 'info',
icon: 'info',
content: 'Info',
},
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: {
key: 'shares',
icon: 'share external',
content: 'Shares',
},
render: () => <Tab.Pane><Shares/></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;
|