diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html index 25eacc2b7d..d8c85ea260 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html @@ -21,6 +21,7 @@ limitations under the License. + @@ -260,10 +261,19 @@ limitations under the License.
-

Commit message

- +

+ Commit message + Edit +

+ + +
diff --git a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.html b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.html new file mode 100644 index 0000000000..f6507e1cb5 --- /dev/null +++ b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.html @@ -0,0 +1,59 @@ + + + + + + + + + diff --git a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.js b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.js new file mode 100644 index 0000000000..3eb7405db8 --- /dev/null +++ b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content.js @@ -0,0 +1,70 @@ +// 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-editable-content', + + /** + * Fired when the save button is pressed. + * + * @event editable-content-save + */ + + /** + * Fired when the cancel button is pressed. + * + * @event editable-content-cancel + */ + + properties: { + content: { + type: String, + notify: true, + }, + disabled: { + type: Boolean, + reflectToAttribute: true, + }, + editing: { + type: Boolean, + value: false, + observer: '_editingChanged', + }, + + _newContent: String, + }, + + focusTextarea: function() { + this.$$('iron-autogrow-textarea').textarea.focus(); + }, + + _editingChanged: function(editing) { + if (!editing) { return; } + this._newContent = this.content; + }, + + _handleSave: function(e) { + e.preventDefault(); + this.fire('editable-content-save', {content: this._newContent}); + }, + + _handleCancel: function(e) { + e.preventDefault(); + this.editing = false; + this.fire('editable-content-cancel'); + }, + }); +})(); diff --git a/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content_test.html b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content_test.html new file mode 100644 index 0000000000..bfeb4be8e4 --- /dev/null +++ b/polygerrit-ui/app/elements/shared/gr-editable-content/gr-editable-content_test.html @@ -0,0 +1,64 @@ + + + + +gr-editable-content + + + + + + + + + + + + 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 162c954316..75b1e1a237 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 @@ -506,6 +506,16 @@ return this.send('POST', url, review, opt_errFn, opt_ctx); }, + saveChangeCommitMessageEdit: function(changeNum, message) { + var url = this.getChangeActionURL(changeNum, null, '/edit:message'); + return this.send('PUT', url, {message: message}); + }, + + publishChangeEdit: function(changeNum) { + return this.send('POST', + this.getChangeActionURL(changeNum, null, '/edit:publish')); + }, + saveChangeStarred: function(changeNum, starred) { var url = '/accounts/self/starred.changes/' + changeNum; var method = starred ? 'PUT' : 'DELETE'; diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html index 565a8d9d06..6fe3a08a31 100644 --- a/polygerrit-ui/app/test/index.html +++ b/polygerrit-ui/app/test/index.html @@ -60,6 +60,7 @@ limitations under the License. 'shared/gr-confirm-dialog/gr-confirm-dialog_test.html', 'shared/gr-cursor-manager/gr-cursor-manager_test.html', 'shared/gr-date-formatter/gr-date-formatter_test.html', + 'shared/gr-editable-content/gr-editable-content_test.html', 'shared/gr-js-api-interface/gr-js-api-interface_test.html', 'shared/gr-editable-label/gr-editable-label_test.html', 'shared/gr-linked-text/gr-linked-text_test.html',