From d4b096d2e638c33a19bfd593b3ca1ed956f527ee Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 3 May 2022 08:56:50 -0500 Subject: make panes navigable by url --- src/web/src/components/System/System.js | 43 +++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'src') 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 ( -
- - }, - { menuItem: 'Options', render: () => }, - { menuItem: 'Logs', render: () => }, - ]}/> - -
- ); - } -} +const System = ({ state = {}, options = {} }) => { + const { params: { tab }} = useRouteMatch(); + + const panes = [ + { route: 'info', menuItem: 'Info', render: () => }, + { route: 'options', menuItem: 'Options', render: () => }, + { route: 'logs', menuItem: 'Logs', render: () => }, + ] + + const activeIndex = panes.findIndex(pane => pane.route === tab) + + return ( +
+ + -1 ? activeIndex : 0} + panes={panes} + /> + +
+ ); +}; export default System; \ No newline at end of file -- cgit v1.2.3