Skip to content

Commit

Permalink
remove vault component presentational updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jprusik committed Jan 6, 2025
1 parent f408574 commit fe40dd8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[ciphers]="ciphers"
[title]="'autofillSuggestions' | i18n"
[showRefresh]="showRefresh"
[sectionIndicators]="sectionIndicators"
(onRefresh)="refreshCurrentTab()"
[description]="(showEmptyAutofillTip$ | async) ? ('autofillSuggestionsTip' | i18n) : null"
showAutofillButton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { CommonModule } from "@angular/common";
import { Component, Input, OnInit } from "@angular/core";
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, TypographyModule } from "@bitwarden/components";
import {
IconButtonModule,
SectionComponent,
SectionHeaderComponent,
TypographyModule,
} from "@bitwarden/components";

import BrowserPopupUtils from "../../../../../platform/popup/browser-popup-utils";
import { VaultPopupAutofillService } from "../../../services/vault-popup-autofill.service";
Expand All @@ -17,9 +22,11 @@ import { VaultListItemsContainerComponent } from "../vault-list-items-container/
standalone: true,
imports: [
CommonModule,
SectionComponent,
TypographyModule,
VaultListItemsContainerComponent,
JslibModule,
SectionHeaderComponent,
IconButtonModule,
],
selector: "app-autofill-vault-list-items",
Expand All @@ -41,11 +48,6 @@ export class AutofillVaultListItemsComponent implements OnInit {

clickItemsToAutofillVaultView = false;

/**
* Indicators for the section.
*/
@Input() sectionIndicators: string[] = [];

/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
<bit-section-header>
<h2 bitTypography="h6">
{{ title }}
<i
*ngIf="showAutofillBlockedIndicator"
class="bwi bwi-info-circle"
[appA11yTitle]="'autofillBlockedTooltip' | i18n"
></i>
</h2>
<button
*ngIf="showRefresh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
Output,
signal,
} from "@angular/core";
import { Router } from "@angular/router";
import { Router, RouterLink } from "@angular/router";
import { map } from "rxjs";

import { JslibModule } from "@bitwarden/angular/jslib.module";
Expand Down Expand Up @@ -50,6 +50,7 @@ import { ItemMoreOptionsComponent } from "../item-more-options/item-more-options
TypographyModule,
JslibModule,
SectionHeaderComponent,
RouterLink,
ItemCopyActionsComponent,
ItemMoreOptionsComponent,
OrgIconDirective,
Expand Down Expand Up @@ -80,8 +81,6 @@ export class VaultListItemsContainerComponent implements AfterViewInit {
map((enabled) => (enabled ? 53 : 59)),
);

protected showAutofillBlockedIndicator = false;

/**
* Timeout used to add a small delay when selecting a cipher to allow for double click to launch
* @private
Expand All @@ -100,11 +99,6 @@ export class VaultListItemsContainerComponent implements AfterViewInit {
@Input()
title: string;

/**
* Indicators for the section.
*/
@Input() sectionIndicators: string[] = [];

