-
Notifications
You must be signed in to change notification settings - Fork 57
Select scooter mode when starting trip from scooter in nearby view #1449
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
Open
alec-georgoff
wants to merge
9
commits into
dev
Choose a base branch
from
nearby-view-scooter-mode-selection
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−7
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5cb8ab5
Select scooter mode when starting trip from scooter in nearby view
alec-georgoff 85993ff
Fix missing import
alec-georgoff 29d5d3f
Remove console log
alec-georgoff 4605c6e
Merge remote-tracking branch 'origin/dev' into nearby-view-scooter-mo…
alec-georgoff 18a74a4
Implement findRequiredOptionsForTransportMode
alec-georgoff c58f43f
Use find instead of filter
alec-georgoff 0302899
Version bump trip form package
alec-georgoff c40127a
Merge remote-tracking branch 'origin/dev' into nearby-view-scooter-mo…
alec-georgoff c9da892
add an empty string handler for jest gql
danielhep File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,15 @@ | |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import { connect } from 'react-redux' | ||
import { | ||
findRequiredOptionsForTransportMode, | ||
RequiredOptionsForTransportMode | ||
} from '@opentripplanner/trip-form' | ||
import { GeolocateControl, NavigationControl } from 'react-map-gl/maplibre' | ||
import { getCurrentDate } from '@opentripplanner/core-utils/lib/time' | ||
import { injectIntl } from 'react-intl' | ||
import { MapLocationActionArg } from '@opentripplanner/types' | ||
import { QueryParamChangeEvent } from '@opentripplanner/trip-form/lib/types' | ||
import BaseMap from '@opentripplanner/base-map' | ||
import generateOTP2TileLayers from '@opentripplanner/otp2-tile-overlay' | ||
import React, { Component } from 'react' | ||
|
@@ -18,10 +24,17 @@ import { | |
vehicleRentalQuery | ||
} from '../../actions/api' | ||
import { ComponentContext } from '../../util/contexts' | ||
import { decodeQueryParams } from 'serialize-query-params' | ||
import { getActiveItinerary, getActiveSearch } from '../../util/state' | ||
import { getCurrentPosition } from '../../actions/location' | ||
import { MainPanelContent } from '../../actions/ui-constants' | ||
import { | ||
modesQueryParamConfig, | ||
onSettingsUpdate, | ||
setModeButton | ||
} from '../form/util' | ||
import { setLocation, setMapPopupLocationAndGeocode } from '../../actions/map' | ||
import { setQueryParam } from '../../actions/form' | ||
import { setViewedStop } from '../../actions/ui' | ||
import { updateOverlayVisibility } from '../../actions/config' | ||
import TransitOperatorIcons from '../util/connected-transit-operator-icons' | ||
|
@@ -303,6 +316,7 @@ class DefaultMap extends Component { | |
carRentalQuery, | ||
carRentalStations, | ||
config, | ||
enabledModeButtons, | ||
getCurrentPosition, | ||
intl, | ||
itinerary, | ||
|
@@ -311,6 +325,7 @@ class DefaultMap extends Component { | |
nearbyViewActive, | ||
pending, | ||
setLocation, | ||
setQueryParam, | ||
setViewedStop, | ||
vehicleRentalQuery, | ||
vehicleRentalStations, | ||
|
@@ -345,6 +360,34 @@ class DefaultMap extends Component { | |
const baseLayerUrls = baseLayersWithNames?.map((bl) => bl.url) | ||
const baseLayerNames = baseLayersWithNames?.map((bl) => bl.name) | ||
|
||
const overlayTypes = overlays | ||
?.find((overlay) => overlay?.type === 'otp2') | ||
?.layers?.map((layer) => layer?.type) | ||
const handleSetLocation = (location: MapLocationActionArg) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one approach, but could we not fix this by adjusting query params? What if we check for map state in the places where query params are set? Might that be a better separation of concerns than setting modes within the map component? |
||
if (overlayTypes && overlayTypes.includes('rentalVehicles')) { | ||
const requiredOptions: RequiredOptionsForTransportMode = | ||
findRequiredOptionsForTransportMode( | ||
config.modes.modeButtons, | ||
config.modes.modeSettingDefinitions, | ||
{ mode: 'SCOOTER', qualifier: 'RENT' } | ||
) | ||
if (requiredOptions) { | ||
const modeSetter = setModeButton( | ||
enabledModeButtons, | ||
onSettingsUpdate(setQueryParam) | ||
) | ||
|
||
modeSetter(requiredOptions.modeButton, true) | ||
|
||
if (requiredOptions.modeSetting) | ||
onSettingsUpdate(setQueryParam)({ | ||
[requiredOptions.modeSetting]: true | ||
}) | ||
} | ||
} | ||
setLocation(location) | ||
} | ||
|
||
const routeBasedTransitVehicleOverlayNameOverride = | ||
overlays?.find((o) => o.type === 'vehicles-one-route') || undefined | ||
|
||
|
@@ -468,7 +511,7 @@ class DefaultMap extends Component { | |
name: getLayerName(l, config, intl) || l.network || l.type | ||
})), | ||
vectorTilesEndpoint, | ||
setLocation, | ||
handleSetLocation, | ||
setViewedStop, | ||
viewedRouteStops, | ||
config.companies, | ||
|
@@ -516,12 +559,20 @@ const mapStateToProps = (state) => { | |
) | ||
) | ||
: null | ||
const urlSearchParams = new URLSearchParams(state.router.location.search) | ||
const { modes } = state.otp.config | ||
|
||
return { | ||
activeNearbyFilters, | ||
bikeRentalStations: state.otp.overlay.bikeRental.stations, | ||
carRentalStations: state.otp.overlay.carRental.stations, | ||
config: state.otp.config, | ||
enabledModeButtons: | ||
decodeQueryParams(modesQueryParamConfig, { | ||
modeButtons: urlSearchParams.get('modeButtons') | ||
})?.modeButtons || | ||
modes?.initialState?.enabledModeButtons || | ||
{}, | ||
itinerary: getActiveItinerary(state), | ||
mapConfig: state.otp.config.map, | ||
nearbyFilters, | ||
|
@@ -541,6 +592,7 @@ const mapDispatchToProps = { | |
getCurrentPosition, | ||
setLocation, | ||
setMapPopupLocationAndGeocode, | ||
setQueryParam, | ||
setViewedStop, | ||
updateOverlayVisibility, | ||
vehicleRentalQuery | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2725,6 +2725,24 @@ | |
lodash.isequal "^4.5.0" | ||
qs "^6.9.1" | ||
|
||
"@opentripplanner/[email protected]": | ||
version "14.0.1" | ||
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-14.0.1.tgz#8800c9cd50680ff09e5375b4a20d2f1c24fb4a8b" | ||
integrity sha512-LfCNtl+YORiBxeutC4+SXL4yMIumrMdL3zNfcV+mghRtpRmus36xd5rCgnzXtv1d6Arbbk+zXixJg90j/tBmwA== | ||
dependencies: | ||
"@conveyal/lonlat" "^1.4.1" | ||
"@mapbox/polyline" "^1.1.1" | ||
"@opentripplanner/geocoder" "3.0.5" | ||
"@styled-icons/foundation" "^10.34.0" | ||
"@turf/along" "^6.0.1" | ||
chroma-js "^2.4.2" | ||
date-fns "^2.28.0" | ||
date-fns-tz "^1.2.2" | ||
graphql "^16.6.0" | ||
lodash.clonedeep "^4.5.0" | ||
lodash.isequal "^4.5.0" | ||
qs "^6.9.1" | ||
|
||
"@opentripplanner/[email protected]": | ||
version "5.0.0" | ||
resolved "https://registry.yarnpkg.com/@opentripplanner/endpoints-overlay/-/endpoints-overlay-5.0.0.tgz#216ba195ef7cf9dd8f76b862480c018e7b96ffc6" | ||
|
@@ -2938,14 +2956,14 @@ | |
flat "^5.0.2" | ||
react-animate-height "^3.0.4" | ||
|
||
"@opentripplanner/trip-form@6.0.1": | ||
version "6.0.1" | ||
resolved "https://registry.yarnpkg.com/@opentripplanner/trip-form/-/trip-form-6.0.1.tgz#262079589e056bf49c285a5b38257c54c59f088f" | ||
integrity sha512-7o8frpL7rhieQmkrSaAxj+kqp8ocHyxmyB2l2LH8jJmoGgGevtQ5VxEmXaVctwpGJ12Fi1P/yiqD08PqnPG49w== | ||
"@opentripplanner/trip-form@6.1.0": | ||
version "6.1.0" | ||
resolved "https://registry.yarnpkg.com/@opentripplanner/trip-form/-/trip-form-6.1.0.tgz#0238052e423436f25ecd0edc3d98c6c5b3429754" | ||
integrity sha512-jeo6wPZBHaf5wBJI3msrjckc5C08WMj6VkRe5b+a2CqEoDwPInxRN658+H6qgxDeCxFzNiOehey3lQq35bTP/Q== | ||
dependencies: | ||
"@floating-ui/react" "^0.19.2" | ||
"@opentripplanner/building-blocks" "3.0.1" | ||
"@opentripplanner/core-utils" "13.0.1" | ||
"@opentripplanner/core-utils" "14.0.1" | ||
"@opentripplanner/icons" "4.0.0" | ||
"@styled-icons/bootstrap" "^10.34.0" | ||
"@styled-icons/boxicons-regular" "^10.38.0" | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.