mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00: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:
@@ -89,7 +89,7 @@
|
|||||||
[selectorLabelText]="'selectGroupsAndMembers' | i18n"
|
[selectorLabelText]="'selectGroupsAndMembers' | i18n"
|
||||||
[selectorHelpText]="'userPermissionOverrideHelper' | i18n"
|
[selectorHelpText]="'userPermissionOverrideHelper' | i18n"
|
||||||
[emptySelectionText]="'noMembersOrGroupsAdded' | i18n"
|
[emptySelectionText]="'noMembersOrGroupsAdded' | i18n"
|
||||||
[flexibleCollectionsEnabled]="flexibleCollectionsEnabled$ | async"
|
[flexibleCollectionsEnabled]="organization.flexibleCollections"
|
||||||
></bit-access-selector>
|
></bit-access-selector>
|
||||||
<bit-access-selector
|
<bit-access-selector
|
||||||
*ngIf="!organization.useGroups"
|
*ngIf="!organization.useGroups"
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
[columnHeader]="'memberColumnHeader' | i18n"
|
[columnHeader]="'memberColumnHeader' | i18n"
|
||||||
[selectorLabelText]="'selectMembers' | i18n"
|
[selectorLabelText]="'selectMembers' | i18n"
|
||||||
[emptySelectionText]="'noMembersAdded' | i18n"
|
[emptySelectionText]="'noMembersAdded' | i18n"
|
||||||
[flexibleCollectionsEnabled]="flexibleCollectionsEnabled$ | async"
|
[flexibleCollectionsEnabled]="organization.flexibleCollections"
|
||||||
></bit-access-selector>
|
></bit-access-selector>
|
||||||
</bit-tab>
|
</bit-tab>
|
||||||
</bit-tab-group>
|
</bit-tab-group>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
switchMap,
|
switchMap,
|
||||||
takeUntil,
|
takeUntil,
|
||||||
} from "rxjs";
|
} from "rxjs";
|
||||||
|
import { first } from "rxjs/operators";
|
||||||
|
|
||||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
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";
|
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",
|
templateUrl: "collection-dialog.component.html",
|
||||||
})
|
})
|
||||||
export class CollectionDialogComponent implements OnInit, OnDestroy {
|
export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||||
protected flexibleCollectionsEnabled$ = this.organizationService
|
protected flexibleCollectionsV1Enabled$ = this.configService
|
||||||
.get$(this.params.organizationId)
|
.getFeatureFlag$(FeatureFlag.FlexibleCollectionsV1, false)
|
||||||
.pipe(map((o) => o?.flexibleCollections));
|
.pipe(first());
|
||||||
|
|
||||||
protected flexibleCollectionsV1Enabled$ = this.configService.getFeatureFlag$(
|
|
||||||
FeatureFlag.FlexibleCollectionsV1,
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
protected organizations$: Observable<Organization[]>;
|
protected organizations$: Observable<Organization[]>;
|
||||||
@@ -126,6 +122,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
.subscribe((id) => this.loadOrg(id, this.params.collectionIds));
|
.subscribe((id) => this.loadOrg(id, this.params.collectionIds));
|
||||||
this.organizations$ = this.organizationService.organizations$.pipe(
|
this.organizations$ = this.organizationService.organizations$.pipe(
|
||||||
|
first(),
|
||||||
map((orgs) =>
|
map((orgs) =>
|
||||||
orgs
|
orgs
|
||||||
.filter((o) => o.canCreateNewCollections && !o.isProviderUser)
|
.filter((o) => o.canCreateNewCollections && !o.isProviderUser)
|
||||||
@@ -165,7 +162,6 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
collection: this.params.collectionId
|
collection: this.params.collectionId
|
||||||
? this.collectionService.get(this.params.collectionId)
|
? this.collectionService.get(this.params.collectionId)
|
||||||
: of(null),
|
: of(null),
|
||||||
flexibleCollections: this.flexibleCollectionsEnabled$,
|
|
||||||
flexibleCollectionsV1: this.flexibleCollectionsV1Enabled$,
|
flexibleCollectionsV1: this.flexibleCollectionsV1Enabled$,
|
||||||
})
|
})
|
||||||
.pipe(takeUntil(this.formGroup.controls.selectedOrg.valueChanges), takeUntil(this.destroy$))
|
.pipe(takeUntil(this.formGroup.controls.selectedOrg.valueChanges), takeUntil(this.destroy$))
|
||||||
@@ -177,7 +173,6 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
groups,
|
groups,
|
||||||
users,
|
users,
|
||||||
collection,
|
collection,
|
||||||
flexibleCollections,
|
|
||||||
flexibleCollectionsV1,
|
flexibleCollectionsV1,
|
||||||
}) => {
|
}) => {
|
||||||
this.organization = organization;
|
this.organization = organization;
|
||||||
@@ -222,7 +217,7 @@ export class CollectionDialogComponent implements OnInit, OnDestroy {
|
|||||||
(u) => u.userId === this.organization?.userId,
|
(u) => u.userId === this.organization?.userId,
|
||||||
)?.id;
|
)?.id;
|
||||||
const initialSelection: AccessItemValue[] =
|
const initialSelection: AccessItemValue[] =
|
||||||
currentOrgUserId !== undefined && flexibleCollections
|
currentOrgUserId !== undefined && organization.flexibleCollections
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
id: currentOrgUserId,
|
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);
|
this.formGroup.controls.access.addValidators(validateCanManagePermission);
|
||||||
} else {
|
} else {
|
||||||
this.formGroup.controls.access.removeValidators(validateCanManagePermission);
|
this.formGroup.controls.access.removeValidators(validateCanManagePermission);
|
||||||
|
|||||||
Reference in New Issue
Block a user