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 a3ebadb7e2b..a0ab3401f4d 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 cd2e849f95b..d17269303ee 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 23ff9593099..4857703d3b1 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 }, + }); + } }