diff --git a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js index a11347717a..6ec04da360 100644 --- a/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js +++ b/polygerrit-ui/app/elements/change/gr-related-changes-list/gr-related-changes-list.js @@ -121,7 +121,7 @@ if (relatedChange.change_id === currentChange.change_id) { classes.push('thisChange'); } - return classes.join(' ');; + return classes.join(' '); }, _computeLinkClass: function(change) { diff --git a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.html b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.html new file mode 100644 index 0000000000..e58f1f2ed6 --- /dev/null +++ b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.html @@ -0,0 +1,63 @@ + + + + + + + + + + diff --git a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.js b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.js new file mode 100644 index 0000000000..9248632f13 --- /dev/null +++ b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password.js @@ -0,0 +1,81 @@ +// Copyright (C) 2016 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-http-password', + + /** + * Fired when getting the password fails with non-404. + * + * @event network-error + */ + + properties: { + _serverConfig: Object, + _username: String, + _password: String, + _passwordVisible: { + type: Boolean, + value: false, + }, + _hasPassword: Boolean, + }, + + loadData: function() { + var promises = []; + + promises.push(this.$.restAPI.getAccount().then(function(account) { + this._username = account.username; + }.bind(this))); + + promises.push(this.$.restAPI + .getAccountHttpPassword(this._handleGetPasswordError.bind(this)) + .then(function(pass) { + this._password = pass; + this._hasPassword = !!pass; + }.bind(this))); + + return Promise.all(promises); + }, + + _handleGetPasswordError: function(response) { + if (response.status === 404) { + this._hasPassword = false; + } else { + this.fire('network-error', {response: response}); + } + }, + + _handleViewPasswordTap: function() { + this._passwordVisible = true; + }, + + _handleGenerateTap: function() { + this.$.restAPI.generateAccountHttpPassword().then(function(newPassword) { + this._hasPassword = true; + this._passwordVisible = true; + this._password = newPassword; + }.bind(this)); + }, + + _handleClearTap: function() { + this.$.restAPI.deleteAccountHttpPassword().then(function() { + this._password = ''; + this._hasPassword = false; + }.bind(this)); + }, + }); +})(); diff --git a/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password_test.html b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password_test.html new file mode 100644 index 0000000000..44bffe5b4e --- /dev/null +++ b/polygerrit-ui/app/elements/settings/gr-http-password/gr-http-password_test.html @@ -0,0 +1,157 @@ + + + + +gr-settings-view + + + + + + + + + + + + diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html index e5f8bee4ad..9e5a63b0d9 100644 --- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html +++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html @@ -19,6 +19,7 @@ limitations under the License. + @@ -256,6 +257,10 @@ limitations under the License. disabled="[[!_computeAddEmailButtonEnabled(_newEmail, _addingEmail)]]" on-tap="_handleAddEmailButton">Send Verification +

HTTP Credentials

+
+ +

Groups

diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js index d9525564ce..51a994e7bf 100644 --- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js +++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.js @@ -112,6 +112,8 @@ promises.push(this.$.groupList.loadData()); + promises.push(this.$.httpPass.loadData()); + this._loadingPromise = Promise.all(promises).then(function() { this._loading = false; }.bind(this)); diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html index 70b7c1c830..1935838b00 100644 --- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html +++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view_test.html @@ -119,6 +119,7 @@ limitations under the License. getAccountEmails: function() { return Promise.resolve(); }, getConfig: function() { return Promise.resolve(config); }, getAccountGroups: function() { return Promise.resolve([]); }, + getAccountHttpPassword: function() { return Promise.resolve(''); }, }); element = fixture('basic'); 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 410f7db341..abf5f94050 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 @@ -835,5 +835,19 @@ return this.send('PUT', '/changes/' + encodeURIComponent(changeNum) + '/topic', {topic: topic}); }, + + getAccountHttpPassword: function(opt_errFn) { + return this._fetchSharedCacheURL('/accounts/self/password.http', + opt_errFn); + }, + + deleteAccountHttpPassword: function() { + return this.send('DELETE', '/accounts/self/password.http'); + }, + + generateAccountHttpPassword: function() { + return this.send('PUT', '/accounts/self/password.http', {generate: true}) + .then(this.getResponseObject); + }, }); })(); diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html index 949c454b0b..e9f0031351 100644 --- a/polygerrit-ui/app/test/index.html +++ b/polygerrit-ui/app/test/index.html @@ -57,6 +57,7 @@ limitations under the License. 'settings/gr-account-info/gr-account-info_test.html', 'settings/gr-email-editor/gr-email-editor_test.html', 'settings/gr-group-list/gr-group-list_test.html', + 'settings/gr-http-password/gr-http-password_test.html', 'settings/gr-menu-editor/gr-menu-editor_test.html', 'settings/gr-settings-view/gr-settings-view_test.html', 'settings/gr-watched-projects-editor/gr-watched-projects-editor_test.html',