diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-05-03 08:56:50 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-05-03 08:56:50 -0500 |
| commit | d4b096d2e638c33a19bfd593b3ca1ed956f527ee (patch) | |
| tree | 725f98b41dcb7a20757666c57816c802a132b09e /src/web | |
| parent | 5eca39f47ce7a9677325559c9d4ec0e1f2167564 (diff) | |
| download | slskd-d4b096d2e638c33a19bfd593b3ca1ed956f527ee.tar.gz | |
make panes navigable by url
Diffstat (limited to 'src/web')
| -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 |
