diff --git a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.html b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.html
index 48f4ecc1f6..eb6a70887b 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.html
+++ b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.html
@@ -19,6 +19,7 @@ limitations under the License.
+
@@ -47,11 +48,20 @@ limitations under the License.
[[itemType(item.type)]] |
-
- [[_getNameForMember(item.member)]]
-
+
+
+ [[_getNameForGroup(item.member)]]
+
+
+
+
+ [[_getIdForUser(item.member)]]
+
+ |
+
+
+ [[_getIdForUser(item.user)]]
|
- [[_getNameForUser(item.user)]] |
diff --git a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.js b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.js
index b150d68397..bc6a5d03b4 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.js
+++ b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log.js
@@ -17,12 +17,14 @@
(function() {
'use strict';
+ const GROUP_EVENTS = ['ADD_GROUP', 'REMOVE_GROUP'];
+
Polymer({
is: 'gr-group-audit-log',
properties: {
- groupId: Object,
- _auditLog: Object,
+ groupId: String,
+ _auditLog: Array,
_loading: {
type: Boolean,
value: true,
@@ -63,12 +65,6 @@
return item.disabled ? 'Disabled' : 'Enabled';
},
- _computeGroupUrl(id) {
- if (!id) { return ''; }
-
- return this.getBaseUrl() + '/admin/groups/' + id;
- },
-
itemType(type) {
let item;
switch (type) {
@@ -86,20 +82,31 @@
return item;
},
- _getNameForUser(account) {
- const accountId = account._account_id ? ' (' +
- account._account_id + ')' : '';
- return this._getNameForMember(account) + accountId;
+ _isGroupEvent(type) {
+ return GROUP_EVENTS.indexOf(type) !== -1;
},
- _getNameForMember(account) {
- if (account && account.name) {
- return account.name;
- } else if (account && account.username) {
- return account.username;
- } else if (account && account.email) {
- return account.email.split('@')[0];
+ _computeGroupUrl(group) {
+ if (group && group.url && group.id) {
+ return Gerrit.Nav.getUrlForGroup(group.id);
}
+
+ return '';
+ },
+
+ _getIdForUser(account) {
+ return account._account_id ? ' (' + account._account_id + ')' : '';
+ },
+
+ _getNameForGroup(group) {
+ if (group && group.name) {
+ return group.name;
+ } else if (group && group.id) {
+ // The URL encoded id of the member
+ return decodeURIComponent(group.id);
+ }
+
+ return '';
},
});
})();
diff --git a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.html b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.html
index 86e8a2585c..59a665b9b7 100644
--- a/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.html
+++ b/polygerrit-ui/app/elements/admin/gr-group-audit-log/gr-group-audit-log_test.html
@@ -47,81 +47,49 @@ limitations under the License.
});
suite('members', () => {
- test('test getNameForMember', () => {
- let account = {
- member: {
- username: 'test-user',
- _account_id: 12,
- },
- };
- assert.equal(element._getNameForMember(account.member, false),
- 'test-user');
-
- account = {
+ test('test _getNameForGroup', () => {
+ let group = {
member: {
name: 'test-name',
- _account_id: 12,
},
};
- assert.equal(element._getNameForMember(account.member), 'test-name');
+ assert.equal(element._getNameForGroup(group.member), 'test-name');
- account = {
- user: {
- email: 'test-email@gmail.com',
+ group = {
+ member: {
+ id: 'test-id',
},
};
- assert.equal(element._getNameForMember(account.user), 'test-email');
+ assert.equal(element._getNameForGroup(group.member), 'test-id');
+ });
+
+ test('test _isGroupEvent', () => {
+ assert.isTrue(element._isGroupEvent('ADD_GROUP'));
+ assert.isTrue(element._isGroupEvent('REMOVE_GROUP'));
+
+ assert.isFalse(element._isGroupEvent('ADD_USER'));
+ assert.isFalse(element._isGroupEvent('REMOVE_USER'));
});
});
suite('users', () => {
- test('test _getName', () => {
- let account = {
+ test('test _getIdForUser', () => {
+ const account = {
user: {
username: 'test-user',
_account_id: 12,
},
};
- assert.equal(element._getNameForUser(account.user), 'test-user (12)');
-
- account = {
- user: {
- name: 'test-name',
- _account_id: 12,
- },
- };
- assert.equal(element._getNameForUser(account.user), 'test-name (12)');
-
- account = {
- user: {
- email: 'test-email@gmail.com',
- _account_id: 12,
- },
- };
- assert.equal(element._getNameForUser(account.user), 'test-email (12)');
+ assert.equal(element._getIdForUser(account.user), ' (12)');
});
test('test _account_id not present', () => {
- let account = {
+ const account = {
user: {
username: 'test-user',
},
};
- assert.equal(element._getNameForUser(account.user), 'test-user');
-
- account = {
- user: {
- name: 'test-name',
- },
- };
- assert.equal(element._getNameForUser(account.user), 'test-name');
-
- account = {
- user: {
- email: 'test-email@gmail.com',
- },
- };
- assert.equal(element._getNameForUser(account.user), 'test-email');
+ assert.equal(element._getIdForUser(account.user), '');
});
});