[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
This commit is contained in:
Nick Krantz 2024-07-26 12:46:06 -05:00 committed by GitHub
parent f96a66ebd9
commit 7594ebead2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 8 deletions

View File

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

View File

@ -28,12 +28,7 @@
<a routerLink="" bitMenuItem (click)="clone()">
{{ "clone" | i18n }}
</a>
<a
routerLink="/assign-collections"
[queryParams]="{ cipherId: this.cipher.id }"
type="button"
bitMenuItem
>
<a bitMenuItem (click)="conditionallyNavigateToAssignCollections()">
{{ "assignToCollections" | i18n }}
</a>
</ng-container>

View File

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