Add url pattern to navigate to comment in diff view
/c/<project>/+/<changeNum>/comment/<commentId>/
This pattern will be used in the emails generated by the backend,
allowing the frontend to resolve this url into patchNum vs
latestPatchNum, instead of Base vs patchNum.
Change-Id: I52cde7cec61cad9be46f509c0a015e5ed1f1fb3e
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 60722d3..79891ee 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.js
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.js
@@ -133,6 +133,12 @@
// Matches /c/<project>/+/<changeNum>/[<patchNum|edit>],edit
CHANGE_EDIT: /^\/c\/(.+)\/\+\/(\d+)(\/(\d+))?,edit\/?$/,
+ // Matches /c/<project>/+/<changeNum>/comment/<commentId>/
+ // Navigates to the diff view
+ // This route is needed to resolve to patchNum vs latestPatchNum used in the
+ // links generated in the emails.
+ COMMENT: /^\/c\/(.+)\/\+\/(\d+)\/comment\/(\w+)\/?$/,
+
// Matches
// /c/<project>/+/<changeNum>/[<basePatchNum|edit>..]<patchNum|edit>/<path>.
// TODO(kaspern): Migrate completely to project based URLs, with backwards
@@ -166,6 +172,8 @@
DOCUMENTATION: /^\/Documentation(\/)?(.+)?/,
};
+export const _testOnly_RoutePattern = RoutePattern;
+
/**
* Pattern to recognize and parse the diff line locations as they appear in
* the hash of diff URLs. In this format, a number on its own indicates that
@@ -877,6 +885,8 @@
this._mapRoute(RoutePattern.CHANGE_EDIT, '_handleChangeEditRoute', true);
+ this._mapRoute(RoutePattern.COMMENT, '_handleCommentRoute');
+
this._mapRoute(RoutePattern.DIFF, '_handleDiffRoute');
this._mapRoute(RoutePattern.CHANGE, '_handleChangeRoute');
@@ -1363,6 +1373,18 @@
this._redirectOrNavigate(params);
}
+ _handleCommentRoute(ctx) {
+ const params = {
+ project: ctx.params[0],
+ changeNum: ctx.params[1],
+ commentId: ctx.params[2],
+ view: GerritNav.View.DIFF,
+ commentLink: true,
+ };
+ this.reporting.setRepoName(params.project);
+ this._redirectOrNavigate(params);
+ }
+
_handleDiffRoute(ctx) {
// Parameter order is based on the regex group number matched.
const params = {