Fix another link for context path users
When making the plugin work with context paths I missed
that there was a link to the service users list from the
left hand side menu when browsing repo/groups, so I missed
to fix that part. This is now remedied.
I could not as easily get the context path from the
plugin.ts file so I changed the approach. For consistency
I changed the other parts as well.
Solves: bug 350779993
Release-Notes: Make serviceuser plugin work with context paths
Change-Id: I6dfd2de529932c59c28aadea485de5195bcbeff3
diff --git a/web/gr-serviceuser-create.ts b/web/gr-serviceuser-create.ts
index 4f49e4e..3ee2a70 100644
--- a/web/gr-serviceuser-create.ts
+++ b/web/gr-serviceuser-create.ts
@@ -225,8 +225,7 @@
}
private getPluginBaseURL() {
- var href = window.location.href;
- return href.substring(0, href.lastIndexOf('/create'));
+ return `${window.location.origin}${window.CANONICAL_PATH || ''}/x/${this.plugin.getPluginName()}`;
}
private getConfig() {
diff --git a/web/gr-serviceuser-list.ts b/web/gr-serviceuser-list.ts
index dc22fe8..ee9e7d0 100644
--- a/web/gr-serviceuser-list.ts
+++ b/web/gr-serviceuser-list.ts
@@ -218,7 +218,6 @@
}
private getPluginBaseURL() {
- var href = window.location.href;
- return href.substring(0, href.lastIndexOf('/list'));
+ return `${window.location.origin}${window.CANONICAL_PATH || ''}/x/${this.plugin.getPluginName()}`;
}
}
diff --git a/web/plugin.ts b/web/plugin.ts
index 1f777f0..d6f90b1 100644
--- a/web/plugin.ts
+++ b/web/plugin.ts
@@ -21,6 +21,12 @@
import './gr-serviceuser-detail';
import './gr-serviceuser-list';
+declare global {
+ interface Window {
+ CANONICAL_PATH?: string;
+ }
+}
+
export interface AccountCapabilityInfo {
administrateServer: boolean;
'serviceuser-createServiceUser': boolean;
@@ -40,6 +46,6 @@
}
plugin.screen('list', 'gr-serviceuser-list');
plugin.screen('user', 'gr-serviceuser-detail');
- plugin.admin().addMenuLink('Service Users', '/x/serviceuser/list');
+ plugin.admin().addMenuLink('Service Users', `${window.CANONICAL_PATH || ''}/x/serviceuser/list`);
});
});