Skip to content

Commit b17ab42

Browse files
authored
Merge pull request #104 from opentripplanner/react16
React 16
2 parents 9d24ce6 + b9be98d commit b17ab42

Some content is hidden

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

64 files changed

+522
-791
lines changed

Diff for: __tests__/test-utils/mock-data/store.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { connectRouter, routerMiddleware } from 'connected-react-router'
22
import Enzyme, {mount} from 'enzyme'
3-
import EnzymeReactAdapter from 'enzyme-adapter-react-15.4'
3+
import EnzymeReactAdapter from 'enzyme-adapter-react-16'
44
import {mountToJson} from 'enzyme-to-json'
55
import { createHashHistory } from 'history'
66
import clone from 'lodash/cloneDeep'

Diff for: lib/actions/api.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,13 @@ export const findGeometryForTripResponse = createAction('FIND_GEOMETRY_FOR_TRIP_
455455
export const findGeometryForTripError = createAction('FIND_GEOMETRY_FOR_TRIP_ERROR')
456456

457457
export function findGeometryForTrip (params) {
458-
return createQueryAction(`index/trips/${params.tripId}/geometry`,
459-
findGeometryForTripResponse, findGeometryForTripError,
460-
(payload) => {
461-
return {
462-
tripId: params.tripId,
463-
geometry: payload
464-
}
458+
const { tripId } = params
459+
return createQueryAction(
460+
`index/trips/${tripId}/geometry`,
461+
findGeometryForTripResponse,
462+
findGeometryForTripError,
463+
{
464+
rewritePayload: (payload) => ({ tripId, geometry: payload })
465465
}
466466
)
467467
}

Diff for: lib/actions/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export const setAutoPlan = createAction('SET_AUTOPLAN')
66
export const setMapCenter = createAction('SET_MAP_CENTER')
77
export const setMapZoom = createAction('SET_MAP_ZOOM')
88
export const setRouterId = createAction('SET_ROUTER_ID')
9+
export const updateOverlayVisibility = createAction('UPDATE_OVERLAY_VISIBILITY')

Diff for: lib/components/app/print-layout.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,16 @@ class PrintLayout extends Component {
3535

3636
componentDidMount () {
3737
const { location } = this.props
38+
// Add print-view class to html tag to ensure that iOS scroll fix only applies
39+
// to non-print views.
40+
const root = document.getElementsByTagName('html')[0]
41+
root.setAttribute('class', 'print-view')
3842
// Parse the URL query parameters, if present
3943
if (location && location.search) {
4044
this.props.parseUrlQueryString()
4145
}
4246
}
4347

44-
/**
45-
* Add print-view class to html tag to ensure that iOS scroll fix only applies
46-
* to non-print views.
47-
*/
48-
componentWillMount () {
49-
const root = document.getElementsByTagName('html')[0]
50-
root.setAttribute('class', 'print-view')
51-
}
52-
5348
/**
5449
* Remove class attribute from html tag on clean up.
5550
*/

Diff for: lib/components/app/responsive-webapp.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class RouterWrapper extends Component {
197197
// combine the router props with the other props that get
198198
// passed to the exported component. This way it's possible for
199199
// the PrintLayout component to receive the custom icons prop.
200-
const props = {...this.props, ...routerProps}
200+
const props = { ...this.props, ...routerProps }
201201
return <PrintLayout {...props} />
202202
}}
203203
/>
@@ -211,7 +211,5 @@ class RouterWrapper extends Component {
211211
)
212212
}
213213
}
214-
215-
export default connect((state, ownProps) => {
216-
return { routerConfig: state.otp.config.reactRouter }
217-
})(RouterWrapper)
214+
const mapStateToWrapperProps = (state, ownProps) => ({ routerConfig: state.otp.config.reactRouter })
215+
export default connect(mapStateToWrapperProps)(RouterWrapper)

Diff for: lib/components/form/checkbox-selector.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, {PropTypes, Component} from 'react'
1+
import React, {Component} from 'react'
2+
import PropTypes from 'prop-types'
23
import { Form, FormGroup, Row, Col, Checkbox } from 'react-bootstrap'
34
import { connect } from 'react-redux'
45

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// import necessary React/Redux libraries
2-
import React, { Component, PropTypes } from 'react'
2+
import React, { Component } from 'react'
3+
import PropTypes from 'prop-types'
34
import { connect } from 'react-redux'
45
import { Button, ButtonGroup } from 'react-bootstrap'
56

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import moment from 'moment'
34
import { connect } from 'react-redux'
45
import { Button } from 'react-bootstrap'

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// import moment from 'moment'
2-
import React, {PropTypes, Component} from 'react'
2+
import React, {Component} from 'react'
3+
import PropTypes from 'prop-types'
34
import { Form, FormGroup, FormControl, Row, Col, Button } from 'react-bootstrap'
45
// import { SingleDatePicker } from 'react-dates'
56
import { connect } from 'react-redux'
@@ -13,6 +14,12 @@ import {
1314
getDateFormat
1415
} from '../../util/time'
1516

17+
function checkInput (type) {
18+
var input = document.createElement('input')
19+
input.setAttribute('type', type)
20+
return input.type === type
21+
}
22+
1623
class DateTimeSelector extends Component {
1724
static propTypes = {
1825
date: PropTypes.string,
@@ -33,6 +40,8 @@ class DateTimeSelector extends Component {
3340
this.state = {
3441
dateFocused: false
3542
}
43+
this._supportsDateTimeInputs = checkInput('date') && checkInput('time')
44+
console.log(`supports date time: ${this._supportsDateTimeInputs}`)
3645
}
3746

3847
_onDateChange = (evt) => {
@@ -80,15 +89,6 @@ class DateTimeSelector extends Component {
8089
}
8190
}
8291

83-
componentWillMount () {
84-
const checkInput = (type) => {
85-
var input = document.createElement('input')
86-
input.setAttribute('type', type)
87-
return input.type === type
88-
}
89-
this._supportsDateTimeInputs = checkInput('date') && checkInput('time')
90-
}
91-
9292
render () {
9393
const { departArrive, date, time, timeFormat, dateFormat } = this.props
9494

Diff for: lib/components/form/dropdown-selector.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, {PropTypes, Component} from 'react'
1+
import React, {Component} from 'react'
2+
import PropTypes from 'prop-types'
23
import { Form, FormGroup, FormControl, Row, Col } from 'react-bootstrap'
34
import { connect } from 'react-redux'
45

Diff for: lib/components/form/error-message.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { connect } from 'react-redux'
34
import TripTools from '../narrative/trip-tools'
45

Diff for: lib/components/form/general-settings-panel.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { connect } from 'react-redux'
34

45
import CheckboxSelector from './checkbox-selector'

Diff for: lib/components/form/location-field.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import ReactDOM from 'react-dom'
34
import {
45
Button,
@@ -62,10 +63,15 @@ class LocationField extends Component {
6263
}
6364
}
6465

65-
componentWillReceiveProps (nextProps) {
66-
if (this.props.location !== nextProps.location) {
66+
componentDidUpdate (prevProps) {
67+
// If location is updated externally, replace value and geocoded features
68+
// in internal state.
69+
// TODO: This might be considered an anti-pattern. There may be a more
70+
// effective way to handle this.
71+
const { location } = this.props
72+
if (location !== prevProps.location) {
6773
this.setState({
68-
value: nextProps.location !== null ? nextProps.location.name : '',
74+
value: location !== null ? location.name : '',
6975
geocodedFeatures: []
7076
})
7177
}

Diff for: lib/components/form/mode-button.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, {PropTypes, Component, PureComponent} from 'react'
1+
import React, {Component, PureComponent} from 'react'
2+
import PropTypes from 'prop-types'
23

34
import { getIcon, isTransit } from '../../util/itinerary'
45

Diff for: lib/components/form/mode-selector.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { FormGroup, ControlLabel, FormControl } from 'react-bootstrap'
34
import { connect } from 'react-redux'
45

Diff for: lib/components/form/modes-panel.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { connect } from 'react-redux'
34

45
import { setQueryParam } from '../../actions/form'

Diff for: lib/components/form/plan-trip-button.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { Button } from 'react-bootstrap'
34
import { connect } from 'react-redux'
45

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { Button } from 'react-bootstrap'
34
import { connect } from 'react-redux'
45

Diff for: lib/components/form/settings-selector-panel.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { Row, Col, Button } from 'react-bootstrap'
34
import { connect } from 'react-redux'
45

@@ -283,7 +284,7 @@ class SettingsSelectorPanel extends Component {
283284
switch (exclusiveMode) {
284285
case 'WALK':
285286
children.push(
286-
<Col xs={4}>
287+
<Col key={key++} xs={4}>
287288
<ModeButton
288289
enabled
289290
key={key++}
@@ -300,7 +301,7 @@ class SettingsSelectorPanel extends Component {
300301
break
301302
case 'BICYCLE':
302303
children.push(
303-
<Col xs={4}>
304+
<Col key={key++} xs={4}>
304305
<ModeButton
305306
enabled
306307
key={key++}
@@ -317,7 +318,7 @@ class SettingsSelectorPanel extends Component {
317318
break
318319
case 'MICROMOBILITY':
319320
children.push(
320-
<Col xs={4}>
321+
<Col key={key++} xs={4}>
321322
<ModeButton
322323
enabled
323324
key={key++}

Diff for: lib/components/form/switch-button.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { Button } from 'react-bootstrap'
34
import { connect } from 'react-redux'
45

Diff for: lib/components/icons/location-icon.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23

34
export default class LocationIcon extends Component {
45
static propTypes = {

Diff for: lib/components/icons/mode-icon.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { Component, PropTypes } from 'react'
1+
import React, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23

34
export default class ModeIcon extends Component {
45
static propTypes = {

0 commit comments

Comments
 (0)