/**
* Optional description for the vault list item section. Will be shown below the title even when
* no ciphers are available.
Expand Down Expand Up @@ -176,10 +170,6 @@ export class VaultListItemsContainerComponent implements AfterViewInit {

this.autofillShortcutTooltip.set(`${autofillTitle} ${autofillShortcut}`);
}

this.showAutofillBlockedIndicator = !!this.sectionIndicators?.find(
(i) => i === "autofillDisabled",
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
</bit-no-items>
</div>

<bit-banner
*ngIf="vaultState !== VaultStateEnum.Empty && showScriptInjectionIsBlockedBanner"
id="domain-script-injection-blocked-banner"
bannerType="info"
slot="full-width-notice"
(onClose)="handleScriptInjectionIsBlockedBannerDismiss()"
>
{{ "autofillBlockedNotice" | i18n }}
</bit-banner>

<!-- Show search & filters outside of the scroll area of the page -->
<ng-container
slot="above-scroll-area"
Expand Down Expand Up @@ -71,9 +61,7 @@
cdkVirtualScrollingElement
class="tw-h-full tw-p-3 bit-compact:tw-p-2 tw-styled-scrollbar"
>
<app-autofill-vault-list-items
[sectionIndicators]="sectionIndicators"
></app-autofill-vault-list-items>
<app-autofill-vault-list-items></app-autofill-vault-list-items>
<app-vault-list-items-container
[title]="'favorites' | i18n"
[ciphers]="favoriteCiphers$ | async"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ import { ScrollingModule } from "@angular/cdk/scrolling";
import { CommonModule } from "@angular/common";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { combineLatest, firstValueFrom, Observable, shareReplay, switchMap } from "rxjs";
import { RouterLink } from "@angular/router";
import { combineLatest, Observable, shareReplay, switchMap } from "rxjs";

import { JslibModule } from "@bitwarden/angular/jslib.module";
import { DomainSettingsService } from "@bitwarden/common/autofill/services/domain-settings.service";
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
import { CipherType } from "@bitwarden/common/vault/enums";
import { BannerModule, ButtonModule, Icons, NoItemsModule } from "@bitwarden/components";
import { ButtonModule, Icons, NoItemsModule } from "@bitwarden/components";
import { VaultIcons } from "@bitwarden/vault";

import { CurrentAccountComponent } from "../../../../auth/popup/account-switching/current-account.component";
import { PopOutComponent } from "../../../../platform/popup/components/pop-out.component";
import { PopupHeaderComponent } from "../../../../platform/popup/layout/popup-header.component";
import { PopupPageComponent } from "../../../../platform/popup/layout/popup-page.component";
import { VaultPopupAutofillService } from "../../services/vault-popup-autofill.service";
import { VaultPopupItemsService } from "../../services/vault-popup-items.service";
import { VaultPopupListFiltersService } from "../../services/vault-popup-list-filters.service";
import { VaultUiOnboardingService } from "../../services/vault-ui-onboarding.service";
Expand Down Expand Up @@ -48,8 +47,8 @@ enum VaultState {
CommonModule,
AutofillVaultListItemsComponent,
VaultListItemsContainerComponent,
BannerModule,
ButtonModule,
RouterLink,
NewItemDropdownV2Component,
ScrollingModule,
VaultHeaderV2Component,
Expand All @@ -62,10 +61,6 @@ export class VaultV2Component implements OnInit, OnDestroy {
protected favoriteCiphers$ = this.vaultPopupItemsService.favoriteCiphers$;
protected remainingCiphers$ = this.vaultPopupItemsService.remainingCiphers$;
protected loading$ = this.vaultPopupItemsService.loading$;
protected scriptInjectionIsBlocked = false;
protected showScriptInjectionIsBlockedBanner = false;
protected autofillTabHostname: string | null = null;
protected sectionIndicators: string[] = [];

protected newItemItemValues$: Observable<NewItemInitialValues> =
this.vaultPopupListFiltersService.filters$.pipe(
Expand Down Expand Up @@ -93,8 +88,6 @@ export class VaultV2Component implements OnInit, OnDestroy {
constructor(
private vaultPopupItemsService: VaultPopupItemsService,
private vaultPopupListFiltersService: VaultPopupListFiltersService,
private domainSettingsService: DomainSettingsService,
private vaultPopupAutofillService: VaultPopupAutofillService,
private vaultUiOnboardingService: VaultUiOnboardingService,
) {
combineLatest([
Expand All @@ -119,58 +112,11 @@ export class VaultV2Component implements OnInit, OnDestroy {
this.vaultState = null;
}
});

combineLatest([
this.domainSettingsService.blockedInteractionsUris$,
this.vaultPopupAutofillService.currentAutofillTab$,
])
.pipe(takeUntilDestroyed())
.subscribe(([blockedInteractionsUris, currentAutofillTab]) => {
if (blockedInteractionsUris && currentAutofillTab?.url?.length) {
const autofillTabURL = new URL(currentAutofillTab.url);
this.autofillTabHostname = autofillTabURL.hostname;
const autofillTabIsBlocked = Object.keys(blockedInteractionsUris).includes(
autofillTabURL.hostname,
);

this.scriptInjectionIsBlocked = autofillTabIsBlocked;

if (autofillTabIsBlocked) {
this.sectionIndicators.push("autofillDisabled");
}

this.showScriptInjectionIsBlockedBanner =
autofillTabIsBlocked &&
!blockedInteractionsUris[autofillTabURL.hostname]?.bannerIsDismissed;
}
});
}

async ngOnInit() {
await this.vaultUiOnboardingService.showOnboardingDialog();
}

ngOnDestroy(): void {}

handleScriptInjectionIsBlockedBannerDismiss() {
if (!this.autofillTabHostname) {
return;
}

try {
void firstValueFrom(this.domainSettingsService.blockedInteractionsUris$).then(
(blockedURIs) => {
this.showScriptInjectionIsBlockedBanner = false;
void this.domainSettingsService.setBlockedInteractionsUris({
...blockedURIs,
[this.autofillTabHostname as string]: { bannerIsDismissed: true },
});
},
);
} catch (e) {
throw new Error(
"There was a problem dismissing the blocked interaction URI notification banner",
);
}
}
}

0 comments on commit fe40dd8

Please sign in to comment.