1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-14 20:01:31 +01:00

[PM-13764] - Update Collection Settings (#12734)

* Updating org when collection settings change.
This commit is contained in:
Jared McCannon 2025-01-09 10:32:21 -06:00 committed by GitHub
parent 20c8eda986
commit 3550a904dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 0 deletions

View File

@ -231,6 +231,20 @@ export class AppComponent implements OnDestroy, OnInit {
}
break;
}
case "syncOrganizationCollectionSettingChanged": {
const { organizationId, limitCollectionCreation, limitCollectionDeletion } = message;
const organizations = await firstValueFrom(this.organizationService.organizations$);
const organization = organizations.find((org) => org.id === organizationId);
if (organization) {
await this.organizationService.upsert({
...organization,
limitCollectionCreation: limitCollectionCreation,
limitCollectionDeletion: limitCollectionDeletion,
});
}
break;
}
default:
break;
}

View File

@ -23,4 +23,5 @@ export enum NotificationType {
SyncOrganizations = 17,
SyncOrganizationStatusChanged = 18,
SyncOrganizationCollectionSettingChanged = 19,
}

View File

@ -45,6 +45,9 @@ export class NotificationResponse extends BaseResponse {
case NotificationType.SyncOrganizationStatusChanged:
this.payload = new OrganizationStatusPushNotification(payload);
break;
case NotificationType.SyncOrganizationCollectionSettingChanged:
this.payload = new OrganizationCollectionSettingChangedPushNotification(payload);
break;
default:
break;
}
@ -126,3 +129,17 @@ export class OrganizationStatusPushNotification extends BaseResponse {
this.enabled = this.getResponseProperty("Enabled");
}
}
export class OrganizationCollectionSettingChangedPushNotification extends BaseResponse {
organizationId: string;
limitCollectionCreation: boolean;
limitCollectionDeletion: boolean;
constructor(response: any) {
super(response);
this.organizationId = this.getResponseProperty("OrganizationId");
this.limitCollectionCreation = this.getResponseProperty("LimitCollectionCreation");
this.limitCollectionDeletion = this.getResponseProperty("LimitCollectionDeletion");
}
}

View File

@ -227,6 +227,11 @@ export class NotificationsService implements NotificationsServiceAbstraction {
await this.syncService.fullSync(true);
}
break;
case NotificationType.SyncOrganizationCollectionSettingChanged:
if (isAuthenticated) {
await this.syncService.fullSync(true);
}
break;
default:
break;
}