Skip to content

Commit bbfec9f

Browse files
Merge pull request #402 from opentripplanner/dev
Release (2021-07)
2 parents 3d4386f + fb581ac commit bbfec9f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2750
-568
lines changed

Diff for: .github/workflows/node-ci.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,12 @@ jobs:
2525
run: yarn lint
2626
- name: Lint docs
2727
run: yarn lint-docs
28-
- name: Run tests with coverage
29-
run: yarn cover
28+
- name: Run tests
29+
run: yarn jest
3030
- name: Build example project
3131
run: yarn build
3232

3333
# at this point, the build is successful
34-
- name: Codecov
35-
uses: codecov/[email protected]
36-
continue-on-error: true
3734
- name: Semantic Release
3835
env:
3936
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: .husky/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

Diff for: .husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

Diff for: __tests__/actions/__snapshots__/api.js.snap

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
exports[`actions > api routingQuery should gracefully handle bad response 1`] = `
44
Array [
5+
Array [
6+
[Function],
7+
],
58
Array [
69
Object {
710
"payload": Object {
@@ -16,6 +19,9 @@ Array [
1619
Array [
1720
[Function],
1821
],
22+
Array [
23+
[Function],
24+
],
1925
Array [
2026
Object {
2127
"payload": Object {
@@ -35,6 +41,9 @@ Array [
3541

3642
exports[`actions > api routingQuery should make a query to OTP 1`] = `
3743
Array [
44+
Array [
45+
[Function],
46+
],
3847
Array [
3948
Object {
4049
"payload": Object {
@@ -52,4 +61,4 @@ Array [
5261
]
5362
`;
5463

55-
exports[`actions > api routingQuery should make a query to OTP: OTP Query Path 1`] = `"/api/plan?fromPlace=Origin%20%2812%2C34%29%3A%3A12%2C34&toPlace=Destination%20%2834%2C12%29%3A%3A34%2C12&mode=WALK%2CTRANSIT"`;
64+
exports[`actions > api routingQuery should make a query to OTP: OTP Query Path 1`] = `"/api/plan?fromPlace=Origin%20%2812%2C34%29%3A%3A12%2C34&toPlace=Destination%20%2834%2C12%29%3A%3A34%2C12&mode=WALK%2CTRANSIT&ignoreRealtimeUpdates=false"`;

Diff for: __tests__/util/itinerary.js

+73-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
/* globals describe, expect, it */
22

3-
import { itineraryCanBeMonitored } from '../../lib/util/itinerary'
3+
import {
4+
getItineraryDefaultMonitoredDays,
5+
itineraryCanBeMonitored
6+
} from '../../lib/util/itinerary'
7+
import { WEEKDAYS, WEEKEND_DAYS } from '../../lib/util/monitored-trip'
8+
9+
const walkLeg = {
10+
mode: 'WALK'
11+
}
412

513
describe('util > itinerary', () => {
614
describe('itineraryCanBeMonitored', () => {
@@ -20,9 +28,6 @@ describe('util > itinerary', () => {
2028
mode: 'MICROMOBILITY_RENT',
2129
rentedVehicle: true
2230
}
23-
const walkLeg = {
24-
mode: 'WALK'
25-
}
2631
const rideHailLeg = {
2732
mode: 'CAR_HAIL',
2833
hailedCar: true
@@ -80,4 +85,68 @@ describe('util > itinerary', () => {
8085
})
8186
})
8287
})
88+
describe('getItineraryDefaultMonitoredDays', () => {
89+
const transitLegWeekday = {
90+
mode: 'BUS',
91+
serviceDate: '20210609', // Wednesday
92+
transitLeg: true
93+
}
94+
const transitLegSaturday = {
95+
mode: 'BUS',
96+
serviceDate: '20210612', // Saturday
97+
transitLeg: true
98+
}
99+
const transitLegSunday = {
100+
mode: 'BUS',
101+
serviceDate: '20210613', // Sunday
102+
transitLeg: true
103+
}
104+
105+
const testCases = [{
106+
expected: WEEKDAYS,
107+
itinerary: {
108+
legs: [walkLeg, transitLegWeekday]
109+
},
110+
title: 'should be [\'monday\' thru \'friday\'] for an itinerary starting on a weekday.'
111+
}, {
112+
expected: WEEKEND_DAYS,
113+
itinerary: {
114+
legs: [walkLeg, transitLegSaturday]
115+
},
116+
title: 'should be [\'saturday\', \'sunday\'] for an itinerary starting on a Saturday.'
117+
}, {
118+
expected: WEEKEND_DAYS,
119+
itinerary: {
120+
legs: [walkLeg, transitLegSunday]
121+
},
122+
title: 'should be [\'saturday\', \'sunday\'] for an itinerary starting on a Sunday.'
123+
}, {
124+
expected: WEEKDAYS,
125+
itinerary: {
126+
legs: [walkLeg],
127+
startTime: 1623341891000 // Thursday 2021-06-10 12:18 pm EDT
128+
},
129+
title: 'should be [\'monday\' thru \'friday\'] for an itinerary without transit starting on a weekday (fallback case).'
130+
}, {
131+
expected: WEEKEND_DAYS,
132+
itinerary: {
133+
legs: [walkLeg],
134+
startTime: 1623514691000 // Saturday 2021-06-12 12:18 pm EDT
135+
},
136+
title: 'should be [\'saturday\', \'sunday\'] for an itinerary without transit starting on a Saturday (fallback case).'
137+
}, {
138+
expected: WEEKEND_DAYS,
139+
itinerary: {
140+
legs: [walkLeg],
141+
startTime: 1623601091000 // Sunday 2021-06-13 12:18 pm EDT
142+
},
143+
title: 'should be [\'saturday\', \'sunday\'] for an itinerary without transit starting on a Sunday (fallback case).'
144+
}]
145+
146+
testCases.forEach(({ expected, itinerary, title }) => {
147+
it(title, () => {
148+
expect(getItineraryDefaultMonitoredDays(itinerary)).toBe(expected)
149+
})
150+
})
151+
})
83152
})

Diff for: __tests__/util/state.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@ describe('util > state', () => {
1515
const testCases = [{
1616
expected: false,
1717
input: {
18-
currentQuery: {
19-
from: fakeFromLocation
18+
otp: {
19+
currentQuery: {
20+
from: fakeFromLocation
21+
}
2022
}
2123
},
2224
title: 'should not be valid with only from location'
2325
}, {
2426
expected: true,
2527
input: {
26-
currentQuery: {
27-
from: fakeFromLocation,
28-
to: fakeToLocation
28+
otp: {
29+
currentQuery: {
30+
from: fakeFromLocation,
31+
to: fakeToLocation
32+
}
2933
}
3034
},
3135
title: 'should be valid with from and to locations'

Diff for: example-config.yml

+51
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@ map:
6969
- name: Stamen Toner Lite
7070
url: http://tile.stamen.com/toner-lite/{z}/{x}/{y}.png
7171
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.'
72+
### Optional transitive.js (route rendering) properties:
73+
### - labeledModes: an array of OTP modes for which the route label should be
74+
### rendered on the map. Example of OTP modes: BUS, RAIL, ...
75+
### The label is rendered under the condition that a route_short_name is provided
76+
### in the GTFS feed for those routes, or that a getTransitiveRouteLabel function is defined
77+
### in the ComponentContext (see example.js for more).
78+
### - styles.labels,
79+
### styles.segment_labels: styles attributes recognized by transitive.js.
80+
### For examples of applicable style attributes, see
81+
### https://github.com/conveyal/transitive.js/blob/master/stories/Transitive.stories.js#L47.
82+
# transitive:
83+
# labeledModes:
84+
# - BUS
85+
# - RAIL
86+
# styles:
87+
# labels:
88+
# font-size: 14px
89+
# font-family: Hind, sans-serif
90+
# segment_labels:
91+
# border-color: "#FFFFFF"
92+
# border-radius: 6
93+
# border-width: 2
94+
# color: "#FFE0D0"
95+
# font-family: Hind, sans-serif
96+
# font-size: 18px
7297

7398
# it is possible to leave out a geocoder config entirely. In that case only
7499
# GPS coordinates will be used when finding the origin/destination.
@@ -135,6 +160,29 @@ modes:
135160
label: Own Bike
136161
iconWidth: 18
137162

163+
# # The following modules require the datastoreUrl and trinetReDirect properties
164+
# # to be set. Note: Most of these components are currently only configured for
165+
# # TriMet.
166+
# datastoreUrl: https://localhost:9000
167+
# trinetReDirect: https://localhost:9001
168+
# modules:
169+
# # Provides UI elements for Call Takers to record calls/trip queries.
170+
# - id: call
171+
# # Provides UI elements for planning field trips on transit vehicles.
172+
# - id: ft
173+
# # Provides a form for constructing PDF documents for mailing to customers.
174+
# - id: mailables
175+
# items:
176+
# - name: Rte 1 Schedule (1-Vermont)
177+
# largePrint: true
178+
# # The below settings allow for customizing the PDF letter.
179+
# horizontalMargin: 108
180+
# verticalMargin: 120
181+
# introduction: 'Thank you for calling us to request information. We have enclosed for you the following item(s):'
182+
# conclusion: Thank you for your patronage!
183+
# footer: Transit Agency • 555-555-RIDE
184+
# # NOTE: headerGraphic requires a valid URL to a png file.
185+
# headerGraphic: 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/98/Trimet_logo.svg/1280px-Trimet_logo.svg.png'
138186

139187
routingTypes:
140188
- key: ITINERARY
@@ -145,6 +193,9 @@ itinerary:
145193
# Show fares for each transit leg (false if omitted).
146194
# (Requires using LineItinerary.)
147195
showRouteFares: false
196+
# Whether the plan first/previous/next/last buttons should be shown along with
197+
# plan trip itineraries.
198+
showPlanFirstLastButtons: false
148199

149200
# The transitOperators key is a list of transit operators that can be used to
150201
# order transit agencies when sorting by route. Also, this can optionally

Diff for: example.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ import {
1616
BatchResultsScreen,
1717
BatchRoutingPanel,
1818
BatchSearchScreen,
19+
CallHistoryWindow,
1920
CallTakerControls,
2021
CallTakerPanel,
21-
CallTakerWindows,
2222
DefaultItinerary,
2323
DefaultMainPanel,
2424
FieldTripWindows,
25+
MailablesWindow,
2526
MobileResultsScreen,
2627
MobileSearchScreen,
2728
ResponsiveWebapp,
@@ -72,6 +73,7 @@ const TermsOfStorage = () => (
7273
// define some application-wide components that should be used in
7374
// various places. The following components can be provided here:
7475
// - defaultMobileTitle (required)
76+
// - getTransitiveRouteLabel (optional, with signature itineraryLeg => string)
7577
// - ItineraryBody (required)
7678
// - ItineraryFooter (optional)
7779
// - LegIcon (required)
@@ -84,7 +86,18 @@ const TermsOfStorage = () => (
8486
// - TermsOfService (required if otpConfig.persistence.strategy === 'otp_middleware')
8587
// - TermsOfStorage (required if otpConfig.persistence.strategy === 'otp_middleware')
8688
const components = {
89+
8790
defaultMobileTitle: () => <div className='navbar-title'>OpenTripPlanner</div>,
91+
/**
92+
* Example of a custom route label provider to pass to @opentripplanner/core-utils/map#itineraryToTransitive.
93+
* @param {*} itineraryLeg The OTP itinerary leg for which to obtain a custom route label.
94+
* @returns A string with the custom label to display for the given leg, or null to render no label.
95+
*/
96+
getTransitiveRouteLabel: itineraryLeg => {
97+
if (itineraryLeg.mode === 'RAIL') return 'Train'
98+
if (itineraryLeg.mode === 'BUS') return itineraryLeg.routeShortName
99+
return null // null or undefined or empty string will tell transitive-js to not render a route label.
100+
},
88101
ItineraryBody: DefaultItinerary,
89102
LegIcon: MyLegIcon,
90103
MainControls: isCallTakerModuleEnabled ? CallTakerControls : null,
@@ -95,8 +108,9 @@ const components = {
95108
: DefaultMainPanel,
96109
MapWindows: isCallTakerModuleEnabled
97110
? () => <>
98-
<CallTakerWindows />
111+
<CallHistoryWindow />
99112
<FieldTripWindows />
113+
<MailablesWindow />
100114
</>
101115
: null,
102116
MobileResultsScreen: isBatchRoutingEnabled
@@ -124,7 +138,7 @@ if (process.env.NODE_ENV === 'development') {
124138
// set up the Redux store
125139
const store = createStore(
126140
combineReducers({
127-
callTaker: createCallTakerReducer(),
141+
callTaker: createCallTakerReducer(otpConfig),
128142
otp: createOtpReducer(otpConfig),
129143
user: createUserReducer(),
130144
router: connectRouter(history)

0 commit comments

Comments
 (0)