Correctly hide/show quota notifications per project#2222
Correctly hide/show quota notifications per project#2222openshift-bot merged 1 commit intoopenshift:masterfrom
Conversation
spadgett
left a comment
There was a problem hiding this comment.
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?
| _.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.
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.
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 |
| // 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.
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.
Ok, fixed -thanks
There was a problem hiding this comment.
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. |
| _.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.
@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.
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.
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.
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.
Might not be relevant, reviewing again, we have id, trackById, and uid. Bleh.
There was a problem hiding this comment.
Either way, I addressed this particular comment. -thanks
|
|
||
| var notificationWatchCallback = function(event, notification) { | ||
| if(!notification.showInDrawer) { | ||
| if(!notification.showInDrawer || EventsService.isCleared(notification.id)) { |
There was a problem hiding this comment.
Shouldn't we be using notification.uid for cleared? We seem to use that in other places.
There was a problem hiding this comment.
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.
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.
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.
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)) { |
| _.each(drawer.notificationGroups, function(group) { | ||
| _.remove(group.notifications, { uid: notification.uid, namespace: notification.namespace }); | ||
| }); | ||
| delete notificationsMap[$routeParams.project][notification.uid]; |
|
[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