1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-11 13:53:34 +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:
Thomas Rittson
2024-01-17 22:33:39 +10:00
committed by GitHub
parent 160a636fa0
commit ee4aa31444
32 changed files with 80 additions and 216 deletions

View File

@@ -12,7 +12,7 @@ export class OrganizationUserResponse extends BaseResponse {
externalId: string;
/**
* @deprecated
* To be removed alongside `FeatureFlag.FlexibleCollections`.
* To be removed after Flexible Collections.
**/
accessAll: boolean;
accessSecretsManager: boolean;

View File

@@ -177,11 +177,15 @@ export class Organization {
}
get canCreateNewCollections() {
return (
!this.limitCollectionCreationDeletion ||
this.isManager ||
this.permissions.createNewCollections
);
if (this.flexibleCollections) {
return (
!this.limitCollectionCreationDeletion ||
this.isAdmin ||
this.permissions.createNewCollections
);
}
return this.isManager || this.permissions.createNewCollections;
}
get canEditAnyCollection() {

View File

@@ -4,10 +4,10 @@ export enum FeatureFlag {
AutofillOverlay = "autofill-overlay",
BrowserFilelessImport = "browser-fileless-import",
ItemShare = "item-share",
FlexibleCollections = "flexible-collections",
FlexibleCollectionsV1 = "flexible-collections-v-1", // v-1 is intentional
BulkCollectionAccess = "bulk-collection-access",
KeyRotationImprovements = "key-rotation-improvements",
FlexibleCollectionsMigration = "flexible-collections-migration",
}
// Replace this with a type safe lookup of the feature flag values in PM-2282

View File

@@ -32,27 +32,27 @@ export class CollectionView implements View, ITreeNodeObject {
}
// For editing collection details, not the items within it.
canEdit(org: Organization, flexibleCollectionsEnabled: boolean): boolean {
canEdit(org: Organization): boolean {
if (org != null && org.id !== this.organizationId) {
throw new Error(
"Id of the organization provided does not match the org id of the collection.",
);
}
return flexibleCollectionsEnabled
return org?.flexibleCollections
? org?.canEditAnyCollection || this.manage
: org?.canEditAnyCollection || org?.canEditAssignedCollections;
}
// For deleting a collection, not the items within it.
canDelete(org: Organization, flexibleCollectionsEnabled: boolean): boolean {
canDelete(org: Organization): boolean {
if (org != null && org.id !== this.organizationId) {
throw new Error(
"Id of the organization provided does not match the org id of the collection.",
);
}
return flexibleCollectionsEnabled
return org?.flexibleCollections
? org?.canDeleteAnyCollection || (!org?.limitCollectionCreationDeletion && this.manage)
: org?.canDeleteAnyCollection || org?.canDeleteAssignedCollections;
}