Skip to content

Commit 03206b9

Browse files
Merge branch 'dev' into labeling-for-nearby-filters
2 parents 920481b + b23a178 commit 03206b9

File tree

8 files changed

+133
-31
lines changed

8 files changed

+133
-31
lines changed

__tests__/reducers/__snapshots__/create-otp-reducer.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Object {
7575
"rideEstimates": Object {},
7676
},
7777
"transitIndex": Object {
78+
"feeds": Array [],
7879
"routes": Object {},
7980
"routesFetchStatus": 0,
8081
"stops": Object {},

lib/actions/api.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,15 @@ export const findingRoutes = createAction('FINDING_ROUTES')
403403
export const findRoutesResponse = createAction('FIND_ROUTES_RESPONSE')
404404
export const findRoutesError = createAction('FIND_ROUTES_ERROR')
405405

406+
// Feeds lookup query
407+
408+
export const findFeedsResponse = createAction('FIND_FEEDS_RESPONSE')
409+
export const findFeedsError = createAction('FIND_FEEDS_ERROR')
410+
411+
export function findFeeds() {
412+
return executeOTPAction('findFeeds')
413+
}
414+
406415
export function findRoutesIfNeeded(params) {
407416
return function (dispatch, getState) {
408417
if (

lib/actions/apiV2.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import {
4242
fetchingStopTimesForStop,
4343
fetchNearbyError,
4444
fetchNearbyResponse,
45+
findFeedsError,
46+
findFeedsResponse,
4547
findRouteError,
4648
findRouteResponse,
4749
findRoutesError,
@@ -962,6 +964,35 @@ export function findRoutes() {
962964
}
963965
}
964966

967+
export function findFeeds() {
968+
return function (dispatch, getState) {
969+
dispatch(
970+
createGraphQLQueryAction(
971+
`query FeedsQuery {
972+
feeds {
973+
feedId
974+
publisher {
975+
name
976+
}
977+
}
978+
}`,
979+
{},
980+
findFeedsResponse,
981+
findFeedsError,
982+
{
983+
noThrottle: true,
984+
rewritePayload: (payload) => {
985+
if (payload.errors) {
986+
return dispatch(findFeedsError(payload.errors))
987+
}
988+
return payload?.data?.feeds || []
989+
}
990+
}
991+
)
992+
)
993+
}
994+
}
995+
965996
export const findPatternsForRoute = (params) =>
966997
function (dispatch, getState) {
967998
const state = getState()
@@ -1324,6 +1355,7 @@ const retrieveServiceTimeRangeIfNeeded = () =>
13241355

13251356
export default {
13261357
fetchNearby,
1358+
findFeeds,
13271359
findPatternsForRoute,
13281360
findRoute,
13291361
findRoutes,

lib/components/app/print-layout.tsx

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import { connect } from 'react-redux'
22
import { FormattedMessage, injectIntl, IntlShape } from 'react-intl'
33
import { Itinerary } from '@opentripplanner/types'
4+
import coreUtils from '@opentripplanner/core-utils'
45
import React, { Component } from 'react'
56

6-
import * as apiActions from '../../actions/api'
77
import * as formActions from '../../actions/form'
8+
import * as narrativeActions from '../../actions/narrative'
89
import { AppReduxState } from '../../util/state-types'
9-
import { getActiveItinerary, getActiveSearch } from '../../util/state'
10+
import {
11+
getActiveItineraries,
12+
getActiveSearch,
13+
getVisibleItineraryIndex
14+
} from '../../util/state'
1015
import { summarizeQuery } from '../form/user-settings-i18n'
1116
import { User } from '../user/types'
1217
import DefaultMap from '../map/default-map'
@@ -19,7 +24,8 @@ type Props = {
1924
intl: IntlShape
2025
itinerary: Itinerary
2126
location?: { search?: string }
22-
parseUrlQueryString: (params?: any, source?: string) => any
27+
parseUrlQueryString: (params?: any, source?: string) => void
28+
setVisibleItinerary: (params: { index: number }) => void
2329
user: User
2430
}
2531

@@ -37,6 +43,23 @@ class PrintLayout extends Component<Props> {
3743
}
3844
}
3945

46+
componentDidUpdate() {
47+
const { activeSearch, itinerary, setVisibleItinerary } = this.props
48+
49+
// Display the desired itinerary on map.
50+
if (!itinerary) {
51+
const { ui_activeItinerary: uiActiveItinerary } =
52+
coreUtils.query.getUrlParams() || {}
53+
if (
54+
activeSearch &&
55+
uiActiveItinerary !== undefined &&
56+
uiActiveItinerary !== '-1'
57+
) {
58+
setVisibleItinerary({ index: +uiActiveItinerary })
59+
}
60+
}
61+
}
62+
4063
render() {
4164
const { activeSearch, intl, itinerary, user } = this.props
4265
const printVerb = intl.formatMessage({ id: 'common.forms.print' })
@@ -68,16 +91,17 @@ const mapStateToProps = (state: AppReduxState) => {
6891
const activeSearch = getActiveSearch(state)
6992
const { localUser, loggedInUser } = state.user
7093
const user = loggedInUser || localUser
94+
const itineraries = getActiveItineraries(state)
7195
return {
7296
activeSearch,
73-
itinerary: getActiveItinerary(state) as Itinerary,
97+
itinerary: itineraries[getVisibleItineraryIndex(state)] as Itinerary,
7498
user
7599
}
76100
}
77101

78102
const mapDispatchToProps = {
79103
parseUrlQueryString: formActions.parseUrlQueryString,
80-
routingQuery: apiActions.routingQuery
104+
setVisibleItinerary: narrativeActions.setVisibleItinerary
81105
}
82106

83107
export default connect(

lib/components/map/default-map.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
assembleBasePath,
1515
bikeRentalQuery,
1616
carRentalQuery,
17+
findFeeds,
1718
findStopTimesForStop,
1819
vehicleRentalQuery
1920
} from '../../actions/api'
@@ -81,6 +82,7 @@ function getCompanyNames(companyIds, config, intl) {
8182
/**
8283
* Determines the localized name of a map layer by its type.
8384
*/
85+
// eslint-disable-next-line complexity
8486
function getLayerName(overlay, config, intl) {
8587
const { companies, name, type } = overlay
8688

@@ -207,6 +209,7 @@ class DefaultMap extends Component {
207209
* as that UI mode sets the access mode and company in the query params.
208210
* TODO: Implement for the batch interface.
209211
*/
212+
// eslint-disable-next-line complexity
210213
_handleQueryChange = (oldQuery, newQuery) => {
211214
const { overlays = [] } = this.props.mapConfig || {}
212215
if (oldQuery.mode) {
@@ -289,6 +292,9 @@ class DefaultMap extends Component {
289292
lat: null,
290293
lon: null
291294
})
295+
296+
// Fetch feeds in the background
297+
this.props.findFeeds()
292298
}
293299

294300
componentDidUpdate(prevProps) {
@@ -303,6 +309,7 @@ class DefaultMap extends Component {
303309
carRentalQuery,
304310
carRentalStations,
305311
config,
312+
feeds,
306313
getCurrentPosition,
307314
intl,
308315
itinerary,
@@ -472,7 +479,8 @@ class DefaultMap extends Component {
472479
setViewedStop,
473480
viewedRouteStops,
474481
config.companies,
475-
this.getEntityPrefix
482+
this.getEntityPrefix,
483+
feeds
476484
)
477485
default:
478486
return null
@@ -497,6 +505,7 @@ const mapStateToProps = (state) => {
497505
const viewedRoute = state.otp?.ui?.viewedRoute?.routeId
498506
const activeNearbyFilters = state.otp?.ui?.nearbyView?.filters
499507
const nearbyFilters = state.otp.config?.nearbyView?.filters
508+
const stops = state.otp.transitIndex.stops
500509
const nearbyViewerActive =
501510
state.otp.ui.mainPanelContent === MainPanelContent.NEARBY_VIEW
502511

@@ -522,6 +531,7 @@ const mapStateToProps = (state) => {
522531
bikeRentalStations: state.otp.overlay.bikeRental.stations,
523532
carRentalStations: state.otp.overlay.carRental.stations,
524533
config: state.otp.config,
534+
feeds: state.otp.transitIndex.feeds,
525535
itinerary: getActiveItinerary(state),
526536
mapConfig: state.otp.config.map,
527537
nearbyFilters,
@@ -537,6 +547,7 @@ const mapStateToProps = (state) => {
537547
const mapDispatchToProps = {
538548
bikeRentalQuery,
539549
carRentalQuery,
550+
findFeeds,
540551
findStopTimesForStop,
541552
getCurrentPosition,
542553
setLocation,

lib/reducers/create-otp-reducer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export function getInitialState(userDefinedConfig) {
219219
rideEstimates: {}
220220
},
221221
transitIndex: {
222+
feeds: [],
222223
routes: {},
223224
routesFetchStatus: FETCH_STATUS.UNFETCHED,
224225
stops: {},
@@ -1126,6 +1127,12 @@ function createOtpReducer(config) {
11261127
return update(state, {
11271128
serviceTimeRange: { $set: action.payload.data.serviceTimeRange }
11281129
})
1130+
case 'FIND_FEEDS_RESPONSE':
1131+
return update(state, {
1132+
transitIndex: {
1133+
feeds: { $set: action.payload }
1134+
}
1135+
})
11291136
case 'SERVICE_TIME_RANGE_ERROR':
11301137
return update(state, {
11311138
serviceTimeRange: { $set: { error: true } }

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@
5050
"@opentripplanner/itinerary-body": "7.0.4",
5151
"@opentripplanner/location-field": "4.0.4",
5252
"@opentripplanner/location-icon": "^2.0.0",
53-
"@opentripplanner/map-popup": "7.0.0",
54-
"@opentripplanner/otp2-tile-overlay": "4.0.0",
53+
"@opentripplanner/map-popup": "7.0.1",
54+
"@opentripplanner/otp2-tile-overlay": "4.0.1",
5555
"@opentripplanner/park-and-ride-overlay": "5.0.0",
5656
"@opentripplanner/printable-itinerary": "4.0.1",
5757
"@opentripplanner/route-viewer-overlay": "5.0.0",
5858
"@opentripplanner/stop-viewer-overlay": "5.0.0",
59-
"@opentripplanner/stops-overlay": "8.0.0",
59+
"@opentripplanner/stops-overlay": "8.0.1",
6060
"@opentripplanner/transit-vehicle-overlay": "7.0.0",
6161
"@opentripplanner/transitive-overlay": "7.0.0",
6262
"@opentripplanner/trip-details": "^8.0.1",
6363
"@opentripplanner/trip-form": "6.0.1",
6464
"@opentripplanner/trip-viewer-overlay": "5.0.0",
65-
"@opentripplanner/vehicle-rental-overlay": "5.0.0",
65+
"@opentripplanner/vehicle-rental-overlay": "5.0.1",
6666
"@styled-icons/fa-regular": "^10.34.0",
6767
"@styled-icons/fa-solid": "^10.34.0",
6868
"@tanstack/react-pacer": "^0.8.0",

yarn.lock

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,24 @@
27252725
lodash.isequal "^4.5.0"
27262726
qs "^6.9.1"
27272727

2728+
"@opentripplanner/[email protected]":
2729+
version "14.0.0"
2730+
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-14.0.0.tgz#8bda57dcd95a0e5b388ef34279ff3a68ff35e66b"
2731+
integrity sha512-0yk1FnZFQQpkVBN3J24bBDPJQCJvlRHeid3GjG0blEtIdSdwdShox94ZwYNoLe/lxg2nRCAP5XSgtTVkgcFjGg==
2732+
dependencies:
2733+
"@conveyal/lonlat" "^1.4.1"
2734+
"@mapbox/polyline" "^1.1.1"
2735+
"@opentripplanner/geocoder" "3.0.5"
2736+
"@styled-icons/foundation" "^10.34.0"
2737+
"@turf/along" "^6.0.1"
2738+
chroma-js "^2.4.2"
2739+
date-fns "^2.28.0"
2740+
date-fns-tz "^1.2.2"
2741+
graphql "^16.6.0"
2742+
lodash.clonedeep "^4.5.0"
2743+
lodash.isequal "^4.5.0"
2744+
qs "^6.9.1"
2745+
27282746
"@opentripplanner/[email protected]":
27292747
version "5.0.0"
27302748
resolved "https://registry.yarnpkg.com/@opentripplanner/endpoints-overlay/-/endpoints-overlay-5.0.0.tgz#216ba195ef7cf9dd8f76b862480c018e7b96ffc6"
@@ -2827,23 +2845,23 @@
28272845
"@styled-icons/fa-regular" "^10.34.0"
28282846
"@styled-icons/fa-solid" "^10.34.0"
28292847

2830-
"@opentripplanner/[email protected].0":
2831-
version "7.0.0"
2832-
resolved "https://registry.yarnpkg.com/@opentripplanner/map-popup/-/map-popup-7.0.0.tgz#87fdf58aee677a123af0d2ffd2616d540ebb13dd"
2833-
integrity sha512-NRnGJKxC9Y0TpIQCQ+Gelo7T1HGyp9llj4zrSR7IdTwWhQhN2QwPXmTb1LLJQdnZ3NYrUzg4Sdx1jIhL8ZOPsw==
2848+
"@opentripplanner/[email protected].1":
2849+
version "7.0.1"
2850+
resolved "https://registry.yarnpkg.com/@opentripplanner/map-popup/-/map-popup-7.0.1.tgz#86c37ed91f0c7a42c3310fbd0d5b7fcc5b1776d7"
2851+
integrity sha512-HXsy7wVY9KwmbZ7G1enl7ES88kxAGw+Cr8dBp5eC52S6u4bTrVAMaM6aMq3CNYilVo3cqwfJcImugQC4idKi4Q==
28342852
dependencies:
28352853
"@opentripplanner/base-map" "6.0.0"
28362854
"@opentripplanner/building-blocks" "3.0.1"
2837-
"@opentripplanner/core-utils" "13.0.1"
2855+
"@opentripplanner/core-utils" "14.0.0"
28382856
"@opentripplanner/from-to-location-picker" "4.0.1"
28392857
flat "^5.0.2"
28402858

2841-
"@opentripplanner/[email protected].0":
2842-
version "4.0.0"
2843-
resolved "https://registry.yarnpkg.com/@opentripplanner/otp2-tile-overlay/-/otp2-tile-overlay-4.0.0.tgz#44aaa17b3933c350ac30d2c27a75189234647f17"
2844-
integrity sha512-YC8sXc2gatP5kv/2Vzg+Mr0uLByAXZKvCPpC6Y8QBTBYt4OeXCHiyenxpqwCEQFOTN3ejZoZzUY1VeREHBeJJg==
2859+
"@opentripplanner/[email protected].1":
2860+
version "4.0.1"
2861+
resolved "https://registry.yarnpkg.com/@opentripplanner/otp2-tile-overlay/-/otp2-tile-overlay-4.0.1.tgz#291226d97364d4c97db140aa529b6f57a0a9416e"
2862+
integrity sha512-U+/JUoGfl8VXfUe/lyf6w2wl2uN0aLw2QUHvuJ1msJVD8hOTneG+ouVRt6gZ+9Z8GnQOBbZmFVTz70Ej/LyVLQ==
28452863
dependencies:
2846-
"@opentripplanner/map-popup" "7.0.0"
2864+
"@opentripplanner/map-popup" "7.0.1"
28472865

28482866
"@opentripplanner/[email protected]":
28492867
version "5.0.0"
@@ -2891,14 +2909,14 @@
28912909
"@opentripplanner/base-map" "6.0.0"
28922910
"@opentripplanner/core-utils" "13.0.1"
28932911

2894-
"@opentripplanner/[email protected].0":
2895-
version "8.0.0"
2896-
resolved "https://registry.yarnpkg.com/@opentripplanner/stops-overlay/-/stops-overlay-8.0.0.tgz#7ab9448f70dc0cbdcd01049e786111370c85f740"
2897-
integrity sha512-R3InZIN7MxwYUQkWcOkuNjJXdPCutYuINfi3rguM0z0VloYw9ruZng7TX61Jm42Dd/xFXloxi+IRFHTbJ0+S7Q==
2912+
"@opentripplanner/[email protected].1":
2913+
version "8.0.1"
2914+
resolved "https://registry.yarnpkg.com/@opentripplanner/stops-overlay/-/stops-overlay-8.0.1.tgz#4bc26f831906fc7fdd8455fa2031c2e4260e795b"
2915+
integrity sha512-UtNNdoTROyZziuxTbdaceYSchDPwbqi/pznRIJFOOP9qH54QZe6cNxv5vOP3E52uqcAMk4Z1t9n7YS/eU7SFJg==
28982916
dependencies:
28992917
"@opentripplanner/base-map" "6.0.0"
29002918
"@opentripplanner/from-to-location-picker" "4.0.1"
2901-
"@opentripplanner/map-popup" "7.0.0"
2919+
"@opentripplanner/map-popup" "7.0.1"
29022920
flat "^5.0.2"
29032921

29042922
"@opentripplanner/[email protected]":
@@ -2971,15 +2989,15 @@
29712989
resolved "https://registry.yarnpkg.com/@opentripplanner/types/-/types-7.0.0.tgz#53738d408a4be2e59fa414b253aebf999a685550"
29722990
integrity sha512-0wY2bDIBVh1Ax8ebz7QMxBIJT23RYqb7A8xbHA0pDnqYAF9ReTnauCxnog3iWw/+yXdao3PuFDj5eBhiQ4b1zg==
29732991

2974-
"@opentripplanner/[email protected].0":
2975-
version "5.0.0"
2976-
resolved "https://registry.yarnpkg.com/@opentripplanner/vehicle-rental-overlay/-/vehicle-rental-overlay-5.0.0.tgz#6c5b7799fd1953a66756cc622e12ea5ec46789f0"
2977-
integrity sha512-Jf8kBXqlpUnLjxmaak5V10J+H3WGFVFP92c/TJlFD2LXnupDZoOw9NPLGgztZm57Y0HhLosQyzd7fwvLgbEPeA==
2992+
"@opentripplanner/[email protected].1":
2993+
version "5.0.1"
2994+
resolved "https://registry.yarnpkg.com/@opentripplanner/vehicle-rental-overlay/-/vehicle-rental-overlay-5.0.1.tgz#8d0a75f62d5f8991d0a30cee547cd43c738a9b24"
2995+
integrity sha512-5eI2BlMg7v7GLaY/BoTFEmNtjyAhXZrnq/VoIxhYQY/807haCzcyNQxztJSmpwGcAHqtEI0tBzPuq+4t7GkurA==
29782996
dependencies:
29792997
"@opentripplanner/base-map" "6.0.0"
2980-
"@opentripplanner/core-utils" "13.0.1"
2998+
"@opentripplanner/core-utils" "14.0.0"
29812999
"@opentripplanner/from-to-location-picker" "4.0.1"
2982-
"@opentripplanner/map-popup" "7.0.0"
3000+
"@opentripplanner/map-popup" "7.0.1"
29833001
"@styled-icons/fa-solid" "^10.34.0"
29843002
flat "^5.0.2"
29853003
lodash.memoize "^4.1.2"

0 commit comments

Comments
 (0)