From 121494fb2e7bf0effa77eb4b862f7c5a8cf0c7ba Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Fri, 17 May 2024 02:15:33 +1000 Subject: [PATCH] [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 --- .../manage/group-add-edit.component.html | 6 +- .../manage/group-add-edit.component.ts | 15 ++++- .../member-dialog.component.html | 17 +++--- .../member-dialog/member-dialog.component.ts | 58 ++++++++++++------- .../collection-dialog.component.html | 2 +- .../bulk-collections-dialog.component.html | 2 +- apps/web/src/locales/en/messages.json | 8 +-- 7 files changed, 69 insertions(+), 39 deletions(-) diff --git a/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.html b/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.html index 5fcf7b0f42..df731c5cf1 100644 --- a/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.html +++ b/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.html @@ -33,7 +33,7 @@

{{ "editGroupMembersDesc" | i18n }} - + {{ "restrictedGroupAccessDesc" | i18n }}

@@ -52,8 +52,8 @@

{{ "editGroupCollectionsDesc" | i18n }} - - {{ "editGroupCollectionsRestrictionsDesc" | i18n }} + + {{ "restrictedCollectionAssignmentDesc" | i18n }}

diff --git a/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.ts b/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.ts index dff549ba6e..a02c4a8da9 100644 --- a/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.ts +++ b/apps/web/src/app/admin-console/organizations/manage/group-add-edit.component.ts @@ -183,7 +183,7 @@ export class GroupAddEditComponent implements OnInit, OnDestroy { shareReplay({ refCount: true, bufferSize: 1 }), ); - allowAdminAccessToAllCollectionItems$ = combineLatest([ + protected allowAdminAccessToAllCollectionItems$ = combineLatest([ this.organization$, this.flexibleCollectionsV1Enabled$, ]).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.groupDetails$, ]).pipe(map(([allowAdminAccess, groupDetails]) => !allowAdminAccess && groupDetails != null)); @@ -229,7 +238,7 @@ export class GroupAddEditComponent implements OnInit, OnDestroy { this.orgCollections$, this.orgMembers$, this.groupDetails$, - this.restrictGroupAccess$, + this.cannotAddSelfToGroup$, this.accountService.activeAccount$, this.organization$, this.flexibleCollectionsV1Enabled$, diff --git a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html index 4d81d070fb..2719666cc8 100644 --- a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html +++ b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html @@ -405,7 +405,7 @@
{{ - (restrictedAccess$ | async) + (restrictEditingSelf$ | async) ? ("restrictedGroupAccess" | i18n) : ("groupAccessUserDesc" | i18n) }} @@ -417,15 +417,18 @@ [selectorLabelText]="'selectGroups' | i18n" [emptySelectionText]="'noGroupsAdded' | i18n" [flexibleCollectionsEnabled]="organization.flexibleCollections" - [hideMultiSelect]="restrictedAccess$ | async" + [hideMultiSelect]="restrictEditingSelf$ | async" > -
- {{ "restrictedCollectionAccess" | i18n }} +
+ {{ "cannotAddYourselfToCollections" | i18n }}
-
- {{ "userPermissionOverrideHelper" | i18n }} +
+ {{ "userPermissionOverrideHelperDesc" | i18n }} + + {{ "restrictedCollectionAssignmentDesc" | i18n }} +
@@ -454,7 +457,7 @@ [selectorLabelText]="'selectCollections' | i18n" [emptySelectionText]="'noCollectionsAdded' | i18n" [flexibleCollectionsEnabled]="organization.flexibleCollections" - [hideMultiSelect]="restrictedAccess$ | async" + [hideMultiSelect]="restrictEditingSelf$ | async" > diff --git a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts index a67bea39c0..8309d4d725 100644 --- a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts +++ b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.ts @@ -105,7 +105,9 @@ export class MemberDialogComponent implements OnDestroy { groups: [[] as AccessItemValue[]], }); - protected restrictedAccess$: Observable; + protected allowAdminAccessToAllCollectionItems$: Observable; + protected restrictEditingSelf$: Observable; + protected canEditAnyCollection$: Observable; protected permissionsGroup = this.formBuilder.group({ manageAssignedCollectionsGroup: this.formBuilder.group>({ @@ -182,43 +184,59 @@ export class MemberDialogComponent implements OnDestroy { ? this.userService.get(this.params.organizationId, this.params.organizationUserId) : of(null); - // The orgUser cannot manage their own Group assignments if collection access is restricted - // TODO: fix disabled state of access-selector rows so that any controls are hidden - this.restrictedAccess$ = combineLatest([ + this.allowAdminAccessToAllCollectionItems$ = combineLatest([ this.organization$, - userDetails$, - this.accountService.activeAccount$, 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( map( - ([organization, userDetails, activeAccount, flexibleCollectionsV1Enabled]) => - // Feature flag conditionals - flexibleCollectionsV1Enabled && - organization.flexibleCollections && - // Business logic conditionals - userDetails != null && - userDetails.userId == activeAccount.id && - !organization.allowAdminAccessToAllCollectionItems, + ([allowAdminAccess, userDetails, activeAccount]) => + !allowAdminAccess && userDetails != null && userDetails.userId == activeAccount.id, ), shareReplay({ refCount: true, bufferSize: 1 }), ); - this.restrictedAccess$.pipe(takeUntil(this.destroy$)).subscribe((restrictedAccess) => { - if (restrictedAccess) { + this.restrictEditingSelf$.pipe(takeUntil(this.destroy$)).subscribe((restrictEditingSelf) => { + if (restrictEditingSelf) { this.formGroup.controls.groups.disable(); } else { 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({ organization: this.organization$, collections: this.collectionAdminService.getAll(this.params.organizationId), userDetails: userDetails$, groups: groups$, - flexibleCollectionsV1Enabled: this.configService.getFeatureFlag$( - FeatureFlag.FlexibleCollectionsV1, - ), + flexibleCollectionsV1Enabled: flexibleCollectionsV1Enabled$, }) .pipe(takeUntil(this.destroy$)) .subscribe( @@ -454,7 +472,7 @@ export class MemberDialogComponent implements OnDestroy { .filter((v) => v.type === AccessItemType.Collection) .map(convertToSelectionView); - userView.groups = (await firstValueFrom(this.restrictedAccess$)) + userView.groups = (await firstValueFrom(this.restrictEditingSelf$)) ? null : this.formGroup.value.groups.map((m) => m.id); diff --git a/apps/web/src/app/vault/components/collection-dialog/collection-dialog.component.html b/apps/web/src/app/vault/components/collection-dialog/collection-dialog.component.html index 6adf6bcf8f..3f5624c0c9 100644 --- a/apps/web/src/app/vault/components/collection-dialog/collection-dialog.component.html +++ b/apps/web/src/app/vault/components/collection-dialog/collection-dialog.component.html @@ -105,7 +105,7 @@ [items]="accessItems" [columnHeader]="'groupSlashMemberColumnHeader' | i18n" [selectorLabelText]="'selectGroupsAndMembers' | i18n" - [selectorHelpText]="'userPermissionOverrideHelper' | i18n" + [selectorHelpText]="'userPermissionOverrideHelperDesc' | i18n" [emptySelectionText]="'noMembersOrGroupsAdded' | i18n" [flexibleCollectionsEnabled]="organization.flexibleCollections" > diff --git a/apps/web/src/app/vault/org-vault/bulk-collections-dialog/bulk-collections-dialog.component.html b/apps/web/src/app/vault/org-vault/bulk-collections-dialog/bulk-collections-dialog.component.html index a2b668f7db..9ce066f06e 100644 --- a/apps/web/src/app/vault/org-vault/bulk-collections-dialog/bulk-collections-dialog.component.html +++ b/apps/web/src/app/vault/org-vault/bulk-collections-dialog/bulk-collections-dialog.component.html @@ -15,7 +15,7 @@ [items]="accessItems" [columnHeader]="'groupSlashMemberColumnHeader' | i18n" [selectorLabelText]="'selectGroupsAndMembers' | i18n" - [selectorHelpText]="'userPermissionOverrideHelper' | i18n" + [selectorHelpText]="'userPermissionOverrideHelperDesc' | i18n" [emptySelectionText]="'noMembersOrGroupsAdded' | i18n" [flexibleCollectionsEnabled]="flexibleCollectionsEnabled$ | async" > diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index d308acaaa8..3afd318266 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -6588,7 +6588,7 @@ "editGroupCollectionsDesc": { "message": "Grant access to collections by adding them to this group." }, - "editGroupCollectionsRestrictionsDesc": { + "restrictedCollectionAssignmentDesc": { "message": "You can only assign collections you manage." }, "accessAllCollectionsDesc": { @@ -6822,8 +6822,8 @@ "selectGroups": { "message": "Select groups" }, - "userPermissionOverrideHelper": { - "message": "Permissions set for a member will replace permissions set by that member's group" + "userPermissionOverrideHelperDesc": { + "message": "Permissions set for a member will replace permissions set by that member's group." }, "noMembersOrGroupsAdded": { "message": "No members or groups added" @@ -7749,7 +7749,7 @@ "restrictedGroupAccess": { "message": "You cannot add yourself to groups." }, - "restrictedCollectionAccess": { + "cannotAddYourselfToCollections": { "message": "You cannot add yourself to collections." }, "assign": {