Temporary workaround for a bug in page.js
Release-Notes: skip
Google-Bug-Id: b/267172750
Change-Id: I132f3f890317164ced78b815b37bf6d1781a9b75
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
index a841958..264560b 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -172,12 +172,17 @@
PLUGINS: /^\/plugins\/(.+)$/,
+ // TODO: The first capturing group in the next 3 patterns works around a bug
+ // in page.js that is fixed in version 1.11.6. Remove it when the new version
+ // is being used at Google.
+ // https://github.com/visionmedia/page.js/commit/60f764b0ca9ad55133bc373914e97a8927a8f2d5
+
// Matches /admin/plugins with optional filter and offset.
- PLUGIN_LIST: /^\/admin\/plugins\/?(?:\/q\/filter:(.*?))?(?:,(\d+))?$/,
+ PLUGIN_LIST: /^(\/admin\/plugins)\/?(?:\/q\/filter:(.*?))?(?:,(\d+))?$/,
// Matches /admin/groups with optional filter and offset.
- GROUP_LIST: /^\/admin\/groups\/?(?:\/q\/filter:(.*?))?(?:,(\d+))?$/,
+ GROUP_LIST: /^(\/admin\/groups)\/?(?:\/q\/filter:(.*?))?(?:,(\d+))?$/,
// Matches /admin/repos with optional filter and offset.
- REPO_LIST: /^\/admin\/repos\/?(?:\/q\/filter:(.*?))?(?:,(\d+))?$/,
+ REPO_LIST: /^(\/admin\/repos)\/?(?:\/q\/filter:(.*?))?(?:,(\d+))?$/,
// Matches /admin/repos/$REPO,branches with optional filter and offset.
BRANCH_LIST:
/^\/admin\/repos\/(.+),branches\/?(?:\/q\/filter:(.*?))?(?:,(\d+))?$/,
@@ -1082,10 +1087,10 @@
const state: AdminViewState = {
view: GerritView.ADMIN,
adminView: AdminChildView.GROUPS,
- offset: ctx.params[1] ?? '0',
- filter: ctx.params[0] ?? null,
+ offset: ctx.params[2] ?? '0',
+ filter: ctx.params[1] ?? null,
openCreateModal:
- !ctx.params[0] && !ctx.params[1] && ctx.hash === 'create',
+ !ctx.params[1] && !ctx.params[2] && ctx.hash === 'create',
};
// Note that router model view must be updated before view models.
this.setState(state);
@@ -1204,10 +1209,10 @@
const state: AdminViewState = {
view: GerritView.ADMIN,
adminView: AdminChildView.REPOS,
- offset: ctx.params[1] ?? '0',
- filter: ctx.params[0] ?? null,
+ offset: ctx.params[2] ?? '0',
+ filter: ctx.params[1] ?? null,
openCreateModal:
- !ctx.params[0] && !ctx.params[1] && ctx.hash === 'create',
+ !ctx.params[1] && !ctx.params[2] && ctx.hash === 'create',
};
// Note that router model view must be updated before view models.
this.setState(state);
@@ -1234,8 +1239,8 @@
const state: AdminViewState = {
view: GerritView.ADMIN,
adminView: AdminChildView.PLUGINS,
- offset: ctx.params[1] ?? '0',
- filter: ctx.params[0] ?? null,
+ offset: ctx.params[2] ?? '0',
+ filter: ctx.params[1] ?? null,
};
// Note that router model view must be updated before view models.
this.setState(state);