Skip to content

Commit 266905f

Browse files
xflordHejdaJakub
authored andcommitted
fix(admin) disable copy members button when there aren't any members to copy
* check number of group direct members before enabling copy button * updated openapi
1 parent 8fed7b0 commit 266905f

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

apps/admin-gui/src/app/vos/pages/group-detail-page/group-members/group-members.component.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,17 @@ <h1 class="page-subtitle">{{'GROUP_DETAIL.MEMBERS.TITLE' | translate}}</h1>
5151
</button>
5252
</mat-menu>
5353
</span>
54-
<span>
55-
<button (click)="onCopyMembers()" *ngIf="copyAuth" class="mr-2" color="accent" mat-flat-button>
54+
<span
55+
[matTooltipDisabled]="!copyDisabled"
56+
[matTooltipPosition]="'above'"
57+
matTooltip="{{'GROUP_DETAIL.MEMBERS.COPY_MEMBERS_DISABLED' | translate}}">
58+
<button
59+
(click)="onCopyMembers()"
60+
*ngIf="copyAuth"
61+
[disabled]="copyDisabled"
62+
class="mr-2"
63+
color="accent"
64+
mat-flat-button>
5665
{{'GROUP_DETAIL.MEMBERS.COPY_MEMBERS' | translate}}
5766
</button>
5867
</span>

apps/admin-gui/src/app/vos/pages/group-detail-page/group-members/group-members.component.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export class GroupMembersComponent implements OnInit {
5757
removeAuth: boolean;
5858
inviteAuth: boolean;
5959
copyAuth: boolean;
60+
copyDisabled = false;
6061
blockManualMemberAdding: boolean;
6162
displayedColumns = [
6263
'checkbox',
@@ -105,6 +106,7 @@ export class GroupMembersComponent implements OnInit {
105106
this.group = this.entityStorageService.getEntity();
106107
this.setAuthRights();
107108
void this.isManualAddingBlocked(this.group.voId).then(() => this.loadPage(this.group.id));
109+
this.isCopyMembersDisabled();
108110
}
109111

110112
loadPage(groupId: number): void {
@@ -156,6 +158,7 @@ export class GroupMembersComponent implements OnInit {
156158
if (wereMembersAdded) {
157159
this.selection.clear();
158160
this.updateTable = !this.updateTable;
161+
this.isCopyMembersDisabled();
159162
}
160163
});
161164
}
@@ -175,6 +178,7 @@ export class GroupMembersComponent implements OnInit {
175178
if (wereMembersDeleted) {
176179
this.selection.clear();
177180
this.updateTable = !this.updateTable;
181+
this.isCopyMembersDisabled();
178182
}
179183
});
180184
}
@@ -264,6 +268,18 @@ export class GroupMembersComponent implements OnInit {
264268
});
265269
}
266270

271+
isCopyMembersDisabled(): void {
272+
this.copyDisabled = false;
273+
this.groupService.getGroupDirectMembersCount(this.group.id).subscribe({
274+
next: (count) => {
275+
this.copyDisabled = count === 0;
276+
},
277+
error: () => {
278+
this.copyDisabled = true;
279+
},
280+
});
281+
}
282+
267283
changeVoStatuses(): void {
268284
this.selection.clear();
269285
this.selectedStatuses = this.statuses.value as VoMemberStatuses[];
@@ -277,5 +293,6 @@ export class GroupMembersComponent implements OnInit {
277293
refreshTable(): void {
278294
this.selection.clear();
279295
this.updateTable = !this.updateTable;
296+
this.isCopyMembersDisabled();
280297
}
281298
}

apps/admin-gui/src/assets/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@
665665
"ADD_MEMBER_DISABLED": "Manual adding of members is blocked for this group.",
666666
"REMOVE_MEMBERS": "Remove",
667667
"COPY_MEMBERS": "Copy",
668+
"COPY_MEMBERS_DISABLED": "There aren't any direct members available to copy.",
668669
"SEARCH_DESCRIPTION": "Search by name, login, email or UUID",
669670
"LIST_ALL": "List all members",
670671
"INVITE": "Invite",

0 commit comments

Comments
 (0)