-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DT-5921 Add car ferry functionality #5121
base: v3
Are you sure you want to change the base?
Conversation
…ar and disable leg text for ferries in the matka config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work. I suggested a fair amount of mainly cosmetic changes, which make the code easier to read and understand.
In general, try to avoid adding unncecessary validation checks 'just in case'. The code should fail fast and crash if variable values are not valid.
app/component/itinerary/CarLeg.js
Outdated
<div className={cx('itinerary-leg-action', 'car')}> | ||
<div className="itinerary-leg-action-content"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge these into one div
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not change these for now. For example, there are similar divs in BicycleLeg, BikeParkLeg, CarParkLeg. Do you want all of these changed or none?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I understand. I would love to see all code improving continuously. Please fix this unless it feels unreasonably big task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two divs have been merged everywhere I could find them.
app/component/itinerary/CarLeg.js
Outdated
<div className={cx('itinerary-leg-action', 'car')}> | ||
<div className="itinerary-leg-action-content"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge divs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not change these for now. For example, there are similar divs in BicycleLeg, BikeParkLeg, CarParkLeg. Do you want all of these changed or none?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two divs have been merged everywhere I could find them.
severityLevel={AlertSeverityLevelType.Info} | ||
/> | ||
</div> | ||
<div className="with-car-info-notification"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge these 2 divs: with-car-info-notification and with-car-info-content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed with-bike-info-header and with-car-info-header in itinerary-list-header.scss, they were not used anymore. I merged with-bike-info-content and with-bike-info-notification as well as with-car-info-content and with-car-info-notification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a new css class .with-car-info-notification-icon which seems to be unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed with-car-info-notification-icon and with-bike-info-notification-icon. The car class was accidentally created based off of the old bike icon class. Both seem unused and I removed them
settings.includeCarSuggestions && | ||
config.carBoardingModes?.FERRY !== undefined && | ||
carPublicPlan.carPublicItineraryCount > 0; | ||
|
||
const showAltBar = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
carPublicPlan.carPublicItineraryCount > 0 is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FERRY checking is now removed. The idea behind checking for FERRY is that only in the configs that it is defined in, the UI will show ferries. Now there isn't a config field for removing carpublic itineraries in case they are found but not wanted. I did not remove settings.includeCarSuggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there be car + public itineraries if includeCarSuggestions === false ? That would be surprising.
The logic gets a bit complicated because car itinerary is fetched for co2 comparison although user does not wish to get car itineraries.
Make sure that car + public won't get populated just because of co2 car routing. It should contain something only when user has selected car routing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a double check here and forgot I checked this earlier. This is now only carPublicPlan.carPublicItineraryCount > 0
(settings.includeCarSuggestions && | ||
(carPlan?.edges?.length || | ||
(config.carBoardingModes?.FERRY !== undefined && | ||
carPublicPlan?.edges?.length)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(settings.includeCarSuggestions && carPlan?.edges?.length) ||
carPublicPlan?.edges?.length > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that the carpublicplan would be shown even without the setting. I think this is wrong. Do you agree? FERRY is now removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combination (settings.includeCarSuggestions && carPlan?.edges?.length) is used because carplan may be comouted for co2 comparison only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has now been changed to (settings.includeCarSuggestions && carPlan?.edges?.length) ||
carPublicPlan?.edges?.length > 0. I had a double check here and forgot I checked this earlier
There is a conflict. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found some new logic errors related to car+public itinerary list creation. Please read my review comments.
app/util/planParamUtil.js
Outdated
return ( | ||
transitModes.length > 0 && | ||
settings.includeCarSuggestions && | ||
config.carBoardingModes?.FERRY !== undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong. I suggest:
settings.includeCarSuggestions && filterTransitModes(...).length > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed this to transitModes.length > 0 && settings.includeCarSuggestions. I didn't realize previously that transitModes is filtered earlier with filterTransitModes.
altStates[PLANTYPE.CAR][0].loading === LOADSTATE.DONE && | ||
altStates[PLANTYPE.CARTRANSIT][0].loading === LOADSTATE.DONE | ||
) { | ||
const plan = mergeCarDirectAndTransitPlans( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is not OK. car + transit should be set only when there are carBoardingModes configured and settings.includeCarSuggestions is true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very similar to how the mergeBikeTransitPlans works. Because the check for making the cartransit query is made in planParamUtil, this should be fine as is. Do you want me to change this and the way it works for bikes or should I leave both as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now changed it to
altStates[PLANTYPE.CAR][0].loading === LOADSTATE.DONE &&
altStates[PLANTYPE.CARTRANSIT][0].loading === LOADSTATE.DONE &&
settings.includeCarSuggestions &&
config.carBoardingModes !== undefined
…n-icon CSS classes.
This should not be merged before the functionality from this pr can be used opentripplanner/OpenTripPlanner#5966,
Proposed Changes