mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01:00
[AC-1899] Fix Collection Access Model Resetting (#7612)
* [AC-1899] Only take the first emission of feature flags and organizations to avoid overwriting form values * [AC-1899] Fix flexibleCollections flag to update when selected org changes * [AC-1899] Prettier
This commit is contained in:
parent
83480e20ed
commit
2e11fb2a24
@ -89,7 +89,7 @@
|
||||
[selectorLabelText]="'selectGroupsAndMembers' | i18n"
|
||||
[selectorHelpText]="'userPermissionOverrideHelper' | i18n"
|
||||
[emptySelectionText]="'noMembersOrGroupsAdded' | i18n"
|
||||
[flexibleCollectionsEnabled]="flexibleCollectionsEnabled$ | async"
|
||||
[flexibleCollectionsEnabled]="organization.flexibleCollections"
|
||||
></bit-access-selector>
|
||||
<bit-access-selector
|
||||
*ngIf="!organization.useGroups"
|
||||
@ -99,7 +99,7 @@
|
||||
[columnHeader]="'memberColumnHeader' | i18n"
|
||||
[selectorLabelText]="'selectMembers' | i18n"
|
||||
[emptySelectionText]="'noMembersAdded' | i18n"
|
||||
[flexibleCollectionsEnabled]="flexibleCollectionsEnabled$ | async"
|
||||
[flexibleCollectionsEnabled]="organization.flexibleCollections"
|
||||
></bit-access-selector>
|
||||
</bit-tab>
|
||||
</bit-tab-group>
|
||||
|
@ -12,6 +12,7 @@ import {
|
||||
switchMap,
|
||||
takeUntil,
|
||||
} from "rxjs";
|
||||
import { first } from "rxjs/operators";
|
||||
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
import { OrganizationUserService } from "@bitwarden/common/admin-console/abstractions/organization-user/organization-user.service";
|
||||
@ -70,14 +71,9 @@ export enum CollectionDialogAction {
|
||||
templateUrl: "collection-dialog.component.html",
|
||||
})
|
||||
export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
protected flexibleCollectionsEnabled$ = this.organizationService
|
||||
.get$(this.params.organizationId)
|
||||
.pipe(map((o) => o?.flexibleCollections));
|
||||
|
||||
protected flexibleCollectionsV1Enabled$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.FlexibleCollectionsV1,
|
||||
false,
|
||||
);
|
||||
protected flexibleCollectionsV1Enabled$ = this.configService
|
||||
.getFeatureFlag$(FeatureFlag.FlexibleCollectionsV1, false)
|
||||
.pipe(first());
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
protected organizations$: Observable<Organization[]>;
|
||||
@ -126,6 +122,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((id) => this.loadOrg(id, this.params.collectionIds));
|
||||
this.organizations$ = this.organizationService.organizations$.pipe(
|
||||
first(),
|
||||
map((orgs) =>
|
||||
orgs
|
||||
.filter((o) => o.canCreateNewCollections && !o.isProviderUser)
|
||||
@ -165,7 +162,6 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
collection: this.params.collectionId
|
||||
? this.collectionService.get(this.params.collectionId)
|
||||
: of(null),
|
||||
flexibleCollections: this.flexibleCollectionsEnabled$,
|
||||
flexibleCollectionsV1: this.flexibleCollectionsV1Enabled$,
|
||||
})
|
||||
.pipe(takeUntil(this.formGroup.controls.selectedOrg.valueChanges), takeUntil(this.destroy$))
|
||||
@ -177,7 +173,6 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
groups,
|
||||
users,
|
||||
collection,
|
||||
flexibleCollections,
|
||||
flexibleCollectionsV1,
|
||||
}) => {
|
||||
this.organization = organization;
|
||||
@ -222,7 +217,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
(u) => u.userId === this.organization?.userId,
|
||||
)?.id;
|
||||
const initialSelection: AccessItemValue[] =
|
||||
currentOrgUserId !== undefined && flexibleCollections
|
||||
currentOrgUserId !== undefined && organization.flexibleCollections
|
||||
? [
|
||||
{
|
||||
id: currentOrgUserId,
|
||||
@ -238,7 +233,11 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
if (flexibleCollectionsV1 && !organization.allowAdminAccessToAllCollectionItems) {
|
||||
if (
|
||||
organization.flexibleCollections &&
|
||||
flexibleCollectionsV1 &&
|
||||
!organization.allowAdminAccessToAllCollectionItems
|
||||
) {
|
||||
this.formGroup.controls.access.addValidators(validateCanManagePermission);
|
||||
} else {
|
||||
this.formGroup.controls.access.removeValidators(validateCanManagePermission);
|
||||
|
Loading…
Reference in New Issue
Block a user