mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 15:23:33 +00:00
[PM-1019] Environment selection clients (#5480)
* [PM-169][PM-142][PM-191] Add Environments to Web and Desktop (#5294) * [PM-1351] Add property to server-config.response. Change config to be able to fetch without being authed. * [PM-1351] fetch every hour. * [PM-1351] fetch on vault sync. * [PM-1351] browser desktop fetch configs on sync complete. * [PM-1351] Add methods to retrieve feature flags * [PM-1351] Add enum to use as key to get values feature flag values * [PM-1351] Remove debug code * [PM-1351] Get flags when unauthed. Add enums as params. Hourly always fetch. * [PM-1351] add check for authed user using auth service * [PM-169] Web: add drop down to select environment * [PM-169] Fix pop up menu margins. Add DisplayEuEnvironmentFlag. * [PM-169] Change menu name. * [PM-169] Add environment selector ts and html. Add declaration and import on login.module * [PM-169] Add environment selector to desktop. * [PM-169] Ignore lint error. * [PM-169] add takeUntil to subscribes * [PM-191] PR Fixes, code format * [PM-168] Add Environments to extension login/registration (#5434)
This commit is contained in:
@@ -2221,7 +2221,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"region": {
|
||||
"message": "Region"
|
||||
},
|
||||
"opensInANewWindow": {
|
||||
"message": "Opens in a new window"
|
||||
},
|
||||
"eu": {
|
||||
"message": "EU",
|
||||
"description": "European Union"
|
||||
},
|
||||
"us": {
|
||||
"message": "US",
|
||||
"description": "United States"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2221,6 +2221,9 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"region": {
|
||||
"message": "Region"
|
||||
},
|
||||
"opensInANewWindow": {
|
||||
"message": "Opens in a new window"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Component, OnInit } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
import { EnvironmentComponent as BaseEnvironmentComponent } from "@bitwarden/angular/components/environment.component";
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
|
||||
@@ -18,9 +19,10 @@ export class EnvironmentComponent extends BaseEnvironmentComponent implements On
|
||||
platformUtilsService: PlatformUtilsService,
|
||||
public environmentService: BrowserEnvironmentService,
|
||||
i18nService: I18nService,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
modalService: ModalService
|
||||
) {
|
||||
super(platformUtilsService, environmentService, i18nService);
|
||||
super(platformUtilsService, environmentService, i18nService, modalService);
|
||||
this.showCustom = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@
|
||||
<label for="email">{{ "emailAddress" | i18n }}</label>
|
||||
<input id="email" type="email" formControlName="email" appInputVerbatim="false" />
|
||||
</div>
|
||||
<div class="box-footer no-margin" *ngIf="selfHostedDomain">
|
||||
{{ "loggingInTo" | i18n : selfHostedDomain }}
|
||||
</div>
|
||||
<environment-selector class="environment-selector-padding"></environment-selector>
|
||||
<div class="remember-email-check">
|
||||
<input
|
||||
id="rememberEmail"
|
||||
@@ -35,6 +33,3 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" routerLink="/environment" class="settings-icon" (click)="setFormValues()">
|
||||
<i class="bwi bwi-cog-f bwi-lg" aria-hidden="true"></i><span> {{ "settings" | i18n }}</span>
|
||||
</button>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
||||
import { FormBuilder, Validators } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Router } from "@angular/router";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
|
||||
import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component";
|
||||
import { EnvironmentService } from "@bitwarden/common/abstractions/environment.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
@@ -12,9 +14,12 @@ import { LoginService } from "@bitwarden/common/auth/abstractions/login.service"
|
||||
selector: "app-home",
|
||||
templateUrl: "home.component.html",
|
||||
})
|
||||
export class HomeComponent implements OnInit {
|
||||
loginInitiated = false;
|
||||
export class HomeComponent implements OnInit, OnDestroy {
|
||||
@ViewChild(EnvironmentSelectorComponent, { static: true })
|
||||
environmentSelector!: EnvironmentSelectorComponent;
|
||||
private destroyed$: Subject<void> = new Subject();
|
||||
|
||||
loginInitiated = false;
|
||||
formGroup = this.formBuilder.group({
|
||||
email: ["", [Validators.required, Validators.email]],
|
||||
rememberEmail: [false],
|
||||
@@ -27,9 +32,9 @@ export class HomeComponent implements OnInit {
|
||||
private router: Router,
|
||||
private i18nService: I18nService,
|
||||
private environmentService: EnvironmentService,
|
||||
private route: ActivatedRoute,
|
||||
private loginService: LoginService
|
||||
) {}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
let savedEmail = this.loginService.getEmail();
|
||||
const rememberEmail = this.loginService.getRememberEmail();
|
||||
@@ -48,6 +53,18 @@ export class HomeComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.environmentSelector.onOpenSelfHostedSettings
|
||||
.pipe(takeUntil(this.destroyed$))
|
||||
.subscribe(() => {
|
||||
this.setFormValues();
|
||||
this.router.navigate(["environment"]);
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroyed$.next();
|
||||
this.destroyed$.complete();
|
||||
}
|
||||
|
||||
submit() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import { FormsModule, ReactiveFormsModule } from "@angular/forms";
|
||||
import { BrowserModule } from "@angular/platform-browser";
|
||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||
|
||||
import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components/environment-selector.component";
|
||||
import { BitwardenToastModule } from "@bitwarden/angular/components/toastr.component";
|
||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||
import { ColorPasswordCountPipe } from "@bitwarden/angular/pipes/color-password-count.pipe";
|
||||
@@ -153,6 +154,7 @@ import "./locales";
|
||||
AboutComponent,
|
||||
HelpAndFeedbackComponent,
|
||||
AutofillComponent,
|
||||
EnvironmentSelectorComponent,
|
||||
],
|
||||
providers: [CurrencyPipe, DatePipe],
|
||||
bootstrap: [AppComponent],
|
||||
|
||||
BIN
apps/browser/src/popup/images/eu-flag.png
Normal file
BIN
apps/browser/src/popup/images/eu-flag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.4 KiB |
BIN
apps/browser/src/popup/images/us-flag.png
Normal file
BIN
apps/browser/src/popup/images/us-flag.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -45,3 +45,67 @@ html.browser_safari {
|
||||
border-color: #2e3440;
|
||||
}
|
||||
}
|
||||
|
||||
.environment-selector-btn {
|
||||
font-size: $font-size-small;
|
||||
color: $text-muted;
|
||||
line-height: 25px;
|
||||
font-weight: 400;
|
||||
padding-left: 5px;
|
||||
|
||||
label {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
a,
|
||||
a label:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.environment-selector-dialog {
|
||||
@include themify($themes) {
|
||||
background-color: themed("boxBackgroundColor");
|
||||
}
|
||||
padding: 5px;
|
||||
width: 100%;
|
||||
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 3px 1px -2px rgba(0, 0, 0, 0.12),
|
||||
0 1px 5px 0 rgba(0, 0, 0, 0.2);
|
||||
border-radius: $border-radius;
|
||||
}
|
||||
|
||||
.environment-selector-dialog-item {
|
||||
@include themify($themes) {
|
||||
color: themed("textColor") !important;
|
||||
}
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
padding: 0px 15px 0px 5px;
|
||||
border-radius: 3px;
|
||||
border: 1px solid transparent;
|
||||
transition: all 0.2s ease-in-out;
|
||||
|
||||
&:hover {
|
||||
@include themify($themes) {
|
||||
background-color: themed("listItemBackgroundHoverColor") !important;
|
||||
}
|
||||
}
|
||||
|
||||
img {
|
||||
margin-bottom: -2px;
|
||||
width: 22px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.img-us {
|
||||
content: url("../images/us-flag.png");
|
||||
}
|
||||
|
||||
.img-eu {
|
||||
content: url("../images/eu-flag.png");
|
||||
}
|
||||
}
|
||||
|
||||
.environment-selector-padding {
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ body.body-full {
|
||||
}
|
||||
|
||||
.remember-email-check {
|
||||
padding-top: 8px;
|
||||
padding-top: 18px;
|
||||
padding-left: 10px;
|
||||
padding-bottom: 18px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user