Use view state objects in `GenerateUrlParameters`
Start with repo, group and dashboard.
Release-Notes: skip
Google-Bug-Id: b/244279450
Change-Id: Icfa8b8b0336d89a7494d86b72593951f97e91e02
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
index e2b81ba..a20a389 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view.ts
@@ -42,10 +42,9 @@
import {customElement, property, state} from 'lit/decorators.js';
import {ifDefined} from 'lit/directives/if-defined.js';
import {ValueChangedEvent} from '../../../types/events';
-import {GroupDetailView, RepoDetailView} from '../../../utils/router-util';
import {AdminChildView, AdminViewState} from '../../../models/views/admin';
-import {GroupViewState} from '../../../models/views/group';
-import {RepoViewState} from '../../../models/views/repo';
+import {GroupDetailView, GroupViewState} from '../../../models/views/group';
+import {RepoDetailView, RepoViewState} from '../../../models/views/repo';
const INTERNAL_GROUP_REGEX = /^[\da-f]{40}$/;
diff --git a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts
index 3ee7e0a..2bace2c 100644
--- a/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts
+++ b/polygerrit-ui/app/elements/admin/gr-admin-view/gr-admin-view_test.ts
@@ -20,9 +20,10 @@
import {GroupId, GroupName, RepoName, Timestamp} from '../../../types/common';
import {GrDropdownList} from '../../shared/gr-dropdown-list/gr-dropdown-list';
import {GrGroup} from '../gr-group/gr-group';
-import {GroupDetailView, RepoDetailView} from '../../../utils/router-util';
import {fixture, html, assert} from '@open-wc/testing';
import {AdminChildView} from '../../../models/views/admin';
+import {GroupDetailView} from '../../../models/views/group';
+import {RepoDetailView} from '../../../models/views/repo';
function createAdminCapabilities() {
return {
diff --git a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.ts b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.ts
index ee8be03..889a859 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog.ts
@@ -16,7 +16,7 @@
import {customElement, property, state} from 'lit/decorators.js';
import {BindValueChangeEvent} from '../../../types/events';
import {fireEvent} from '../../../utils/event-util';
-import {RepoDetailView} from '../../../utils/router-util';
+import {RepoDetailView} from '../../../models/views/repo';
declare global {
interface HTMLElementTagNameMap {
diff --git a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.ts b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.ts
index 6188b5f..9e455d1 100644
--- a/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.ts
+++ b/polygerrit-ui/app/elements/admin/gr-create-pointer-dialog/gr-create-pointer-dialog_test.ts
@@ -13,8 +13,8 @@
} from '../../../test/test-utils';
import {BranchName} from '../../../types/common';
import {IronInputElement} from '@polymer/iron-input';
-import {RepoDetailView} from '../../../utils/router-util';
import {fixture, html, assert} from '@open-wc/testing';
+import {RepoDetailView} from '../../../models/views/repo';
suite('gr-create-pointer-dialog tests', () => {
let element: GrCreatePointerDialog;
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
index cec6fde..86d4bc5 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
@@ -36,8 +36,7 @@
import {BindValueChangeEvent} from '../../../types/events';
import {assertIsDefined} from '../../../utils/common-util';
import {ifDefined} from 'lit/directives/if-defined.js';
-import {RepoDetailView} from '../../../utils/router-util';
-import {RepoViewState} from '../../../models/views/repo';
+import {RepoDetailView, RepoViewState} from '../../../models/views/repo';
const PGP_START = '-----BEGIN PGP SIGNATURE-----';
@@ -407,7 +406,7 @@
repo: RepoName | undefined,
itemsPerPage: number,
offset: number | undefined,
- detailType: string
+ detailType?: string
) {
if (filter === undefined || !repo || offset === undefined) {
return Promise.reject(new Error('filter or repo or offset undefined'));
@@ -514,7 +513,7 @@
this.repo,
this.itemsPerPage,
this.offset,
- this.detailType!
+ this.detailType
);
}
});
@@ -547,7 +546,7 @@
this.repo,
this.itemsPerPage,
this.offset,
- this.detailType!
+ this.detailType
);
}
});
@@ -561,7 +560,7 @@
this.repo,
this.itemsPerPage,
this.offset,
- this.detailType!
+ this.detailType
);
}
});
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.ts b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.ts
index bbdf99c..13f6b2b 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list_test.ts
@@ -34,8 +34,8 @@
import {GrDialog} from '../../shared/gr-dialog/gr-dialog';
import {GrListView} from '../../shared/gr-list-view/gr-list-view';
import {SHOWN_ITEMS_COUNT} from '../../../constants/constants';
-import {RepoDetailView} from '../../../utils/router-util';
import {fixture, html, assert} from '@open-wc/testing';
+import {RepoDetailView} from '../../../models/views/repo';
function branchGenerator(counter: number) {
return {
diff --git a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts
index 46cb2f0..9d01e00 100644
--- a/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts
+++ b/polygerrit-ui/app/elements/core/gr-navigation/gr-navigation.ts
@@ -28,9 +28,9 @@
import {
DashboardSection,
GenerateUrlParameters,
- GroupDetailView,
- RepoDetailView,
} from '../../../utils/router-util';
+import {RepoDetailView} from '../../../models/views/repo';
+import {GroupDetailView} from '../../../models/views/group';
// Navigation parameters object format:
//
@@ -617,7 +617,7 @@
getUrlForRepoDashboard(repo: RepoName, dashboard: DashboardId) {
return this._getUrlFor({
view: GerritView.DASHBOARD,
- repo,
+ project: repo,
dashboard,
});
},
@@ -632,11 +632,11 @@
this._navigate(relativeUrl);
},
- getUrlForRepo(repoName: RepoName) {
+ getUrlForRepo(repo: RepoName) {
return this._getUrlFor({
view: GerritView.REPO,
detail: RepoDetailView.GENERAL,
- repoName,
+ repo,
});
},
@@ -647,42 +647,42 @@
this._navigate(this.getUrlForRepo(repoName));
},
- getUrlForRepoTags(repoName: RepoName) {
+ getUrlForRepoTags(repo: RepoName) {
return this._getUrlFor({
view: GerritView.REPO,
- repoName,
+ repo,
detail: RepoDetailView.TAGS,
});
},
- getUrlForRepoBranches(repoName: RepoName) {
+ getUrlForRepoBranches(repo: RepoName) {
return this._getUrlFor({
view: GerritView.REPO,
- repoName,
+ repo,
detail: RepoDetailView.BRANCHES,
});
},
- getUrlForRepoAccess(repoName: RepoName) {
+ getUrlForRepoAccess(repo: RepoName) {
return this._getUrlFor({
view: GerritView.REPO,
- repoName,
+ repo,
detail: RepoDetailView.ACCESS,
});
},
- getUrlForRepoCommands(repoName: RepoName) {
+ getUrlForRepoCommands(repo: RepoName) {
return this._getUrlFor({
view: GerritView.REPO,
- repoName,
+ repo,
detail: RepoDetailView.COMMANDS,
});
},
- getUrlForRepoDashboards(repoName: RepoName) {
+ getUrlForRepoDashboards(repo: RepoName) {
return this._getUrlFor({
view: GerritView.REPO,
- repoName,
+ repo,
detail: RepoDetailView.DASHBOARDS,
});
},
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 804a2fd..9719c99 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -50,8 +50,6 @@
GenerateUrlChangeViewParameters,
GenerateUrlDiffViewParameters,
GenerateUrlParameters,
- GroupDetailView,
- RepoDetailView,
} from '../../../utils/router-util';
import {
LATEST_ATTEMPT,
@@ -59,6 +57,8 @@
} from '../../../models/checks/checks-util';
import {AdminChildView} from '../../../models/views/admin';
import {AgreementViewState} from '../../../models/views/agreement';
+import {RepoDetailView} from '../../../models/views/repo';
+import {GroupDetailView} from '../../../models/views/group';
const RoutePattern = {
ROOT: '/',
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
index af67b2a..5f8c278 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
@@ -38,13 +38,13 @@
import {AppElementParams} from '../../gr-app-types';
import {
GenerateUrlParameters,
- GroupDetailView,
GenerateUrlEditViewParameters,
GenerateUrlChangeViewParameters,
- RepoDetailView,
} from '../../../utils/router-util';
import {assert} from '@open-wc/testing';
import {AdminChildView} from '../../../models/views/admin';
+import {RepoDetailView} from '../../../models/views/repo';
+import {GroupDetailView} from '../../../models/views/group';
suite('gr-router tests', () => {
let router: GrRouter;