aboutsummaryrefslogtreecommitdiffstats
path: root/src/web
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-05-03 09:23:02 -0500
committerJP Dillingham <jp@dillingham.me>2022-05-03 09:23:02 -0500
commit12f2aded2257a7dcc9dbb00cbbd8bafc28579ad4 (patch)
tree06c3f12f92f1174eef8548e5d39b0f0e23d4ad7d /src/web
parentd4b096d2e638c33a19bfd593b3ca1ed956f527ee (diff)
downloadslskd-12f2aded2257a7dcc9dbb00cbbd8bafc28579ad4.tar.gz
navigate on tab click, set initial tab with redirect
Diffstat (limited to 'src/web')
-rw-r--r--src/web/src/components/System/System.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/web/src/components/System/System.js b/src/web/src/components/System/System.js
index ac6f5dfd..ca88c50d 100644
--- a/src/web/src/components/System/System.js
+++ b/src/web/src/components/System/System.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { useRouteMatch } from "react-router-dom";
+import { useRouteMatch, useHistory, Redirect } from "react-router-dom";
import { Segment, Tab } from 'semantic-ui-react';
@@ -10,7 +10,8 @@ import Logs from './Logs';
import Options from './Options';
const System = ({ state = {}, options = {} }) => {
- const { params: { tab }} = useRouteMatch();
+ const { params: { tab }, ...route } = useRouteMatch();
+ const history = useHistory();
const panes = [
{ route: 'info', menuItem: 'Info', render: () => <Tab.Pane><Info state={state}/></Tab.Pane> },
@@ -20,12 +21,21 @@ const System = ({ state = {}, options = {} }) => {
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>