mirror of
https://github.com/bitwarden/browser
synced 2025-12-23 19:53:43 +00:00
[AC-2027] Update Flexible Collections logic to use organization property (#7445)
* Remove unused feature flag * Replace feature flag ref with org flag * Remove deprecated feature flag to discourage use * Add check to org.canCreateNewCollections * Adjust init logic of components to avoid race conditions * Make canCreateNewCollections logic more explicit * Resolve merge conflicts with vault changes * Update comments * Remove uses of old feature flag * Remove last of old feature flag * Clean up feature flag * Fix linting * Fix linting
This commit is contained in:
@@ -69,10 +69,9 @@ export enum CollectionDialogAction {
|
||||
templateUrl: "collection-dialog.component.html",
|
||||
})
|
||||
export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
protected flexibleCollectionsEnabled$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.FlexibleCollections,
|
||||
false,
|
||||
);
|
||||
protected flexibleCollectionsEnabled$ = this.organizationService
|
||||
.get$(this.params.organizationId)
|
||||
.pipe(map((o) => o?.flexibleCollections));
|
||||
|
||||
protected flexibleCollectionsV1Enabled$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.FlexibleCollectionsV1,
|
||||
@@ -110,9 +109,9 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private organizationUserService: OrganizationUserService,
|
||||
private configService: ConfigServiceAbstraction,
|
||||
private dialogService: DialogService,
|
||||
private changeDetectorRef: ChangeDetectorRef,
|
||||
private configService: ConfigServiceAbstraction,
|
||||
) {
|
||||
this.tabIndex = params.initialTab ?? CollectionDialogTabType.Info;
|
||||
}
|
||||
@@ -209,7 +208,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
access: accessSelections,
|
||||
});
|
||||
|
||||
this.showDeleteButton = this.collection.canDelete(organization, flexibleCollections);
|
||||
this.showDeleteButton = this.collection.canDelete(organization);
|
||||
} else {
|
||||
this.nestOptions = collections;
|
||||
const parent = collections.find((c) => c.id === this.params.parentCollectionId);
|
||||
|
||||
@@ -1,12 +1,4 @@
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
HostBinding,
|
||||
HostListener,
|
||||
Input,
|
||||
OnInit,
|
||||
Output,
|
||||
} from "@angular/core";
|
||||
import { Component, EventEmitter, HostBinding, HostListener, Input, Output } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
@@ -19,7 +11,6 @@ import { CollectionAdminView } from "../../core/views/collection-admin.view";
|
||||
import {
|
||||
convertToPermission,
|
||||
getPermissionList,
|
||||
Permission,
|
||||
} from "./../../../admin-console/organizations/shared/components/access-selector/access-selector.models";
|
||||
import { VaultItemEvent } from "./vault-item-event";
|
||||
import { RowHeightClass } from "./vault-items.component";
|
||||
@@ -28,7 +19,7 @@ import { RowHeightClass } from "./vault-items.component";
|
||||
selector: "tr[appVaultCollectionRow]",
|
||||
templateUrl: "vault-collection-row.component.html",
|
||||
})
|
||||
export class VaultCollectionRowComponent implements OnInit {
|
||||
export class VaultCollectionRowComponent {
|
||||
protected RowHeightClass = RowHeightClass;
|
||||
|
||||
@Input() disabled: boolean;
|
||||
@@ -41,24 +32,17 @@ export class VaultCollectionRowComponent implements OnInit {
|
||||
@Input() organizations: Organization[];
|
||||
@Input() groups: GroupView[];
|
||||
@Input() showPermissionsColumn: boolean;
|
||||
@Input() flexibleCollectionsEnabled: boolean;
|
||||
|
||||
@Output() onEvent = new EventEmitter<VaultItemEvent>();
|
||||
|
||||
@Input() checked: boolean;
|
||||
@Output() checkedToggled = new EventEmitter<void>();
|
||||
|
||||
private permissionList: Permission[];
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private i18nService: I18nService,
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.permissionList = getPermissionList(this.flexibleCollectionsEnabled);
|
||||
}
|
||||
|
||||
@HostBinding("class")
|
||||
get classes() {
|
||||
return [].concat(this.disabled ? [] : ["tw-cursor-pointer"]);
|
||||
@@ -80,8 +64,9 @@ export class VaultCollectionRowComponent implements OnInit {
|
||||
if (!(this.collection as CollectionAdminView).assigned) {
|
||||
return "-";
|
||||
} else {
|
||||
const permissionList = getPermissionList(this.organization?.flexibleCollections);
|
||||
return this.i18nService.t(
|
||||
this.permissionList.find((p) => p.perm === convertToPermission(this.collection))?.labelId,
|
||||
permissionList.find((p) => p.perm === convertToPermission(this.collection))?.labelId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,6 @@
|
||||
[canDeleteCollection]="canDeleteCollection(item.collection)"
|
||||
[canEditCollection]="canEditCollection(item.collection)"
|
||||
[checked]="selection.isSelected(item)"
|
||||
[flexibleCollectionsEnabled]="flexibleCollectionsEnabled"
|
||||
(checkedToggled)="selection.toggle(item)"
|
||||
(onEvent)="event($event)"
|
||||
></tr>
|
||||
|
||||
@@ -2,8 +2,6 @@ import { SelectionModel } from "@angular/cdk/collections";
|
||||
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
||||
|
||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
||||
import { ConfigServiceAbstraction } from "@bitwarden/common/platform/abstractions/config/config.service.abstraction";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { CollectionView } from "@bitwarden/common/vault/models/view/collection.view";
|
||||
import { TableDataSource } from "@bitwarden/components";
|
||||
@@ -29,8 +27,6 @@ const MaxSelectionCount = 500;
|
||||
export class VaultItemsComponent {
|
||||
protected RowHeight = RowHeight;
|
||||
|
||||
protected flexibleCollectionsEnabled: boolean;
|
||||
|
||||
@Input() disabled: boolean;
|
||||
@Input() showOwner: boolean;
|
||||
@Input() showCollections: boolean;
|
||||
@@ -73,14 +69,6 @@ export class VaultItemsComponent {
|
||||
protected dataSource = new TableDataSource<VaultItem>();
|
||||
protected selection = new SelectionModel<VaultItem>(true, [], true);
|
||||
|
||||
constructor(private configService: ConfigServiceAbstraction) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.flexibleCollectionsEnabled = await this.configService.getFeatureFlag(
|
||||
FeatureFlag.FlexibleCollections,
|
||||
);
|
||||
}
|
||||
|
||||
get showExtraColumn() {
|
||||
return this.showCollections || this.showGroups || this.showOwner;
|
||||
}
|
||||
@@ -108,7 +96,7 @@ export class VaultItemsComponent {
|
||||
}
|
||||
|
||||
const organization = this.allOrganizations.find((o) => o.id === collection.organizationId);
|
||||
return collection.canEdit(organization, this.flexibleCollectionsEnabled);
|
||||
return collection.canEdit(organization);
|
||||
}
|
||||
|
||||
protected canDeleteCollection(collection: CollectionView): boolean {
|
||||
@@ -118,7 +106,7 @@ export class VaultItemsComponent {
|
||||
}
|
||||
|
||||
const organization = this.allOrganizations.find((o) => o.id === collection.organizationId);
|
||||
return collection.canDelete(organization, this.flexibleCollectionsEnabled);
|
||||
return collection.canDelete(organization);
|
||||
}
|
||||
|
||||
protected toggleAll() {
|
||||
|
||||
Reference in New Issue
Block a user