[AC-1389] update collection dialog copy based on admin access setting (#7137)

* update collection dialog access copy based on allowAdminAccessToAllCollectionItems setting

* remove requirement to have a Can Manage user if v1 flag is off or admins have access to all collections

---------

Co-authored-by: Thomas Rittson <trittson@bitwarden.com>
This commit is contained in:
Will Martin 2024-01-04 22:26:23 -05:00 committed by GitHub
parent 92f593df08
commit 1a38bec901
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 6 deletions

View File

@ -64,6 +64,12 @@
</bit-form-field>
</bit-tab>
<bit-tab label="{{ 'access' | i18n }}">
<div class="tw-mb-3" *ngIf="flexibleCollectionsV1Enabled$ | async">
{{ "grantCollectionAccess" | i18n }}
<span *ngIf="organization.allowAdminAccessToAllCollectionItems">{{
" " + ("adminCollectionAccess" | i18n)
}}</span>
</div>
<div
class="tw-mb-3 tw-text-danger"
*ngIf="formGroup.controls.access.hasError('managePermissionRequired')"

View File

@ -3,7 +3,6 @@ import { ChangeDetectorRef, Component, Inject, OnDestroy, OnInit } from "@angula
import { AbstractControl, FormBuilder, Validators } from "@angular/forms";
import {
combineLatest,
firstValueFrom,
from,
map,
Observable,
@ -75,6 +74,11 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
false,
);
protected flexibleCollectionsV1Enabled$ = this.configService.getFeatureFlag$(
FeatureFlag.FlexibleCollectionsV1,
false,
);
private destroy$ = new Subject<void>();
protected organizations$: Observable<Organization[]>;
@ -134,10 +138,6 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
this.formGroup.patchValue({ selectedOrg: this.params.organizationId });
await this.loadOrg(this.params.organizationId, this.params.collectionIds);
}
if (await firstValueFrom(this.flexibleCollectionsEnabled$)) {
this.formGroup.controls.access.addValidators(validateCanManagePermission);
}
}
async loadOrg(orgId: string, collectionIds: string[]) {
@ -162,10 +162,19 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
groups: groups$,
users: this.organizationUserService.getAllUsers(orgId),
flexibleCollections: this.flexibleCollectionsEnabled$,
flexibleCollectionsV1: this.flexibleCollectionsV1Enabled$,
})
.pipe(takeUntil(this.formGroup.controls.selectedOrg.valueChanges), takeUntil(this.destroy$))
.subscribe(
({ organization, collections, collectionDetails, groups, users, flexibleCollections }) => {
({
organization,
collections,
collectionDetails,
groups,
users,
flexibleCollections,
flexibleCollectionsV1,
}) => {
this.organization = organization;
this.accessItems = [].concat(
groups.map(mapGroupToAccessItemView),
@ -223,6 +232,13 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
});
}
if (flexibleCollectionsV1 && !organization.allowAdminAccessToAllCollectionItems) {
this.formGroup.controls.access.addValidators(validateCanManagePermission);
} else {
this.formGroup.controls.access.removeValidators(validateCanManagePermission);
}
this.formGroup.controls.access.updateValueAndValidity();
this.loading = false;
},
);

View File

@ -7447,6 +7447,12 @@
"collectionAccessRestricted": {
"message": "Collection access is restricted"
},
"grantCollectionAccess": {
"message": "Grant groups or members access to this collection."
},
"adminCollectionAccess": {
"message": "Administrators can access and manage collections."
},
"serviceAccountAccessUpdated": {
"message": "Service account access updated"
}