diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/components/System/System.js | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/web/src/components/System/System.js b/src/web/src/components/System/System.js index 8b0ea4d4..ac6f5dfd 100644 --- a/src/web/src/components/System/System.js +++ b/src/web/src/components/System/System.js @@ -1,24 +1,35 @@ -import React, { Component } from 'react'; +import React from 'react'; +import { useRouteMatch } 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'; -class System extends Component { - render = () => { - return ( - <div className='system'> - <Segment raised> - <Tab panes={[ - { menuItem: 'Info', render: () => <Tab.Pane><Info state={this.props.state}/></Tab.Pane> }, - { menuItem: 'Options', render: () => <Tab.Pane className='full-height'><Options options={this.props.options}/></Tab.Pane> }, - { menuItem: 'Logs', render: () => <Tab.Pane><Logs/></Tab.Pane> }, - ]}/> - </Segment> - </div> - ); - } -} +const System = ({ state = {}, options = {} }) => { + const { params: { tab }} = useRouteMatch(); + + const panes = [ + { route: 'info', menuItem: 'Info', render: () => <Tab.Pane><Info state={state}/></Tab.Pane> }, + { route: 'options', menuItem: 'Options', render: () => <Tab.Pane className='full-height'><Options options={options}/></Tab.Pane> }, + { route: 'logs', menuItem: 'Logs', render: () => <Tab.Pane><Logs/></Tab.Pane> }, + ] + + const activeIndex = panes.findIndex(pane => pane.route === tab) + + return ( + <div className='system'> + <Segment raised> + <Tab + activeIndex={activeIndex > -1 ? activeIndex : 0} + panes={panes} + /> + </Segment> + </div> + ); +}; export default System;
\ No newline at end of file |
