1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +00:00

[AC-1139] Deprecated Organization canEditAssignedCollections, canDeleteAssignedCollections, canViewAssignedCollections

This commit is contained in:
Rui Tome
2023-11-16 14:48:30 +00:00
parent ca1ef99054
commit 7ce712aa7c
6 changed files with 27 additions and 7 deletions

View File

@@ -106,7 +106,7 @@ export class VaultItemsComponent {
} }
const organization = this.allOrganizations.find((o) => o.id === collection.organizationId); const organization = this.allOrganizations.find((o) => o.id === collection.organizationId);
return collection.canEdit(organization); return collection.canEdit(organization, this.flexibleCollectionsEnabled);
} }
protected canDeleteCollection(collection: CollectionView): boolean { protected canDeleteCollection(collection: CollectionView): boolean {

View File

@@ -31,9 +31,13 @@ export class CollectionAdminView extends CollectionView {
this.assigned = response.assigned; this.assigned = response.assigned;
} }
override canEdit(org: Organization): boolean { override canEdit(org: Organization, flexibleCollectionsEnabled: boolean): boolean {
if (flexibleCollectionsEnabled) {
return org?.canEditAnyCollection;
} else {
return org?.canEditAnyCollection || (org?.canEditAssignedCollections && this.assigned); return org?.canEditAnyCollection || (org?.canEditAssignedCollections && this.assigned);
} }
}
override canDelete(org: Organization, flexibleCollectionsEnabled: boolean): boolean { override canDelete(org: Organization, flexibleCollectionsEnabled: boolean): boolean {
if (flexibleCollectionsEnabled) { if (flexibleCollectionsEnabled) {

View File

@@ -143,7 +143,7 @@ export class VaultHeaderComponent {
const organization = this.organizations.find( const organization = this.organizations.find(
(o) => o.id === this.collection?.node.organizationId (o) => o.id === this.collection?.node.organizationId
); );
return this.collection.node.canEdit(organization); return this.collection.node.canEdit(organization, this.flexibleCollectionsEnabled);
} }
async editCollection(tab: CollectionDialogTabType): Promise<void> { async editCollection(tab: CollectionDialogTabType): Promise<void> {

View File

@@ -152,7 +152,7 @@ export class VaultHeaderComponent {
} }
// Otherwise, check if we can edit the specified collection // Otherwise, check if we can edit the specified collection
return this.collection.node.canEdit(this.organization); return this.collection.node.canEdit(this.organization, this.flexibleCollectionsEnabled);
} }
addCipher() { addCipher() {

View File

@@ -184,14 +184,26 @@ export class Organization {
return this.canEditAnyCollection || this.canDeleteAnyCollection; return this.canEditAnyCollection || this.canDeleteAnyCollection;
} }
/**
* @deprecated
* This is deprecated with the introduction of Flexible Collections.
*/
get canEditAssignedCollections() { get canEditAssignedCollections() {
return this.isManager || this.permissions.editAssignedCollections; return this.isManager || this.permissions.editAssignedCollections;
} }
/**
* @deprecated
* This is deprecated with the introduction of Flexible Collections.
*/
get canDeleteAssignedCollections() { get canDeleteAssignedCollections() {
return this.isManager || this.permissions.deleteAssignedCollections; return this.isManager || this.permissions.deleteAssignedCollections;
} }
/**
* @deprecated
* This is deprecated with the introduction of Flexible Collections.
*/
get canViewAssignedCollections() { get canViewAssignedCollections() {
return this.canDeleteAssignedCollections || this.canEditAssignedCollections; return this.canDeleteAssignedCollections || this.canEditAssignedCollections;
} }

View File

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