diff --git a/src/App.tsx b/src/App.tsx index f9dfd38..86a4788 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -27,7 +27,7 @@ import MyFiles from './components/Center/Files' import GettingStarted from './components/Documentation/GettingStarted' import TransferData from './components/Project/TransferData' import Service from './components/Services/Service' - +import Services from './components/Services/Services' export interface Space { label: string route: string @@ -97,7 +97,7 @@ const App = () => ( }> }> - } /> + } /> }> > ] + tabbedServices: [ + string[], + React.Dispatch> + ] } export const AppContext = React.createContext({} as IAppState) @@ -100,6 +104,7 @@ export const AppStoreProvider = ({ null ) const [tabbedDesktops, setTabbedDesktops] = useState([]) + const [tabbedServices, setTabbedServices] = useState([]) // BIDS Tools Store, to be renamed or refactored into a new type const [selectedBidsDataset, setSelectedBidsDataset] = useState() @@ -201,6 +206,7 @@ export const AppStoreProvider = ({ selectedParticipants: [selectedParticipants, setSelectedParticipants], selectedFiles: [selectedFiles, setSelectedFiles], tabbedDesktops: [tabbedDesktops, setTabbedDesktops], + tabbedServices: [tabbedServices, setTabbedServices], }), [ debug, diff --git a/src/components/Documentation/AppList.tsx b/src/components/Documentation/AppList.tsx index e0f7c0f..d444957 100644 --- a/src/components/Documentation/AppList.tsx +++ b/src/components/Documentation/AppList.tsx @@ -23,7 +23,7 @@ const Apps = () => { diff --git a/src/components/Services/Service.tsx b/src/components/Services/Service.tsx index a1a736c..1e4861e 100644 --- a/src/components/Services/Service.tsx +++ b/src/components/Services/Service.tsx @@ -1,19 +1,18 @@ import React, { useEffect, useRef, useState } from 'react' import TitleBar from '../UI/titleBar' -import { Box, CircularProgress, Typography } from '@mui/material' -import { useLocation, useNavigate, useParams } from 'react-router-dom' -import { - APP_MARGIN_TOP, - DRAWER_WIDTH, - ROUTE_PREFIX, - SERVICES, -} from '../../constants' +import { CircularProgress } from '@mui/material' +import { useParams } from 'react-router-dom' +import { SERVICES } from '../../constants' +import { useAppStore } from '../../Store' export default function Service() { const [loading, setLoading] = useState(true) const [service, setService] = useState(null) const iFrameRef = useRef(null) const params = useParams() + const { + tabbedServices: [tabbedServices, setTabbedServices], + } = useAppStore() // Remove scroll for entire window useEffect(() => { @@ -24,10 +23,23 @@ export default function Service() { }, []) useEffect(() => { - const serviceId = Number(params?.serviceId) + if (!params.serviceId) return + + const serviceId = params?.serviceId const service = SERVICES.find(s => s.id === serviceId) + + if (!service) return + setService(service) - }, [params]) + setTabbedServices((prev: any) => { + const index = prev.findIndex((s: any) => s === serviceId) + if (index === -1) { + return [...prev, serviceId] + } + + return prev + }) + }, [params, setTabbedServices, setService]) useEffect(() => { if (!iFrameRef.current) return @@ -37,19 +49,37 @@ export default function Service() { }, [iFrameRef]) return ( - service && ( -