add route and params to link (#6103)

This commit is contained in:
rr-bw 2023-09-06 12:05:24 -07:00 committed by GitHub
parent e8a5c5b337
commit 6eb57ff312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -2,7 +2,9 @@
<bit-menu #environmentOptions>
<a
bitMenuItem
[attr.href]="isUsServer ? 'javascript:void(0)' : 'https://vault.bitwarden.com'"
[attr.href]="
isUsServer ? 'javascript:void(0)' : 'https://vault.bitwarden.com' + routeAndParams
"
class="pr-4"
>
<i
@ -19,7 +21,9 @@
</a>
<a
bitMenuItem
[attr.href]="isEuServer ? 'javascript:void(0)' : 'https://vault.bitwarden.eu'"
[attr.href]="
isEuServer ? 'javascript:void(0)' : 'https://vault.bitwarden.eu' + routeAndParams
"
class="pr-4"
*ngIf="euServerFlagEnabled"
>

View File

@ -1,4 +1,5 @@
import { Component, Input, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction";
@ -13,14 +14,17 @@ import { Utils } from "@bitwarden/common/platform/misc/utils";
export class EnvironmentSelectorComponent implements OnInit {
constructor(
private configService: ConfigServiceAbstraction,
private platformUtilsService: PlatformUtilsService
private platformUtilsService: PlatformUtilsService,
private router: Router
) {}
@Input() hasFlags: boolean;
isEuServer: boolean;
isUsServer: boolean;
showRegionSelector = false;
euServerFlagEnabled: boolean;
selectedRegionImageName: string;
routeAndParams: string;
async ngOnInit() {
this.euServerFlagEnabled = await this.configService.getFeatureFlagBool(
@ -31,6 +35,7 @@ export class EnvironmentSelectorComponent implements OnInit {
this.isUsServer = domain.includes(RegionDomain.US) || domain.includes(RegionDomain.USQA);
this.selectedRegionImageName = this.getRegionImage();
this.showRegionSelector = !this.platformUtilsService.isSelfHost();
this.routeAndParams = `/#${this.router.url}`;
}
getRegionImage(): string {