1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

[AC-2610] [AC-2613] Fix copy in members and groups dialogs (#9200)

* Add missing copy to member dialog

* [AC-2613] Fix copy for providers in Collections tabs
This commit is contained in:
Thomas Rittson 2024-05-17 02:15:33 +10:00 committed by GitHub
parent aa0627fa38
commit 121494fb2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 69 additions and 39 deletions

View File

@ -33,7 +33,7 @@
<bit-tab label="{{ 'members' | i18n }}"> <bit-tab label="{{ 'members' | i18n }}">
<p> <p>
{{ "editGroupMembersDesc" | i18n }} {{ "editGroupMembersDesc" | i18n }}
<span *ngIf="restrictGroupAccess$ | async"> <span *ngIf="cannotAddSelfToGroup$ | async">
{{ "restrictedGroupAccessDesc" | i18n }} {{ "restrictedGroupAccessDesc" | i18n }}
</span> </span>
</p> </p>
@ -52,8 +52,8 @@
<bit-tab label="{{ 'collections' | i18n }}"> <bit-tab label="{{ 'collections' | i18n }}">
<p> <p>
{{ "editGroupCollectionsDesc" | i18n }} {{ "editGroupCollectionsDesc" | i18n }}
<span *ngIf="!(allowAdminAccessToAllCollectionItems$ | async)"> <span *ngIf="!(canEditAnyCollection$ | async)">
{{ "editGroupCollectionsRestrictionsDesc" | i18n }} {{ "restrictedCollectionAssignmentDesc" | i18n }}
</span> </span>
</p> </p>
<div *ngIf="!(flexibleCollectionsEnabled$ | async)" class="tw-my-3"> <div *ngIf="!(flexibleCollectionsEnabled$ | async)" class="tw-my-3">

View File

@ -183,7 +183,7 @@ export class GroupAddEditComponent implements OnInit, OnDestroy {
shareReplay({ refCount: true, bufferSize: 1 }), shareReplay({ refCount: true, bufferSize: 1 }),
); );
allowAdminAccessToAllCollectionItems$ = combineLatest([ protected allowAdminAccessToAllCollectionItems$ = combineLatest([
this.organization$, this.organization$,
this.flexibleCollectionsV1Enabled$, this.flexibleCollectionsV1Enabled$,
]).pipe( ]).pipe(
@ -196,7 +196,16 @@ export class GroupAddEditComponent implements OnInit, OnDestroy {
}), }),
); );
restrictGroupAccess$ = combineLatest([ protected canEditAnyCollection$ = combineLatest([
this.organization$,
this.flexibleCollectionsV1Enabled$,
]).pipe(
map(([org, flexibleCollectionsV1Enabled]) =>
org.canEditAnyCollection(flexibleCollectionsV1Enabled),
),
);
protected cannotAddSelfToGroup$ = combineLatest([
this.allowAdminAccessToAllCollectionItems$, this.allowAdminAccessToAllCollectionItems$,
this.groupDetails$, this.groupDetails$,
]).pipe(map(([allowAdminAccess, groupDetails]) => !allowAdminAccess && groupDetails != null)); ]).pipe(map(([allowAdminAccess, groupDetails]) => !allowAdminAccess && groupDetails != null));
@ -229,7 +238,7 @@ export class GroupAddEditComponent implements OnInit, OnDestroy {
this.orgCollections$, this.orgCollections$,
this.orgMembers$, this.orgMembers$,
this.groupDetails$, this.groupDetails$,
this.restrictGroupAccess$, this.cannotAddSelfToGroup$,
this.accountService.activeAccount$, this.accountService.activeAccount$,
this.organization$, this.organization$,
this.flexibleCollectionsV1Enabled$, this.flexibleCollectionsV1Enabled$,

View File

@ -405,7 +405,7 @@
<bit-tab *ngIf="organization.useGroups" [label]="'groups' | i18n"> <bit-tab *ngIf="organization.useGroups" [label]="'groups' | i18n">
<div class="tw-mb-6"> <div class="tw-mb-6">
{{ {{
(restrictedAccess$ | async) (restrictEditingSelf$ | async)
? ("restrictedGroupAccess" | i18n) ? ("restrictedGroupAccess" | i18n)
: ("groupAccessUserDesc" | i18n) : ("groupAccessUserDesc" | i18n)
}} }}
@ -417,15 +417,18 @@
[selectorLabelText]="'selectGroups' | i18n" [selectorLabelText]="'selectGroups' | i18n"
[emptySelectionText]="'noGroupsAdded' | i18n" [emptySelectionText]="'noGroupsAdded' | i18n"
[flexibleCollectionsEnabled]="organization.flexibleCollections" [flexibleCollectionsEnabled]="organization.flexibleCollections"
[hideMultiSelect]="restrictedAccess$ | async" [hideMultiSelect]="restrictEditingSelf$ | async"
></bit-access-selector> ></bit-access-selector>
</bit-tab> </bit-tab>
<bit-tab [label]="'collections' | i18n"> <bit-tab [label]="'collections' | i18n">
<div class="tw-mb-6" *ngIf="restrictedAccess$ | async"> <div class="tw-mb-6" *ngIf="restrictEditingSelf$ | async">
{{ "restrictedCollectionAccess" | i18n }} {{ "cannotAddYourselfToCollections" | i18n }}
</div> </div>
<div *ngIf="organization.useGroups && !(restrictedAccess$ | async)" class="tw-mb-6"> <div *ngIf="organization.useGroups && !(restrictEditingSelf$ | async)" class="tw-mb-6">
{{ "userPermissionOverrideHelper" | i18n }} {{ "userPermissionOverrideHelperDesc" | i18n }}
<span *ngIf="!(canEditAnyCollection$ | async)">
{{ "restrictedCollectionAssignmentDesc" | i18n }}
</span>
</div> </div>
<div *ngIf="!organization.flexibleCollections" class="tw-mb-6"> <div *ngIf="!organization.flexibleCollections" class="tw-mb-6">
<bit-form-control> <bit-form-control>
@ -454,7 +457,7 @@
[selectorLabelText]="'selectCollections' | i18n" [selectorLabelText]="'selectCollections' | i18n"
[emptySelectionText]="'noCollectionsAdded' | i18n" [emptySelectionText]="'noCollectionsAdded' | i18n"
[flexibleCollectionsEnabled]="organization.flexibleCollections" [flexibleCollectionsEnabled]="organization.flexibleCollections"
[hideMultiSelect]="restrictedAccess$ | async" [hideMultiSelect]="restrictEditingSelf$ | async"
></bit-access-selector ></bit-access-selector
></bit-tab> ></bit-tab>
</bit-tab-group> </bit-tab-group>

View File

@ -105,7 +105,9 @@ export class MemberDialogComponent implements OnDestroy {
groups: [[] as AccessItemValue[]], groups: [[] as AccessItemValue[]],
}); });
protected restrictedAccess$: Observable<boolean>; protected allowAdminAccessToAllCollectionItems$: Observable<boolean>;
protected restrictEditingSelf$: Observable<boolean>;
protected canEditAnyCollection$: Observable<boolean>;
protected permissionsGroup = this.formBuilder.group({ protected permissionsGroup = this.formBuilder.group({
manageAssignedCollectionsGroup: this.formBuilder.group<Record<string, boolean>>({ manageAssignedCollectionsGroup: this.formBuilder.group<Record<string, boolean>>({
@ -182,43 +184,59 @@ export class MemberDialogComponent implements OnDestroy {
? this.userService.get(this.params.organizationId, this.params.organizationUserId) ? this.userService.get(this.params.organizationId, this.params.organizationUserId)
: of(null); : of(null);
// The orgUser cannot manage their own Group assignments if collection access is restricted this.allowAdminAccessToAllCollectionItems$ = combineLatest([
// TODO: fix disabled state of access-selector rows so that any controls are hidden
this.restrictedAccess$ = combineLatest([
this.organization$, this.organization$,
userDetails$,
this.accountService.activeAccount$,
this.configService.getFeatureFlag$(FeatureFlag.FlexibleCollectionsV1), this.configService.getFeatureFlag$(FeatureFlag.FlexibleCollectionsV1),
]).pipe(
map(([organization, flexibleCollectionsV1Enabled]) => {
if (!flexibleCollectionsV1Enabled || !organization.flexibleCollections) {
return true;
}
return organization.allowAdminAccessToAllCollectionItems;
}),
);
// The orgUser cannot manage their own Group assignments if collection access is restricted
this.restrictEditingSelf$ = combineLatest([
this.allowAdminAccessToAllCollectionItems$,
userDetails$,
this.accountService.activeAccount$,
]).pipe( ]).pipe(
map( map(
([organization, userDetails, activeAccount, flexibleCollectionsV1Enabled]) => ([allowAdminAccess, userDetails, activeAccount]) =>
// Feature flag conditionals !allowAdminAccess && userDetails != null && userDetails.userId == activeAccount.id,
flexibleCollectionsV1Enabled &&
organization.flexibleCollections &&
// Business logic conditionals
userDetails != null &&
userDetails.userId == activeAccount.id &&
!organization.allowAdminAccessToAllCollectionItems,
), ),
shareReplay({ refCount: true, bufferSize: 1 }), shareReplay({ refCount: true, bufferSize: 1 }),
); );
this.restrictedAccess$.pipe(takeUntil(this.destroy$)).subscribe((restrictedAccess) => { this.restrictEditingSelf$.pipe(takeUntil(this.destroy$)).subscribe((restrictEditingSelf) => {
if (restrictedAccess) { if (restrictEditingSelf) {
this.formGroup.controls.groups.disable(); this.formGroup.controls.groups.disable();
} else { } else {
this.formGroup.controls.groups.enable(); this.formGroup.controls.groups.enable();
} }
}); });
const flexibleCollectionsV1Enabled$ = this.configService.getFeatureFlag$(
FeatureFlag.FlexibleCollectionsV1,
);
this.canEditAnyCollection$ = combineLatest([
this.organization$,
flexibleCollectionsV1Enabled$,
]).pipe(
map(([org, flexibleCollectionsV1Enabled]) =>
org.canEditAnyCollection(flexibleCollectionsV1Enabled),
),
);
combineLatest({ combineLatest({
organization: this.organization$, organization: this.organization$,
collections: this.collectionAdminService.getAll(this.params.organizationId), collections: this.collectionAdminService.getAll(this.params.organizationId),
userDetails: userDetails$, userDetails: userDetails$,
groups: groups$, groups: groups$,
flexibleCollectionsV1Enabled: this.configService.getFeatureFlag$( flexibleCollectionsV1Enabled: flexibleCollectionsV1Enabled$,
FeatureFlag.FlexibleCollectionsV1,
),
}) })
.pipe(takeUntil(this.destroy$)) .pipe(takeUntil(this.destroy$))
.subscribe( .subscribe(
@ -454,7 +472,7 @@ export class MemberDialogComponent implements OnDestroy {
.filter((v) => v.type === AccessItemType.Collection) .filter((v) => v.type === AccessItemType.Collection)
.map(convertToSelectionView); .map(convertToSelectionView);
userView.groups = (await firstValueFrom(this.restrictedAccess$)) userView.groups = (await firstValueFrom(this.restrictEditingSelf$))
? null ? null
: this.formGroup.value.groups.map((m) => m.id); : this.formGroup.value.groups.map((m) => m.id);

View File

@ -105,7 +105,7 @@
[items]="accessItems" [items]="accessItems"
[columnHeader]="'groupSlashMemberColumnHeader' | i18n" [columnHeader]="'groupSlashMemberColumnHeader' | i18n"
[selectorLabelText]="'selectGroupsAndMembers' | i18n" [selectorLabelText]="'selectGroupsAndMembers' | i18n"
[selectorHelpText]="'userPermissionOverrideHelper' | i18n" [selectorHelpText]="'userPermissionOverrideHelperDesc' | i18n"
[emptySelectionText]="'noMembersOrGroupsAdded' | i18n" [emptySelectionText]="'noMembersOrGroupsAdded' | i18n"
[flexibleCollectionsEnabled]="organization.flexibleCollections" [flexibleCollectionsEnabled]="organization.flexibleCollections"
></bit-access-selector> ></bit-access-selector>

View File

@ -15,7 +15,7 @@
[items]="accessItems" [items]="accessItems"
[columnHeader]="'groupSlashMemberColumnHeader' | i18n" [columnHeader]="'groupSlashMemberColumnHeader' | i18n"
[selectorLabelText]="'selectGroupsAndMembers' | i18n" [selectorLabelText]="'selectGroupsAndMembers' | i18n"
[selectorHelpText]="'userPermissionOverrideHelper' | i18n" [selectorHelpText]="'userPermissionOverrideHelperDesc' | i18n"
[emptySelectionText]="'noMembersOrGroupsAdded' | i18n" [emptySelectionText]="'noMembersOrGroupsAdded' | i18n"
[flexibleCollectionsEnabled]="flexibleCollectionsEnabled$ | async" [flexibleCollectionsEnabled]="flexibleCollectionsEnabled$ | async"
></bit-access-selector> ></bit-access-selector>

View File

@ -6588,7 +6588,7 @@
"editGroupCollectionsDesc": { "editGroupCollectionsDesc": {
"message": "Grant access to collections by adding them to this group." "message": "Grant access to collections by adding them to this group."
}, },
"editGroupCollectionsRestrictionsDesc": { "restrictedCollectionAssignmentDesc": {
"message": "You can only assign collections you manage." "message": "You can only assign collections you manage."
}, },
"accessAllCollectionsDesc": { "accessAllCollectionsDesc": {
@ -6822,8 +6822,8 @@
"selectGroups": { "selectGroups": {
"message": "Select groups" "message": "Select groups"
}, },
"userPermissionOverrideHelper": { "userPermissionOverrideHelperDesc": {
"message": "Permissions set for a member will replace permissions set by that member's group" "message": "Permissions set for a member will replace permissions set by that member's group."
}, },
"noMembersOrGroupsAdded": { "noMembersOrGroupsAdded": {
"message": "No members or groups added" "message": "No members or groups added"
@ -7749,7 +7749,7 @@
"restrictedGroupAccess": { "restrictedGroupAccess": {
"message": "You cannot add yourself to groups." "message": "You cannot add yourself to groups."
}, },
"restrictedCollectionAccess": { "cannotAddYourselfToCollections": {
"message": "You cannot add yourself to collections." "message": "You cannot add yourself to collections."
}, },
"assign": { "assign": {