Skip to content

Commit

Permalink
Merge branch 'dev' into cleanup-duplicate-headsigns
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-corson-ibigroup authored Mar 28, 2024
2 parents 8487a0c + 1d015c8 commit afa0023
Show file tree
Hide file tree
Showing 25 changed files with 33,906 additions and 15,044 deletions.
47,874 changes: 33,362 additions & 14,512 deletions __tests__/components/viewers/__snapshots__/nearby-view.js.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ exports[`components > viewers > stop viewer should render with initial stop id a
"wrapRichTextChunksInFragment": undefined,
}
}
setLocation={[Function]}
showBlockIds={false}
stopId="TriMet:13170"
transitOperators={Array []}
Expand Down Expand Up @@ -266,24 +265,32 @@ exports[`components > viewers > stop viewer should render with initial stop id a
</button>
</Button>
</div>
<div
className="header-text"
>
<h1>
<FormattedMessage
id="components.StopViewer.loadingText"
>
components.StopViewer.loadingText
</FormattedMessage>
</h1>
<Connect(FavoriteStopToggle)>
<FavoriteStopToggle
forgetStop={[Function]}
isFavoriteStop={false}
rememberStop={[Function]}
/>
</Connect(FavoriteStopToggle)>
</div>
<styled.div>
<div
className="sc-cjHJky bihPUp"
>
<styled.div>
<div
className="sc-edoYdd ipgOiu"
>
<h1>
<FormattedMessage
id="components.StopViewer.loadingText"
>
components.StopViewer.loadingText
</FormattedMessage>
</h1>
</div>
</styled.div>
</div>
</styled.div>
<Connect(FavoriteStopToggle)>
<FavoriteStopToggle
forgetStop={[Function]}
isFavoriteStop={false}
rememberStop={[Function]}
/>
</Connect(FavoriteStopToggle)>
<div
style={
Object {
Expand Down
2 changes: 2 additions & 0 deletions example-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ itinerary:
renderRouteNamesInBlocks: true
# Whether the mode icons should be colored as well
fillModeIcons: true
# Allow user to collapse alerts in itinerary body
allowUserAlertCollapsing: true
# If multiple fares are returned by OTP, assign names to the fare keys here
#fareKeyNameMap:
# regular: "Transit Fare"
Expand Down
3 changes: 3 additions & 0 deletions lib/actions/apiV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ export const findStopTimesForStop = (params) =>
headsign
id: code
route {
agency {
gtfsId
}
gtfsId
}
stops {
Expand Down
2 changes: 1 addition & 1 deletion lib/actions/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function setMapCenter(map /* MapRef */, location) {
*/
export function zoomToPlace(map /* MapRef */, place, zoom) {
return function () {
if (place && map) {
if (place && place.lat !== undefined && place.lon !== undefined && map) {
map.flyTo({ center: [place.lon, place.lat], zoom: zoom || 17 })
}
}
Expand Down
18 changes: 9 additions & 9 deletions lib/components/admin/field-trip-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,16 @@ class FieldTripList extends Component {
<IconWithText Icon={GraduationCap}>
Field Trip Requests
</IconWithText>{' '}
<button
className="clear-button-formatting"
onClick={this._onClickRefresh}
style={{ marginRight: '5px', verticalAlign: 'bottom' }}
>
<StyledIconWrapper>
<RedoAlt />
</StyledIconWrapper>
</button>
<span className="pull-right">
<button
className="clear-button-formatting"
onClick={this._onClickRefresh}
style={{ marginRight: '5px', verticalAlign: 'bottom' }}
>
<StyledIconWrapper>
<RedoAlt />
</StyledIconWrapper>
</button>
<input
defaultValue={search}
onKeyUp={this._handleSearchKeyUp}
Expand Down
16 changes: 13 additions & 3 deletions lib/components/form/connect-location-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,19 @@ export default function connectLocationField(
}

const geocoderConfig = config.geocoder
if (currentPosition?.coords) {
const { latitude: lat, longitude: lon } = currentPosition.coords
geocoderConfig.focusPoint = { lat, lon }
if (geocoderConfig) {
if (query.to && query.to?.lat && query.to?.lon) {
const { lat, lon } = query.to
geocoderConfig.focusPoint = { lat, lon }
}
if (query.from && query.from?.lat && query.from?.lon) {
const { lat, lon } = query.from
geocoderConfig.focusPoint = { lat, lon }
}
if (currentPosition?.coords) {
const { latitude: lat, longitude: lon } = currentPosition.coords
geocoderConfig.focusPoint = { lat, lon }
}
}

const stateToProps = {
Expand Down
10 changes: 3 additions & 7 deletions lib/components/map/point-popup.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { connect } from 'react-redux'
import { MapRef, useMap } from 'react-map-gl'
import { Popup } from '@opentripplanner/base-map'
import { Search } from '@styled-icons/fa-solid/Search'
import { useIntl, WrappedComponentProps } from 'react-intl'
import { useMap } from 'react-map-gl'
import FromToLocationPicker from '@opentripplanner/from-to-location-picker'
import React, { useCallback } from 'react'
import styled from 'styled-components'
Expand All @@ -11,7 +11,7 @@ import type { Location } from '@opentripplanner/types'
import * as mapActions from '../../actions/map'
import { Icon } from '../util/styledIcon'
import { renderCoordinates } from '../../util/i18n'
import { SetLocationHandler } from '../util/types'
import { SetLocationHandler, ZoomToPlaceHandler } from '../util/types'

const PopupTitleWrapper = styled.div`
align-items: flex-start;
Expand All @@ -36,11 +36,7 @@ type Props = {
clearMapPopupLocation: () => void
mapPopupLocation: Location
setLocation: SetLocationHandler
zoomToPlace: (
map?: MapRef,
place?: { lat: number; lon: number },
zoom?: number
) => void
zoomToPlace: ZoomToPlaceHandler
} & WrappedComponentProps

const DEFAULT_ZOOM = 15
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class ConnectedItineraryBody extends Component {
const clonedItinerary = clone(itinerary)

const showViewTripButton = !config?.itinerary?.hideViewTripButton
const allowUserAlertCollapsing = config?.itinerary?.allowUserAlertCollapsing

// Support OTP1 flex messages in Trip Details
// Adding empty pickupBookingInfo and dropOffBookingInfo objects
Expand Down Expand Up @@ -116,6 +117,7 @@ class ConnectedItineraryBody extends Component {
<ItineraryBodyContainer>
<StyledItineraryBody
accessibilityScoreGradationMap={accessibilityScoreGradationMap}
alwaysCollapseAlerts={allowUserAlertCollapsing}
config={config}
diagramVisible={diagramVisible}
itinerary={clonedItinerary}
Expand Down
5 changes: 3 additions & 2 deletions lib/components/user/places/favorite-place-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class FavoritePlaceScreen extends Component {
const { pendingSave } = this.state
// Get the places as shown (and not as retrieved from db), so that the index passed from URL applies
// (indexes 0 and 1 are for Home and Work locations).
const place = this._getPlaceToEdit(loggedInUser)
// Clone the place to avoid improper state mutation in the lines below.
const place = clone(this._getPlaceToEdit(loggedInUser))
// For <input> controls, the value must be at least ''.
if (place?.name === null) {
place.name = ''
Expand Down Expand Up @@ -154,7 +155,7 @@ class FavoritePlaceScreen extends Component {
id: 'components.SubNav.myAccount'
}) : '']} />
<Formik
initialValues={clone(place)}
initialValues={place}
onSubmit={this._handleSave}
validateOnBlur
// Avoid validating on change as it is annoying. Validating on blur is enough.
Expand Down
33 changes: 33 additions & 0 deletions lib/components/util/link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ComponentType, HTMLAttributes } from 'react'
import { connect } from 'react-redux'

import { AppReduxState } from '../../util/state-types'
import { combineQueryParams } from '../../util/api'
import { isBlank } from '../../util/ui'

interface OwnProps extends HTMLAttributes<HTMLAnchorElement> {
to: string
toParams?: Record<string, unknown>
}

/**
* Renders an anchor element <a> with specified path and query params,
* that preserves other existing query params.
*/
const Link: ComponentType = 'a' as unknown as ComponentType

// connect to the redux store so that the search params get updated in timely fashion.

const mapStateToProps = (state: AppReduxState, ownProps: OwnProps) => {
const queryParams = combineQueryParams(ownProps.toParams)
const href = `#${ownProps.to}${isBlank(queryParams) ? '' : `?${queryParams}`}`
return {
href,
// Remove the passed to and toParams props from the rendered HTML.
to: undefined,
toParams: undefined
}
}

// Pass an empty object as mapDispatchToProps to remove dispatch from the rendered HTML.
export default connect(mapStateToProps, {})(Link)
34 changes: 0 additions & 34 deletions lib/components/util/link.tsx

This file was deleted.

7 changes: 7 additions & 0 deletions lib/components/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Route,
Stop
} from '@opentripplanner/types'
import { MapRef } from 'react-map-gl'

export interface StopTimeTrip {
blockId?: string
Expand Down Expand Up @@ -101,3 +102,9 @@ export type SetViewedRouteHandler = (route?: ViewedRouteState) => void
export type SetViewedStopHandler = (payload: Stop | null) => void

export type SetLocationHandler = (payload: MapLocationActionArg) => void

export type ZoomToPlaceHandler = (
map?: MapRef,
place?: { lat: number; lon: number },
zoom?: number
) => void
43 changes: 43 additions & 0 deletions lib/components/viewers/nearby/from-to-picker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { connect } from 'react-redux'
import { Place } from '@opentripplanner/types'
import FromToLocationPicker from '@opentripplanner/from-to-location-picker'
import React, { useCallback, useMemo } from 'react'

import * as mapActions from '../../../actions/map'
import { SetLocationHandler } from '../../util/types'

interface Props {
className?: string
place: Place
setLocation: SetLocationHandler
}

const FromToPicker = ({ className, place, setLocation }: Props) => {
const location = useMemo(
() => ({
lat: place.lat ?? 0,
lon: place.lon ?? 0,
name: place.name
}),
[place]
)
return (
<span className={className} role="group">
<FromToLocationPicker
label
onFromClick={useCallback(() => {
setLocation({ location, locationType: 'from', reverseGeocode: false })
}, [location, setLocation])}
onToClick={useCallback(() => {
setLocation({ location, locationType: 'to', reverseGeocode: false })
}, [location, setLocation])}
/>
</span>
)
}

const mapDispatchToProps = {
setLocation: mapActions.setLocation
}

export default connect(null, mapDispatchToProps)(FromToPicker)
Loading

0 comments on commit afa0023

Please sign in to comment.