-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Correctly hide/show quota notifications per project #2222
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My worry is that this doesn't fix the problem for other notifications that don't include the project name in the ID.
@dtaylor113 If you prepend the project name to the uid
the notification drawer assigns, does it just work?
This might be a one line fix without needing the common changes?
@@ -74,7 +74,8 @@ angular.module("openshiftConsole") | |||
var setQuotaNotifications = function(quotas, clusterQuotas, projectName) { | |||
var notifications = QuotaService.getQuotaNotifications(quotas, clusterQuotas, projectName); | |||
_.each(notifications, function(notification) { | |||
if(!NotificationsService.isNotificationPermanentlyHidden(notification)) { | |||
// Only add a quota notification if it wasn't specifically set to be hidden by user | |||
if(!NotificationsService.isNotificationHidden(notification)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be necessary since the drawer tracks what was cleared in session storage. I think the drawer should know whether to show or hide the notification already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My worry is that this doesn't fix the problem for other notifications that don't include the project name in the ID.
That's why I was working in namespace
into the common NotificationsService 😄
@dtaylor113 If you prepend the project name to the uid the notification drawer assigns, does it just work?
This might be a one line fix without needing the common changes?
I'll have to test after removing the isNotificationHidden(..)
call in resourceAlerts.js. The drawer currently uses EventsService.isCleared() for filtering the APIEvents; I need to add the EventsService.isCleared()
call to the notifications callback.
Until |
I had to add |
@@ -184,7 +185,7 @@ | |||
// using uid to match API events and have one filed to pass | |||
// to EventsService for read/cleared, etc | |||
trackByID: notification.trackByID, | |||
uid: id, | |||
uid: _.includes(id, project) ? id : project + "/" + id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should always prepend project rather than trying to check if it's in id
. There's no harm and it makes things simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fixed -thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree on keeping it simpler. If the id
is being created on line 180
, can we keep all the id
manipulation logic there? Manipulating it in a couple spots might open doors to bugs...
Thanks @dtaylor113. I understand your point now about the memory leak in NotificationsService. I'm good with this change (with one small comment), and I think we should tackle the other problem separately. |
@@ -99,6 +99,7 @@ | |||
_.each(drawer.notificationGroups, function(group) { | |||
_.remove(group.notifications, { uid: notification.uid, namespace: notification.namespace }); | |||
}); | |||
delete notificationsMap[$routeParams.project][notification.uid]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjaminapetersen Is this a bug in remove? It seems like the _.each
above should take care of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notificationsMap is different from the group.notifications. notificationsMap actually generates the group.notifications when switching projects, so it needs to be cleared in the map as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think so as well, looking.
@@ -184,7 +185,7 @@ | |||
// using uid to match API events and have one filed to pass | |||
// to EventsService for read/cleared, etc | |||
trackByID: notification.trackByID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to keep all the id
generation/manipulation together on line 180
? I'd tend to think it should always be the same value if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might not be relevant, reviewing again, we have id
, trackById
, and uid
. Bleh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either way, I addressed this particular comment. -thanks
@@ -172,7 +173,7 @@ | |||
}; | |||
|
|||
var notificationWatchCallback = function(event, notification) { | |||
if(!notification.showInDrawer) { | |||
if(!notification.showInDrawer || EventsService.isCleared(notification.id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be using notification.uid
for cleared? We seem to use that in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notification in this callback doesn't have the uid
; the uid
is set if it gets past this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that relates to my comment above. Should always be consistent in the drawer. Think I settled on uid
originally because of apiEvents
first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I don't think we're not checking the right ID.... If we're clearing uid
but checking id
, isn't this check just wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, addressed this logic issue.
var project = notification.namespace || $routeParams.project; | ||
var id = notification.id ? project + "/" + notification.id : _.uniqueId('notification_') + Date.now(); | ||
|
||
if(!notification.showInDrawer || EventsService.isCleared(id)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dtaylor113, this looks better
@@ -99,6 +99,7 @@ | |||
_.each(drawer.notificationGroups, function(group) { | |||
_.remove(group.notifications, { uid: notification.uid, namespace: notification.namespace }); | |||
}); | |||
delete notificationsMap[$routeParams.project][notification.uid]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, thanks.
[merge] |
Evaluated for origin web console merge up to 033fe62 |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin_web_console/320/) (Base Commit: b642a34) (PR Branch Commit: 033fe62) |
Follow up issue openshift/origin-web-common#220 |
Addresses issues when switching between projects and viewing and hiding/clearing quota notifications.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1495455#c4