Make serviceuser work with Gerrit setups with context paths Solves: bug 350779993 Release-Notes: Make serviceuser plugin work with context paths Change-Id: I1a5e9f9db82eee44035fb8300de011d9568ef178
diff --git a/web/gr-serviceuser-create.ts b/web/gr-serviceuser-create.ts index 2e6367d..4f49e4e 100644 --- a/web/gr-serviceuser-create.ts +++ b/web/gr-serviceuser-create.ts
@@ -221,9 +221,12 @@ } private forwardToDetails() { - window.location.href = `${ - window.location.origin - }/x/${this.plugin.getPluginName()}/user/${this.accountId}`; + window.location.href = `${this.getPluginBaseURL()}/user/${this.accountId}`; + } + + private getPluginBaseURL() { + var href = window.location.href; + return href.substring(0, href.lastIndexOf('/create')); } private getConfig() {
diff --git a/web/gr-serviceuser-list.ts b/web/gr-serviceuser-list.ts index b4bece4..dc22fe8 100644 --- a/web/gr-serviceuser-list.ts +++ b/web/gr-serviceuser-list.ts
@@ -210,14 +210,15 @@ } private computeServiceUserUrl(id: AccountId) { - return `${ - window.location.origin - }/x/${this.plugin.getPluginName()}/user/${id}`; + return `${this.getPluginBaseURL()}/user/${id}`; } private createNewServiceUser() { - window.location.href = `${ - window.location.origin - }/x/${this.plugin.getPluginName()}/create`; + window.location.href = `${this.getPluginBaseURL()}/create`; + } + + private getPluginBaseURL() { + var href = window.location.href; + return href.substring(0, href.lastIndexOf('/list')); } }