fix(vault): hide archive/unarchive from bulk bar in Admin Console (#21873)

canArchive and canUnarchive in VaultBatchBarService were not checking
isOrgVault, causing both actions to appear in the Admin Console bulk bar
where they should not be available. PM-40105 (PR #21741) removed an
organizationId guard to fix org-owned items in the personal vault, but
left no guard against the org vault context. Added isOrgVault check to
match the existing pattern used by showBulkAddToFolder.

[PM-40444]
This commit is contained in:
Nick Krantz 2026-07-15 14:28:46 -05:00 committed by GitHub
parent 466ed7c141
commit fef10547e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 2 deletions

View File

@ -348,6 +348,15 @@ describe("VaultBatchBarService", () => {
expect(service.canArchive()).toBe(true);
});
it("returns false when in org vault (admin console)", () => {
userCanArchiveSubject.next(true);
service.setConfig(makeConfig({ isOrgVault: true }));
service.selection.select(makeCipherItem({ organizationId: orgId }));
expect(service.canArchive()).toBe(false);
});
});
describe("canUnarchive", () => {
@ -380,6 +389,14 @@ describe("VaultBatchBarService", () => {
expect(service.canUnarchive()).toBe(true);
});
it("returns false when in org vault (admin console)", () => {
service.setConfig(makeConfig({ isOrgVault: true }));
service.selection.select(makeCipherItem({ archivedDate: new Date(), organizationId: orgId }));
expect(service.canUnarchive()).toBe(false);
});
});
describe("canRestore", () => {

View File

@ -198,7 +198,13 @@ export class VaultBatchBarService<C extends CipherViewLike> {
readonly canArchive = computed(() => {
const selected = this.selected();
const hasCollections = selected.some((i) => i.collection);
if (selected.length === 0 || !this.userCanArchive() || hasCollections || this.inTrash()) {
if (
selected.length === 0 ||
!this.userCanArchive() ||
hasCollections ||
this.inTrash() ||
this.config().isOrgVault
) {
return false;
}
return !selected.find((item) => item.cipher && item.cipher.archivedDate);
@ -207,7 +213,7 @@ export class VaultBatchBarService<C extends CipherViewLike> {
/** True when all selected ciphers can be unarchived. */
readonly canUnarchive = computed(() => {
const selected = this.selected();
if (selected.length === 0 || this.inTrash()) {
if (selected.length === 0 || this.inTrash() || this.config().isOrgVault) {
return false;
}
return !selected.find((i) => !i.cipher?.archivedDate);