Skip to content

Commit 4d49437

Browse files
author
OpenShift Bot
authored
Merge pull request #1988 from benjaminapetersen/bpeterse/issue/1981/notification-drawer-flicker
Merged by openshift-bot
2 parents 6ff495e + 362717c commit 4d49437

File tree

7 files changed

+107
-94
lines changed

7 files changed

+107
-94
lines changed

app/scripts/directives/notifications/notificationDrawerWrapper.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
// var clientGeneratedNotifications = [];
5050

5151
var eventsWatcher;
52-
var eventsByNameData = {};
5352
var eventsMap = {};
5453

5554
// TODO:
@@ -159,6 +158,7 @@
159158
ensureProjectGroupExists(filtered, event.metadata.namespace);
160159
filtered[event.metadata.namespace].notifications.push({
161160
unread: !EventsService.isRead(event),
161+
uid: event.metadata.uid,
162162
event: event,
163163
actions: null
164164
});
@@ -198,8 +198,7 @@
198198
// TODO: follow-on PR to decide which of these events to toast,
199199
// via config in constants.js
200200
var eventWatchCallback = function(eventData) {
201-
eventsByNameData = eventData.by('metadata.name');
202-
eventsMap = formatAndFilterEvents(eventsByNameData);
201+
eventsMap = formatAndFilterEvents(eventData.by('metadata.uid'));
203202
// TODO: Update to an intermediate map, so that we can then combine both
204203
// events + notifications into the final notificationGroups output
205204
notificationGroups = sortNotificationGroups(eventsMap);
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<pf-notification-drawer
2-
drawer-hidden="$ctrl.drawerHidden"
32
allow-expand="$ctrl.allowExpand"
3+
custom-scope="$ctrl.customScope"
44
drawer-expanded="$ctrl.drawerExpanded"
5+
drawer-hidden="$ctrl.drawerHidden"
56
drawer-title="{{$ctrl.drawerTitle}}"
6-
show-clear-all="$ctrl.showClearAll"
7-
show-mark-all-read="$ctrl.showMarkAllRead"
8-
notification-groups="$ctrl.notificationGroups"
97
heading-include="{{$ctrl.headingInclude}}"
108
notification-body-include="{{$ctrl.notificationBodyInclude}}"
9+
notification-groups="$ctrl.notificationGroups"
10+
notification-track-field="uid"
1111
on-close="$ctrl.onClose"
12-
on-mark-all-read="$ctrl.onMarkAllRead"
1312
on-clear-all="$ctrl.onClearAll"
14-
custom-scope="$ctrl.customScope"></pf-notification-drawer>
13+
on-mark-all-read="$ctrl.onMarkAllRead"
14+
show-clear-all="$ctrl.showClearAll"
15+
show-mark-all-read="$ctrl.showMarkAllRead"></pf-notification-drawer>

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"angular-touch": "1.5.11",
1414
"angular-route": "1.5.11",
1515
"angular-bootstrap": "0.14.3",
16-
"angular-patternfly": "4.5.6",
16+
"angular-patternfly": "4.7.1",
1717
"angular-gettext": "2.3.9",
1818
"uri.js": "1.18.12",
1919
"moment": "2.14.2",
@@ -47,7 +47,7 @@
4747
"angular-utf8-base64": "0.0.5",
4848
"file-saver": "1.3.3",
4949
"origin-web-common": "0.0.51",
50-
"origin-web-catalog": "0.0.41"
50+
"origin-web-catalog": "0.0.42"
5151
},
5252
"devDependencies": {
5353
"angular-mocks": "1.5.11",

dist/scripts/scripts.js

+44-43
Original file line numberDiff line numberDiff line change
@@ -13888,69 +13888,70 @@ u(), d();
1388813888
angular.module("openshiftConsole").component("notificationDrawerWrapper", {
1388913889
templateUrl: "views/directives/notifications/notification-drawer-wrapper.html",
1389013890
controller: [ "$filter", "$interval", "$location", "$timeout", "$routeParams", "$rootScope", "Constants", "DataService", "NotificationsService", "EventsService", function(e, t, n, a, r, o, i, s, c, l) {
13891-
var u, d, m = _.get(i, "DISABLE_GLOBAL_EVENT_WATCH"), p = e("isIE")() || e("isEdge")(), f = this, g = [], h = {}, v = {}, y = [], b = {}, C = function(e) {
13891+
var u, d, m = _.get(i, "DISABLE_GLOBAL_EVENT_WATCH"), p = e("isIE")() || e("isEdge")(), f = this, g = [], h = {}, v = [], y = {}, b = function(e) {
1389213892
return s.get("projects", e, {}, {
1389313893
errorNotification: !1
1389413894
}).then(function(e) {
13895-
return b[e.metadata.name] = e, e;
13895+
return y[e.metadata.name] = e, e;
1389613896
});
13897-
}, S = function(t, n) {
13897+
}, C = function(t, n) {
1389813898
n && !t[n] && (t[n] = {
13899-
heading: e("displayName")(b[n]) || n,
13900-
project: b[n],
13899+
heading: e("displayName")(y[n]) || n,
13900+
project: y[n],
1390113901
notifications: []
1390213902
});
13903-
}, w = function() {
13903+
}, S = function() {
1390413904
d && s.unwatch(d);
13905-
}, k = function(e, t) {
13906-
w(), e && (d = s.watch("events", {
13905+
}, w = function(e, t) {
13906+
S(), e && (d = s.watch("events", {
1390713907
namespace: e
1390813908
}, _.debounce(t, 400), {
1390913909
skipDigest: !0
1391013910
}));
13911-
}, j = function() {
13911+
}, k = function() {
1391213912
u && u(), u = null;
13913-
}, P = function(e) {
13913+
}, j = function(e) {
1391413914
return _.filter(e, "unread");
13915-
}, R = function(e) {
13915+
}, P = function(e) {
1391613916
o.$applyAsync(function() {
13917-
e.totalUnread = P(e.notifications).length, e.hasUnread = !!e.totalUnread, o.$emit("NotificationDrawerWrapper.count", e.totalUnread);
13917+
e.totalUnread = j(e.notifications).length, e.hasUnread = !!e.totalUnread, o.$emit("NotificationDrawerWrapper.count", e.totalUnread);
1391813918
});
13919-
}, E = function() {
13920-
_.each(y, R);
13921-
}, T = function(e) {
13919+
}, R = function() {
13920+
_.each(v, P);
13921+
}, E = function(e) {
1392213922
return _.orderBy(e, [ "event.lastTimestamp", "event.firstTimestamp" ], [ "desc", "desc" ]);
13923-
}, I = function(e) {
13923+
}, T = function(e) {
1392413924
var t = _.sortBy(e, function(e) {
1392513925
return e.heading;
1392613926
});
1392713927
return _.each(t, function(e) {
13928-
e.notifications = T(e.notifications), e.counts = R(e);
13928+
e.notifications = E(e.notifications), e.counts = P(e);
1392913929
}), t;
13930-
}, N = function(e) {
13930+
}, I = function(e) {
1393113931
var t = {};
13932-
return S(t, r.project), _.each(e, function(e) {
13933-
l.isImportantEvent(e) && !l.isCleared(e) && (S(t, e.metadata.namespace), t[e.metadata.namespace].notifications.push({
13932+
return C(t, r.project), _.each(e, function(e) {
13933+
l.isImportantEvent(e) && !l.isCleared(e) && (C(t, e.metadata.namespace), t[e.metadata.namespace].notifications.push({
1393413934
unread: !l.isRead(e),
13935+
uid: e.metadata.uid,
1393513936
event: e,
1393613937
actions: null
1393713938
}));
1393813939
}), t;
13939-
}, D = function() {
13940+
}, N = function() {
1394013941
_.each(g, function(e) {
1394113942
e();
1394213943
}), g = [];
13943-
}, $ = function(e) {
13944+
}, D = function(e) {
1394413945
e || (f.drawerHidden = !0);
13945-
}, A = function() {
13946+
}, $ = function() {
1394613947
o.$evalAsync(function() {
13947-
E(), f.notificationGroups = _.filter(y, function(e) {
13948+
R(), f.notificationGroups = _.filter(v, function(e) {
1394813949
return e.project.metadata.name === r.project;
1394913950
});
1395013951
});
13951-
}, B = function(e) {
13952-
h = e.by("metadata.name"), v = N(h), y = I(v), A();
13953-
}, L = {
13952+
}, A = function(e) {
13953+
h = I(e.by("metadata.uid")), v = T(h), $();
13954+
}, B = {
1395413955
Normal: "pficon pficon-info",
1395513956
Warning: "pficon pficon-warning-triangle-o"
1395613957
};
@@ -13968,51 +13969,51 @@ f.drawerHidden = !0;
1396813969
onMarkAllRead: function(e) {
1396913970
_.each(e.notifications, function(e) {
1397013971
e.unread = !1, l.markRead(e.event);
13971-
}), A(), o.$emit("NotificationDrawerWrapper.onMarkAllRead");
13972+
}), $(), o.$emit("NotificationDrawerWrapper.onMarkAllRead");
1397213973
},
1397313974
onClearAll: function(e) {
1397413975
_.each(e.notifications, function(e) {
1397513976
l.markRead(e.event), l.markCleared(e.event);
13976-
}), e.notifications = [], A(), o.$emit("NotificationDrawerWrapper.onMarkAllRead");
13977+
}), e.notifications = [], $(), o.$emit("NotificationDrawerWrapper.onMarkAllRead");
1397713978
},
13978-
notificationGroups: y,
13979+
notificationGroups: v,
1397913980
headingInclude: "views/directives/notifications/header.html",
1398013981
notificationBodyInclude: "views/directives/notifications/notification-body.html",
1398113982
customScope: {
1398213983
clear: function(e, t, n) {
13983-
l.markCleared(e.event), n.notifications.splice(t, 1), E();
13984+
l.markCleared(e.event), n.notifications.splice(t, 1), R();
1398413985
},
1398513986
markRead: function(e) {
13986-
e.unread = !1, l.markRead(e.event), E();
13987+
e.unread = !1, l.markRead(e.event), R();
1398713988
},
1398813989
getNotficationStatusIconClass: function(e) {
13989-
return L[e.type] || L.info;
13990+
return B[e.type] || B.info;
1399013991
},
1399113992
getStatusForCount: function(e) {
13992-
return L[e] || L.info;
13993+
return B[e] || B.info;
1399313994
},
1399413995
close: function() {
1399513996
f.drawerHidden = !0;
1399613997
}
1399713998
}
1399813999
});
13999-
var U = function(e, t) {
14000+
var L = function(e, t) {
1400014001
return _.get(e, "params.project") !== _.get(t, "params.project");
14001-
}, O = function() {
14002-
C(r.project).then(function() {
14003-
k(r.project, B), $(r.project), A();
14002+
}, U = function() {
14003+
b(r.project).then(function() {
14004+
w(r.project, A), D(r.project), $();
1400414005
});
14005-
}, F = function() {
14006-
r.project && O(), g.push(o.$on("$routeChangeSuccess", function(e, t, n) {
14007-
U(t, n) && (f.customScope.projectName = r.project, O());
14006+
}, O = function() {
14007+
r.project && U(), g.push(o.$on("$routeChangeSuccess", function(e, t, n) {
14008+
L(t, n) && (f.customScope.projectName = r.project, U());
1400814009
})), g.push(o.$on("NotificationDrawerWrapper.toggle", function() {
1400914010
f.drawerHidden = !f.drawerHidden;
1401014011
}));
1401114012
};
1401214013
f.$onInit = function() {
14013-
m || p || F();
14014+
m || p || O();
1401414015
}, f.$onDestroy = function() {
14015-
j(), w(), D();
14016+
k(), S(), N();
1401614017
};
1401714018
} ]
1401814019
});

dist/scripts/templates.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7533,7 +7533,7 @@ angular.module('openshiftConsoleTemplates', []).run(['$templateCache', function(
75337533

75347534

75357535
$templateCache.put('views/directives/notifications/notification-drawer-wrapper.html',
7536-
"<pf-notification-drawer drawer-hidden=\"$ctrl.drawerHidden\" allow-expand=\"$ctrl.allowExpand\" drawer-expanded=\"$ctrl.drawerExpanded\" drawer-title=\"{{$ctrl.drawerTitle}}\" show-clear-all=\"$ctrl.showClearAll\" show-mark-all-read=\"$ctrl.showMarkAllRead\" notification-groups=\"$ctrl.notificationGroups\" heading-include=\"{{$ctrl.headingInclude}}\" notification-body-include=\"{{$ctrl.notificationBodyInclude}}\" on-close=\"$ctrl.onClose\" on-mark-all-read=\"$ctrl.onMarkAllRead\" on-clear-all=\"$ctrl.onClearAll\" custom-scope=\"$ctrl.customScope\"></pf-notification-drawer>"
7536+
"<pf-notification-drawer allow-expand=\"$ctrl.allowExpand\" custom-scope=\"$ctrl.customScope\" drawer-expanded=\"$ctrl.drawerExpanded\" drawer-hidden=\"$ctrl.drawerHidden\" drawer-title=\"{{$ctrl.drawerTitle}}\" heading-include=\"{{$ctrl.headingInclude}}\" notification-body-include=\"{{$ctrl.notificationBodyInclude}}\" notification-groups=\"$ctrl.notificationGroups\" notification-track-field=\"uid\" on-close=\"$ctrl.onClose\" on-clear-all=\"$ctrl.onClearAll\" on-mark-all-read=\"$ctrl.onMarkAllRead\" show-clear-all=\"$ctrl.showClearAll\" show-mark-all-read=\"$ctrl.showMarkAllRead\"></pf-notification-drawer>"
75377537
);
75387538

75397539

0 commit comments

Comments
 (0)