Skip to content

Commit 42508f8

Browse files
committed
Reapply "Merge pull request #5464 from HSLdevcom/DT-6325"
This reverts commit a05ce71.
1 parent a05ce71 commit 42508f8

File tree

4 files changed

+53
-46
lines changed

4 files changed

+53
-46
lines changed

app/component/DisruptionBanner.js

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import { createFragmentContainer, graphql } from 'react-relay';
43
import connectToStores from 'fluxible-addons-react/connectToStores';
54
import isEmpty from 'lodash/isEmpty';
65
import { configShape, alertShape } from '../util/shapes';
@@ -110,37 +109,13 @@ class DisruptionBanner extends React.Component {
110109
}
111110
const DisruptionBannerWithBreakpoint = withBreakpoint(DisruptionBanner);
112111

113-
const containerComponent = createFragmentContainer(
114-
connectToStores(
115-
DisruptionBannerWithBreakpoint,
116-
['TimeStore', 'PreferencesStore'],
117-
({ getStore }) => ({
118-
currentTime: getStore('TimeStore').getCurrentTime(),
119-
language: getStore('PreferencesStore').getLanguage(),
120-
}),
121-
),
122-
{
123-
alerts: graphql`
124-
fragment DisruptionBanner_alerts on Alert @relay(plural: true) {
125-
feed
126-
id
127-
alertSeverityLevel
128-
alertHeaderText
129-
alertEffect
130-
alertCause
131-
alertDescriptionText
132-
effectiveStartDate
133-
effectiveEndDate
134-
entities {
135-
__typename
136-
... on Route {
137-
mode
138-
shortName
139-
}
140-
}
141-
}
142-
`,
143-
},
112+
const containerComponent = connectToStores(
113+
DisruptionBannerWithBreakpoint,
114+
['TimeStore', 'PreferencesStore'],
115+
({ getStore }) => ({
116+
currentTime: getStore('TimeStore').getCurrentTime(),
117+
language: getStore('PreferencesStore').getLanguage(),
118+
}),
144119
);
145120

146121
export { containerComponent as default, DisruptionBanner as Component };

app/component/map/NearYouMap.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ const handleBounds = (location, edges) => {
117117
};
118118

119119
const getLocationMarker = location => {
120-
return <LocationMarker position={location} type="from" />;
120+
return (
121+
<LocationMarker
122+
key={`from-${location.lat}:${location.lat}`}
123+
position={location}
124+
type="from"
125+
/>
126+
);
121127
};
122128

123129
function NearYouMap(

app/component/nearyou/NearYouPage.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
checkPositioningPermission,
2323
startLocationWatch,
2424
} from '../../action/PositionActions';
25-
import DisruptionBanner from '../DisruptionBanner';
2625
import StopsNearYouSearch from './StopsNearYouSearch';
2726
import {
2827
getGeolocationState,
@@ -247,7 +246,6 @@ class NearYouPage extends React.Component {
247246
filterByModes: modes,
248247
filterByPlaceTypes: placeTypes,
249248
omitNonPickups: this.context.config.omitNonPickups,
250-
feedIds: this.context.config.feedIds,
251249
prioritizedStopIds: prioritizedStops,
252250
filterByNetwork: allowedNetworks,
253251
};
@@ -438,7 +436,6 @@ class NearYouPage extends React.Component {
438436
$maxResults: Int!
439437
$maxDistance: Int!
440438
$omitNonPickups: Boolean!
441-
$feedIds: [String!]
442439
$filterByNetwork: [String!]
443440
) {
444441
stopPatterns: viewer {
@@ -455,9 +452,6 @@ class NearYouPage extends React.Component {
455452
filterByNetwork: $filterByNetwork
456453
)
457454
}
458-
alerts: alerts(feeds: $feedIds, severityLevel: [SEVERE]) {
459-
...DisruptionBanner_alerts
460-
}
461455
}
462456
`}
463457
variables={this.getQueryVariables(nearByStopMode)}
@@ -482,13 +476,6 @@ class NearYouPage extends React.Component {
482476
config.prioritizedStopsNearYou[nearByStopMode.toLowerCase()];
483477
return (
484478
<div className="stops-near-you-page">
485-
{renderDisruptionBanner && (
486-
<DisruptionBanner
487-
alerts={(props && props.alerts) || []}
488-
mode={nearByStopMode}
489-
trafficNowLink={config.trafficNowLink}
490-
/>
491-
)}
492479
{renderSearch && (
493480
<StopsNearYouSearch
494481
mode={nearByStopMode}
@@ -623,6 +610,8 @@ class NearYouPage extends React.Component {
623610
stopPatterns={props.stopPatterns}
624611
position={this.state.searchPosition}
625612
withSeparator={!renderSearch}
613+
nearByStopMode={nearByStopMode}
614+
renderDisruptionBanner={renderDisruptionBanner}
626615
/>
627616
)}
628617
</div>

app/component/nearyou/StopsNearYouContainer.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import CityBikeStopNearYou from './VehicleRentalStationNearYou';
1515
import Loading from '../Loading';
1616
import Icon from '../Icon';
1717
import { getDefaultNetworks } from '../../util/vehicleRentalUtils';
18+
import DisruptionBanner from '../DisruptionBanner';
1819

1920
class StopsNearYouContainer extends React.Component {
2021
static propTypes = {
@@ -33,12 +34,15 @@ class StopsNearYouContainer extends React.Component {
3334
}).isRequired,
3435
withSeparator: PropTypes.bool,
3536
prioritizedStops: PropTypes.arrayOf(PropTypes.string),
37+
nearByStopMode: PropTypes.string.isRequired,
38+
renderDisruptionBanner: PropTypes.bool,
3639
};
3740

3841
static defaultProps = {
3942
stopPatterns: undefined,
4043
withSeparator: false,
4144
prioritizedStops: undefined,
45+
renderDisruptionBanner: false,
4246
};
4347

4448
static contextTypes = {
@@ -254,12 +258,23 @@ class StopsNearYouContainer extends React.Component {
254258
/>
255259
);
256260
const stops = this.createNearbyStops().filter(e => e);
261+
const alerts = stops
262+
.flatMap(stop => stop.props.stop?.routes || [])
263+
.flatMap(route => route?.alerts || [])
264+
.filter(alert => alert.alertSeverityLevel === 'SEVERE');
257265
const noStopsFound =
258266
!stops.length &&
259267
this.state.refetches >= this.state.maxRefetches &&
260268
!this.state.isLoadingmoreStops;
261269
return (
262270
<>
271+
{this.props.renderDisruptionBanner && (
272+
<DisruptionBanner
273+
alerts={alerts || []}
274+
mode={this.props.nearByStopMode}
275+
trafficNowLink={this.context.config.trafficNowLink}
276+
/>
277+
)}
263278
{((!this.props.relay.hasMore() &&
264279
!stops.length &&
265280
!this.props.prioritizedStops?.length) ||
@@ -389,6 +404,28 @@ const refetchContainer = createPaginationContainer(
389404
) {
390405
scheduledArrival
391406
}
407+
routes {
408+
... on Route {
409+
alerts {
410+
feed
411+
id
412+
alertSeverityLevel
413+
alertHeaderText
414+
alertEffect
415+
alertCause
416+
alertDescriptionText
417+
effectiveStartDate
418+
effectiveEndDate
419+
entities {
420+
__typename
421+
... on Route {
422+
mode
423+
shortName
424+
}
425+
}
426+
}
427+
}
428+
}
392429
}
393430
}
394431
}

0 commit comments

Comments
 (0)