Skip to content

Commit

Permalink
Fiche navire - Afficher les informations de positions du navire actue…
Browse files Browse the repository at this point in the history
…l pour les utilisateurs externes (#3155)

## Linked issues

- Resolve #3154

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
louptheron committed Apr 30, 2024
2 parents 8fac5d6 + 7be3ba4 commit 4d5d253
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/external_monitorfish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ context('External MonitorFish', () => {

// Vessel sidebar menus
cy.get('*[data-cy="vessel-menu-identity"]').should('be.visible')
cy.get('*[data-cy="vessel-menu-summary"]').should('be.visible')
cy.get('*[data-cy="vessel-menu-fishing"]').should('be.visible')
cy.get('*[data-cy="vessel-menu-controls"]').should('be.visible')

Expand All @@ -39,7 +40,6 @@ context('External MonitorFish', () => {
.click({ timeout: 10000 })
cy.get('*[data-cy="vessel-control"]').should('not.contain', 'Ouvrir le contrôle')

cy.get('*[data-cy="vessel-menu-resume"]').should('not.exist')
cy.get('*[data-cy="vessel-menu-reporting"]').should('not.exist')
cy.get('*[data-cy="vessel-menu-ers-vms"]').should('not.exist')

Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/nav_monitorfish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ context('Light MonitorFish', () => {

// Vessel sidebar menus
cy.get('*[data-cy="vessel-menu-identity"]').should('be.visible')
cy.get('*[data-cy="vessel-menu-summary"]').should('be.visible')
cy.get('*[data-cy="vessel-menu-fishing"]').should('be.visible')
cy.get('*[data-cy="vessel-menu-controls"]').should('be.visible')

Expand All @@ -30,7 +31,6 @@ context('Light MonitorFish', () => {
.click({ timeout: 10000 })
cy.get('*[data-cy="vessel-control"]').should('not.contain', 'Ouvrir le contrôle')

cy.get('*[data-cy="vessel-menu-resume"]').should('not.exist')
cy.get('*[data-cy="vessel-menu-reporting"]').should('not.exist')
cy.get('*[data-cy="vessel-menu-ers-vms"]').should('not.exist')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ context('Offline management', () => {
cy.get('*[data-cy="vessel-sidebar-error"]').contains("Nous n'avons pas pu récupérer les informations du navire")

// When clicking on Resume tab
cy.get('*[data-cy="vessel-menu-resume"').click()
cy.get('*[data-cy="vessel-menu-summary"').click()
cy.wait('@openVessel')
cy.get('*[data-cy="vessel-sidebar-error"]').contains("Nous n'avons pas pu récupérer les informations du navire")
cy.clickButton('Réessayer')
Expand Down Expand Up @@ -107,7 +107,7 @@ context('Offline management', () => {
'&IRCS=CALLME&vesselIdentifier=INTERNAL_REFERENCE_NUMBER&trackDepth=TWELVE_HOURS&afterDateTime=&beforeDateTime=',
cy.spy().as('openVesselSpyed')
)
cy.get('*[data-cy="vessel-menu-resume"').click()
cy.get('*[data-cy="vessel-menu-summary"').click()
cy.get('@openVesselSpyed').should('not.have.been.called')
cy.get('*[data-cy="vessel-sidebar-error"]').should('not.exist')

Expand Down
6 changes: 1 addition & 5 deletions frontend/src/domain/entities/authorization/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import { VesselSidebarTab } from '../vessel/vessel'

export const forbiddenVesselSidebarPaths = [
VesselSidebarTab.SUMMARY,
VesselSidebarTab.REPORTING,
VesselSidebarTab.ERSVMS
]
export const forbiddenVesselSidebarPaths = [VesselSidebarTab.REPORTING, VesselSidebarTab.ERSVMS]
2 changes: 1 addition & 1 deletion frontend/src/features/VesselSidebar/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function Body() {
<Wrapper hasHealthcheckTextWarning={!!healthcheckTextWarning.length}>
{isSuperUser && <AlertWarning selectedVessel={selectedVessel} />}
{isSuperUser && <BeaconMalfunctionWarning selectedVessel={selectedVessel} />}
{isSuperUser && vesselSidebarTab === VesselSidebarTab.SUMMARY && <VesselSummary />}
{vesselSidebarTab === VesselSidebarTab.SUMMARY && <VesselSummary />}
{vesselSidebarTab === VesselSidebarTab.IDENTITY && <Identity />}
{vesselSidebarTab === VesselSidebarTab.VOYAGES && <VesselLogbook />}
{vesselSidebarTab === VesselSidebarTab.CONTROLS && <Controls />}
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/features/VesselSidebar/Summary/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { useIsSuperUser } from '@hooks/authorization/useIsSuperUser'
import { useMainAppDispatch } from '@hooks/useMainAppDispatch'
import { useMainAppSelector } from '@hooks/useMainAppSelector'
import { useEffect, useState } from 'react'
import { FingerprintSpinner } from 'react-epic-spinners'
import styled from 'styled-components'
Expand All @@ -7,8 +10,6 @@ import { COLORS } from '../../../constants/constants'
import { getCoordinates } from '../../../coordinates'
import { WSG84_PROJECTION } from '../../../domain/entities/map/constants'
import { showVessel } from '../../../domain/use_cases/vessel/showVessel'
import { useMainAppDispatch } from '../../../hooks/useMainAppDispatch'
import { useMainAppSelector } from '../../../hooks/useMainAppSelector'
import { getDateTime, timeagoFrenchLocale } from '../../../utils'
import InfoSVG from '../../icons/Information.svg?react'
import NoVesselSVG from '../../icons/Picto_photo_navire_manquante.svg?react'
Expand All @@ -19,6 +20,7 @@ timeago.register('fr', timeagoFrenchLocale)

export function VesselSummary() {
const dispatch = useMainAppDispatch()
const isSuperUser = useIsSuperUser()
const coordinatesFormat = useMainAppSelector(state => state.map.coordinatesFormat)
const { loadingVessel, selectedVessel, selectedVesselIdentity, selectedVesselPositions } = useMainAppSelector(
state => state.vessel
Expand Down Expand Up @@ -149,7 +151,7 @@ export function VesselSummary() {
</FieldValue>
</Position>
</ZoneWithoutBackground>
<RiskFactorResume />
{isSuperUser && <RiskFactorResume />}
</Body>
) : (
<FingerprintSpinner className="radar" color={COLORS.charcoal} size={100} />
Expand Down
16 changes: 7 additions & 9 deletions frontend/src/features/VesselSidebar/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ export function Tabs() {

return (
<TabList>
{isSuperUser && (
<Tab
data-cy="vessel-menu-resume"
isActive={vesselSidebarTab === VesselSidebarTab.SUMMARY}
onClick={() => showTab(VesselSidebarTab.SUMMARY)}
>
<SummaryIcon /> <br /> Résumé
</Tab>
)}
<Tab
data-cy="vessel-menu-summary"
isActive={vesselSidebarTab === VesselSidebarTab.SUMMARY}
onClick={() => showTab(VesselSidebarTab.SUMMARY)}
>
<SummaryIcon /> <br /> Résumé
</Tab>
<Tab
data-cy="vessel-menu-identity"
isActive={vesselSidebarTab === VesselSidebarTab.IDENTITY}
Expand Down

0 comments on commit 4d5d253

Please sign in to comment.