Skip to content

Commit e034d4e

Browse files
committed
fix(alerts): fix issue with alert ID type mismatch
fix #459
1 parent 2edad94 commit e034d4e

File tree

7 files changed

+16
-10
lines changed

7 files changed

+16
-10
lines changed

lib/alerts/actions/alerts.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function deleteAlert (alert: Alert) {
9696
}
9797
}
9898

99-
export function setActiveAlert (alertId: number) {
99+
function setActiveAlert (alertId: string) {
100100
return function (dispatch: dispatchFn, getState: getStateFn) {
101101
const alert = getState().alerts.all.find(a => a.id === alertId)
102102
if (alert) {
@@ -202,7 +202,7 @@ export function onAlertEditorMount (
202202
if (!alertId) {
203203
dispatch(createAlert())
204204
} else {
205-
dispatch(setActiveAlert(+alertId))
205+
dispatch(setActiveAlert(alertId))
206206
}
207207
if (permissionFilter !== 'edit-alert') {
208208
dispatch(updatePermissionFilter('edit-alert'))

lib/alerts/components/AlertEditor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ type Props = ContainerProps & {
3636
project: Project,
3737
publishableFeeds: Array<Feed>,
3838
saveAlert: typeof alertActions.saveAlert,
39-
setActiveAlert: typeof alertActions.setActiveAlert,
4039
setActiveProperty: typeof activeAlertActions.setActiveProperty,
4140
setActivePublished: typeof activeAlertActions.setActivePublished,
4241
updateActiveEntity: typeof activeAlertActions.updateActiveEntity,

lib/alerts/containers/ActiveAlertEditor.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
createAlert,
77
deleteAlert,
88
onAlertEditorMount,
9-
saveAlert,
10-
setActiveAlert
9+
saveAlert
1110
} from '../actions/alerts'
1211
import {
1312
setActiveProperty,
@@ -44,7 +43,6 @@ const mapDispatchToProps = {
4443
deleteAlert,
4544
onAlertEditorMount,
4645
saveAlert,
47-
setActiveAlert,
4846
setActiveProperty,
4947
setActivePublished,
5048
updateActiveEntity

lib/alerts/reducers/alerts.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ const alerts = (
9393
case 'RECEIVED_RTD_ALERTS': {
9494
const entityList = []
9595
const {project, rtdAlerts} = action.payload
96-
// console.log(rtdAlerts)
9796
const filteredAlerts = rtdAlerts
9897
? rtdAlerts
9998
// For MTC, filter out all alerts that were created with the TRAMS tool,
@@ -107,6 +106,10 @@ const alerts = (
107106
if (alert && alert.ServiceAlertEntities && alert.ServiceAlertEntities.length > 0) {
108107
for (var j = 0; j < alert.ServiceAlertEntities.length; j++) {
109108
const entity = alert.ServiceAlertEntities[j]
109+
// FIXME: Cast IDs to strings until RTD updates its types.
110+
// See https://github.com/ibi-group/datatools-ui/issues/459
111+
entity.Id = `${entity.Id}`
112+
entity.AlertId = `${entity.AlertId}`
110113
if (entity.StopId) {
111114
entityList.push({type: 'stop', entity, gtfs: {}})
112115
}

lib/alerts/util/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ function mapRtdEntity (rtdEntity: RtdEntity, project: Project): AlertEntity {
153153
type = 'MODE'
154154
}
155155
return {
156-
id,
156+
// FIXME: For now RTD incorrectly returns id as an int.
157+
// See https://github.com/ibi-group/datatools-ui/issues/459
158+
id: `${id}`,
157159
agency,
158160
type,
159161
mode,

lib/gtfs/components/gtfs-search.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ class GtfsSearch extends Component<Props, State> {
123123
// FIXME: Need to filter on selected feeds?
124124
.filter(feed => feed.publishedVersionId)
125125
.map(feed => searchEntitiesWithString(input, feed.publishedVersionId, entities, filterByRoute, filterByStop, user))
126+
if (queries.length === 0) {
127+
console.warn('No queries to process (there are likely no published feeds).')
128+
return
129+
}
126130
}
127131
return Promise
128132
.all(queries)

lib/types/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ export type ZoneInfo = {
757757

758758
export type AlertEntity = {
759759
agency: ?Feed,
760-
id: number,
760+
id: string,
761761
mode?: ?any,
762762
route?: GtfsRoute & {feed_id: string},
763763
route_id?: ?string,
@@ -772,7 +772,7 @@ export type Alert = {
772772
description: string,
773773
effect: string,
774774
end: number,
775-
id: number,
775+
id: string,
776776
published: boolean,
777777
start: number,
778778
title: string,

0 commit comments

Comments
 (0)