Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/components/Contexts/InstallationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const InstallationProvider: FC<Props> = ({ children }) => {
AlertType.RequestFail,
<FailedRequestAlertContent
translatedMessage={TranslateText(
'Failed to retrieve areas on inspectionArea {0}',
'Failed to retrieve areas on inspection area {0}',
[inspectionArea.inspectionAreaName]
)}
/>,
Expand All @@ -108,7 +108,7 @@ export const InstallationProvider: FC<Props> = ({ children }) => {
AlertType.RequestFail,
<FailedRequestAlertListContent
translatedMessage={TranslateText(
'Failed to retrieve areas on inspectionArea {0}',
'Failed to retrieve areas on inspection area {0}',
[inspectionArea.inspectionAreaName]
)}
/>,
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Circle = styled.div`
height: 9px;
border-radius: 50%;
`

export const Header = ({ page }: { page: string }) => {
const { alerts, listAlerts } = useAlertContext()
const { installationName } = useInstallationContext()
Expand All @@ -90,7 +91,9 @@ export const Header = ({ page }: { page: string }) => {
<StyledWrapper>
<TopBar.Header
onClick={() => {
window.location.href = `${config.FRONTEND_BASE_ROUTE}/FrontPage`
window.location.href = installationName
? `${config.FRONTEND_BASE_ROUTE}/FrontPage`
: `${config.FRONTEND_BASE_ROUTE}/`
}}
>
<StyledTopBarHeader>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/Pages/FrontPage/FrontPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { InspectionOverviewSection } from 'components/Pages/InspectionPage/Inspe
import { StopRobotDialog } from './MissionOverview/StopDialogs'
import { tokens } from '@equinor/eds-tokens'
import { MissionControlSection } from './MissionOverview/MissionControlSection'
import { redirectIfNoInstallationSelected } from 'utils/RedirectIfNoInstallationSelected'

const StyledFrontPage = styled.div`
display: flex;
Expand All @@ -15,6 +16,8 @@ const StyledFrontPage = styled.div`
`

export const FrontPage = () => {
redirectIfNoInstallationSelected()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we wanted to be even more optimal we could useMemo, or a useEffect with empty conditionals here, to prevent this function from needing to be rerun on each render, but it's not too important.


return (
<>
<Header page={'frontPage'} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Header } from 'components/Header/Header'
import { StyledPage } from 'components/Styles/StyledComponents'
import { styled } from 'styled-components'
import { tokens } from '@equinor/eds-tokens'
import { redirectIfNoInstallationSelected } from 'utils/RedirectIfNoInstallationSelected'

export type RefreshProps = {
refreshInterval: number
Expand All @@ -15,6 +16,8 @@ const StyledMissionHistoryPage = styled(StyledPage)`
export const MissionHistoryPage = () => {
const refreshInterval = 1000

redirectIfNoInstallationSelected()

return (
<>
<Header page={'history'} />
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/utils/RedirectIfNoInstallationSelected.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useInstallationContext } from 'components/Contexts/InstallationContext'
import { config } from 'config'

export function redirectIfNoInstallationSelected() {
const { installationCode, installationName } = useInstallationContext()
if (installationCode === '' && installationName === '') {
window.location.href = `${config.FRONTEND_BASE_ROUTE}/`
}
}