Skip to content

Commit e067069

Browse files
committed
fix(alerts): set title and desc to empty strings in case they are null
1 parent 1431c61 commit e067069

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/alerts/reducers/alerts.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,13 @@ const alerts = (state = defaultState, action) => {
9999

100100
const alert = {
101101
id: rtdAlert.Id,
102-
title: rtdAlert.HeaderText,
102+
// Alert title and description are fields we expect to have values, i.e. they are required fields.
103+
// If for some reason they are null, change them to empty strings so as not to upset the application
104+
// downstream.
105+
title: rtdAlert.HeaderText || '',
103106
// RTD server sends back two-char new lines, which can mess up character limit counts
104107
// Here, we replace any of those occurrences with a single new line char.
105-
description: rtdAlert.DescriptionText && rtdAlert.DescriptionText.replace(/(\r\n)/g, '\n'),
108+
description: rtdAlert.DescriptionText && rtdAlert.DescriptionText.replace(/(\r\n)/g, '\n') || '',
106109
cause: rtdAlert.Cause,
107110
effect: rtdAlert.Effect,
108111
editedBy: rtdAlert.EditedBy,

lib/alerts/selectors/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export const getVisibleAlerts = createSelector(
77
[state => state.alerts.all, state => state.alerts.filter],
88
(alerts, visibilityFilter) => {
99
if (!alerts) return []
10+
11+
// filter alerts by the search text string
1012
let visibleAlerts = alerts.filter(alert =>
1113
alert.title.toLowerCase().indexOf((visibilityFilter.searchText || '').toLowerCase()) !== -1)
1214

0 commit comments

Comments
 (0)