From a38eb68c8fa7b5c49b15cff16f5f3401b66452ee Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Thu, 28 Dec 2023 15:58:13 -0500
Subject: [PATCH 01/17] feat(apiV2): Pass user's mobilityProfile (if present)
to plan queries.
---
lib/actions/apiV2.js | 2 ++
lib/components/user/types.ts | 1 +
2 files changed, 3 insertions(+)
diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js
index 044266497..ad6aea476 100644
--- a/lib/actions/apiV2.js
+++ b/lib/actions/apiV2.js
@@ -823,6 +823,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
return function (dispatch, getState) {
const state = getState()
const { config, currentQuery, modeSettingDefinitions } = state.otp
+ const { loggedInUser } = state.user
const persistenceMode = getPersistenceMode(config.persistence)
const activeItinerary =
getActiveItinerary(state) ||
@@ -889,6 +890,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
},
date,
from: currentQuery.from,
+ mobilityProfile: loggedInUser?.mobilityProfile?.mobilityMode,
modes: modes || activeModes,
modeSettings,
numItineraries: numItineraries || config?.modes?.numItineraries || 7,
diff --git a/lib/components/user/types.ts b/lib/components/user/types.ts
index f09a3abcf..0124a298c 100644
--- a/lib/components/user/types.ts
+++ b/lib/components/user/types.ts
@@ -25,6 +25,7 @@ export type VisionLimitation = typeof visionLimitations[number]
export interface MobilityProfile {
isMobilityLimited: boolean
mobilityDevices: string[]
+ mobilityMode: string
visionLimitation: VisionLimitation
}
From 49c0e67a89a810ec16a3206df10c45ecac793532 Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Mon, 29 Jan 2024 10:24:50 -0500
Subject: [PATCH 02/17] chore(deps): Add reference to OTP-UI branch for
mobility profile
---
package.json | 2 +-
yarn.lock | 20 +++++++++++++++++++-
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index f6b206467..d07c26464 100644
--- a/package.json
+++ b/package.json
@@ -40,7 +40,7 @@
"@bugsnag/plugin-react": "^7.17.0",
"@floating-ui/react": "^0.19.2",
"@opentripplanner/base-map": "^3.0.15",
- "@opentripplanner/core-utils": "^11.2.2",
+ "@opentripplanner/core-utils": "^11.2.3-mobility-profile",
"@opentripplanner/endpoints-overlay": "^2.0.11",
"@opentripplanner/from-to-location-picker": "^2.1.11",
"@opentripplanner/geocoder": "^2.0.0",
diff --git a/yarn.lock b/yarn.lock
index d2a9b317c..f4c2e12aa 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2492,7 +2492,7 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"
-"@opentripplanner/core-utils@^11.1.3", "@opentripplanner/core-utils@^11.2.2":
+"@opentripplanner/core-utils@^11.1.3":
version "11.2.2"
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.2.2.tgz#38b38d852f2f1cf45a1760b86b105dff103c1860"
integrity sha512-aByXh4GuSLqt34vgMFaBh8QnAZs7UoxwpJE8mSJzA8YU86jo6lLg+lLCM/XOzKzwpikRwIJllkUBYjALGlu+NA==
@@ -2510,6 +2510,24 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"
+"@opentripplanner/core-utils@^11.2.3-mobility-profile":
+ version "11.2.3-mobility-profile"
+ resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.2.3-mobility-profile.tgz#9fb9efa7261aca8462103d7560ba9aa731c6c202"
+ integrity sha512-JC+tmVBSU9O+q/3vhGdUuGiEmTJNNxF7fnhkpCYT4js4RqR2v0UbtF+sSDpUGEPS+4fScaGFoLCiAz7922mThQ==
+ dependencies:
+ "@conveyal/lonlat" "^1.4.1"
+ "@mapbox/polyline" "^1.1.0"
+ "@opentripplanner/geocoder" "^2.0.0"
+ "@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/endpoints-overlay@^2.0.11":
version "2.0.11"
resolved "https://registry.yarnpkg.com/@opentripplanner/endpoints-overlay/-/endpoints-overlay-2.0.11.tgz#b85a98ab5b94a056a3de7f143576d1ab6e420826"
From b3a6135cd7a01f64e16f723177849e20c0aa4d89 Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Wed, 10 Apr 2024 12:36:38 -0400
Subject: [PATCH 03/17] fix(actions/user): Replan with profile after fetching
user data.
---
lib/actions/user.js | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/lib/actions/user.js b/lib/actions/user.js
index 9ec2d9965..dd4b97549 100644
--- a/lib/actions/user.js
+++ b/lib/actions/user.js
@@ -244,7 +244,8 @@ function setUser(user, fetchTrips) {
return function (dispatch, getState) {
positionHomeAndWorkFirst(user)
// If mobility profile is enabled, set a default selection for "no mobility devices".
- if (getState().otp.config.mobilityProfile) {
+ const hasMobilityProfile = !!getState().otp.config.mobilityProfile
+ if (hasMobilityProfile) {
setAtLeastNoMobilityDevice(user)
}
dispatch(setCurrentUser(user))
@@ -261,6 +262,20 @@ function setUser(user, fetchTrips) {
if (!isBlank(preferredLocale)) {
dispatch(setLocale(preferredLocale))
}
+
+ // Also replan itinerary search for the current user profile.
+ if (hasMobilityProfile) {
+ // TODO: Refactor below.
+ // This prevents some kind of race condition whose origin I can't figure
+ // out. Unless this is called after redux catches up with routing to the '/'
+ // path, then the old path will be used and the screen won't change.
+ // Therefore, this timeout occurs so that the view of the homepage has time
+ // to render itself.
+ // FIXME: remove hack
+ setTimeout(() => {
+ dispatch(routingQuery())
+ }, 300)
+ }
}
}
From f0820683fc7265e07daf9d04c425f1807a45b774 Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Thu, 11 Apr 2024 17:28:52 -0400
Subject: [PATCH 04/17] fix(actions/user): Don't replan if within the account
screens.
---
lib/actions/user.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/actions/user.js b/lib/actions/user.js
index dd4b97549..0a1fef24c 100644
--- a/lib/actions/user.js
+++ b/lib/actions/user.js
@@ -264,7 +264,10 @@ function setUser(user, fetchTrips) {
}
// Also replan itinerary search for the current user profile.
- if (hasMobilityProfile) {
+ if (
+ hasMobilityProfile &&
+ !getState().router.location.pathname.startsWith('/account')
+ ) {
// TODO: Refactor below.
// This prevents some kind of race condition whose origin I can't figure
// out. Unless this is called after redux catches up with routing to the '/'
From 7354a9df15bf651122f2805f9b935e2881582286 Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Fri, 26 Apr 2024 17:52:57 -0400
Subject: [PATCH 05/17] refactor(MobilityPane): Use new Link component to
navigate to mobility profile.
---
.../user/mobility-profile/mobility-pane.tsx | 27 ++++++-------------
1 file changed, 8 insertions(+), 19 deletions(-)
diff --git a/lib/components/user/mobility-profile/mobility-pane.tsx b/lib/components/user/mobility-profile/mobility-pane.tsx
index a45ea8b85..4004d0617 100644
--- a/lib/components/user/mobility-profile/mobility-pane.tsx
+++ b/lib/components/user/mobility-profile/mobility-pane.tsx
@@ -1,24 +1,17 @@
-import { Button } from 'react-bootstrap'
-import { connect } from 'react-redux'
import { FormattedList, FormattedMessage } from 'react-intl'
import { FormikProps } from 'formik'
-import React, { useCallback } from 'react'
+import React from 'react'
-import * as uiActions from '../../../actions/ui'
import { EditedUser } from '../types'
import { NONE_SINGLETON } from '../../../util/user'
-
-interface Props extends FormikProps {
- routeTo: (url: string) => void
-}
+import Link from '../../util/link'
/**
* Renders a button to show the mobility profile settings.
*/
-const MobilityPane = ({ routeTo, values: userData }: Props): JSX.Element => {
- const handleClick = useCallback(() => {
- routeTo('/account/mobilityProfile/')
- }, [routeTo])
+const MobilityPane = ({
+ values: userData
+}: FormikProps): JSX.Element => {
const {
isMobilityLimited,
mobilityDevices = [],
@@ -54,15 +47,11 @@ const MobilityPane = ({ routeTo, values: userData }: Props): JSX.Element => {
id={`components.MobilityProfile.LimitationsPane.visionLimitations.${visionLimitation}`}
/>
-
+
)
}
-const mapDispatchToProps = {
- routeTo: uiActions.routeTo
-}
-
-export default connect(null, mapDispatchToProps)(MobilityPane)
+export default MobilityPane
From ceeea83f37505e5bcdad742ff29b5822e3afcfda Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Thu, 16 May 2024 09:19:07 -0400
Subject: [PATCH 06/17] fix(NavLoginButton): Make help link valid when running
locally
---
lib/components/user/nav-login-button.tsx | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/components/user/nav-login-button.tsx b/lib/components/user/nav-login-button.tsx
index 078b2eb34..c4dbf93f9 100644
--- a/lib/components/user/nav-login-button.tsx
+++ b/lib/components/user/nav-login-button.tsx
@@ -84,7 +84,13 @@ const NavLoginButton = ({
if (link.url.startsWith('http')) {
return (
-
+ element here,
+ // so that the link works even when running the app locally.
+ as="a"
+ href={link.url}
+ target="_blank"
+ >
Date: Fri, 26 Jul 2024 12:54:46 -0400
Subject: [PATCH 07/17] chore(deps): Downgrade some packages
---
package.json | 4 ++--
yarn.lock | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/package.json b/package.json
index 5e4fe9551..96b07a556 100644
--- a/package.json
+++ b/package.json
@@ -42,8 +42,8 @@
"@bugsnag/js": "^7.17.0",
"@bugsnag/plugin-react": "^7.17.0",
"@floating-ui/react": "^0.19.2",
- "@opentripplanner/base-map": "^3.2.0",
- "@opentripplanner/building-blocks": "^1.1.0",
+ "@opentripplanner/base-map": "^3.1.0",
+ "@opentripplanner/building-blocks": "^1.0.3",
"@opentripplanner/core-utils": "^11.2.3-mobility-profile",
"@opentripplanner/endpoints-overlay": "^2.1.1",
"@opentripplanner/from-to-location-picker": "^2.1.13",
diff --git a/yarn.lock b/yarn.lock
index 8bf6bffef..850a96130 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2383,7 +2383,7 @@
dependencies:
"@octokit/openapi-types" "^10.0.0"
-"@opentripplanner/base-map@^3.0.16", "@opentripplanner/base-map@^3.1.0", "@opentripplanner/base-map@^3.2.0":
+"@opentripplanner/base-map@^3.0.16", "@opentripplanner/base-map@^3.1.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/base-map/-/base-map-3.2.0.tgz#db4410319d9614077ec925d739165a998c4a2485"
integrity sha512-d/yTKEnXqrw9pXhSvCERT+wLFa077Xr4wEFu4pYB+WYoZFflNxuTuAXXjm268HS/d0kjNndkjSMkxaKk6AjsvA==
@@ -2393,7 +2393,7 @@
maplibre-gl "^2.1.9"
react-map-gl "^7.0.15"
-"@opentripplanner/building-blocks@^1.1.0":
+"@opentripplanner/building-blocks@^1.0.3":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-1.1.0.tgz#ef9fe862ce0a3e92c9a6c2c2db749a9a02deebd5"
integrity sha512-nx7pU1zIZzJcSkCFYyZ7gt+jd0gXj7bjx8rXn1msgF5uLWmtN/70dsmYNEApeA7haC076KOO3B/Jh44YfXG95g==
From fdd9c7a0ed127fd1cbf195617b914724067f8e9a Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Mon, 29 Jul 2024 08:45:07 -0400
Subject: [PATCH 08/17] chore(deps): Update core-utils to
11.4.2-mobility-profile
---
package.json | 6 +++---
yarn.lock | 33 +++++++++++----------------------
2 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/package.json b/package.json
index 96b07a556..5018da665 100644
--- a/package.json
+++ b/package.json
@@ -42,9 +42,9 @@
"@bugsnag/js": "^7.17.0",
"@bugsnag/plugin-react": "^7.17.0",
"@floating-ui/react": "^0.19.2",
- "@opentripplanner/base-map": "^3.1.0",
- "@opentripplanner/building-blocks": "^1.0.3",
- "@opentripplanner/core-utils": "^11.2.3-mobility-profile",
+ "@opentripplanner/base-map": "^3.2.0",
+ "@opentripplanner/building-blocks": "^1.1.0",
+ "@opentripplanner/core-utils": "11.4.2-mobility-profile",
"@opentripplanner/endpoints-overlay": "^2.1.1",
"@opentripplanner/from-to-location-picker": "^2.1.13",
"@opentripplanner/geocoder": "^3.0.1",
diff --git a/yarn.lock b/yarn.lock
index 850a96130..55bca20a1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2383,7 +2383,7 @@
dependencies:
"@octokit/openapi-types" "^10.0.0"
-"@opentripplanner/base-map@^3.0.16", "@opentripplanner/base-map@^3.1.0":
+"@opentripplanner/base-map@^3.0.16", "@opentripplanner/base-map@^3.1.0", "@opentripplanner/base-map@^3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/base-map/-/base-map-3.2.0.tgz#db4410319d9614077ec925d739165a998c4a2485"
integrity sha512-d/yTKEnXqrw9pXhSvCERT+wLFa077Xr4wEFu4pYB+WYoZFflNxuTuAXXjm268HS/d0kjNndkjSMkxaKk6AjsvA==
@@ -2393,15 +2393,15 @@
maplibre-gl "^2.1.9"
react-map-gl "^7.0.15"
-"@opentripplanner/building-blocks@^1.0.3":
+"@opentripplanner/building-blocks@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-1.1.0.tgz#ef9fe862ce0a3e92c9a6c2c2db749a9a02deebd5"
integrity sha512-nx7pU1zIZzJcSkCFYyZ7gt+jd0gXj7bjx8rXn1msgF5uLWmtN/70dsmYNEApeA7haC076KOO3B/Jh44YfXG95g==
-"@opentripplanner/core-utils@^11.2.3", "@opentripplanner/core-utils@^11.4.0":
- version "11.4.2"
- resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.2.tgz#cc6034fb80ccda44e50f7f0a1e80a7bad8387f84"
- integrity sha512-EVYVN73Cgf9IC+uya49843MFJnVkmv0nHAjsQwmPGSx/w5fY49X4fSpDprL7Bn+MTzk58U2udDsn6OzKmV0JdA==
+"@opentripplanner/core-utils@11.4.2-mobility-profile":
+ version "11.4.2-mobility-profile"
+ resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.2-mobility-profile.tgz#aaee67e54c705bf533fcd143c3e8ed61a7f1f1e3"
+ integrity sha512-OJ0upp86oDpwplVlEFdakLgYNspwTfn03bzYL9vGKl+YRZR6EFcEgHYng/KJEqCiYA06Uz/xZBsc68Rx1BQiNQ==
dependencies:
"@conveyal/lonlat" "^1.4.1"
"@mapbox/polyline" "^1.1.0"
@@ -2416,14 +2416,14 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"
-"@opentripplanner/core-utils@^11.2.3-mobility-profile":
- version "11.2.3-mobility-profile"
- resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.2.3-mobility-profile.tgz#9fb9efa7261aca8462103d7560ba9aa731c6c202"
- integrity sha512-JC+tmVBSU9O+q/3vhGdUuGiEmTJNNxF7fnhkpCYT4js4RqR2v0UbtF+sSDpUGEPS+4fScaGFoLCiAz7922mThQ==
+"@opentripplanner/core-utils@^11.2.3", "@opentripplanner/core-utils@^11.4.0":
+ version "11.4.2"
+ resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.2.tgz#cc6034fb80ccda44e50f7f0a1e80a7bad8387f84"
+ integrity sha512-EVYVN73Cgf9IC+uya49843MFJnVkmv0nHAjsQwmPGSx/w5fY49X4fSpDprL7Bn+MTzk58U2udDsn6OzKmV0JdA==
dependencies:
"@conveyal/lonlat" "^1.4.1"
"@mapbox/polyline" "^1.1.0"
- "@opentripplanner/geocoder" "^2.0.0"
+ "@opentripplanner/geocoder" "^3.0.0"
"@styled-icons/foundation" "^10.34.0"
"@turf/along" "^6.0.1"
chroma-js "^2.4.2"
@@ -2454,17 +2454,6 @@
"@opentripplanner/location-icon" "^1.4.1"
flat "^5.0.2"
-"@opentripplanner/geocoder@^2.0.0":
- version "2.2.0"
- resolved "https://registry.yarnpkg.com/@opentripplanner/geocoder/-/geocoder-2.2.0.tgz#071f91664e898b06705c781fddd4f75dfcb3cc3f"
- integrity sha512-V41WOCIpvwLRHEchBg3vRzGOOxoI+SdxczLGgLGPJ/Q/XiqaTqUgsK8WUv+hAUAGYNxI7jZbx7zdC2pXCH0m4w==
- dependencies:
- "@conveyal/geocoder-arcgis-geojson" "^0.0.3"
- "@conveyal/lonlat" "^1.4.1"
- "@leeoniya/ufuzzy" "^1.0.14"
- isomorphic-mapzen-search "^1.6.1"
- lodash.memoize "^4.1.2"
-
"@opentripplanner/geocoder@^3.0.0", "@opentripplanner/geocoder@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@opentripplanner/geocoder/-/geocoder-3.0.1.tgz#834960bc52f515e1223346a8002fb847674d33bc"
From 26fde5602482fbb83f93f73375f6fa8c901e202d Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Wed, 14 Aug 2024 10:38:16 -0400
Subject: [PATCH 09/17] chore(deps): Update core-utils to
1.4.3-mobility-profile
---
package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 5018da665..95b9440ca 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,7 @@
"@floating-ui/react": "^0.19.2",
"@opentripplanner/base-map": "^3.2.0",
"@opentripplanner/building-blocks": "^1.1.0",
- "@opentripplanner/core-utils": "11.4.2-mobility-profile",
+ "@opentripplanner/core-utils": "11.4.3-mobility-profile",
"@opentripplanner/endpoints-overlay": "^2.1.1",
"@opentripplanner/from-to-location-picker": "^2.1.13",
"@opentripplanner/geocoder": "^3.0.1",
diff --git a/yarn.lock b/yarn.lock
index 55bca20a1..30f3bed50 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2398,10 +2398,10 @@
resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-1.1.0.tgz#ef9fe862ce0a3e92c9a6c2c2db749a9a02deebd5"
integrity sha512-nx7pU1zIZzJcSkCFYyZ7gt+jd0gXj7bjx8rXn1msgF5uLWmtN/70dsmYNEApeA7haC076KOO3B/Jh44YfXG95g==
-"@opentripplanner/core-utils@11.4.2-mobility-profile":
- version "11.4.2-mobility-profile"
- resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.2-mobility-profile.tgz#aaee67e54c705bf533fcd143c3e8ed61a7f1f1e3"
- integrity sha512-OJ0upp86oDpwplVlEFdakLgYNspwTfn03bzYL9vGKl+YRZR6EFcEgHYng/KJEqCiYA06Uz/xZBsc68Rx1BQiNQ==
+"@opentripplanner/core-utils@11.4.3-mobility-profile":
+ version "11.4.3-mobility-profile"
+ resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.3-mobility-profile.tgz#b1d5675c6c1f85a3454234b720059efa03ad6ed2"
+ integrity sha512-+6IjMwXCUZHNmTLnZZ+u23Awtm2v4DcRVmkyxy8m8Dd5GxB9tMxXBhvvwxuzD2KV6Wf4tk4j+HqiAf8gW0Dfbg==
dependencies:
"@conveyal/lonlat" "^1.4.1"
"@mapbox/polyline" "^1.1.0"
From 4ff7e504ee7ac742f01bd43fa65530c8f25bc3db Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Wed, 25 Sep 2024 10:54:32 -0400
Subject: [PATCH 10/17] refactor(apiV2): Pass mobility profile param to OTP
based on config.
---
example-config.yml | 3 +++
lib/actions/apiV2.js | 7 +++++--
package.json | 2 +-
yarn.lock | 10 +++++-----
4 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/example-config.yml b/example-config.yml
index c24e1265d..b8470663a 100644
--- a/example-config.yml
+++ b/example-config.yml
@@ -15,6 +15,9 @@ api:
# If your OTP server is at a path other than "/otp" (usually due to a proxy)
# Then you can set the OPTIONAL property basePath. The default is "/otp"
basePath: /otp
+ ### Custom GraphQL plan query to override the default one (it still needs to include expected variables).
+ # planQuery: |
+ # query Plan()
port: 8080
v2: true
diff --git a/lib/actions/apiV2.js b/lib/actions/apiV2.js
index 2a38c1061..13e7407b7 100644
--- a/lib/actions/apiV2.js
+++ b/lib/actions/apiV2.js
@@ -924,6 +924,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
return function (dispatch, getState) {
const state = getState()
const { config, currentQuery, modeSettingDefinitions } = state.otp
+ const { planQuery } = config.api
const { loggedInUser } = state.user
const persistenceMode = getPersistenceMode(config.persistence)
const activeItinerary =
@@ -999,7 +1000,6 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
},
date,
from: currentQuery.from,
- mobilityProfile: loggedInUser?.mobilityProfile?.mobilityMode,
modes: modes || activeModes,
modeSettings,
time,
@@ -1009,6 +1009,9 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
...currentQuery,
numItineraries: numItineraries || getDefaultNumItineraries(config)
}
+ if (config.mobilityProfile) {
+ baseQuery.mobilityProfile = loggedInUser?.mobilityProfile?.mobilityMode
+ }
// Generate combinations if the modes for query are not specified in the query
// FIXME: BICYCLE_RENT does not appear in this list unless TRANSIT is also enabled.
// This is likely due to the fact that BICYCLE_RENT is treated as a transit submode.
@@ -1032,7 +1035,7 @@ export function routingQuery(searchId = null, updateSearchInReducer) {
const query = generateOtp2Query(combo)
dispatch(
createGraphQLQueryAction(
- query.query,
+ planQuery || query.query,
query.variables,
(response) => {
const dispatchedRoutingResponse = routingResponse(response)
diff --git a/package.json b/package.json
index a94fba861..596e5e849 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,7 @@
"@floating-ui/react": "^0.19.2",
"@opentripplanner/base-map": "^3.2.2",
"@opentripplanner/building-blocks": "^1.2.3",
- "@opentripplanner/core-utils": "11.4.3-mobility-profile",
+ "@opentripplanner/core-utils": "11.4.4",
"@opentripplanner/endpoints-overlay": "^2.1.4",
"@opentripplanner/from-to-location-picker": "^2.1.14",
"@opentripplanner/geocoder": "^3.0.2",
diff --git a/yarn.lock b/yarn.lock
index 86208d8b8..ec7c4aab4 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2408,14 +2408,14 @@
resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-1.2.3.tgz#404e8f9038867d66d55f51adf8855b1326c51ed5"
integrity sha512-I0AxiZrTZu+e7+av4u0tHW2ijqpxH0AkLHrhf75BHf1Ep2FOGxaul/v+8UT18mNYiM5eHNstOX3XiXaDjtCUaw==
-"@opentripplanner/core-utils@11.4.3-mobility-profile":
- version "11.4.3-mobility-profile"
- resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.3-mobility-profile.tgz#b1d5675c6c1f85a3454234b720059efa03ad6ed2"
- integrity sha512-+6IjMwXCUZHNmTLnZZ+u23Awtm2v4DcRVmkyxy8m8Dd5GxB9tMxXBhvvwxuzD2KV6Wf4tk4j+HqiAf8gW0Dfbg==
+"@opentripplanner/core-utils@11.4.4":
+ version "11.4.4"
+ resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-11.4.4.tgz#11c1be91a5e90afda4fc265831c761d3e044d933"
+ integrity sha512-WKhOuG7Q+Yxdm+P5MPmJyXndx+JUtGn44GTeilOnUqDdO8lTLTvqqt0hYeEWjA77jWP0u8tG7fAAsft8IZn2cg==
dependencies:
"@conveyal/lonlat" "^1.4.1"
"@mapbox/polyline" "^1.1.0"
- "@opentripplanner/geocoder" "^3.0.0"
+ "@opentripplanner/geocoder" "^3.0.2"
"@styled-icons/foundation" "^10.34.0"
"@turf/along" "^6.0.1"
chroma-js "^2.4.2"
From ad9ce17e1ba97fbd3377eb2fd6aaa7daeea55423 Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Fri, 11 Oct 2024 16:54:17 -0400
Subject: [PATCH 11/17] chore(deps): Update core-utils to 12.0.1.
---
package.json | 2 +-
yarn.lock | 26 ++++++++++++++++++++++----
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 7b69da5c0..e7ed5b415 100644
--- a/package.json
+++ b/package.json
@@ -44,7 +44,7 @@
"@floating-ui/react": "^0.19.2",
"@opentripplanner/base-map": "4.0.0",
"@opentripplanner/building-blocks": "2.0.0",
- "@opentripplanner/core-utils": "12.0.0",
+ "@opentripplanner/core-utils": "12.0.1",
"@opentripplanner/endpoints-overlay": "3.0.0",
"@opentripplanner/from-to-location-picker": "3.0.0",
"@opentripplanner/geocoder": "^3.0.2",
diff --git a/yarn.lock b/yarn.lock
index 1a65ef7a9..3385bc918 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2413,10 +2413,10 @@
resolved "https://registry.yarnpkg.com/@opentripplanner/building-blocks/-/building-blocks-1.2.3.tgz#404e8f9038867d66d55f51adf8855b1326c51ed5"
integrity sha512-I0AxiZrTZu+e7+av4u0tHW2ijqpxH0AkLHrhf75BHf1Ep2FOGxaul/v+8UT18mNYiM5eHNstOX3XiXaDjtCUaw==
-"@opentripplanner/core-utils@12.0.0", "@opentripplanner/core-utils@^12.0.0":
- version "12.0.0"
- resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-12.0.0.tgz#cc40af92620b207f4dce817d08f99def0cdaea7a"
- integrity sha512-udLF8XU+k7gxZ+yyyw7ASz6/4D540zYIv8a9GbUL61TF8HmgGhcMk3XOgBnm5jdOukuaNNpOFE4J3oJc5QsSBQ==
+"@opentripplanner/core-utils@12.0.1":
+ version "12.0.1"
+ resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-12.0.1.tgz#2bafb78133393213b4943c76fec5d46436c0fb6d"
+ integrity sha512-QUTxEcpiOnbqaoiu6RQngTLlQHjSHO4PCMJqR9IRiaei08FnlTx2jgpvIaRla6u7tRNr12YCzptc37+a10ryww==
dependencies:
"@conveyal/lonlat" "^1.4.1"
"@mapbox/polyline" "^1.1.0"
@@ -2449,6 +2449,24 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"
+"@opentripplanner/core-utils@^12.0.0":
+ version "12.0.0"
+ resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-12.0.0.tgz#cc40af92620b207f4dce817d08f99def0cdaea7a"
+ integrity sha512-udLF8XU+k7gxZ+yyyw7ASz6/4D540zYIv8a9GbUL61TF8HmgGhcMk3XOgBnm5jdOukuaNNpOFE4J3oJc5QsSBQ==
+ dependencies:
+ "@conveyal/lonlat" "^1.4.1"
+ "@mapbox/polyline" "^1.1.0"
+ "@opentripplanner/geocoder" "^3.0.2"
+ "@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/endpoints-overlay@3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@opentripplanner/endpoints-overlay/-/endpoints-overlay-3.0.0.tgz#17bb943f5bf2b8571cb808b12b5a2185fd18196a"
From 788f1cbe3ebb4e0338af3eb3bebf5629fc0a81d0 Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Wed, 16 Oct 2024 16:57:53 -0400
Subject: [PATCH 12/17] chore(deps): Add webpack raw-loader
---
package.json | 1 +
yarn.lock | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/package.json b/package.json
index 77e39c1eb..707a514ca 100644
--- a/package.json
+++ b/package.json
@@ -195,6 +195,7 @@
"pinst": "^2.1.6",
"prettier": "^2.3.2",
"puppeteer": "^10.2.0",
+ "raw-loader": "^4.0.2",
"react-refresh": "^0.10.0",
"react-scripts": "^4.0.3",
"redux-mock-store": "^1.5.3",
diff --git a/yarn.lock b/yarn.lock
index d4f948996..fc46f8d41 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -15166,6 +15166,14 @@ raw-body@2.5.2:
iconv-lite "0.4.24"
unpipe "1.0.0"
+raw-loader@^4.0.2:
+ version "4.0.2"
+ resolved "https://registry.yarnpkg.com/raw-loader/-/raw-loader-4.0.2.tgz#1aac6b7d1ad1501e66efdac1522c73e59a584eb6"
+ integrity sha512-ZnScIV3ag9A4wPX/ZayxL/jZH+euYb6FcUinPcgiQW0+UBtEv0O6Q3lGd3cqJ+GHH+rksEv3Pj99oxJ3u3VIKA==
+ dependencies:
+ loader-utils "^2.0.0"
+ schema-utils "^3.0.0"
+
rc@^1.0.1, rc@^1.1.6, rc@^1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
From 9d606badea84376bc41ce958ca23b72ec800b81d Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Wed, 16 Oct 2024 17:00:34 -0400
Subject: [PATCH 13/17] build(craco): Include local graphql file in build.
---
craco.config.js | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/craco.config.js b/craco.config.js
index 283dc3350..f156dcfe1 100644
--- a/craco.config.js
+++ b/craco.config.js
@@ -48,6 +48,8 @@ module.exports = {
findBackwardsCompatibleEnvVar('JS_CONFIG')
backwardsCompatibleEnv.HTML_FILE =
findBackwardsCompatibleEnvVar('HTML_FILE')
+ backwardsCompatibleEnv.PLAN_QUERY_RESOURCE_URI =
+ findBackwardsCompatibleEnvVar('PLAN_QUERY_RESOURCE_URI')
backwardsCompatibleEnv.CUSTOM_CSS =
findBackwardsCompatibleEnvVar('CUSTOM_CSS')
@@ -65,6 +67,13 @@ module.exports = {
}
addBeforeLoader(webpackConfig, loaderByName('file-loader'), yamlLoader)
+ // Support YAML
+ const graphqlLoader = {
+ loader: ['raw-loader'],
+ test: /\.graphql$/
+ }
+ addBeforeLoader(webpackConfig, loaderByName('file-loader'), graphqlLoader)
+
// Support webfonts (for font awesome)
const webfontLoader = {
loader: ['url-loader'],
@@ -82,7 +91,7 @@ module.exports = {
loader.exclude = /node_modules/
})
- // Gather the CSS, HTML, YAML, and JS override files.
+ // Gather the CSS, HTML, YAML, GraphQL, and JS override files.
const CUSTOM_CSS =
(process.env && process.env.CUSTOM_CSS) ||
backwardsCompatibleEnv.CUSTOM_CSS ||
@@ -91,6 +100,22 @@ module.exports = {
(process.env && process.env.HTML_FILE) ||
backwardsCompatibleEnv.HTML_FILE ||
'lib/index.tpl.html'
+ // resolve the custom GraphQL file. If it is present, copy the file to a
+ // temporary folder within this project so that it can be bundled and loaded at runtime.
+ let customPlanGraphQLFile = './planQuery.graphql'
+ const PLAN_QUERY_RESOURCE_URI =
+ (process.env && process.env.PLAN_QUERY_RESOURCE_URI) ||
+ backwardsCompatibleEnv.PLAN_QUERY_RESOURCE_URI ||
+ 'node_modules/@opentripplanner/core-utils/src/planQuery.graphql'
+ if (PLAN_QUERY_RESOURCE_URI) {
+ const splitPath = PLAN_QUERY_RESOURCE_URI.split(path.sep)
+ customPlanGraphQLFile = `../tmp/${splitPath[splitPath.length - 1]}`
+ // copy location is relative to root, while js file for app is relative to lib
+ fs.copySync(
+ PLAN_QUERY_RESOURCE_URI,
+ `./tmp/${splitPath[splitPath.length - 1]}`
+ )
+ }
const YAML_CONFIG =
(process.env && process.env.YAML_CONFIG) ||
backwardsCompatibleEnv.YAML_CONFIG ||
@@ -143,6 +168,7 @@ module.exports = {
new webpack.DefinePlugin({
CSS: JSON.stringify(CUSTOM_CSS),
JS_CONFIG: JSON.stringify(customJsFile),
+ PLAN_QUERY_RESOURCE: JSON.stringify(customPlanGraphQLFile),
// Optionally override the default config files with some other
// files.
YAML_CONFIG: JSON.stringify(YAML_CONFIG)
From 1f44061c26b07fc9a2dd263744aaa7fa77db7947 Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Wed, 16 Oct 2024 17:19:45 -0400
Subject: [PATCH 14/17] feat(main): Use plan GraphQL template from config
---
lib/main.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/main.js b/lib/main.js
index 780584e27..33e36c552 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -34,6 +34,18 @@ import(CSS)
// eslint-disable-next-line no-undef
const otpConfig = require(YAML_CONFIG)
+// Loads a JavaScript file which is set in the webpack section of the craco.config.js file.
+// This setting is defined from a custom environment setting passed into webpack or
+// defaults to ./config.js
+// defined in webpack config:
+// The JS_CONFIG variable is passed to this file by webpack's `DefinePlugin` that replaces the variable
+// with its content at compile time (like C's `#define` preprocessor directive).
+// eslint-disable-next-line no-undef
+const jsConfig = require(JS_CONFIG).configure(otpConfig)
+
+// Plug the plan query into the config (if available)
+otpConfig.api.planQuery = jsConfig.planQuery
+
const history = createHashHistory()
const middleware = [
From c403cf051f48bbc6cac0026d3c03a09a66e46a4e Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Thu, 17 Oct 2024 13:30:28 -0400
Subject: [PATCH 15/17] chore(example-config): Remove custom plan query
---
example-config.yml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/example-config.yml b/example-config.yml
index 6ad279aae..79a242954 100644
--- a/example-config.yml
+++ b/example-config.yml
@@ -15,9 +15,6 @@ api:
# If your OTP server is at a path other than "/otp" (usually due to a proxy)
# Then you can set the OPTIONAL property basePath. The default is "/otp"
basePath: /otp
- ### Custom GraphQL plan query to override the default one (it still needs to include expected variables).
- # planQuery: |
- # query Plan()
port: 8080
v2: true
From 37260077aab004d45b0ced9dbef13c10226dbb8c Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Fri, 1 Nov 2024 08:09:30 -0400
Subject: [PATCH 16/17] chore(craco): Update comment for graphql files
---
craco.config.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/craco.config.js b/craco.config.js
index f156dcfe1..074f3309e 100644
--- a/craco.config.js
+++ b/craco.config.js
@@ -67,7 +67,7 @@ module.exports = {
}
addBeforeLoader(webpackConfig, loaderByName('file-loader'), yamlLoader)
- // Support YAML
+ // Support import of raw GraphQL files
const graphqlLoader = {
loader: ['raw-loader'],
test: /\.graphql$/
From e60f6942111a56e4be995cdb0349a5522f30d94a Mon Sep 17 00:00:00 2001
From: binh-dam-ibigroup <56846598+binh-dam-ibigroup@users.noreply.github.com>
Date: Fri, 1 Nov 2024 08:10:27 -0400
Subject: [PATCH 17/17] refactor(main): Update comment regarding custom graphql
query.
---
lib/main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/main.js b/lib/main.js
index 33e36c552..03aeeb322 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -43,7 +43,7 @@ const otpConfig = require(YAML_CONFIG)
// eslint-disable-next-line no-undef
const jsConfig = require(JS_CONFIG).configure(otpConfig)
-// Plug the plan query into the config (if available)
+// If defined, plug custom plan query into the redux config, so it is available from actions.
otpConfig.api.planQuery = jsConfig.planQuery
const history = createHashHistory()