Skip to content

Commit

Permalink
[PM-10757] Pass current tab uri in new item dropdown (#10505)
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-melton authored Aug 13, 2024
1 parent a1d9423 commit 8274ea7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface NewItemInitialValues {
folderId?: string;
organizationId?: OrganizationId;
collectionId?: CollectionId;
uri?: string;
}

@Component({
Expand Down Expand Up @@ -42,6 +43,7 @@ export class NewItemDropdownV2Component {
collectionId: this.initialValues?.collectionId,
organizationId: this.initialValues?.organizationId,
folderId: this.initialValues?.folderId,
uri: this.initialValues?.uri,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down Expand Up @@ -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 }),
);

Expand Down

0 comments on commit 8274ea7

Please sign in to comment.