Skip to content
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

Merged
merged 1 commit into from
Oct 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
_.each(drawer.notificationGroups, function(group) {
_.remove(group.notifications, { uid: notification.uid, namespace: notification.namespace });
});
delete notificationsMap[$routeParams.project][notification.uid];
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, thanks.

Copy link
Contributor

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.

};

var formatAPIEvents = function(apiEvents) {
Expand Down Expand Up @@ -172,11 +173,13 @@
};

var notificationWatchCallback = function(event, notification) {
if(!notification.showInDrawer) {
var project = notification.namespace || $routeParams.project;
var id = notification.id ? project + "/" + notification.id : _.uniqueId('notification_') + Date.now();

if(!notification.showInDrawer || EventsService.isCleared(id)) {
Copy link
Member

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

return;
}
var project = notification.namespace || $routeParams.project;
var id = notification.id || _.uniqueId('notification_') + Date.now();

notificationsMap[project] = notificationsMap[project] || {};
notificationsMap[project][id] = {
actions: notification.actions,
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/services/quota.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ angular.module("openshiftConsole")

if(hardValue <= usedValue) {
notifications.push({
id: "quota-limit-reached-" + quotaKey,
id: projectName + "/quota-limit-reached-" + quotaKey,
namespace: projectName,
type: (hardValue < usedValue ? 'warning' : 'info'),
message: getNotificaitonMessage(used, usedValue, hard, hardValue, quotaKey),
Expand Down
12 changes: 5 additions & 7 deletions dist/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3598,7 +3598,7 @@ var t = e.status.total || e.status;
_.each(t.hard, function(e, s) {
var c = m(e), l = _.get(t, [ "used", s ]), d = m(l);
"resourcequotas" !== s && c && d && c <= d && i.push({
id: "quota-limit-reached-" + s,
id: o + "/quota-limit-reached-" + s,
namespace: o,
type: c < d ? "warning" : "info",
message: I(0, d, e, c, s),
Expand Down Expand Up @@ -14418,7 +14418,7 @@ _.remove(t.notifications, {
uid: e.uid,
namespace: e.namespace
});
});
}), delete h[r.project][e.uid];
}, P = function(e) {
return _.map(e, function(e) {
return {
Expand Down Expand Up @@ -14456,9 +14456,8 @@ l && l(), l = null;
}, $ = function(e) {
g[r.project] = P(R(e.by("metadata.name"))), T();
}, B = function(e, t) {
if (t.showInDrawer) {
var n = t.namespace || r.project, a = t.id || _.uniqueId("notification_") + Date.now();
h[n] = h[n] || {}, h[n][a] = {
var n = t.namespace || r.project, a = t.id ? n + "/" + t.id : _.uniqueId("notification_") + Date.now();
t.showInDrawer && !c.isCleared(a) && (h[n] = h[n] || {}, h[n][a] = {
actions: t.actions,
unread: !c.isRead(a),
trackByID: t.trackByID,
Expand All @@ -14470,8 +14469,7 @@ isHTML: t.isHTML,
details: t.details,
namespace: n,
links: t.links
}, T();
}
}, T());
}, L = function(e, t) {
D(), e && (u = s.watch("events", {
namespace: e
Expand Down