@@ -46,6 +47,9 @@ limitations under the License.
nav a:first-of-type {
margin-right: .5em;
}
+ .hide {
+ display: none;
+ }
@media only screen and (max-width: 50em) {
.loading,
.error {
@@ -55,6 +59,9 @@ limitations under the License.
Loading...
+
{
+ assert.isNull(element._userId);
+ element._query = 'owner: foo@bar';
+ element._changes = [{owner: {email: 'foo@bar'}}];
+ flush(() => {
+ assert.equal(element._userId, 'foo@bar');
+
+ element._query = 'foo bar baz';
+ element._changes = [{owner: {email: 'foo@bar'}}];
+ assert.isNull(element._userId);
+
+ done();
+ });
+ });
+
suite('query based navigation', () => {
test('Searching for a change ID redirects to change', done => {
sandbox.stub(element, '_getChanges')
diff --git a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.html b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.html
new file mode 100644
index 0000000000..9a7ca336ed
--- /dev/null
+++ b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.html
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
diff --git a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.js b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.js
new file mode 100644
index 0000000000..dd3512ae53
--- /dev/null
+++ b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header.js
@@ -0,0 +1,68 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+(function() {
+ 'use strict';
+
+ Polymer({
+ is: 'gr-user-header',
+ properties: {
+ /** @type {?String} */
+ userId: {
+ type: String,
+ observer: '_accountChanged',
+ },
+
+ /**
+ * @type {?{name: ?, email: ?, registered_on: ?}}
+ */
+ _accountDetails: {
+ type: Object,
+ value: null,
+ },
+
+ /** @type {?String} */
+ _status: {
+ type: String,
+ value: null,
+ },
+ },
+
+ _accountChanged(userId) {
+ if (!userId) {
+ this._accountDetails = null;
+ this._status = null;
+ return;
+ }
+
+ this.$.restAPI.getAccountDetails(userId).then(details => {
+ this._accountDetails = details;
+ });
+ this.$.restAPI.getAccountStatus(userId).then(status => {
+ this._status = status;
+ });
+ },
+
+ _computeDisplayClass(status) {
+ return status ? ' ' : 'hide';
+ },
+
+ _computeDetail(accountDetails, name) {
+ return accountDetails ? accountDetails[name] : '';
+ },
+
+ _computeStatusClass(accountDetails) {
+ return this._computeDetail(accountDetails, 'status') ? '' : 'hide';
+ },
+ });
+})();
diff --git a/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header_test.html b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header_test.html
new file mode 100644
index 0000000000..ab3b249589
--- /dev/null
+++ b/polygerrit-ui/app/elements/change-list/gr-user-header/gr-user-header_test.html
@@ -0,0 +1,72 @@
+
+
+
+
+gr-user-header
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
index 4e0f3b7235..5153fb0575 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
@@ -486,6 +486,14 @@
});
},
+ /**
+ * @param {string} userId the ID of the user usch as an email address.
+ * @return {!Promise}
+ */
+ getAccountDetails(userId) {
+ return this.fetchJSON(`/accounts/${encodeURIComponent(userId)}/detail`);
+ },
+
getAccountEmails() {
return this._fetchSharedCacheURL('/accounts/self/emails');
},
@@ -579,6 +587,10 @@
});
},
+ getAccountStatus(userId) {
+ return this.fetchJSON(`/accounts/${encodeURIComponent(userId)}/status`);
+ },
+
getAccountGroups() {
return this._fetchSharedCacheURL('/accounts/self/groups');
},
diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html
index 7c8b6ffd71..2e8f1424f0 100644
--- a/polygerrit-ui/app/test/index.html
+++ b/polygerrit-ui/app/test/index.html
@@ -52,6 +52,7 @@ limitations under the License.
'change-list/gr-change-list-item/gr-change-list-item_test.html',
'change-list/gr-change-list-view/gr-change-list-view_test.html',
'change-list/gr-change-list/gr-change-list_test.html',
+ 'change-list/gr-user-header/gr-user-header_test.html',
'change/gr-account-entry/gr-account-entry_test.html',
'change/gr-account-list/gr-account-list_test.html',
'change/gr-change-actions/gr-change-actions_test.html',