Skip to content

Commit c42ee86

Browse files
committed
Hide deck overview when we only have one deck
1 parent e188f4e commit c42ee86

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

frontend/src/components/NavigationMenu/NavigationMenu.tsx

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Button, Icon, Menu } from '@equinor/eds-core-react'
2+
import { useInstallationContext } from 'components/Contexts/InstallationContext'
23
import { useLanguageContext } from 'components/Contexts/LanguageContext'
34
import { config } from 'config'
45
import { useState } from 'react'
@@ -13,6 +14,7 @@ const StyledButton = styled(Button)`
1314

1415
export const NavigationMenu = () => {
1516
const { TranslateText } = useLanguageContext()
17+
const { installationInspectionAreas } = useInstallationContext()
1618
const [isOpen, setIsOpen] = useState(false)
1719
const [anchorEl, setAnchorEl] = useState(null)
1820
const openMenu = () => {
@@ -22,14 +24,23 @@ export const NavigationMenu = () => {
2224
setIsOpen(false)
2325
}
2426

25-
const paths = [
26-
{ path: 'missionControl', label: 'Mission Control' },
27-
{ path: 'history', label: 'Mission History' },
28-
{ path: 'inspectionOverview', label: 'Deck Overview' },
29-
{ path: 'predefinedMissions', label: 'Predefined Missions' },
30-
{ path: 'autoSchedule', label: 'Auto Scheduling' },
31-
{ path: 'robots', label: 'Robots' },
32-
]
27+
const paths =
28+
installationInspectionAreas.length > 1
29+
? [
30+
{ path: 'missionControl', label: 'Mission Control' },
31+
{ path: 'history', label: 'Mission History' },
32+
{ path: 'inspectionOverview', label: 'Deck Overview' },
33+
{ path: 'predefinedMissions', label: 'Predefined Missions' },
34+
{ path: 'autoSchedule', label: 'Auto Scheduling' },
35+
{ path: 'robots', label: 'Robots' },
36+
]
37+
: [
38+
{ path: 'missionControl', label: 'Mission Control' },
39+
{ path: 'history', label: 'Mission History' },
40+
{ path: 'predefinedMissions', label: 'Predefined Missions' },
41+
{ path: 'autoSchedule', label: 'Auto Scheduling' },
42+
{ path: 'robots', label: 'Robots' },
43+
]
3344

3445
const navigate = useNavigate()
3546
const routeChange = (routePath: string) => {

frontend/src/components/Pages/FrontPage/FrontPage.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Icons } from 'utils/icons'
1616
import { useMissionsContext } from 'components/Contexts/MissionRunsContext'
1717
import { useNavigate } from 'react-router-dom'
1818
import { config } from 'config'
19+
import { useInstallationContext } from 'components/Contexts/InstallationContext'
1920

2021
const StyledFrontPage = styled.div`
2122
display: flex;
@@ -90,6 +91,7 @@ export enum TabNames {
9091
export const FrontPage = ({ initialTab }: { initialTab: TabNames }) => {
9192
const [activeTab, setActiveTab] = useState(initialTab)
9293
const { TranslateText } = useLanguageContext()
94+
const { installationInspectionAreas } = useInstallationContext()
9395

9496
redirectIfNoInstallationSelected()
9597

@@ -114,7 +116,11 @@ export const FrontPage = ({ initialTab }: { initialTab: TabNames }) => {
114116
<StyledTabHeader>
115117
<StyledTabsList>
116118
<Tabs.Tab>{TranslateText('Mission Control')}</Tabs.Tab>
117-
<Tabs.Tab>{TranslateText('Deck Overview')}</Tabs.Tab>
119+
{installationInspectionAreas.length > 1 ? (
120+
<Tabs.Tab>{TranslateText('Deck Overview')}</Tabs.Tab>
121+
) : (
122+
<></>
123+
)}
118124
<Tabs.Tab>{TranslateText('Predefined Missions')}</Tabs.Tab>
119125
<Tabs.Tab>{TranslateText('Mission History')}</Tabs.Tab>
120126
<Tabs.Tab>{TranslateText('Auto Scheduling')}</Tabs.Tab>

0 commit comments

Comments
 (0)