From 7594ebead23fdce480a5e6cdb96a9f533ce38865 Mon Sep 17 00:00:00 2001 From: Nick Krantz <125900171+nick-livefront@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:46:06 -0500 Subject: [PATCH] [PM-9953][PM-9963] Collections Reprompt and Org assignment (#10194) * prompt for master password for assigning-collections * only pass collections that are within the cipher's org * remove type=button on anchor element --- .../assign-collections.component.ts | 15 +++++++++++++-- .../item-more-options.component.html | 7 +------ .../item-more-options.component.ts | 11 +++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/apps/browser/src/vault/popup/components/vault-v2/assign-collections/assign-collections.component.ts b/apps/browser/src/vault/popup/components/vault-v2/assign-collections/assign-collections.component.ts index a3ebadb7e2..a0ab3401f4 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/assign-collections/assign-collections.component.ts +++ b/apps/browser/src/vault/popup/components/vault-v2/assign-collections/assign-collections.component.ts @@ -66,10 +66,21 @@ export class AssignCollections { combineLatest([$cipher, this.collectionService.decryptedCollections$]) .pipe(takeUntilDestroyed(), first()) .subscribe(([cipherView, collections]) => { + let availableCollections = collections.filter((c) => !c.readOnly); + const organizationId = (cipherView?.organizationId as OrganizationId) ?? null; + + // If the cipher is already a part of an organization, + // only show collections that belong to that organization + if (organizationId) { + availableCollections = availableCollections.filter( + (c) => c.organizationId === organizationId, + ); + } + this.params = { ciphers: [cipherView], - organizationId: (cipherView?.organizationId as OrganizationId) ?? null, - availableCollections: collections.filter((c) => !c.readOnly), + organizationId, + availableCollections, }; }); } diff --git a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html index cd2e849f95..d17269303e 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html +++ b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.html @@ -28,12 +28,7 @@ {{ "clone" | i18n }} - + {{ "assignToCollections" | i18n }} diff --git a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts index 23ff959309..4857703d3b 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts +++ b/apps/browser/src/vault/popup/components/vault-v2/item-more-options/item-more-options.component.ts @@ -152,4 +152,15 @@ export class ItemMoreOptionsComponent { } as AddEditQueryParams, }); } + + /** Prompts for password when necessary then navigates to the assign collections route */ + async conditionallyNavigateToAssignCollections() { + if (this.cipher.reprompt && !(await this.passwordRepromptService.showPasswordPrompt())) { + return; + } + + await this.router.navigate(["/assign-collections"], { + queryParams: { cipherId: this.cipher.id }, + }); + } }