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 3f5bd13e4a..148cd342ac 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 @@ -587,6 +587,7 @@ limitations under the License. change-comments="[[_changeComments]]" project-name="[[_change.project]]" show-reply-buttons="[[_loggedIn]]" + on-message-anchor-tap="_handleMessageAnchorTap" on-reply="_handleMessageReply"> { + element.message = { + type: 'REVIEWER_UPDATE', + updated: '2016-01-12 20:24:49.448000000', + reviewer: {}, + id: '47c43261_55aa2c41', + }; + flushAsynchronousOperations(); + const stub = sinon.stub(); + element.addEventListener('message-anchor-tap', stub); + const dateEl = element.$$('.date'); + assert.ok(dateEl); + MockInteractions.tap(dateEl); + + assert.isTrue(stub.called); + assert.deepEqual(stub.lastCall.args[0].detail, {id: element.message.id}); + }); + test('votes', () => { element.message = { author: {}, diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.html b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.html index 0a7dacc759..80708a1d33 100644 --- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.html +++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.html @@ -109,7 +109,7 @@ limitations under the License. hide-automated="[[_hideAutomated]]" project-name="[[projectName]]" show-reply-button="[[showReplyButtons]]" - on-scroll-to="_handleScrollTo" + on-message-anchor-tap="_handleAnchorTap" label-extremes="[[_labelExtremes]]" data-message-id$="[[message.id]]"> diff --git a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js index 89a3523dc8..023431c57c 100644 --- a/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js +++ b/polygerrit-ui/app/elements/change/gr-messages-list/gr-messages-list.js @@ -184,8 +184,8 @@ this.handleExpandCollapse(!this._expanded); }, - _handleScrollTo(e) { - this.scrollToMessage(e.detail.message.id); + _handleAnchorTap(e) { + this.scrollToMessage(e.detail.id); }, _hasAutomatedMessages(messages) { diff --git a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html index bc31b60694..5be259c36d 100644 --- a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html +++ b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.html @@ -33,6 +33,8 @@ limitations under the License. // also be provided. // - `edit`, optional, Boolean: whether or not to load the file list with // edit controls. + // - `messageHash`, optional, String: the hash of the change message to + // scroll to. // // - Gerrit.Nav.View.SEARCH: // - `query`, optional, String: the literal search query. If provided, @@ -352,9 +354,11 @@ limitations under the License. * @param {number|string=} opt_basePatchNum The string 'PARENT' can be * used for none. * @param {boolean=} opt_isEdit + * @param {string=} opt_messageHash * @return {string} */ - getUrlForChange(change, opt_patchNum, opt_basePatchNum, opt_isEdit) { + getUrlForChange(change, opt_patchNum, opt_basePatchNum, opt_isEdit, + opt_messageHash) { if (opt_basePatchNum === PARENT_PATCHNUM) { opt_basePatchNum = undefined; } @@ -368,6 +372,7 @@ limitations under the License. basePatchNum: opt_basePatchNum, edit: opt_isEdit, host: change.internalHost || undefined, + messageHash: opt_messageHash, }); }, diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.js b/polygerrit-ui/app/elements/core/gr-router/gr-router.js index bdd0942d0c..2ea7e37356 100644 --- a/polygerrit-ui/app/elements/core/gr-router/gr-router.js +++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.js @@ -395,6 +395,9 @@ } else if (params.edit) { suffix += ',edit'; } + if (params.messageHash) { + suffix += params.messageHash; + } if (params.project) { const encodedProject = this.encodeURL(params.project, true); return `/c/${encodedProject}/+/${params.changeNum}${suffix}`; diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html index 53a7c07d21..270faf0cdd 100644 --- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html +++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.html @@ -281,6 +281,9 @@ limitations under the License. paramsWithQuery.basePatchNum = 5; assert.equal(element._generateUrl(paramsWithQuery), '/c/test/+/1234/5..10?revert&foo=bar'); + + params.messageHash = '#123'; + assert.equal(element._generateUrl(params), '/c/test/+/1234/5..10#123'); }); test('change with repo name encoding', () => {