From f434334a886d2229f65216a52b4593ecb42397a7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 27 Dec 2024 08:51:17 -0500 Subject: [PATCH] [PM-16428] Option for primary click action to autofill on Vault view (#12557) * add option for primary click action to autofill * setting option string * autofill setting for click items to autofill * fix showQuickCopyActions * apply setting --- apps/browser/src/_locales/en/messages.json | 3 +++ .../popup/settings/autofill.component.html | 14 +++++++++++++- .../popup/settings/autofill.component.ts | 9 +++++++++ .../autofill-vault-list-items.component.html | 1 + .../autofill-vault-list-items.component.ts | 16 +++++++++++++--- .../item-more-options.component.html | 5 +++++ .../item-more-options.component.ts | 17 +++++++++++++++++ .../vault-list-items-container.component.html | 9 ++++++--- .../vault-list-items-container.component.ts | 6 ++++++ .../vault-settings/vault-settings.service.ts | 12 ++++++++++++ .../services/key-state/vault-settings.state.ts | 9 +++++++++ .../vault-settings/vault-settings.service.ts | 16 ++++++++++++++++ 12 files changed, 110 insertions(+), 7 deletions(-) diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index 8fe283ba28..06f11406b6 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -1004,6 +1004,9 @@ "showIdentitiesCurrentTabDesc": { "message": "List identity items on the Tab page for easy autofill." }, + "clickToAutofillOnVault": { + "message": "Click items to autofill on Vault view" + }, "clearClipboard": { "message": "Clear clipboard", "description": "Clipboard is the operating system thing where you copy/paste data to on your device." diff --git a/apps/browser/src/autofill/popup/settings/autofill.component.html b/apps/browser/src/autofill/popup/settings/autofill.component.html index 18c6f51533..e8882cf7bb 100644 --- a/apps/browser/src/autofill/popup/settings/autofill.component.html +++ b/apps/browser/src/autofill/popup/settings/autofill.component.html @@ -120,7 +120,7 @@ /> {{ "showCardsInVaultView" | i18n }} - + + + + + {{ "clickToAutofillOnVault" | i18n }} + + diff --git a/apps/browser/src/autofill/popup/settings/autofill.component.ts b/apps/browser/src/autofill/popup/settings/autofill.component.ts index 828b45e7b3..da997f550b 100644 --- a/apps/browser/src/autofill/popup/settings/autofill.component.ts +++ b/apps/browser/src/autofill/popup/settings/autofill.component.ts @@ -110,6 +110,7 @@ export class AutofillComponent implements OnInit { uriMatchOptions: { name: string; value: UriMatchStrategySetting }[]; showCardsCurrentTab: boolean = true; showIdentitiesCurrentTab: boolean = true; + clickItemsVaultView: boolean = false; autofillKeyboardHelperText: string; accountSwitcherEnabled: boolean = false; @@ -207,6 +208,10 @@ export class AutofillComponent implements OnInit { this.showIdentitiesCurrentTab = await firstValueFrom( this.vaultSettingsService.showIdentitiesCurrentTab$, ); + + this.clickItemsVaultView = await firstValueFrom( + this.vaultSettingsService.clickItemsToAutofillVaultView$, + ); } async updateInlineMenuVisibility() { @@ -413,4 +418,8 @@ export class AutofillComponent implements OnInit { async updateShowInlineMenuIdentities() { await this.autofillSettingsService.setShowInlineMenuIdentities(this.showInlineMenuIdentities); } + + async updateClickItemsVaultView() { + await this.vaultSettingsService.setClickItemsToAutofillVaultView(this.clickItemsVaultView); + } } diff --git a/apps/browser/src/vault/popup/components/vault-v2/autofill-vault-list-items/autofill-vault-list-items.component.html b/apps/browser/src/vault/popup/components/vault-v2/autofill-vault-list-items/autofill-vault-list-items.component.html index 52ae387e8b..7c4ea3e5b4 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/autofill-vault-list-items/autofill-vault-list-items.component.html +++ b/apps/browser/src/vault/popup/components/vault-v2/autofill-vault-list-items/autofill-vault-list-items.component.html @@ -6,4 +6,5 @@ (onRefresh)="refreshCurrentTab()" [description]="(showEmptyAutofillTip$ | async) ? ('autofillSuggestionsTip' | i18n) : null" showAutofillButton + [primaryActionAutofill]="clickItemsToAutofillVaultView" > diff --git a/apps/browser/src/vault/popup/components/vault-v2/autofill-vault-list-items/autofill-vault-list-items.component.ts b/apps/browser/src/vault/popup/components/vault-v2/autofill-vault-list-items/autofill-vault-list-items.component.ts index 8e72d84053..deba204bd7 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/autofill-vault-list-items/autofill-vault-list-items.component.ts +++ b/apps/browser/src/vault/popup/components/vault-v2/autofill-vault-list-items/autofill-vault-list-items.component.ts @@ -1,8 +1,9 @@ import { CommonModule } from "@angular/common"; -import { Component } from "@angular/core"; -import { combineLatest, map, Observable } from "rxjs"; +import { Component, OnInit } from "@angular/core"; +import { combineLatest, firstValueFrom, map, Observable } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; +import { VaultSettingsService } from "@bitwarden/common/vault/abstractions/vault-settings/vault-settings.service"; import { CipherType } from "@bitwarden/common/vault/enums"; import { IconButtonModule, @@ -31,7 +32,7 @@ import { VaultListItemsContainerComponent } from "../vault-list-items-container/ selector: "app-autofill-vault-list-items", templateUrl: "autofill-vault-list-items.component.html", }) -export class AutofillVaultListItemsComponent { +export class AutofillVaultListItemsComponent implements OnInit { /** * The list of ciphers that can be used to autofill the current page. * @protected @@ -45,6 +46,8 @@ export class AutofillVaultListItemsComponent { */ protected showRefresh: boolean = BrowserPopupUtils.inSidebar(window); + clickItemsToAutofillVaultView = false; + /** * Observable that determines whether the empty autofill tip should be shown. * The tip is shown when there are no login ciphers to autofill, no filter is applied, and autofill is allowed in @@ -65,10 +68,17 @@ export class AutofillVaultListItemsComponent { constructor( private vaultPopupItemsService: VaultPopupItemsService, private vaultPopupAutofillService: VaultPopupAutofillService, + private vaultSettingsService: VaultSettingsService, ) { // TODO: Migrate logic to show Autofill policy toast PM-8144 } + async ngOnInit() { + this.clickItemsToAutofillVaultView = await firstValueFrom( + this.vaultSettingsService.clickItemsToAutofillVaultView$, + ); + } + /** * Refreshes the current tab to re-populate the autofill ciphers. * @protected diff --git a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html index 8b70896e01..7f87f32fcd 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html +++ b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html @@ -18,6 +18,11 @@ + + + diff --git a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts index 9dca0eec7c..5d3dee9018 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts +++ b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts @@ -46,6 +46,13 @@ export class ItemMoreOptionsComponent implements OnInit { return this._cipher$.value; } + /** + * Flag to show view item menu option. Used when something else is + * assigned as the primary action for the item, such as autofill. + */ + @Input({ transform: booleanAttribute }) + showViewOption: boolean; + /** * Flag to hide the autofill menu options. Used for items that are * already in the autofill list suggestion. @@ -111,6 +118,16 @@ export class ItemMoreOptionsComponent implements OnInit { await this.vaultPopupAutofillService.doAutofillAndSave(this.cipher, false); } + async onView() { + const repromptPassed = await this.passwordRepromptService.passwordRepromptCheck(this.cipher); + if (!repromptPassed) { + return; + } + await this.router.navigate(["/view-cipher"], { + queryParams: { cipherId: this.cipher.id, type: this.cipher.type }, + }); + } + /** * Toggles the favorite status of the cipher and updates it on the server. */ diff --git a/apps/browser/src/vault/popup/components/vault-v2/vault-list-items-container/vault-list-items-container.component.html b/apps/browser/src/vault/popup/components/vault-v2/vault-list-items-container/vault-list-items-container.component.html index 067c8dbdf0..72ac590c77 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/vault-list-items-container/vault-list-items-container.component.html +++ b/apps/browser/src/vault/popup/components/vault-v2/vault-list-items-container/vault-list-items-container.component.html @@ -27,9 +27,11 @@ - +