Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-12345] Add cipher type settings for inline autofill menu #11260

Merged
merged 10 commits into from
Oct 15, 2024
Merged
6 changes: 6 additions & 0 deletions apps/browser/src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,12 @@
"showInlineMenuLabel": {
"message": "Show autofill suggestions on form fields"
},
"showInlineMenuIdentitiesLabel": {
"message": "Display identities as suggestions"
},
"showInlineMenuCardsLabel": {
"message": "Display cards as suggestions"
},
"showInlineMenuOnIconSelectionLabel": {
"message": "Display suggestions when icon is selected"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ export type OverlayBackgroundExtensionMessageHandlers = {
updateIsFieldCurrentlyFilling: ({ message }: BackgroundMessageParam) => void;
checkIsFieldCurrentlyFilling: () => boolean;
getAutofillInlineMenuVisibility: () => void;
getInlineMenuCardsVisibility: () => void;
getInlineMenuIdentitiesVisibility: () => void;
openAutofillInlineMenu: () => void;
closeAutofillInlineMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
checkAutofillInlineMenuFocused: ({ sender }: BackgroundSenderParam) => void;
Expand Down
16 changes: 16 additions & 0 deletions apps/browser/src/autofill/background/overlay.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@
updateIsFieldCurrentlyFilling: ({ message }) => this.updateIsFieldCurrentlyFilling(message),
checkIsFieldCurrentlyFilling: () => this.checkIsFieldCurrentlyFilling(),
getAutofillInlineMenuVisibility: () => this.getInlineMenuVisibility(),
getInlineMenuCardsVisibility: () => this.getInlineMenuCardsVisibility(),
getInlineMenuIdentitiesVisibility: () => this.getInlineMenuIdentitiesVisibility(),

Check warning on line 136 in apps/browser/src/autofill/background/overlay.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/background/overlay.background.ts#L135-L136

Added lines #L135 - L136 were not covered by tests
openAutofillInlineMenu: () => this.openInlineMenu(false),
closeAutofillInlineMenu: ({ message, sender }) => this.closeInlineMenu(sender, message),
checkAutofillInlineMenuFocused: ({ sender }) => this.checkInlineMenuFocused(sender),
Expand Down Expand Up @@ -1483,6 +1485,20 @@
return await firstValueFrom(this.autofillSettingsService.inlineMenuVisibility$);
}

/**
* Gets the inline menu's visibility setting for Cards from the settings service.
*/
private async getInlineMenuCardsVisibility(): Promise<boolean> {
return await firstValueFrom(this.autofillSettingsService.showInlineMenuCards$);

Check warning on line 1492 in apps/browser/src/autofill/background/overlay.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/background/overlay.background.ts#L1492

Added line #L1492 was not covered by tests
}

/**
* Gets the inline menu's visibility setting for Identities from the settings service.
*/
private async getInlineMenuIdentitiesVisibility(): Promise<boolean> {
return await firstValueFrom(this.autofillSettingsService.showInlineMenuIdentities$);

Check warning on line 1499 in apps/browser/src/autofill/background/overlay.background.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/background/overlay.background.ts#L1499

Added line #L1499 was not covered by tests
}

/**
* Gets the user's authentication status from the auth service.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status";
import { InlineMenuVisibilitySetting } from "@bitwarden/common/autofill/types";
import { CipherType } from "@bitwarden/common/vault/enums";

import { AutofillOverlayElementType } from "../../enums/autofill-overlay.enum";
Expand All @@ -23,7 +24,7 @@ export type AutofillExtensionMessage = {
data?: {
direction?: "previous" | "next" | "current";
forceCloseInlineMenu?: boolean;
inlineMenuVisibility?: number;
newSettingValue?: InlineMenuVisibilitySetting;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,32 @@ <h1 class="center">
</div>
</div>
</div>
<div class="box tw-mb-5" *ngIf="inlineMenuPositioningImprovementsEnabled && inlineMenuIsEnabled">
<div class="box-content">
<div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="show-inline-menu-identities" class="!tw-mr-0">{{
"showInlineMenuIdentitiesLabel" | i18n
}}</label>
<input
id="show-inline-menu-identities"
type="checkbox"
(change)="updateShowInlineMenuIdentities()"
[(ngModel)]="showInlineMenuIdentities"
/>
</div>
<div class="box-content-row box-content-row-checkbox" appBoxRow>
<label for="show-inline-menu-cards" class="!tw-mr-0">{{
"showInlineMenuCardsLabel" | i18n
}}</label>
<input
id="show-inline-menu-cards"
type="checkbox"
(change)="updateShowInlineMenuCards()"
[(ngModel)]="showInlineMenuCards"
/>
</div>
</div>
</div>
<div class="box">
<div class="box-content" *ngIf="canOverrideBrowserAutofillSetting">
<div class="box-content-row box-content-row-checkbox" appBoxRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
InlineMenuVisibilitySetting,
ClearClipboardDelaySetting,
} from "@bitwarden/common/autofill/types";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";

Check warning on line 11 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L11

Added line #L11 was not covered by tests
import {
UriMatchStrategy,
UriMatchStrategySetting,
} from "@bitwarden/common/models/domain/domain-service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";

Check warning on line 16 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L16

Added line #L16 was not covered by tests
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand All @@ -20,7 +22,6 @@

import { BrowserApi } from "../../../platform/browser/browser-api";
import { enableAccountSwitching } from "../../../platform/flags";
import { AutofillService } from "../../services/abstractions/autofill.service";

@Component({
selector: "app-autofill-v1",
Expand All @@ -32,6 +33,10 @@
protected autoFillOverlayVisibility: InlineMenuVisibilitySetting;
protected autoFillOverlayVisibilityOptions: any[];
protected disablePasswordManagerLink: string;
protected inlineMenuPositioningImprovementsEnabled: boolean = false;
protected showInlineMenuIdentities: boolean = true;
protected showInlineMenuCards: boolean = true;
inlineMenuIsEnabled: boolean = false;

Check warning on line 39 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L36-L39

Added lines #L36 - L39 were not covered by tests
enableAutoFillOnPageLoad = false;
autoFillOnPageLoadDefault = false;
autoFillOnPageLoadOptions: any[];
Expand All @@ -50,7 +55,7 @@
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
private domainSettingsService: DomainSettingsService,
private autofillService: AutofillService,
private configService: ConfigService,
private dialogService: DialogService,
private autofillSettingsService: AutofillSettingsServiceAbstraction,
private messagingService: MessagingService,
Expand Down Expand Up @@ -109,6 +114,20 @@
this.autofillSettingsService.inlineMenuVisibility$,
);

this.inlineMenuPositioningImprovementsEnabled = await this.configService.getFeatureFlag(

Check warning on line 117 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L117

Added line #L117 was not covered by tests
FeatureFlag.InlineMenuPositioningImprovements,
);

this.inlineMenuIsEnabled = this.isInlineMenuEnabled();

Check warning on line 121 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L121

Added line #L121 was not covered by tests

this.showInlineMenuIdentities =

Check warning on line 123 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L123

Added line #L123 was not covered by tests
this.inlineMenuPositioningImprovementsEnabled &&
(await firstValueFrom(this.autofillSettingsService.showInlineMenuIdentities$));

this.showInlineMenuCards =

Check warning on line 127 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L127

Added line #L127 was not covered by tests
this.inlineMenuPositioningImprovementsEnabled &&
(await firstValueFrom(this.autofillSettingsService.showInlineMenuCards$));

this.enableAutoFillOnPageLoad = await firstValueFrom(
this.autofillSettingsService.autofillOnPageLoad$,
);
Expand Down Expand Up @@ -140,9 +159,18 @@
);
}

isInlineMenuEnabled() {
return (

Check warning on line 163 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L163

Added line #L163 was not covered by tests
this.autoFillOverlayVisibility === AutofillOverlayVisibility.OnFieldFocus ||
this.autoFillOverlayVisibility === AutofillOverlayVisibility.OnButtonClick
);
}

async updateAutoFillOverlayVisibility() {
await this.autofillSettingsService.setInlineMenuVisibility(this.autoFillOverlayVisibility);
await this.requestPrivacyPermission();

this.inlineMenuIsEnabled = this.isInlineMenuEnabled();

Check warning on line 173 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L173

Added line #L173 was not covered by tests
}

async updateAutoFillOnPageLoad() {
Expand Down Expand Up @@ -298,4 +326,12 @@
async updateShowIdentitiesCurrentTab() {
await this.vaultSettingsService.setShowIdentitiesCurrentTab(this.showIdentitiesCurrentTab);
}

async updateShowInlineMenuCards() {
await this.autofillSettingsService.setShowInlineMenuCards(this.showInlineMenuCards);

Check warning on line 331 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L331

Added line #L331 was not covered by tests
}

async updateShowInlineMenuIdentities() {
await this.autofillSettingsService.setShowInlineMenuIdentities(this.showInlineMenuIdentities);

Check warning on line 335 in apps/browser/src/autofill/popup/settings/autofill-v1.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill-v1.component.ts#L335

Added line #L335 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,37 @@ <h2 bitTypography="h6">{{ "autofillSuggestionsSectionTitle" | i18n }}</h2>
{{ "showInlineMenuOnFormFieldsDescAlt" | i18n }}
</bit-hint>
</bit-form-control>
<bit-form-control *ngIf="enableInlineMenu" class="tw-pl-5">
<bit-form-control
*ngIf="inlineMenuPositioningImprovementsEnabled && enableInlineMenu"
class="tw-ml-5"
>
<input
bitCheckbox
id="show-inline-menu-identities"
type="checkbox"
(change)="updateShowInlineMenuIdentities()"
[(ngModel)]="showInlineMenuIdentities"
/>
<bit-label for="show-inline-menu-identities">
{{ "showInlineMenuIdentitiesLabel" | i18n }}
</bit-label>
</bit-form-control>
<bit-form-control
*ngIf="inlineMenuPositioningImprovementsEnabled && enableInlineMenu"
class="tw-ml-5"
>
<input
bitCheckbox
id="show-inline-menu-cards"
type="checkbox"
(change)="updateShowInlineMenuCards()"
[(ngModel)]="showInlineMenuCards"
/>
<bit-label for="show-inline-menu-cards">
{{ "showInlineMenuCardsLabel" | i18n }}
</bit-label>
</bit-form-control>
<bit-form-control *ngIf="enableInlineMenu" class="tw-ml-5">
<input
bitCheckbox
id="show-autofill-suggestions-on-icon"
Expand Down
26 changes: 26 additions & 0 deletions apps/browser/src/autofill/popup/settings/autofill.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
DisablePasswordManagerUri,
InlineMenuVisibilitySetting,
} from "@bitwarden/common/autofill/types";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";

Check warning on line 24 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L24

Added line #L24 was not covered by tests
import {
UriMatchStrategy,
UriMatchStrategySetting,
} from "@bitwarden/common/models/domain/domain-service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";

Check warning on line 29 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L29

Added line #L29 was not covered by tests
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
Expand Down Expand Up @@ -82,6 +84,7 @@
protected defaultBrowserAutofillDisabled: boolean = false;
protected inlineMenuVisibility: InlineMenuVisibilitySetting =
AutofillOverlayVisibility.OnFieldFocus;
protected inlineMenuPositioningImprovementsEnabled: boolean = false;

Check warning on line 87 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L87

Added line #L87 was not covered by tests
protected browserClientVendor: BrowserClientVendor = BrowserClientVendors.Unknown;
protected disablePasswordManagerURI: DisablePasswordManagerUri =
DisablePasswordManagerUris.Unknown;
Expand All @@ -93,6 +96,8 @@
enableAutofillOnPageLoad: boolean = false;
enableInlineMenu: boolean = false;
enableInlineMenuOnIconSelect: boolean = false;
showInlineMenuIdentities: boolean = true;
showInlineMenuCards: boolean = true;

Check warning on line 100 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L99-L100

Added lines #L99 - L100 were not covered by tests
autofillOnPageLoadDefault: boolean = false;
autofillOnPageLoadOptions: { name: string; value: boolean }[];
enableContextMenuItem: boolean = false;
Expand All @@ -114,6 +119,7 @@
private autofillSettingsService: AutofillSettingsServiceAbstraction,
private messagingService: MessagingService,
private vaultSettingsService: VaultSettingsService,
private configService: ConfigService,

Check warning on line 122 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L122

Added line #L122 was not covered by tests
) {
this.autofillOnPageLoadOptions = [
{ name: i18nService.t("autoFillOnPageLoadYes"), value: true },
Expand Down Expand Up @@ -151,6 +157,18 @@
this.autofillSettingsService.inlineMenuVisibility$,
);

this.inlineMenuPositioningImprovementsEnabled = await this.configService.getFeatureFlag(

Check warning on line 160 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L160

Added line #L160 was not covered by tests
FeatureFlag.InlineMenuPositioningImprovements,
);

this.showInlineMenuIdentities =

Check warning on line 164 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L164

Added line #L164 was not covered by tests
this.inlineMenuPositioningImprovementsEnabled &&
(await firstValueFrom(this.autofillSettingsService.showInlineMenuIdentities$));

this.showInlineMenuCards =

Check warning on line 168 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L168

Added line #L168 was not covered by tests
this.inlineMenuPositioningImprovementsEnabled &&
(await firstValueFrom(this.autofillSettingsService.showInlineMenuCards$));

this.enableInlineMenuOnIconSelect =
this.inlineMenuVisibility === AutofillOverlayVisibility.OnButtonClick;

Expand Down Expand Up @@ -381,4 +399,12 @@
async updateShowIdentitiesCurrentTab() {
await this.vaultSettingsService.setShowIdentitiesCurrentTab(this.showIdentitiesCurrentTab);
}

async updateShowInlineMenuCards() {
await this.autofillSettingsService.setShowInlineMenuCards(this.showInlineMenuCards);

Check warning on line 404 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L404

Added line #L404 was not covered by tests
}

async updateShowInlineMenuIdentities() {
await this.autofillSettingsService.setShowInlineMenuIdentities(this.showInlineMenuIdentities);

Check warning on line 408 in apps/browser/src/autofill/popup/settings/autofill.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/browser/src/autofill/popup/settings/autofill.component.ts#L408

Added line #L408 was not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2238,7 +2238,7 @@ describe("AutofillOverlayContentService", () => {
it("updates the inlineMenuVisibility property", () => {
sendMockExtensionMessage({
command: "updateAutofillInlineMenuVisibility",
data: { inlineMenuVisibility: AutofillOverlayVisibility.OnButtonClick },
data: { newSettingValue: AutofillOverlayVisibility.OnButtonClick },
});

expect(autofillOverlayContentService["inlineMenuVisibility"]).toEqual(
Expand Down
Loading
Loading