Skip to content

Commit ad3c82c

Browse files
Merge branch 'dev' into fix-mobile-map
2 parents 0d56db0 + 2132f1e commit ad3c82c

19 files changed

+196
-2487
lines changed

Diff for: README.md

+31
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,37 @@ The same environment variables which affect the behavior of `yarn start` also af
3434
env JS_CONFIG=my-custom-js.js CUSTOM_CSS=my-custom-css.css yarn build
3535
```
3636

37+
## Internationalization
38+
39+
OTP-react-redux uses `react-intl` from the [`formatjs`](https://github.com/formatjs/formatjs) library for internationalization.
40+
Both `react-intl` and `formatjs` take advantage of native internationalization features provided by web browsers.
41+
42+
Language-specific content is located in YML files under the `i18n` folder
43+
(e.g. `en-US.yml` for American English, `fr.yml` for generic French, etc.).
44+
45+
Most textual content can also be customized using the `language` section of `config.yml`,
46+
whether for all languages at once or for each supported individual language.
47+
48+
### Contributing translations
49+
50+
OTP-react-redux now uses [Hosted Weblate](https://www.weblate.org) to manage translations!
51+
52+
<figure>
53+
<a href="https://hosted.weblate.org/engage/otp-react-redux/">
54+
<img src="https://hosted.weblate.org/widgets/otp-react-redux/-/horizontal-auto.svg" alt="Translation status" />
55+
</a>
56+
<figcaption>Translation status for
57+
<a href="https://hosted.weblate.org/engage/otp-react-redux/">OTP-react-redux and OTP-UI on Hosted Weblate</a>
58+
</figcaption>
59+
</figure>
60+
61+
62+
Translations from the community are welcome and very much appreciated,
63+
please see instructions at https://hosted.weblate.org/projects/otp-react-redux/.
64+
Community input from Weblate will appear as pull requests with changes to files in the `i18n` folder for our review.
65+
66+
If changes to a specific language file is needed but not enabled in Weblate, please open an issue or a pull request with the changes needed.
67+
3768
## Library Documentation
3869

3970
More coming soon...

Diff for: lib/actions/api.js

+3-20
Original file line numberDiff line numberDiff line change
@@ -701,28 +701,11 @@ export function findStopTimesForStop(params) {
701701

702702
// Routes lookup query
703703

704-
const findRoutesResponse = createAction('FIND_ROUTES_RESPONSE')
705-
const findRoutesError = createAction('FIND_ROUTES_ERROR')
704+
export const findRoutesResponse = createAction('FIND_ROUTES_RESPONSE')
705+
export const findRoutesError = createAction('FIND_ROUTES_ERROR')
706706

707707
export function findRoutes(params) {
708-
return createQueryAction(
709-
'index/routes',
710-
findRoutesResponse,
711-
findRoutesError,
712-
{
713-
postprocess: (payload, dispatch) => {
714-
dispatch(setViewedStop(null))
715-
},
716-
rewritePayload: (payload) => {
717-
const routes = {}
718-
payload.forEach((rte) => {
719-
routes[rte.id] = rte
720-
})
721-
return routes
722-
},
723-
serviceId: 'routes'
724-
}
725-
)
708+
return executeOTPAction('findRoutes', params)
726709
}
727710

728711
// Patterns for Route lookup query

Diff for: lib/actions/apiV1.js

+24
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
findRouteError,
1414
findRouteResponse,
1515
findRoutesAtStop,
16+
findRoutesError,
17+
findRoutesResponse,
1618
findStopError,
1719
findStopResponse,
1820
findStopsForPattern,
@@ -234,10 +236,32 @@ export const findRoute = (params) =>
234236
}
235237
)
236238

239+
export function findRoutes() {
240+
return createQueryAction(
241+
'index/routes',
242+
findRoutesResponse,
243+
findRoutesError,
244+
{
245+
postprocess: (payload, dispatch) => {
246+
dispatch(setViewedStop(null))
247+
},
248+
rewritePayload: (payload) => {
249+
const routes = {}
250+
payload.forEach((rte) => {
251+
routes[rte.id] = rte
252+
})
253+
return routes
254+
},
255+
serviceId: 'routes'
256+
}
257+
)
258+
}
259+
237260
export default {
238261
fetchStopInfo,
239262
findPatternsForRoute,
240263
findRoute,
264+
findRoutes,
241265
findTrip,
242266
getVehiclePositionsForRoute,
243267
vehicleRentalQuery

Diff for: lib/actions/apiV2.js

+62
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
findNearbyAmenitiesResponse,
88
findRouteError,
99
findRouteResponse,
10+
findRoutesError,
11+
findRoutesResponse,
1012
findStopError,
1113
findStopResponse,
1214
findStopTimesForTrip,
@@ -538,11 +540,14 @@ export const findRoute = (params) =>
538540
phone
539541
}
540542
longName
543+
shortName
544+
mode
541545
type
542546
color
543547
textColor
544548
bikesAllowed
545549
routeBikesAllowed: bikesAllowed
550+
url
546551
547552
patterns {
548553
id
@@ -610,6 +615,62 @@ export const findRoute = (params) =>
610615
)
611616
}
612617

618+
export function findRoutes() {
619+
return function (dispatch) {
620+
dispatch(
621+
createGraphQLQueryAction(
622+
`{
623+
routes {
624+
id: gtfsId
625+
agency {
626+
id: gtfsId
627+
name
628+
}
629+
longName
630+
shortName
631+
mode
632+
color
633+
}
634+
}
635+
`,
636+
{},
637+
findRoutesResponse,
638+
findRoutesError,
639+
{
640+
noThrottle: true,
641+
// TODO: avoid re-writing OTP2 route object to match OTP1 style
642+
rewritePayload: (payload) => {
643+
if (payload.errors) {
644+
return dispatch(findRoutesError(payload.errors))
645+
}
646+
const { routes } = payload?.data
647+
if (!routes) return
648+
649+
// To initialize the route viewer,
650+
// convert the routes array to a dictionary indexed by route ids.
651+
return routes.reduce(
652+
(result, { agency, color, id, longName, mode, shortName }) => {
653+
result[id] = {
654+
agencyId: agency.id,
655+
agencyName: agency.name,
656+
color,
657+
id,
658+
longName,
659+
mode,
660+
shortName,
661+
v2: true
662+
}
663+
return result
664+
},
665+
{}
666+
)
667+
}
668+
}
669+
)
670+
)
671+
}
672+
}
673+
613674
export const findPatternsForRoute = (params) =>
614675
function (dispatch, getState) {
615676
const state = getState()
@@ -628,6 +689,7 @@ export default {
628689
fetchStopInfo,
629690
findPatternsForRoute,
630691
findRoute,
692+
findRoutes,
631693
findTrip,
632694
getVehiclePositionsForRoute,
633695
vehicleRentalQuery

Diff for: lib/components/admin/call-record.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable react/prop-types */
22
import { Circle } from '@styled-icons/fa-solid/Circle'
3-
import { Clock } from '@styled-icons/fa-regular'
3+
import { Clock } from '@styled-icons/fa-regular/Clock'
44
import { differenceInMilliseconds, format } from 'date-fns'
55
import { Phone } from '@styled-icons/fa-solid/Phone'
66
import { PhoneAlt } from '@styled-icons/fa-solid/PhoneAlt'

Diff for: lib/components/admin/call-taker-controls.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import { connect } from 'react-redux'
2+
import { GraduationCap } from '@styled-icons/fa-solid/GraduationCap'
3+
import { History } from '@styled-icons/fa-solid/History'
24
import { injectIntl, IntlShape, WrappedComponentProps } from 'react-intl'
5+
import { Phone } from '@styled-icons/fa-solid/Phone'
6+
import { Plus } from '@styled-icons/fa-solid/Plus'
7+
import { Stop } from '@styled-icons/fa-solid/Stop'
38
import React, { Component } from 'react'
49

510
import * as apiActions from '../../actions/api'
611
import * as callTakerActions from '../../actions/call-taker'
712
import * as fieldTripActions from '../../actions/field-trip'
813
import * as uiActions from '../../actions/ui'
9-
import {
10-
GraduationCap,
11-
History,
12-
Phone,
13-
Plus,
14-
Stop
15-
} from '@styled-icons/fa-solid'
1614
import { isModuleEnabled, Modules } from '../../util/config'
1715

1816
import {

Diff for: lib/components/admin/draggable-window.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Times } from '@styled-icons/fa-solid'
1+
import { Times } from '@styled-icons/fa-solid/Times'
22
import Draggable, { DraggableProps } from 'react-draggable'
33
import React, { HTMLAttributes, ReactNode } from 'react'
44

Diff for: lib/components/admin/field-trip-notes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable react/prop-types */
22
import { Badge, Button as BsButton } from 'react-bootstrap'
33
import { Plus } from '@styled-icons/fa-solid/Plus'
4-
import { StickyNote } from '@styled-icons/fa-regular'
4+
import { StickyNote } from '@styled-icons/fa-regular/StickyNote'
55
import { Trash } from '@styled-icons/fa-solid/Trash'
66
import React, { Component } from 'react'
77
import styled from 'styled-components'

Diff for: lib/components/form/date-time-preview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { CaretUp } from '@styled-icons/fa-solid/CaretUp'
88
import { Clock } from '@styled-icons/fa-regular/Clock'
99
import { connect } from 'react-redux'
1010
import { injectIntl } from 'react-intl'
11-
import { PencilAlt } from '@styled-icons/fa-solid'
11+
import { PencilAlt } from '@styled-icons/fa-solid/PencilAlt'
1212
import { toDate } from 'date-fns-tz'
1313
import PropTypes from 'prop-types'
1414
import React, { Component } from 'react'

Diff for: lib/components/form/settings-preview.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
/* eslint-disable jsx-a11y/no-static-element-interactions */
33
/* eslint-disable jsx-a11y/click-events-have-key-events */
44
import { Button } from 'react-bootstrap'
5-
import { CaretDown, CaretUp, PencilAlt } from '@styled-icons/fa-solid'
5+
import { CaretDown } from '@styled-icons/fa-solid/CaretDown'
6+
import { CaretUp } from '@styled-icons/fa-solid/CaretUp'
67
import { connect } from 'react-redux'
8+
import { PencilAlt } from '@styled-icons/fa-solid/PencilAlt'
79
import { useIntl } from 'react-intl'
810
import coreUtils from '@opentripplanner/core-utils'
911
import PropTypes from 'prop-types'

Diff for: lib/components/map/map.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { setMapillaryId } from '../../actions/map'
99
import DefaultMap from './default-map'
1010
import LegDiagram from './leg-diagram'
1111
import MapillaryFrame from './mapillary-frame'
12-
import StylizedMap from './stylized-map'
1312

1413
class Map extends Component {
1514
constructor() {
@@ -19,16 +18,6 @@ class Map extends Component {
1918
}
2019
}
2120

22-
getComponentForView(view) {
23-
// TODO: allow a 'CUSTOM' type
24-
switch (view.type) {
25-
case 'DEFAULT':
26-
return <DefaultMap />
27-
case 'STYLIZED':
28-
return <StylizedMap />
29-
}
30-
}
31-
3221
render() {
3322
const { activeMapillaryImage, diagramLeg, mapConfig, setMapillaryId } =
3423
this.props
@@ -52,7 +41,7 @@ class Map extends Component {
5241
i === this.state.activeViewIndex ? 'visible' : 'hidden'
5342
}}
5443
>
55-
{this.getComponentForView(view)}
44+
<DefaultMap />
5645
</div>
5746
)
5847
})}

0 commit comments

Comments
 (0)