mirror of
https://github.com/bitwarden/clients.git
synced 2026-07-21 21:17:06 +08:00
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:
parent
466ed7c141
commit
fef10547e7
@ -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", () => {
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user