DEV: Handle null notification level when generating data attribute ()

This happens in tests, but handling it properly will make the production code more robust. Followup to ebdebf152dd7fb259c0ecf06ce2356c5b0143c08
This commit is contained in:
David Taylor 2020-02-04 17:05:49 +00:00 committed by GitHub
parent 095e3d8946
commit fec1c0f097
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -88,9 +88,10 @@ const Category = RestModel.extend({
@discourseComputed("notification_level")
notificationLevelString(notificationLevel) {
// Get the key from the value
return Object.keys(NotificationLevels)
.find(key => NotificationLevels[key] === notificationLevel)
.toLowerCase();
const notificationLevelString = Object.keys(NotificationLevels).find(
key => NotificationLevels[key] === notificationLevel
);
if (notificationLevelString) return notificationLevelString.toLowerCase();
},
@discourseComputed("name")