Fix issue where topics and assignees can't get set if same change id There was an issue where multiple changes can have the same change ID (on different branches). If one change is submitted and then cherry-picked onto another branch, the topic or assignee can't be set on the cherry-picked CL. These endpoints accept multiple values to identify the change. This change replaces the change-id with the change-number, which is not repeated in instances like this. This is the same way that GWT makes its API requests as well. This eliminates the error. Bug: Issue 5081 Change-Id: I48f27660bc19f80da826ef684c1f452c0ca8295c
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js index f16dc8a..8504a51 100644 --- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js +++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata.js
@@ -66,11 +66,11 @@ if (this.change.assignee && acct._account_id === this.change.assignee._account_id) { return; } this.set(['change', 'assignee'], acct); - this.$.restAPI.setAssignee(this.change.change_id, acct._account_id); + this.$.restAPI.setAssignee(this.change._number, acct._account_id); } else { if (!this.change.assignee) { return; } this.set(['change', 'assignee'], undefined); - this.$.restAPI.deleteAssignee(this.change.change_id); + this.$.restAPI.deleteAssignee(this.change._number); } }, @@ -119,7 +119,7 @@ _handleTopicChanged: function(e, topic) { if (!topic.length) { topic = null; } - this.$.restAPI.setChangeTopic(this.change.change_id, topic); + this.$.restAPI.setChangeTopic(this.change._number, topic); }, _computeTopicReadOnly: function(mutable, change) { @@ -207,7 +207,7 @@ _handleTopicRemoved: function() { this.set(['change', 'topic'], ''); - this.$.restAPI.setChangeTopic(this.change.change_id, null); + this.$.restAPI.setChangeTopic(this.change._number, null); }, }); })();
diff --git a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html index b2c0fc9..b7c2fed 100644 --- a/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-metadata/gr-change-metadata_test.html
@@ -103,6 +103,7 @@ sandbox.stub(element, '_computeValueTooltip').returns(''); sandbox.stub(element, '_computeTopicReadOnly').returns(true); element.change = { + _number: 'the number', change_id: 'the id', topic: 'the topic', status: 'NEW', @@ -171,7 +172,7 @@ var topicStub = sandbox.stub(element.$.restAPI, 'setChangeTopic', function() {}); element._handleTopicChanged({}, 'the new topic'); - assert.isTrue(topicStub.calledWith('the id', 'the new topic')); + assert.isTrue(topicStub.calledWith('the number', 'the new topic')); }); test('clicking x on topic chip removes topic', function() {