Skip to content

Commit a7f96ff

Browse files
Add track by to notification drawer
1 parent 04d694f commit a7f96ff

File tree

7 files changed

+118
-101
lines changed

7 files changed

+118
-101
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

+1-1
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",

dist/scripts/scripts.js

+44-43
Original file line numberDiff line numberDiff line change
@@ -13861,69 +13861,70 @@ u(), d();
1386113861
angular.module("openshiftConsole").component("notificationDrawerWrapper", {
1386213862
templateUrl: "views/directives/notifications/notification-drawer-wrapper.html",
1386313863
controller: [ "$filter", "$interval", "$location", "$timeout", "$routeParams", "$rootScope", "Constants", "DataService", "NotificationsService", "EventsService", function(e, t, n, a, r, o, i, s, c, l) {
13864-
var u, d, m = _.get(i, "DISABLE_GLOBAL_EVENT_WATCH"), p = e("isIE")() || e("isEdge")(), g = this, f = [], h = {}, v = {}, y = [], b = {}, C = function(e) {
13864+
var u, d, m = _.get(i, "DISABLE_GLOBAL_EVENT_WATCH"), p = e("isIE")() || e("isEdge")(), g = this, f = [], h = {}, v = [], y = {}, b = function(e) {
1386513865
return s.get("projects", e, {}, {
1386613866
errorNotification: !1
1386713867
}).then(function(e) {
13868-
return b[e.metadata.name] = e, e;
13868+
return y[e.metadata.name] = e, e;
1386913869
});
13870-
}, S = function(t, n) {
13870+
}, C = function(t, n) {
1387113871
n && !t[n] && (t[n] = {
13872-
heading: e("displayName")(b[n]) || n,
13873-
project: b[n],
13872+
heading: e("displayName")(y[n]) || n,
13873+
project: y[n],
1387413874
notifications: []
1387513875
});
13876-
}, w = function() {
13876+
}, S = function() {
1387713877
d && s.unwatch(d);
13878-
}, k = function(e, t) {
13879-
w(), e && (d = s.watch("events", {
13878+
}, w = function(e, t) {
13879+
S(), e && (d = s.watch("events", {
1388013880
namespace: e
1388113881
}, _.debounce(t, 400), {
1388213882
skipDigest: !0
1388313883
}));
13884-
}, j = function() {
13884+
}, k = function() {
1388513885
u && u(), u = null;
13886-
}, P = function(e) {
13886+
}, j = function(e) {
1388713887
return _.filter(e, "unread");
13888-
}, R = function(e) {
13888+
}, P = function(e) {
1388913889
o.$applyAsync(function() {
13890-
e.totalUnread = P(e.notifications).length, e.hasUnread = !!e.totalUnread, o.$emit("NotificationDrawerWrapper.count", e.totalUnread);
13890+
e.totalUnread = j(e.notifications).length, e.hasUnread = !!e.totalUnread, o.$emit("NotificationDrawerWrapper.count", e.totalUnread);
1389113891
});
13892-
}, E = function() {
13893-
_.each(y, R);
13894-
}, T = function(e) {
13892+
}, R = function() {
13893+
_.each(v, P);
13894+
}, E = function(e) {
1389513895
return _.orderBy(e, [ "event.lastTimestamp", "event.firstTimestamp" ], [ "desc", "desc" ]);
13896-
}, I = function(e) {
13896+
}, T = function(e) {
1389713897
var t = _.sortBy(e, function(e) {
1389813898
return e.heading;
1389913899
});
1390013900
return _.each(t, function(e) {
13901-
e.notifications = T(e.notifications), e.counts = R(e);
13901+
e.notifications = E(e.notifications), e.counts = P(e);
1390213902
}), t;
13903-
}, N = function(e) {
13903+
}, I = function(e) {
1390413904
var t = {};
13905-
return S(t, r.project), _.each(e, function(e) {
13906-
l.isImportantEvent(e) && !l.isCleared(e) && (S(t, e.metadata.namespace), t[e.metadata.namespace].notifications.push({
13905+
return C(t, r.project), _.each(e, function(e) {
13906+
l.isImportantEvent(e) && !l.isCleared(e) && (C(t, e.metadata.namespace), t[e.metadata.namespace].notifications.push({
1390713907
unread: !l.isRead(e),
13908+
uid: e.metadata.uid,
1390813909
event: e,
1390913910
actions: null
1391013911
}));
1391113912
}), t;
13912-
}, D = function() {
13913+
}, N = function() {
1391313914
_.each(f, function(e) {
1391413915
e();
1391513916
}), f = [];
13916-
}, $ = function(e) {
13917+
}, D = function(e) {
1391713918
e || (g.drawerHidden = !0);
13918-
}, A = function() {
13919+
}, $ = function() {
1391913920
o.$evalAsync(function() {
13920-
E(), g.notificationGroups = _.filter(y, function(e) {
13921+
R(), g.notificationGroups = _.filter(v, function(e) {
1392113922
return e.project.metadata.name === r.project;
1392213923
});
1392313924
});
13924-
}, B = function(e) {
13925-
h = e.by("metadata.name"), v = N(h), y = I(v), A();
13926-
}, L = {
13925+
}, A = function(e) {
13926+
h = I(e.by("metadata.uid")), v = T(h), $();
13927+
}, B = {
1392713928
Normal: "pficon pficon-info",
1392813929
Warning: "pficon pficon-warning-triangle-o"
1392913930
};
@@ -13941,51 +13942,51 @@ g.drawerHidden = !0;
1394113942
onMarkAllRead: function(e) {
1394213943
_.each(e.notifications, function(e) {
1394313944
e.unread = !1, l.markRead(e.event);
13944-
}), A(), o.$emit("NotificationDrawerWrapper.onMarkAllRead");
13945+
}), $(), o.$emit("NotificationDrawerWrapper.onMarkAllRead");
1394513946
},
1394613947
onClearAll: function(e) {
1394713948
_.each(e.notifications, function(e) {
1394813949
l.markRead(e.event), l.markCleared(e.event);
13949-
}), e.notifications = [], A(), o.$emit("NotificationDrawerWrapper.onMarkAllRead");
13950+
}), e.notifications = [], $(), o.$emit("NotificationDrawerWrapper.onMarkAllRead");
1395013951
},
13951-
notificationGroups: y,
13952+
notificationGroups: v,
1395213953
headingInclude: "views/directives/notifications/header.html",
1395313954
notificationBodyInclude: "views/directives/notifications/notification-body.html",
1395413955
customScope: {
1395513956
clear: function(e, t, n) {
13956-
l.markCleared(e.event), n.notifications.splice(t, 1), E();
13957+
l.markCleared(e.event), n.notifications.splice(t, 1), R();
1395713958
},
1395813959
markRead: function(e) {
13959-
e.unread = !1, l.markRead(e.event), E();
13960+
e.unread = !1, l.markRead(e.event), R();
1396013961
},
1396113962
getNotficationStatusIconClass: function(e) {
13962-
return L[e.type] || L.info;
13963+
return B[e.type] || B.info;
1396313964
},
1396413965
getStatusForCount: function(e) {
13965-
return L[e] || L.info;
13966+
return B[e] || B.info;
1396613967
},
1396713968
close: function() {
1396813969
g.drawerHidden = !0;
1396913970
}
1397013971
}
1397113972
});
13972-
var U = function(e, t) {
13973+
var L = function(e, t) {
1397313974
return _.get(e, "params.project") !== _.get(t, "params.project");
13974-
}, O = function() {
13975-
C(r.project).then(function() {
13976-
k(r.project, B), $(r.project), A();
13975+
}, U = function() {
13976+
b(r.project).then(function() {
13977+
w(r.project, A), D(r.project), $();
1397713978
});
13978-
}, x = function() {
13979-
r.project && O(), f.push(o.$on("$routeChangeSuccess", function(e, t, n) {
13980-
U(t, n) && (g.customScope.projectName = r.project, O());
13979+
}, O = function() {
13980+
r.project && U(), f.push(o.$on("$routeChangeSuccess", function(e, t, n) {
13981+
L(t, n) && (g.customScope.projectName = r.project, U());
1398113982
})), f.push(o.$on("NotificationDrawerWrapper.toggle", function() {
1398213983
g.drawerHidden = !g.drawerHidden;
1398313984
}));
1398413985
};
1398513986
g.$onInit = function() {
13986-
m || p || x();
13987+
m || p || O();
1398713988
}, g.$onDestroy = function() {
13988-
j(), w(), D();
13989+
k(), S(), N();
1398913990
};
1399013991
} ]
1399113992
});

dist/scripts/templates.js

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

77997799

78007800
$templateCache.put('views/directives/notifications/notification-drawer-wrapper.html',
7801-
"<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>"
7801+
"<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>"
78027802
);
78037803

78047804

0 commit comments

Comments
 (0)