From 8274ea783cd17812bdb58f5c5bc335c1885e0a51 Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Tue, 13 Aug 2024 15:59:27 -0700 Subject: [PATCH] [PM-10757] Pass current tab uri in new item dropdown (#10505) --- .../new-item-dropdown-v2.component.ts | 2 ++ .../components/vault/vault-v2.component.ts | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/apps/browser/src/vault/popup/components/vault-v2/new-item-dropdown/new-item-dropdown-v2.component.ts b/apps/browser/src/vault/popup/components/vault-v2/new-item-dropdown/new-item-dropdown-v2.component.ts index ee9d7c28fec7..daa0f3d795c5 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/new-item-dropdown/new-item-dropdown-v2.component.ts +++ b/apps/browser/src/vault/popup/components/vault-v2/new-item-dropdown/new-item-dropdown-v2.component.ts @@ -14,6 +14,7 @@ export interface NewItemInitialValues { folderId?: string; organizationId?: OrganizationId; collectionId?: CollectionId; + uri?: string; } @Component({ @@ -42,6 +43,7 @@ export class NewItemDropdownV2Component { collectionId: this.initialValues?.collectionId, organizationId: this.initialValues?.organizationId, folderId: this.initialValues?.folderId, + uri: this.initialValues?.uri, }; } diff --git a/apps/browser/src/vault/popup/components/vault/vault-v2.component.ts b/apps/browser/src/vault/popup/components/vault/vault-v2.component.ts index 97f028895b04..a2b778984d71 100644 --- a/apps/browser/src/vault/popup/components/vault/vault-v2.component.ts +++ b/apps/browser/src/vault/popup/components/vault/vault-v2.component.ts @@ -2,7 +2,7 @@ import { CommonModule } from "@angular/common"; import { Component, OnDestroy, OnInit } from "@angular/core"; import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { RouterLink } from "@angular/router"; -import { combineLatest, map, Observable, shareReplay } from "rxjs"; +import { combineLatest, Observable, shareReplay, switchMap } from "rxjs"; import { JslibModule } from "@bitwarden/angular/jslib.module"; import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid"; @@ -11,6 +11,7 @@ import { ButtonModule, Icons, NoItemsModule } from "@bitwarden/components"; import { VaultIcons } from "@bitwarden/vault"; import { CurrentAccountComponent } from "../../../../auth/popup/account-switching/current-account.component"; +import { BrowserApi } from "../../../../platform/browser/browser-api"; 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"; @@ -62,12 +63,16 @@ export class VaultV2Component implements OnInit, OnDestroy { protected newItemItemValues$: Observable = this.vaultPopupListFiltersService.filters$.pipe( - map((filter) => ({ - organizationId: (filter.organization?.id || - filter.collection?.organizationId) as OrganizationId, - collectionId: filter.collection?.id as CollectionId, - folderId: filter.folder?.id, - })), + switchMap( + async (filter) => + ({ + organizationId: (filter.organization?.id || + filter.collection?.organizationId) as OrganizationId, + collectionId: filter.collection?.id as CollectionId, + folderId: filter.folder?.id, + uri: (await BrowserApi.getTabFromCurrentWindow())?.url, + }) as NewItemInitialValues, + ), shareReplay({ refCount: true, bufferSize: 1 }), );