1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +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()"> <a bitMenuItem (click)="clone()">
{{ "clone" | i18n }} {{ "clone" | i18n }}
</a> </a>
<a bitMenuItem (click)="conditionallyNavigateToAssignCollections()"> <a bitMenuItem *ngIf="hasOrganizations" (click)="conditionallyNavigateToAssignCollections()">
{{ "assignToCollections" | i18n }} {{ "assignToCollections" | i18n }}
</a> </a>
</ng-container> </ng-container>

View File

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

View File

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

View File

@ -299,6 +299,11 @@ export class VaultItemsComponent {
return false; 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) { if (this.selection.selected.length === 0) {
return true; return true;
} }