remove user match strategy on the web (#11385)
This commit is contained in:
parent
2c8f09d547
commit
22b16b20a7
|
@ -7,6 +7,7 @@ import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/s
|
||||||
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
||||||
import { UriMatchStrategy } from "@bitwarden/common/models/domain/domain-service";
|
import { UriMatchStrategy } from "@bitwarden/common/models/domain/domain-service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
||||||
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
||||||
|
@ -23,10 +24,12 @@ describe("AutofillOptionsComponent", () => {
|
||||||
let liveAnnouncer: MockProxy<LiveAnnouncer>;
|
let liveAnnouncer: MockProxy<LiveAnnouncer>;
|
||||||
let domainSettingsService: MockProxy<DomainSettingsService>;
|
let domainSettingsService: MockProxy<DomainSettingsService>;
|
||||||
let autofillSettingsService: MockProxy<AutofillSettingsServiceAbstraction>;
|
let autofillSettingsService: MockProxy<AutofillSettingsServiceAbstraction>;
|
||||||
|
let platformUtilsService: MockProxy<PlatformUtilsService>;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
cipherFormContainer = mock<CipherFormContainer>();
|
cipherFormContainer = mock<CipherFormContainer>();
|
||||||
liveAnnouncer = mock<LiveAnnouncer>();
|
liveAnnouncer = mock<LiveAnnouncer>();
|
||||||
|
platformUtilsService = mock<PlatformUtilsService>();
|
||||||
domainSettingsService = mock<DomainSettingsService>();
|
domainSettingsService = mock<DomainSettingsService>();
|
||||||
domainSettingsService.defaultUriMatchStrategy$ = new BehaviorSubject(null);
|
domainSettingsService.defaultUriMatchStrategy$ = new BehaviorSubject(null);
|
||||||
|
|
||||||
|
@ -45,6 +48,7 @@ describe("AutofillOptionsComponent", () => {
|
||||||
{ provide: LiveAnnouncer, useValue: liveAnnouncer },
|
{ provide: LiveAnnouncer, useValue: liveAnnouncer },
|
||||||
{ provide: DomainSettingsService, useValue: domainSettingsService },
|
{ provide: DomainSettingsService, useValue: domainSettingsService },
|
||||||
{ provide: AutofillSettingsServiceAbstraction, useValue: autofillSettingsService },
|
{ provide: AutofillSettingsServiceAbstraction, useValue: autofillSettingsService },
|
||||||
|
{ provide: PlatformUtilsService, useValue: platformUtilsService },
|
||||||
],
|
],
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,15 @@ import { AsyncPipe, NgForOf, NgIf } from "@angular/common";
|
||||||
import { Component, OnInit, QueryList, ViewChildren } from "@angular/core";
|
import { Component, OnInit, QueryList, ViewChildren } from "@angular/core";
|
||||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
||||||
import { Subject, switchMap, take } from "rxjs";
|
import { filter, Subject, switchMap, take } from "rxjs";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service";
|
import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service";
|
||||||
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
|
||||||
|
import { ClientType } from "@bitwarden/common/enums";
|
||||||
import { UriMatchStrategySetting } from "@bitwarden/common/models/domain/domain-service";
|
import { UriMatchStrategySetting } from "@bitwarden/common/models/domain/domain-service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
||||||
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
import { LoginView } from "@bitwarden/common/vault/models/view/login.view";
|
||||||
import {
|
import {
|
||||||
|
@ -69,7 +71,10 @@ export class AutofillOptionsComponent implements OnInit {
|
||||||
return this.autofillOptionsForm.controls.uris.controls;
|
return this.autofillOptionsForm.controls.uris.controls;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected defaultMatchDetection$ = this.domainSettingsService.defaultUriMatchStrategy$;
|
protected defaultMatchDetection$ = this.domainSettingsService.defaultUriMatchStrategy$.pipe(
|
||||||
|
// The default match detection should only be shown when used on the browser
|
||||||
|
filter(() => this.platformUtilsService.getClientType() == ClientType.Browser),
|
||||||
|
);
|
||||||
protected autofillOnPageLoadEnabled$ = this.autofillSettingsService.autofillOnPageLoad$;
|
protected autofillOnPageLoadEnabled$ = this.autofillSettingsService.autofillOnPageLoad$;
|
||||||
|
|
||||||
protected autofillOptions: { label: string; value: boolean | null }[] = [
|
protected autofillOptions: { label: string; value: boolean | null }[] = [
|
||||||
|
@ -90,6 +95,7 @@ export class AutofillOptionsComponent implements OnInit {
|
||||||
private liveAnnouncer: LiveAnnouncer,
|
private liveAnnouncer: LiveAnnouncer,
|
||||||
private domainSettingsService: DomainSettingsService,
|
private domainSettingsService: DomainSettingsService,
|
||||||
private autofillSettingsService: AutofillSettingsServiceAbstraction,
|
private autofillSettingsService: AutofillSettingsServiceAbstraction,
|
||||||
|
private platformUtilsService: PlatformUtilsService,
|
||||||
) {
|
) {
|
||||||
this.cipherFormContainer.registerChildForm("autoFillOptions", this.autofillOptionsForm);
|
this.cipherFormContainer.registerChildForm("autoFillOptions", this.autofillOptionsForm);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,13 @@ describe("UriOptionComponent", () => {
|
||||||
expect(component).toBeTruthy();
|
expect(component).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not update the default uri match strategy label when it is null", () => {
|
||||||
|
component.defaultMatchDetection = null;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(component["uriMatchOptions"][0].label).toBe("default");
|
||||||
|
});
|
||||||
|
|
||||||
it("should update the default uri match strategy label", () => {
|
it("should update the default uri match strategy label", () => {
|
||||||
component.defaultMatchDetection = UriMatchStrategy.Exact;
|
component.defaultMatchDetection = UriMatchStrategy.Exact;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
|
@ -83,6 +83,11 @@ export class UriOptionComponent implements ControlValueAccessor {
|
||||||
*/
|
*/
|
||||||
@Input({ required: true })
|
@Input({ required: true })
|
||||||
set defaultMatchDetection(value: UriMatchStrategySetting) {
|
set defaultMatchDetection(value: UriMatchStrategySetting) {
|
||||||
|
// The default selection has a value of `null` avoid showing "Default (Default)"
|
||||||
|
if (!value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.uriMatchOptions[0].label = this.i18nService.t(
|
this.uriMatchOptions[0].label = this.i18nService.t(
|
||||||
"defaultLabel",
|
"defaultLabel",
|
||||||
this.uriMatchOptions.find((o) => o.value === value)?.label,
|
this.uriMatchOptions.find((o) => o.value === value)?.label,
|
||||||
|
|
Loading…
Reference in New Issue