1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-21 16:18:28 +01:00

[PM-13187] Hide "Assign To Collections" when the user has no orgs (#11668)

* web - hide assign to collections button when the user has no organizations

* browser - hide assign to collections button when the user has no organizations

* hide assign to collections in the bulk edit menu when the user doesn't belong to an organization
This commit is contained in:
Nick Krantz 2024-10-24 10:30:46 -05:00 committed by GitHub
parent 548abfe906
commit 44e182e32e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 4 deletions

View File

@ -28,7 +28,7 @@
<a bitMenuItem (click)="clone()">
{{ "clone" | i18n }}
</a>
<a bitMenuItem (click)="conditionallyNavigateToAssignCollections()">
<a bitMenuItem *ngIf="hasOrganizations" (click)="conditionallyNavigateToAssignCollections()">
{{ "assignToCollections" | i18n }}
</a>
</ng-container>

View File

@ -1,9 +1,10 @@
import { CommonModule } from "@angular/common";
import { booleanAttribute, Component, Input } from "@angular/core";
import { booleanAttribute, Component, Input, OnInit } from "@angular/core";
import { Router, RouterModule } from "@angular/router";
import { firstValueFrom, map } from "rxjs";
import { JslibModule } from "@bitwarden/angular/jslib.module";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
@ -29,7 +30,7 @@ import { AddEditQueryParams } from "../add-edit/add-edit-v2.component";
templateUrl: "./item-more-options.component.html",
imports: [ItemModule, IconButtonModule, MenuModule, CommonModule, JslibModule, RouterModule],
})
export class ItemMoreOptionsComponent {
export class ItemMoreOptionsComponent implements OnInit {
@Input({
required: true,
})
@ -44,6 +45,9 @@ export class ItemMoreOptionsComponent {
protected autofillAllowed$ = this.vaultPopupAutofillService.autofillAllowed$;
/** Boolean dependent on the current user having access to an organization */
protected hasOrganizations = false;
constructor(
private cipherService: CipherService,
private passwordRepromptService: PasswordRepromptService,
@ -53,8 +57,13 @@ export class ItemMoreOptionsComponent {
private i18nService: I18nService,
private vaultPopupAutofillService: VaultPopupAutofillService,
private accountService: AccountService,
private organizationService: OrganizationService,
) {}
async ngOnInit(): Promise<void> {
this.hasOrganizations = await this.organizationService.hasOrganizations();
}
get canEdit() {
return this.cipher.edit;
}

View File

@ -92,7 +92,7 @@ export class VaultCipherRowComponent implements OnInit {
}
protected get showAssignToCollections() {
return this.canEditCipher && !this.cipher.isDeleted;
return this.organizations?.length && this.canEditCipher && !this.cipher.isDeleted;
}
protected get showClone() {

View File

@ -299,6 +299,11 @@ export class VaultItemsComponent {
return false;
}
// When the user doesn't belong to an organization, hide assign to collections
if (this.allOrganizations.length === 0) {
return false;
}
if (this.selection.selected.length === 0) {
return true;
}