Replace ProjectName type to RepoName

Also UrlEncodedProjectName to UrlEncodedRepoName

Change-Id: I5cdeec59aa3f1463f9afd3a2bd4730cb6a4e4eb9
This commit is contained in:
Tao Zhou
2020-08-19 11:52:07 +02:00
parent 350f29cfaf
commit e544d2586f
7 changed files with 92 additions and 94 deletions

View File

@@ -27,7 +27,7 @@ import {htmlTemplate} from './gr-create-pointer-dialog_html';
import {encodeURL, getBaseUrl} from '../../../utils/url-util'; import {encodeURL, getBaseUrl} from '../../../utils/url-util';
import {page} from '../../../utils/page-wrapper-utils'; import {page} from '../../../utils/page-wrapper-utils';
import {customElement, property, observe} from '@polymer/decorators'; import {customElement, property, observe} from '@polymer/decorators';
import {BranchName, ProjectName} from '../../../types/common'; import {BranchName, RepoName} from '../../../types/common';
import {RestApiService} from '../../../services/services/gr-rest-api/gr-rest-api'; import {RestApiService} from '../../../services/services/gr-rest-api/gr-rest-api';
enum DetailType { enum DetailType {
@@ -53,7 +53,7 @@ export class GrCreatePointerDialog extends GestureEventListeners(
detailType?: string; detailType?: string;
@property({type: String}) @property({type: String})
repoName?: ProjectName; repoName?: RepoName;
@property({type: Boolean, notify: true}) @property({type: Boolean, notify: true})
hasNewItemName = false; hasNewItemName = false;

View File

@@ -25,7 +25,7 @@ import {PolymerElement} from '@polymer/polymer/polymer-element';
import {htmlTemplate} from './gr-repo-header_html'; import {htmlTemplate} from './gr-repo-header_html';
import {GerritNav} from '../../core/gr-navigation/gr-navigation'; import {GerritNav} from '../../core/gr-navigation/gr-navigation';
import {customElement, property} from '@polymer/decorators'; import {customElement, property} from '@polymer/decorators';
import {ProjectName} from '../../../types/common'; import {RepoName} from '../../../types/common';
/** @extends PolymerElement */ /** @extends PolymerElement */
@customElement('gr-repo-header') @customElement('gr-repo-header')
@@ -42,7 +42,7 @@ class GrRepoHeader extends GestureEventListeners(
@property({type: String}) @property({type: String})
_repoUrl: string | null = null; _repoUrl: string | null = null;
_repoChanged(repoName: ProjectName) { _repoChanged(repoName: RepoName) {
if (!repoName) { if (!repoName) {
this._repoUrl = null; this._repoUrl = null;
return; return;

View File

@@ -18,7 +18,7 @@ import {
BranchName, BranchName,
ChangeInfo, ChangeInfo,
PatchSetNum, PatchSetNum,
ProjectName, RepoName,
TopicName, TopicName,
GroupId, GroupId,
DashboardId, DashboardId,
@@ -230,7 +230,7 @@ export interface GenerateUrlSearchViewParameters {
view: GerritView.SEARCH; view: GerritView.SEARCH;
query?: string; query?: string;
offset?: number; offset?: number;
project?: ProjectName; project?: RepoName;
branch?: BranchName; branch?: BranchName;
topic?: TopicName; topic?: TopicName;
// TODO(TS): Define more precise type (enum?) // TODO(TS): Define more precise type (enum?)
@@ -244,7 +244,7 @@ export interface GenerateUrlChangeViewParameters {
view: GerritView.CHANGE; view: GerritView.CHANGE;
// TODO(TS): NumericChangeId - not sure about it, may be it can be removeds // TODO(TS): NumericChangeId - not sure about it, may be it can be removeds
changeNum: NumericChangeId | LegacyChangeId; changeNum: NumericChangeId | LegacyChangeId;
project: ProjectName; project: RepoName;
patchNum?: PatchSetNum; patchNum?: PatchSetNum;
basePatchNum?: PatchSetNum; basePatchNum?: PatchSetNum;
edit?: boolean; edit?: boolean;
@@ -254,14 +254,14 @@ export interface GenerateUrlChangeViewParameters {
export interface GenerateUrlRepoViewParameters { export interface GenerateUrlRepoViewParameters {
view: GerritView.REPO; view: GerritView.REPO;
repoName: ProjectName; repoName: RepoName;
detail?: RepoDetailView; detail?: RepoDetailView;
} }
export interface GenerateUrlDashboardViewParameters { export interface GenerateUrlDashboardViewParameters {
view: GerritView.DASHBOARD; view: GerritView.DASHBOARD;
user?: string; user?: string;
repo?: ProjectName; repo?: RepoName;
dashboard?: DashboardId; dashboard?: DashboardId;
} }
@@ -274,7 +274,7 @@ export interface GenerateUrlGroupViewParameters {
export interface GenerateUrlEditViewParameters { export interface GenerateUrlEditViewParameters {
view: GerritView.EDIT; view: GerritView.EDIT;
changeNum: NumericChangeId | LegacyChangeId; changeNum: NumericChangeId | LegacyChangeId;
project: ProjectName; project: RepoName;
path: string; path: string;
patchNum: PatchSetNum; patchNum: PatchSetNum;
lineNum?: number; lineNum?: number;
@@ -291,7 +291,7 @@ export interface GenerateUrlSettingsViewParameters {
export interface GenerateUrlDiffViewParameters { export interface GenerateUrlDiffViewParameters {
view: GerritView.DIFF; view: GerritView.DIFF;
changeNum: NumericChangeId | LegacyChangeId; changeNum: NumericChangeId | LegacyChangeId;
project: ProjectName; project: RepoName;
path?: string; path?: string;
patchNum?: PatchSetNum; patchNum?: PatchSetNum;
basePatchNum?: PatchSetNum | ParentPatchSetNum; basePatchNum?: PatchSetNum | ParentPatchSetNum;
@@ -313,14 +313,14 @@ export type GenerateUrlParameters =
export interface GenerateWebLinksPatchsetParameters { export interface GenerateWebLinksPatchsetParameters {
type: WeblinkType.PATCHSET; type: WeblinkType.PATCHSET;
repo: ProjectName; repo: RepoName;
commit: CommitId; commit: CommitId;
// TODO(TS): provide better typing // TODO(TS): provide better typing
options?: unknown; options?: unknown;
} }
export interface GenerateWebLinksFileParameters { export interface GenerateWebLinksFileParameters {
type: WeblinkType.FILE; type: WeblinkType.FILE;
repo: ProjectName; repo: RepoName;
commit: CommitId; commit: CommitId;
file: string; file: string;
// TODO(TS): provide better typing // TODO(TS): provide better typing
@@ -328,7 +328,7 @@ export interface GenerateWebLinksFileParameters {
} }
export interface GenerateWebLinksChangeParameters { export interface GenerateWebLinksChangeParameters {
type: WeblinkType.CHANGE; type: WeblinkType.CHANGE;
repo: ProjectName; repo: RepoName;
commit: CommitId; commit: CommitId;
// TODO(TS): provide better typing // TODO(TS): provide better typing
options?: unknown; options?: unknown;
@@ -479,7 +479,7 @@ export const GerritNav = {
* @param host The host in which to search. * @param host The host in which to search.
*/ */
getUrlForProjectChanges( getUrlForProjectChanges(
project: ProjectName, project: RepoName,
openOnly?: boolean, openOnly?: boolean,
host?: string host?: string
) { ) {
@@ -497,7 +497,7 @@ export const GerritNav = {
*/ */
getUrlForBranch( getUrlForBranch(
branch: BranchName, branch: BranchName,
project: ProjectName, project: RepoName,
status?: string, status?: string,
host?: string host?: string
) { ) {
@@ -589,7 +589,7 @@ export const GerritNav = {
getUrlForChangeById( getUrlForChangeById(
changeNum: NumericChangeId, changeNum: NumericChangeId,
project: ProjectName, project: RepoName,
patchNum?: PatchSetNum patchNum?: PatchSetNum
) { ) {
return this._getUrlFor({ return this._getUrlFor({
@@ -642,7 +642,7 @@ export const GerritNav = {
getUrlForComment( getUrlForComment(
changeNum: NumericChangeId | LegacyChangeId, changeNum: NumericChangeId | LegacyChangeId,
project: ProjectName, project: RepoName,
commentId: UrlEncodedCommentId commentId: UrlEncodedCommentId
) { ) {
return this._getUrlFor({ return this._getUrlFor({
@@ -658,7 +658,7 @@ export const GerritNav = {
*/ */
getUrlForDiffById( getUrlForDiffById(
changeNum: NumericChangeId | LegacyChangeId, changeNum: NumericChangeId | LegacyChangeId,
project: ProjectName, project: RepoName,
filePath: string, filePath: string,
patchNum?: PatchSetNum, patchNum?: PatchSetNum,
basePatchNum?: PatchSetNum | ParentPatchSetNum, basePatchNum?: PatchSetNum | ParentPatchSetNum,
@@ -704,7 +704,7 @@ export const GerritNav = {
*/ */
getEditUrlForDiffById( getEditUrlForDiffById(
changeNum: NumericChangeId | LegacyChangeId, changeNum: NumericChangeId | LegacyChangeId,
project: ProjectName, project: RepoName,
filePath: string, filePath: string,
patchNum?: PatchSetNum, patchNum?: PatchSetNum,
lineNum?: number lineNum?: number
@@ -763,7 +763,7 @@ export const GerritNav = {
* @param repo The name of the repo. * @param repo The name of the repo.
* @param dashboard The ID of the dashboard, in the form of '<ref>:<path>'. * @param dashboard The ID of the dashboard, in the form of '<ref>:<path>'.
*/ */
getUrlForRepoDashboard(repo: ProjectName, dashboard: DashboardId) { getUrlForRepoDashboard(repo: RepoName, dashboard: DashboardId) {
return this._getUrlFor({ return this._getUrlFor({
view: GerritView.DASHBOARD, view: GerritView.DASHBOARD,
repo, repo,
@@ -781,7 +781,7 @@ export const GerritNav = {
this._navigate(relativeUrl); this._navigate(relativeUrl);
}, },
getUrlForRepo(repoName: ProjectName) { getUrlForRepo(repoName: RepoName) {
return this._getUrlFor({ return this._getUrlFor({
view: GerritView.REPO, view: GerritView.REPO,
repoName, repoName,
@@ -791,11 +791,11 @@ export const GerritNav = {
/** /**
* Navigate to a repo settings page. * Navigate to a repo settings page.
*/ */
navigateToRepo(repoName: ProjectName) { navigateToRepo(repoName: RepoName) {
this._navigate(this.getUrlForRepo(repoName)); this._navigate(this.getUrlForRepo(repoName));
}, },
getUrlForRepoTags(repoName: ProjectName) { getUrlForRepoTags(repoName: RepoName) {
return this._getUrlFor({ return this._getUrlFor({
view: GerritView.REPO, view: GerritView.REPO,
repoName, repoName,
@@ -803,7 +803,7 @@ export const GerritNav = {
}); });
}, },
getUrlForRepoBranches(repoName: ProjectName) { getUrlForRepoBranches(repoName: RepoName) {
return this._getUrlFor({ return this._getUrlFor({
view: GerritView.REPO, view: GerritView.REPO,
repoName, repoName,
@@ -811,7 +811,7 @@ export const GerritNav = {
}); });
}, },
getUrlForRepoAccess(repoName: ProjectName) { getUrlForRepoAccess(repoName: RepoName) {
return this._getUrlFor({ return this._getUrlFor({
view: GerritView.REPO, view: GerritView.REPO,
repoName, repoName,
@@ -819,7 +819,7 @@ export const GerritNav = {
}); });
}, },
getUrlForRepoCommands(repoName: ProjectName) { getUrlForRepoCommands(repoName: RepoName) {
return this._getUrlFor({ return this._getUrlFor({
view: GerritView.REPO, view: GerritView.REPO,
repoName, repoName,
@@ -827,7 +827,7 @@ export const GerritNav = {
}); });
}, },
getUrlForRepoDashboards(repoName: ProjectName) { getUrlForRepoDashboards(repoName: RepoName) {
return this._getUrlFor({ return this._getUrlFor({
view: GerritView.REPO, view: GerritView.REPO,
repoName, repoName,
@@ -863,7 +863,7 @@ export const GerritNav = {
}, },
getFileWebLinks( getFileWebLinks(
repo: ProjectName, repo: RepoName,
commit: CommitId, commit: CommitId,
file: string, file: string,
options?: unknown options?: unknown
@@ -881,7 +881,7 @@ export const GerritNav = {
}, },
getPatchSetWeblink( getPatchSetWeblink(
repo: ProjectName, repo: RepoName,
commit: CommitId, commit: CommitId,
options?: unknown options?: unknown
): WebLink { ): WebLink {
@@ -905,7 +905,7 @@ export const GerritNav = {
}, },
getChangeWeblinks( getChangeWeblinks(
repo: ProjectName, repo: RepoName,
commit: CommitId, commit: CommitId,
options?: unknown options?: unknown
): WebLink[] { ): WebLink[] {

View File

@@ -100,7 +100,7 @@ import {
ProjectInfo, ProjectInfo,
ProjectInput, ProjectInput,
ProjectWatchInfo, ProjectWatchInfo,
ProjectName, RepoName,
ReviewInput, ReviewInput,
RobotCommentInfo, RobotCommentInfo,
ServerInfo, ServerInfo,
@@ -153,7 +153,7 @@ let siteBasedCache = new SiteBasedCache(); // Shared across instances.
let fetchPromisesCache = new FetchPromisesCache(); // Shared across instances. let fetchPromisesCache = new FetchPromisesCache(); // Shared across instances.
let pendingRequest: {[promiseName: string]: Array<Promise<unknown>>} = {}; // Shared across instances. let pendingRequest: {[promiseName: string]: Array<Promise<unknown>>} = {}; // Shared across instances.
let grEtagDecorator = new GrEtagDecorator(); // Shared across instances. let grEtagDecorator = new GrEtagDecorator(); // Shared across instances.
let projectLookup: {[changeNum: string]: ProjectName} = {}; // Shared across instances. let projectLookup: {[changeNum: string]: RepoName} = {}; // Shared across instances.
export type ChangeNum = number; // !!!TODO: define correct types export type ChangeNum = number; // !!!TODO: define correct types
@@ -365,7 +365,7 @@ export class GrRestApiInterface
} }
getRepo( getRepo(
repo: ProjectName, repo: RepoName,
errFn?: ErrorCallback errFn?: ErrorCallback
): Promise<ProjectInfo | undefined> { ): Promise<ProjectInfo | undefined> {
// TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend // TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend
@@ -378,7 +378,7 @@ export class GrRestApiInterface
} }
getProjectConfig( getProjectConfig(
repo: ProjectName, repo: RepoName,
errFn?: ErrorCallback errFn?: ErrorCallback
): Promise<ConfigInfo | undefined> { ): Promise<ConfigInfo | undefined> {
// TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend // TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend
@@ -390,7 +390,7 @@ export class GrRestApiInterface
}) as Promise<ConfigInfo | undefined>; }) as Promise<ConfigInfo | undefined>;
} }
getRepoAccess(repo: ProjectName): Promise<ProjectAccessInfoMap | undefined> { getRepoAccess(repo: RepoName): Promise<ProjectAccessInfoMap | undefined> {
// TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend // TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend
// supports it. // supports it.
return this._fetchSharedCacheURL({ return this._fetchSharedCacheURL({
@@ -400,7 +400,7 @@ export class GrRestApiInterface
} }
getRepoDashboards( getRepoDashboards(
repo: ProjectName, repo: RepoName,
errFn?: ErrorCallback errFn?: ErrorCallback
): Promise<DashboardInfo[] | undefined> { ): Promise<DashboardInfo[] | undefined> {
// TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend // TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend
@@ -412,16 +412,16 @@ export class GrRestApiInterface
}) as Promise<DashboardInfo[] | undefined>; }) as Promise<DashboardInfo[] | undefined>;
} }
saveRepoConfig(repo: ProjectName, config: ConfigInput): Promise<Response>; saveRepoConfig(repo: RepoName, config: ConfigInput): Promise<Response>;
saveRepoConfig( saveRepoConfig(
repo: ProjectName, repo: RepoName,
config: ConfigInput, config: ConfigInput,
errFn: ErrorCallback errFn: ErrorCallback
): Promise<Response | undefined>; ): Promise<Response | undefined>;
saveRepoConfig( saveRepoConfig(
repo: ProjectName, repo: RepoName,
config: ConfigInput, config: ConfigInput,
errFn?: ErrorCallback errFn?: ErrorCallback
): Promise<Response | undefined> { ): Promise<Response | undefined> {
@@ -438,14 +438,14 @@ export class GrRestApiInterface
}); });
} }
runRepoGC(repo: ProjectName): Promise<Response>; runRepoGC(repo: RepoName): Promise<Response>;
runRepoGC( runRepoGC(
repo: ProjectName, repo: RepoName,
errFn: ErrorCallback errFn: ErrorCallback
): Promise<Response | undefined>; ): Promise<Response | undefined>;
runRepoGC(repo: ProjectName, errFn?: ErrorCallback) { runRepoGC(repo: RepoName, errFn?: ErrorCallback) {
if (!repo) { if (!repo) {
// TODO(TS): fix return value // TODO(TS): fix return value
return ''; return '';
@@ -462,10 +462,10 @@ export class GrRestApiInterface
}); });
} }
createRepo(config: ProjectInput & {name: ProjectName}): Promise<Response>; createRepo(config: ProjectInput & {name: RepoName}): Promise<Response>;
createRepo( createRepo(
config: ProjectInput & {name: ProjectName}, config: ProjectInput & {name: RepoName},
errFn: ErrorCallback errFn: ErrorCallback
): Promise<Response | undefined>; ): Promise<Response | undefined>;
@@ -519,15 +519,15 @@ export class GrRestApiInterface
}) as Promise<GroupInfo | undefined>; }) as Promise<GroupInfo | undefined>;
} }
deleteRepoBranches(repo: ProjectName, ref: GitRef): Promise<Response>; deleteRepoBranches(repo: RepoName, ref: GitRef): Promise<Response>;
deleteRepoBranches( deleteRepoBranches(
repo: ProjectName, repo: RepoName,
ref: GitRef, ref: GitRef,
errFn: ErrorCallback errFn: ErrorCallback
): Promise<Response | undefined>; ): Promise<Response | undefined>;
deleteRepoBranches(repo: ProjectName, ref: GitRef, errFn?: ErrorCallback) { deleteRepoBranches(repo: RepoName, ref: GitRef, errFn?: ErrorCallback) {
if (!repo || !ref) { if (!repo || !ref) {
// TODO(TS): fix return value // TODO(TS): fix return value
return ''; return '';
@@ -545,15 +545,15 @@ export class GrRestApiInterface
}); });
} }
deleteRepoTags(repo: ProjectName, ref: GitRef): Promise<Response>; deleteRepoTags(repo: RepoName, ref: GitRef): Promise<Response>;
deleteRepoTags( deleteRepoTags(
repo: ProjectName, repo: RepoName,
ref: GitRef, ref: GitRef,
errFn: ErrorCallback errFn: ErrorCallback
): Promise<Response | undefined>; ): Promise<Response | undefined>;
deleteRepoTags(repo: ProjectName, ref: GitRef, errFn?: ErrorCallback) { deleteRepoTags(repo: RepoName, ref: GitRef, errFn?: ErrorCallback) {
if (!repo || !ref) { if (!repo || !ref) {
// TODO(TS): fix return type // TODO(TS): fix return type
return ''; return '';
@@ -572,20 +572,20 @@ export class GrRestApiInterface
} }
createRepoBranch( createRepoBranch(
name: ProjectName, name: RepoName,
branch: BranchName, branch: BranchName,
revision: BranchInput revision: BranchInput
): Promise<Response>; ): Promise<Response>;
createRepoBranch( createRepoBranch(
name: ProjectName, name: RepoName,
branch: BranchName, branch: BranchName,
revision: BranchInput, revision: BranchInput,
errFn: ErrorCallback errFn: ErrorCallback
): Promise<Response | undefined>; ): Promise<Response | undefined>;
createRepoBranch( createRepoBranch(
name: ProjectName, name: RepoName,
branch: BranchName, branch: BranchName,
revision: BranchInput, revision: BranchInput,
errFn?: ErrorCallback errFn?: ErrorCallback
@@ -608,20 +608,20 @@ export class GrRestApiInterface
} }
createRepoTag( createRepoTag(
name: ProjectName, name: RepoName,
tag: string, tag: string,
revision: TagInput revision: TagInput
): Promise<Response>; ): Promise<Response>;
createRepoTag( createRepoTag(
name: ProjectName, name: RepoName,
tag: string, tag: string,
revision: TagInput, revision: TagInput,
errFn: ErrorCallback errFn: ErrorCallback
): Promise<Response | undefined>; ): Promise<Response | undefined>;
createRepoTag( createRepoTag(
name: ProjectName, name: RepoName,
tag: string, tag: string,
revision: TagInput, revision: TagInput,
errFn?: ErrorCallback errFn?: ErrorCallback
@@ -1742,7 +1742,7 @@ export class GrRestApiInterface
}) as Promise<ProjectInfo | undefined>; }) as Promise<ProjectInfo | undefined>;
} }
setRepoHead(repo: ProjectName, ref: GitRef) { setRepoHead(repo: RepoName, ref: GitRef) {
// TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend // TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend
// supports it. // supports it.
return this._restApiHelper.send({ return this._restApiHelper.send({
@@ -1755,7 +1755,7 @@ export class GrRestApiInterface
getRepoBranches( getRepoBranches(
filter: string, filter: string,
repo: ProjectName, repo: RepoName,
reposBranchesPerPage: number, reposBranchesPerPage: number,
offset?: number, offset?: number,
errFn?: ErrorCallback errFn?: ErrorCallback
@@ -1776,7 +1776,7 @@ export class GrRestApiInterface
getRepoTags( getRepoTags(
filter: string, filter: string,
repo: ProjectName, repo: RepoName,
reposTagsPerPage: number, reposTagsPerPage: number,
offset?: number, offset?: number,
errFn?: ErrorCallback errFn?: ErrorCallback
@@ -1813,7 +1813,7 @@ export class GrRestApiInterface
}); });
} }
getRepoAccessRights(repoName: ProjectName, errFn?: ErrorCallback) { getRepoAccessRights(repoName: RepoName, errFn?: ErrorCallback) {
// TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend // TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend
// supports it. // supports it.
return this._restApiHelper.fetchJSON({ return this._restApiHelper.fetchJSON({
@@ -1823,7 +1823,7 @@ export class GrRestApiInterface
}); });
} }
setRepoAccessRights(repoName: ProjectName, repoInfo: ProjectAccessInput) { setRepoAccessRights(repoName: RepoName, repoInfo: ProjectAccessInput) {
// TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend // TODO(kaspern): Rename rest api from /projects/ to /repos/ once backend
// supports it. // supports it.
return this._restApiHelper.send({ return this._restApiHelper.send({
@@ -1835,7 +1835,7 @@ export class GrRestApiInterface
} }
setRepoAccessRightsForReview( setRepoAccessRightsForReview(
projectName: ProjectName, projectName: RepoName,
projectInfo: ProjectAccessInput projectInfo: ProjectAccessInput
): Promise<ChangeInfo> { ): Promise<ChangeInfo> {
return (this._restApiHelper.send({ return (this._restApiHelper.send({
@@ -1979,7 +1979,7 @@ export class GrRestApiInterface
} }
getChangeCherryPicks( getChangeCherryPicks(
project: ProjectName, project: RepoName,
changeID: ChangeId, changeID: ChangeId,
changeNum: ChangeNum changeNum: ChangeNum
) { ) {
@@ -2123,7 +2123,7 @@ export class GrRestApiInterface
} }
createChange( createChange(
project: ProjectName, project: RepoName,
branch: BranchName, branch: BranchName,
subject: string, subject: string,
topic?: string, topic?: string,
@@ -2368,10 +2368,8 @@ export class GrRestApiInterface
// alongside the change number, so resolve the project name // alongside the change number, so resolve the project name
// first. // first.
return this.getFromProjectLookup(changeNum).then(project => { return this.getFromProjectLookup(changeNum).then(project => {
const encodedProjectName = project const encodedRepoName = project ? encodeURIComponent(project) + '~' : '';
? encodeURIComponent(project) + '~' const url = `/accounts/self/starred.changes/${encodedRepoName}${changeNum}`;
: '';
const url = `/accounts/self/starred.changes/${encodedProjectName}${changeNum}`;
return this._restApiHelper.send({ return this._restApiHelper.send({
method: starred ? HttpMethod.PUT : HttpMethod.DELETE, method: starred ? HttpMethod.PUT : HttpMethod.DELETE,
url, url,
@@ -2787,7 +2785,7 @@ export class GrRestApiInterface
} }
getCommitInfo( getCommitInfo(
project: ProjectName, project: RepoName,
commit: CommitId commit: CommitId
): Promise<CommitInfo | undefined> { ): Promise<CommitInfo | undefined> {
return this._restApiHelper.fetchJSON({ return this._restApiHelper.fetchJSON({
@@ -2890,7 +2888,7 @@ export class GrRestApiInterface
_changeBaseURL( _changeBaseURL(
changeNum: ChangeNum, changeNum: ChangeNum,
patchNum?: PatchSetNum, patchNum?: PatchSetNum,
project?: ProjectName project?: RepoName
): Promise<string> { ): Promise<string> {
// TODO(kaspern): For full slicer migration, app should warn with a call // TODO(kaspern): For full slicer migration, app should warn with a call
// stack every time _changeBaseURL is called without a project. // stack every time _changeBaseURL is called without a project.
@@ -2900,7 +2898,7 @@ export class GrRestApiInterface
return projectPromise.then(project => { return projectPromise.then(project => {
// TODO(TS): unclear why project can't be null here. Fix it // TODO(TS): unclear why project can't be null here. Fix it
let url = `/changes/${encodeURIComponent( let url = `/changes/${encodeURIComponent(
project as ProjectName project as RepoName
)}~${changeNum}`; )}~${changeNum}`;
if (patchNum) { if (patchNum) {
url += `/revisions/${patchNum}`; url += `/revisions/${patchNum}`;
@@ -3207,7 +3205,7 @@ export class GrRestApiInterface
}); });
} }
setInProjectLookup(changeNum: ChangeNum, project: ProjectName) { setInProjectLookup(changeNum: ChangeNum, project: RepoName) {
if ( if (
this._projectLookup[changeNum] && this._projectLookup[changeNum] &&
this._projectLookup[changeNum] !== project this._projectLookup[changeNum] !== project
@@ -3225,7 +3223,7 @@ export class GrRestApiInterface
* project. If not, calls the restAPI to get the change, populates * project. If not, calls the restAPI to get the change, populates
* _projectLookup with the project for that change, and returns the project. * _projectLookup with the project for that change, and returns the project.
*/ */
getFromProjectLookup(changeNum: ChangeNum): Promise<ProjectName | undefined> { getFromProjectLookup(changeNum: ChangeNum): Promise<RepoName | undefined> {
const project = this._projectLookup[`${changeNum}`]; const project = this._projectLookup[`${changeNum}`];
if (project) { if (project) {
return Promise.resolve(project); return Promise.resolve(project);
@@ -3420,7 +3418,7 @@ export class GrRestApiInterface
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-dashboard * https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#get-dashboard
*/ */
getDashboard( getDashboard(
project: ProjectName, project: RepoName,
dashboard: DashboardId, dashboard: DashboardId,
errFn?: ErrorCallback errFn?: ErrorCallback
): Promise<DashboardInfo | undefined> { ): Promise<DashboardInfo | undefined> {

View File

@@ -31,7 +31,7 @@ import {
DiffPreferencesInfo, DiffPreferencesInfo,
DiffPreferenceInput, DiffPreferenceInput,
SshKeyInfo, SshKeyInfo,
ProjectName, RepoName,
BranchName, BranchName,
BranchInput, BranchInput,
TagInput, TagInput,
@@ -177,26 +177,26 @@ export interface RestApiService {
addAccountSSHKey(key: string): Promise<SshKeyInfo>; addAccountSSHKey(key: string): Promise<SshKeyInfo>;
createRepoBranch( createRepoBranch(
name: ProjectName, name: RepoName,
branch: BranchName, branch: BranchName,
revision: BranchInput revision: BranchInput
): Promise<Response>; ): Promise<Response>;
createRepoBranch( createRepoBranch(
name: ProjectName, name: RepoName,
branch: BranchName, branch: BranchName,
revision: BranchInput, revision: BranchInput,
errFn: ErrorCallback errFn: ErrorCallback
): Promise<Response | undefined>; ): Promise<Response | undefined>;
createRepoTag( createRepoTag(
name: ProjectName, name: RepoName,
tag: string, tag: string,
revision: TagInput revision: TagInput
): Promise<Response>; ): Promise<Response>;
createRepoTag( createRepoTag(
name: ProjectName, name: RepoName,
tag: string, tag: string,
revision: TagInput, revision: TagInput,
errFn: ErrorCallback errFn: ErrorCallback

View File

@@ -63,8 +63,8 @@ export type ChangeId = BrandType<string, '_changeId'>;
export type ChangeMessageId = BrandType<string, '_changeMessageId'>; export type ChangeMessageId = BrandType<string, '_changeMessageId'>;
export type LegacyChangeId = BrandType<number, '_legacyChangeId'>; export type LegacyChangeId = BrandType<number, '_legacyChangeId'>;
export type NumericChangeId = BrandType<number, '_numericChangeId'>; export type NumericChangeId = BrandType<number, '_numericChangeId'>;
export type ProjectName = BrandType<string, '_projectName'>; export type RepoName = BrandType<string, '_repoName'>;
export type UrlEncodedProjectName = BrandType<string, '_urlEncodedProjectName'>; export type UrlEncodedRepoName = BrandType<string, '_urlEncodedRepoName'>;
export type TopicName = BrandType<string, '_topicName'>; export type TopicName = BrandType<string, '_topicName'>;
// TODO(TS): Probably, we should separate AccountId and EncodedAccountId // TODO(TS): Probably, we should separate AccountId and EncodedAccountId
export type AccountId = BrandType<number, '_accountId'>; export type AccountId = BrandType<number, '_accountId'>;
@@ -176,7 +176,7 @@ export interface ContributorAgreementInfo {
*/ */
export interface ChangeInfo { export interface ChangeInfo {
id: ChangeInfoId; id: ChangeInfoId;
project: ProjectName; project: RepoName;
branch: BranchName; branch: BranchName;
topic?: TopicName; topic?: TopicName;
attention_set?: IdToAttentionSetMap; attention_set?: IdToAttentionSetMap;
@@ -1025,13 +1025,13 @@ export interface CommentRange {
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-info * https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-info
*/ */
export interface ProjectInfo { export interface ProjectInfo {
id: UrlEncodedProjectName; id: UrlEncodedRepoName;
// name is not set if returned in a map where the project name is used as // name is not set if returned in a map where the project name is used as
// map key // map key
name?: ProjectName; name?: RepoName;
// ?-<n> if the parent project is not visible (<n> is a number which // ?-<n> if the parent project is not visible (<n> is a number which
// is increased for each non-visible project). // is increased for each non-visible project).
parent?: ProjectName; parent?: RepoName;
description?: string; description?: string;
state?: ProjectState; state?: ProjectState;
branches?: {[branchName: string]: CommitId}; branches?: {[branchName: string]: CommitId};
@@ -1356,8 +1356,8 @@ export interface PermissionRuleInfo {
*/ */
export interface DashboardInfo { export interface DashboardInfo {
id: DashboardId; id: DashboardId;
project: ProjectName; project: RepoName;
defining_project: ProjectName; defining_project: RepoName;
ref: string; // The name of the ref in which the dashboard is defined, without the refs/meta/dashboards/ prefix ref: string; // The name of the ref in which the dashboard is defined, without the refs/meta/dashboards/ prefix
description?: string; description?: string;
foreach?: string; foreach?: string;
@@ -1414,8 +1414,8 @@ export type ConfigInfoCommentLinks = {
* https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-input * https://gerrit-review.googlesource.com/Documentation/rest-api-projects.html#project-input
*/ */
export interface ProjectInput { export interface ProjectInput {
name?: ProjectName; name?: RepoName;
parent?: ProjectName; parent?: RepoName;
description?: string; description?: string;
permissions_only?: boolean; permissions_only?: boolean;
create_empty_commit?: boolean; create_empty_commit?: boolean;
@@ -1479,7 +1479,7 @@ export interface Base64FileContent {
* https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#project-watch-info * https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#project-watch-info
*/ */
export interface ProjectWatchInfo { export interface ProjectWatchInfo {
project: ProjectName; project: RepoName;
filter?: string; filter?: string;
notify_new_changes?: boolean; notify_new_changes?: boolean;
notify_new_patch_sets?: boolean; notify_new_patch_sets?: boolean;

View File

@@ -21,7 +21,7 @@ import {
GroupDetailView, GroupDetailView,
} from '../elements/core/gr-navigation/gr-navigation'; } from '../elements/core/gr-navigation/gr-navigation';
import { import {
ProjectName, RepoName,
GroupId, GroupId,
AccountDetailInfo, AccountDetailInfo,
CapabilityInfo, CapabilityInfo,
@@ -171,7 +171,7 @@ export function getGroupSubsections(
return subsection; return subsection;
} }
export function getRepoSubsections(repoName: ProjectName) { export function getRepoSubsections(repoName: RepoName) {
return { return {
name: repoName, name: repoName,
view: GerritNav.View.REPO, view: GerritNav.View.REPO,
@@ -220,7 +220,7 @@ export interface SubsectionInterface {
} }
export interface AdminNavLinksOption { export interface AdminNavLinksOption {
repoName?: ProjectName; repoName?: RepoName;
groupId?: GroupId; groupId?: GroupId;
groupName?: string; groupName?: string;
groupIsInternal?: boolean; groupIsInternal?: boolean;