1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-11 10:10:25 +01:00

[PM-10757] Pass current tab uri in new item dropdown (#10505)

This commit is contained in:
Shane Melton 2024-08-13 15:59:27 -07:00 committed by GitHub
parent a1d94233e3
commit 8274ea783c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 7 deletions

View File

@ -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,
};
}

View File

@ -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<NewItemInitialValues> =
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 }),
);