Skip to content

Commit

Permalink
Merge pull request #1976 from UKHomeOffice/DRTII-1667-SPIKE-ACL-origi…
Browse files Browse the repository at this point in the history
…n-not-always-matching-API-origin

Drtii 1667 spike acl origin not always matching api origin
  • Loading branch information
richbirch authored Jan 9, 2025
2 parents 56019fa + 0356d07 commit a0fd720
Show file tree
Hide file tree
Showing 98 changed files with 388 additions and 459 deletions.
2 changes: 1 addition & 1 deletion client/src/main/scala/drt/client/actions/Actions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ object Actions {

case class GetManifestSummariesForDate(date: UtcDate) extends Action

case class GetManifestSummaries(arrivalKeys: Set[ArrivalKey]) extends Action
case class GetManifestSummaries(arrivalKeys: Set[ManifestKey]) extends Action

case class SetManifestSummaries(summaries: Set[FlightManifestSummary]) extends Action

Expand Down
3 changes: 3 additions & 0 deletions client/src/main/scala/drt/client/components/ArrivalInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ object ArrivalInfo {
("Feed", None),
("Flight", None),
("Origin", None),
("Previous Port", None),
("Terminal", None),
("Gate / Stand", Option("gate-stand")),
("Baggage", None),
Expand Down Expand Up @@ -80,10 +81,12 @@ object FeedSourceRow {
val isCiriumAsPortLive = props.airportConfig.noLivePortFeed && props.airportConfig.aclDisabled
val paxTotal: String = arrival.bestPaxEstimate(props.paxFeedSourceOrder).passengers.actual.map(_.toString).getOrElse("-")
val paxTrans: String = arrival.bestPaxEstimate(props.paxFeedSourceOrder).passengers.transit.map(_.toString).getOrElse("-")
val prevPort: String = arrival.PreviousPort.map(_.iata).getOrElse("n/a")
val flightFields = List[TagMod](
<.td(feedDisplayName(isCiriumAsPortLive, feedSource)),
<.td(arrival.flightCodeString),
<.td(arrival.Origin.toString),
<.td(prevPort),
<.td(arrival.Terminal.toString),
<.td(s"${arrival.Gate.getOrElse("")}/${arrival.Stand.getOrElse("")}"),
<.td(s"${arrival.BaggageReclaimId.getOrElse("")}"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package drt.client.components

import drt.shared.ArrivalKey
import drt.shared.ManifestKey
import drt.shared.api.{FlightManifestSummary, PaxAgeRange}
import japgolly.scalajs.react.vdom.{VdomElement, html_<^}
import japgolly.scalajs.react.vdom.all.EmptyVdom
Expand Down Expand Up @@ -30,14 +30,14 @@ object FlightHighlighter {
}

def findHighlightedFlightsCount(sortedFlights: Seq[(ApiFlightWithSplits, Seq[String])],
flightManifestSummaries: Map[ArrivalKey, FlightManifestSummary],
flightManifestSummaries: Map[ManifestKey, FlightManifestSummary],
flaggedNationalities: Set[drt.shared.Country],
flaggedAgeGroups: Set[PaxAgeRange],
showNumberOfVisaNationals: Boolean,
showHighlightedRows: Boolean,
showRequireAllSelected: Boolean): Int = {
val flightManifestSummary: Seq[FlightManifestSummary] = sortedFlights.flatMap {
case (flightWithSplits, _) => flightManifestSummaries.get(ArrivalKey(flightWithSplits.apiFlight))
case (flightWithSplits, _) => flightManifestSummaries.get(ManifestKey(flightWithSplits.apiFlight))
}
val flaggedInSummary: Seq[Option[Int]] = flightManifestSummary.map { manifestSummary =>

Expand Down
6 changes: 2 additions & 4 deletions client/src/main/scala/drt/client/components/FlightTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ object FlightTable {
paxFeedSourceOrder: List[FeedSource],
flightHighlight: FlightHighlight,
flights: Pot[Seq[ApiFlightWithSplits]],
flightManifestSummaries: Map[ArrivalKey, FlightManifestSummary],
flightManifestSummaries: Map[ManifestKey, FlightManifestSummary],
arrivalSources: Option[(UniqueArrival, Pot[List[Option[FeedSourceArrival]]])],
originMapper: (PortCode, html_<^.TagMod) => VdomNode,
originMapper: (PortCode, Option[PortCode], html_<^.TagMod) => VdomNode,
) extends UseValueEq

case class State(showHighlightedRows: Boolean)

implicit val stateReuse: Reusability[State] = Reusability.always

val ageGroups: js.Array[String] =
js.Array(AgeRange(0, 9).title,
AgeRange(10, 24).title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import diode.UseValueEq
import diode.data.Pot
import drt.client.components.ToolTips._
import drt.client.services._
import drt.shared.{ArrivalKey, CodeShares, DefaultFlightDisplayFilter, FlightHighlight, LhrFlightDisplayFilter}
import drt.shared.{ManifestKey, CodeShares, DefaultFlightDisplayFilter, FlightHighlight, LhrFlightDisplayFilter}
import drt.shared.api.{FlightManifestSummary, PaxAgeRange, WalkTimes}
import drt.shared.redlist.{DirectRedListFlight, IndirectRedListPax, LhrRedListDatesImpl, LhrTerminalTypes}
import io.kinoplan.scalajs.react.material.ui.core.system.SxProps
import io.kinoplan.scalajs.react.material.ui.core.{MuiAlert, MuiTypography}
import japgolly.scalajs.react.component.Scala.Component
import japgolly.scalajs.react.vdom.html_<^.{<, ^, _}
import japgolly.scalajs.react.vdom.html_<^._
import japgolly.scalajs.react.vdom.{TagOf, html_<^}
import japgolly.scalajs.react.{CtorType, _}
import japgolly.scalajs.react._
import org.scalajs.dom
import org.scalajs.dom.html.{TableCell, TableSection}
import uk.gov.homeoffice.drt.arrivals.ApiFlightWithSplits
Expand All @@ -28,7 +28,7 @@ import scala.scalajs.js

object FlightTableContent {
case class Props(flights: Pot[Seq[ApiFlightWithSplits]],
flightManifestSummaries: Map[ArrivalKey, FlightManifestSummary],
flightManifestSummaries: Map[ManifestKey, FlightManifestSummary],
queueOrder: Seq[Queue],
hasEstChox: Boolean,
loggedInUser: LoggedInUser,
Expand All @@ -44,7 +44,7 @@ object FlightTableContent {
flightHighlight: FlightHighlight,
paxFeedSourceOrder: List[FeedSource],
shortLabel: Boolean = false,
originMapper: (PortCode, html_<^.TagMod) => VdomNode,
originMapper: (PortCode, Option[PortCode], html_<^.TagMod) => VdomNode,
) extends UseValueEq

case class Model(airportInfos: Map[PortCode, Pot[AirportInfo]]) extends UseValueEq
Expand Down Expand Up @@ -105,8 +105,8 @@ object FlightTableContent {
props.terminal,
flightWithSplits.apiFlight.Terminal,
isRedListOrigin)
val manifestSummary: Option[FlightManifestSummary] = props.flightManifestSummaries.get(ArrivalKey(flightWithSplits.apiFlight))

val maybeManifestSummary = props.flightManifestSummaries.get(ManifestKey(flightWithSplits.apiFlight))
val redListPaxInfo = IndirectRedListPax(props.displayRedListInfo, flightWithSplits)

def flightTableRow(showHightlighted: Boolean) = FlightTableRow.Props(
Expand All @@ -128,12 +128,12 @@ object FlightTableContent {
showNumberOfVisaNationals = props.flightHighlight.showNumberOfVisaNationals,
showHighlightedRows = props.flightHighlight.showNumberOfVisaNationals,
showRequireAllSelected = props.flightHighlight.showRequireAllSelected,
manifestSummary = props.flightManifestSummaries.get(ArrivalKey(flightWithSplits.apiFlight)),
maybeManifestSummary = maybeManifestSummary,
paxFeedSourceOrder = props.paxFeedSourceOrder,
showHighLighted = showHightlighted
)

FlightHighlighter.highlightedFlight(manifestSummary,
FlightHighlighter.highlightedFlight(maybeManifestSummary,
props.flightHighlight.selectedNationalities,
ageGroups,
props.flightHighlight.showNumberOfVisaNationals,
Expand Down
22 changes: 12 additions & 10 deletions client/src/main/scala/drt/client/components/FlightTableRow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object FlightTableRow {

case class Props(flightWithSplits: ApiFlightWithSplits,
codeShareFlightCodes: Seq[String],
originMapper: (PortCode, html_<^.TagMod) => VdomNode,
originMapper: (PortCode, Option[PortCode], html_<^.TagMod) => VdomNode,
splitsQueueOrder: Seq[Queue],
loggedInUser: LoggedInUser,
viewMode: ViewMode,
Expand All @@ -50,15 +50,15 @@ object FlightTableRow {
showNumberOfVisaNationals: Boolean,
showHighlightedRows: Boolean,
showRequireAllSelected: Boolean,
manifestSummary: Option[FlightManifestSummary],
maybeManifestSummary: Option[FlightManifestSummary],
paxFeedSourceOrder: List[FeedSource],
showHighLighted: Boolean,
) extends UseValueEq

implicit val propsReuse: Reusability[Props] = Reusability {
(a, b) =>
a.flightWithSplits.lastUpdated == b.flightWithSplits.lastUpdated &&
a.manifestSummary == b.manifestSummary &&
a.maybeManifestSummary == b.maybeManifestSummary &&
a.flaggedNationalities == b.flaggedNationalities &&
a.flaggedAgeGroups == b.flaggedAgeGroups
}
Expand All @@ -77,7 +77,7 @@ object FlightTableRow {

val highlighterIsActive = props.flaggedNationalities.nonEmpty || props.flaggedAgeGroups.nonEmpty || props.showNumberOfVisaNationals

val highlightPaxExists: Boolean = FlightHighlighter.highlightedFlight(props.manifestSummary,
val highlightPaxExists: Boolean = FlightHighlighter.highlightedFlight(props.maybeManifestSummary,
props.flaggedNationalities,
props.flaggedAgeGroups,
props.showNumberOfVisaNationals,
Expand All @@ -90,7 +90,7 @@ object FlightTableRow {
props.showRequireAllSelected,
props.flaggedAgeGroups,
props.flaggedNationalities,
props.manifestSummary)
props.maybeManifestSummary)
if (chip != EmptyVdom) Some(chip) else None
} else None

Expand Down Expand Up @@ -154,7 +154,7 @@ object FlightTableRow {

val expectedContent = maybeLocalTimeWithPopup(bestExpectedTime, Option(timesPopUp), None)

val charts = (flightWithSplits.hasApi, props.manifestSummary) match {
val charts = (flightWithSplits.hasApi, props.maybeManifestSummary) match {
case (true, Some(manifestSummary)) =>
val maybeLivePcpPax = flightWithSplits.apiFlight.bestPcpPaxEstimate(Seq(LiveFeedSource))
val maybePaxDiffAndPct = maybeLivePcpPax.map { pcpPax =>
Expand All @@ -172,6 +172,8 @@ object FlightTableRow {
val highlighterClass = s"arrivals__table__flight-code__highlighter-${if (highlighterIsActive) "on" else "off"}"
val isHighlightedClass = if (highlighterIsActive) "arrivals__table__flight-code-wrapper__highlighted" else ""

val maybePreviousPort = None //flight.PreviousPort.filter(_ != flight.Origin)

val firstCells = List[TagMod](
<.td(^.className := flightCodeClass,
<.div(^.cls := s"$highlighterClass $isHighlightedClass arrivals__table__flight-code-wrapper",
Expand All @@ -181,13 +183,13 @@ object FlightTableRow {
.getOrElse {
if (highlighterIsActive) <.td(^.className := "arrivals__table__flags-column", "") else EmptyVdom
},
<.td(TerminalContentComponent.airportWrapper(flight.Origin) { proxy: ModelProxy[Pot[AirportInfo]] =>
<.td(TerminalContentComponent.airportWrapper(flight.Origin) { airportInfoPot: ModelProxy[Pot[AirportInfo]] =>
<.span(
proxy().renderEmpty(props.originMapper(flight.Origin, EmptyVdom)),
proxy().render { ai =>
airportInfoPot().renderEmpty(props.originMapper(flight.Origin, maybePreviousPort, EmptyVdom)),
airportInfoPot().render { ai =>
val redListCountry = props.indirectRedListPax.isEnabled && isRedListCountry(ai.country, props.viewMode.dayEnd, props.redListUpdates)
val style: html_<^.TagMod = if (redListCountry) ScalaCssReact.scalacssStyleaToTagMod(ArrivalsPageStylesDefault.redListCountryField) else EmptyVdom
props.originMapper(flight.Origin, style)
props.originMapper(flight.Origin, maybePreviousPort, style)
}
)
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package drt.client.components

import diode.UseValueEq
import diode.data.{Pending, Pot}
import diode.react.{ModelProxy, ReactConnectProxy}
import diode.react.ReactConnectProxy
import drt.client.SPAMain
import drt.client.SPAMain.{Loc, TerminalPageTabLoc}
import drt.client.components.ArrivalsExportComponent.componentFactory
Expand Down Expand Up @@ -56,7 +56,7 @@ object TerminalContentComponent {
walkTimes: Pot[WalkTimes],
paxFeedSourceOrder: List[FeedSource],
flights: Pot[Seq[ApiFlightWithSplits]],
flightManifestSummaries: Map[ArrivalKey, FlightManifestSummary],
flightManifestSummaries: Map[ManifestKey, FlightManifestSummary],
arrivalSources: Option[(UniqueArrival, Pot[List[Option[FeedSourceArrival]]])],
simulationResult: Pot[SimulationResult],
flightHighlight: FlightHighlight,
Expand All @@ -72,16 +72,31 @@ object TerminalContentComponent {

def airportWrapper(portCode: PortCode): ReactConnectProxy[Pot[AirportInfo]] = SPACircuit.connect(_.airportInfos.getOrElse(portCode, Pending()))

def originMapper(portCode: PortCode, style: html_<^.TagMod): VdomElement = airportWrapper(portCode) {
proxy: ModelProxy[Pot[AirportInfo]] =>
def originMapper(origin: PortCode, maybePrevious: Option[PortCode], style: html_<^.TagMod): VdomElement =
airportWrapper(origin) { originProxy => {
val prevPort = maybePrevious.map(previousPortMapper(_, style)) match {
case Some(prevPort) => <.div(s"via ", prevPort)
case None => <.span()
}
<.span(
style,
proxy().render(ai =>
originProxy().render(ai =>
<.dfn(^.className := "flight-origin-dfn", Tippy.describe(<.span(s"${ai.airportName}, ${ai.city}, ${ai.country}"),
<.abbr(^.className := "dotted-underline", s"${portCode.toString}")), s", ${ai.country}")),
proxy().renderEmpty(<.abbr(^.className := "dotted-underline", portCode.toString))
<.abbr(^.className := "dotted-underline", s"${origin.toString}")), <.span(s", ${ai.country}", prevPort))),
originProxy().renderEmpty(<.abbr(^.className := "dotted-underline", <.span(origin.toString, prevPort)))
)
}
}}

def previousPortMapper(previous: PortCode, style: html_<^.TagMod): VdomElement =
airportWrapper(previous) { previousProxy =>
<.span(
style,
previousProxy().render(ai =>
<.dfn(^.className := "flight-origin-dfn", Tippy.describe(<.span(s"${ai.airportName}, ${ai.city}, ${ai.country}"),
<.abbr(^.className := "dotted-underline", s"${previous.toString}")), s", ${ai.country}")),
previousProxy().renderEmpty(<.abbr(^.className := "dotted-underline", previous.toString))
)
}

class Backend {
def render(props: Props, state: State): TagOf[Div] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object TerminalDashboardComponent {
walkTimes: Pot[WalkTimes],
paxFeedSourceOrder: List[FeedSource],
portState: Pot[PortState],
flightManifestSummaries: Map[ArrivalKey, FlightManifestSummary],
flightManifestSummaries: Map[ManifestKey, FlightManifestSummary],
arrivalSources: Option[(UniqueArrival, Pot[List[Option[FeedSourceArrival]]])],
flightHighlight: FlightHighlight,
) extends UseValueEq
Expand Down
4 changes: 2 additions & 2 deletions client/src/main/scala/drt/client/services/SPACircuit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ case class RootModel(applicationVersion: Pot[ClientServerVersions] = Empty,
featureFlags: Pot[FeatureFlags] = Empty,
fileUploadState: Pot[FileUploadState] = Empty,
simulationResult: Pot[SimulationResult] = Empty,
passengerInfoSummariesByArrival: Pot[Map[ArrivalKey, FlightManifestSummary]] = Ready(Map()),
passengerInfoSummariesByArrival: Pot[Map[ManifestKey, FlightManifestSummary]] = Ready(Map()),
snackbarMessage: Pot[String] = Empty,
redListPorts: Pot[HashSet[PortCode]] = Empty,
redListUpdates: Pot[RedListUpdates] = Empty,
Expand All @@ -176,7 +176,7 @@ case class RootModel(applicationVersion: Pot[ClientServerVersions] = Empty,
featureGuides: Pot[Seq[FeatureGuide]] = Empty,
maybeTimeMachineDate: Option[SDateLike] = None,
flaggedNationalities: Set[Country] = Set(),
flightManifestSummaries: Map[ArrivalKey, FlightManifestSummary] = Map(),
flightManifestSummaries: Map[ManifestKey, FlightManifestSummary] = Map(),
paxFeedSourceOrder: List[FeedSource] = List(),
showNewFeatureGuideOnLogin: Pot[Boolean] = Empty,
featureGuideViewedIds: Pot[Seq[String]] = Empty,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package drt.client.services.handlers
import diode._
import drt.client.actions.Actions._
import drt.client.services.DrtApi
import drt.shared.ArrivalKey
import drt.shared.ManifestKey
import drt.shared.api.FlightManifestSummary
import io.lemonlabs.uri.QueryString
import upickle.default._

import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue

class FlightManifestSummariesHandler[M](modelRW: ModelRW[M, Map[ArrivalKey, FlightManifestSummary]]) extends LoggingActionHandler(modelRW) {
class FlightManifestSummariesHandler[M](modelRW: ModelRW[M, Map[ManifestKey, FlightManifestSummary]]) extends LoggingActionHandler(modelRW) {
override def handle: PartialFunction[Any, ActionResult[M]] = {
case GetManifestSummariesForDate(date) =>
val request = Effect(DrtApi.get(s"manifest-summaries/$date/summary")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ class InitialPortStateHandler[M](getCurrentViewMode: () => ViewMode,

case SetPortState(viewMode, portState) =>
val originCodes = portState.flights
.map { case (_, fws) => fws.apiFlight.Origin }
.flatMap { case (_, fws) =>
Set(fws.apiFlight.Origin, fws.apiFlight.PreviousPort.getOrElse(fws.apiFlight.Origin))
}
.toSet

val hideLoader = Effect(Future(HideLoader()))
Expand Down
Loading

0 comments on commit a0fd720

Please sign in to comment.