[PM-9190] Browser Refresh - Autofill section fixes (#10488)

* [PM-10751] Add count to website URI label

* [PM-10752] Hide autofill on page load field when the setting is disabled

* [PM-10790] Fix bottom margin
This commit is contained in:
Shane Melton 2024-08-13 08:58:16 -07:00 committed by GitHub
parent 471dd3bd7b
commit 7ad42ae18b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 53 additions and 3 deletions

View File

@ -3883,6 +3883,16 @@
"websiteUri": { "websiteUri": {
"message": "Website (URI)" "message": "Website (URI)"
}, },
"websiteUriCount": {
"message": "Website (URI) $COUNT$",
"description": "Label for an input field that contains a website URI. The input field is part of a list of fields, and the count indicates the position of the field in the list.",
"placeholders": {
"count": {
"content": "$1",
"example": "3"
}
}
},
"websiteAdded": { "websiteAdded": {
"message": "Website added" "message": "Website added"
}, },

View File

@ -57,6 +57,16 @@
"websiteUri": { "websiteUri": {
"message": "Website (URI)" "message": "Website (URI)"
}, },
"websiteUriCount": {
"message": "Website (URI) $COUNT$",
"description": "Label for an input field that contains a website URI. The input field is part of a list of fields, and the count indicates the position of the field in the list.",
"placeholders": {
"count": {
"content": "$1",
"example": "3"
}
}
},
"websiteAdded": { "websiteAdded": {
"message": "Website added" "message": "Website added"
}, },

View File

@ -13,6 +13,7 @@
(remove)="removeUri(i)" (remove)="removeUri(i)"
[canRemove]="uriControls.length > 1" [canRemove]="uriControls.length > 1"
[defaultMatchDetection]="defaultMatchDetection$ | async" [defaultMatchDetection]="defaultMatchDetection$ | async"
[index]="i"
></vault-autofill-uri-option> ></vault-autofill-uri-option>
</ng-container> </ng-container>
@ -20,7 +21,7 @@
type="button" type="button"
bitLink bitLink
linkType="primary" linkType="primary"
class="tw-mb-6" [class.tw-mb-6]="autofillOnPageLoadEnabled$ | async"
(click)="addUri({ uri: null, matchDetection: null }, true)" (click)="addUri({ uri: null, matchDetection: null }, true)"
*ngIf="autofillOptionsForm.enabled" *ngIf="autofillOptionsForm.enabled"
> >
@ -28,7 +29,7 @@
{{ "addWebsite" | i18n }} {{ "addWebsite" | i18n }}
</button> </button>
<bit-form-field> <bit-form-field *ngIf="autofillOnPageLoadEnabled$ | async" disableMargin>
<bit-label>{{ "autoFillOnPageLoad" | i18n }}</bit-label> <bit-label>{{ "autoFillOnPageLoad" | i18n }}</bit-label>
<bit-select formControlName="autofillOnPageLoad" [items]="autofillOptions"></bit-select> <bit-select formControlName="autofillOnPageLoad" [items]="autofillOptions"></bit-select>
</bit-form-field> </bit-form-field>

View File

@ -32,6 +32,7 @@ describe("AutofillOptionsComponent", () => {
autofillSettingsService = mock<AutofillSettingsServiceAbstraction>(); autofillSettingsService = mock<AutofillSettingsServiceAbstraction>();
autofillSettingsService.autofillOnPageLoadDefault$ = new BehaviorSubject(false); autofillSettingsService.autofillOnPageLoadDefault$ = new BehaviorSubject(false);
autofillSettingsService.autofillOnPageLoad$ = new BehaviorSubject(true);
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [AutofillOptionsComponent], imports: [AutofillOptionsComponent],
@ -145,6 +146,22 @@ describe("AutofillOptionsComponent", () => {
expect(component["autofillOptions"][0].label).toEqual("defaultLabel yes"); expect(component["autofillOptions"][0].label).toEqual("defaultLabel yes");
}); });
it("hides the autofill on page load field when the setting is disabled", () => {
fixture.detectChanges();
let control = fixture.nativeElement.querySelector(
"bit-select[formControlName='autofillOnPageLoad']",
);
expect(control).toBeTruthy();
(autofillSettingsService.autofillOnPageLoad$ as BehaviorSubject<boolean>).next(false);
fixture.detectChanges();
control = fixture.nativeElement.querySelector(
"bit-select[formControlName='autofillOnPageLoad']",
);
expect(control).toBeFalsy();
});
it("announces the addition of a new URI input", fakeAsync(() => { it("announces the addition of a new URI input", fakeAsync(() => {
fixture.detectChanges(); fixture.detectChanges();

View File

@ -70,6 +70,7 @@ export class AutofillOptionsComponent implements OnInit {
} }
protected defaultMatchDetection$ = this.domainSettingsService.defaultUriMatchStrategy$; protected defaultMatchDetection$ = this.domainSettingsService.defaultUriMatchStrategy$;
protected autofillOnPageLoadEnabled$ = this.autofillSettingsService.autofillOnPageLoad$;
protected autofillOptions: { label: string; value: boolean | null }[] = [ protected autofillOptions: { label: string; value: boolean | null }[] = [
{ label: this.i18nService.t("default"), value: null }, { label: this.i18nService.t("default"), value: null },

View File

@ -1,6 +1,6 @@
<ng-container [formGroup]="uriForm"> <ng-container [formGroup]="uriForm">
<bit-form-field> <bit-form-field>
<bit-label>{{ "websiteUri" | i18n }}</bit-label> <bit-label>{{ uriLabel }}</bit-label>
<input bitInput formControlName="uri" #uriInput /> <input bitInput formControlName="uri" #uriInput />
<button <button
type="button" type="button"

View File

@ -89,6 +89,11 @@ export class UriOptionComponent implements ControlValueAccessor {
); );
} }
/**
* The index of the URI in the form. Used to render the correct label.
*/
@Input({ required: true }) index: number;
/** /**
* Emits when the remove button is clicked and URI should be removed from the form. * Emits when the remove button is clicked and URI should be removed from the form.
*/ */
@ -104,6 +109,12 @@ export class UriOptionComponent implements ControlValueAccessor {
} }
} }
protected get uriLabel() {
return this.index === 0
? this.i18nService.t("websiteUri")
: this.i18nService.t("websiteUriCount", this.index + 1);
}
protected get toggleTitle() { protected get toggleTitle() {
return this.showMatchDetection return this.showMatchDetection
? this.i18nService.t("hideMatchDetection", this.uriForm.value.uri) ? this.i18nService.t("hideMatchDetection", this.uriForm.value.uri)