Skip to content

Commit 3bb9bcd

Browse files
David Florxkureck
authored andcommitted
fix(admin): disable checkboxes for members from member VOs
* on the members section of a VO, disable checkboxes for members that come from member VOs, which previously was doable and resulted in an error.
1 parent d361a90 commit 3bb9bcd

File tree

8 files changed

+55
-3
lines changed

8 files changed

+55
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export class VoMembersComponent implements OnInit {
4343
Urns.USER_DEF_ORGANIZATION,
4444
Urns.USER_DEF_PREFERRED_MAIL,
4545
Urns.MEMBER_DEF_EXPIRATION,
46+
Urns.MEMBER_LIFECYCLE_ALTERABLE,
4647
];
4748
statuses = new FormControl();
4849
statusList = ['VALID', 'INVALID', 'EXPIRED', 'DISABLED'];

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2195,7 +2195,8 @@
21952195
"NO_MEMBERS_ALERT": "No members present",
21962196
"NO_FILTER_RESULTS_ALERT": "No members are matching your query",
21972197
"INDIRECT_MEMBER": "Indirect member",
2198-
"CHECKBOX_TOOLTIP": "Indirect members cannot be removed"
2198+
"CHECKBOX_TOOLTIP_INDIRECT": "Indirect members cannot be removed",
2199+
"CHECKBOX_TOOLTIP_UNALTERABLE": "Members from member organizations cannot be directly removed"
21992200
},
22002201
"MEMBERS_CANDIDATES_LIST": {
22012202
"STATUS": "Status",

libs/perun/components/src/lib/members-dynamic-list/members-dynamic-list.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
[aria-label]="checkboxLabel(member)"
3535
[checked]="selection.isSelected(member)"
3636
attr.data-cy="{{member.user.firstName | lowercase}}-checkbox"
37-
[disabled]="member.membershipType === 'INDIRECT'"
38-
[matTooltip]="member.membershipType === 'INDIRECT' ? ('MEMBERS_LIST.CHECKBOX_TOOLTIP' | translate):''"
37+
[disabled]="(member | memberListCheckboxDisabled)"
38+
[matTooltip]="(member | memberCheckboxLabel)"
3939
color="primary">
4040
</mat-checkbox>
4141
</td>

libs/perun/pipes/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export * from './lib/member-status-icon.pipe';
99
export * from './lib/member-status-tooltip.pipe';
1010
export * from './lib/member-email.pipe';
1111
export * from './lib/member-logins.pipe';
12+
export * from './lib/member-list-checkbox-disabled.pipe';
13+
export * from './lib/member-checkbox-label.pipe';
1214
export * from './lib/parse-date.pipe';
1315
export * from './lib/technical-owners.pipe';
1416
export * from './lib/filter-unique-objects.pipe';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
import { TranslateService } from '@ngx-translate/core';
3+
import { RichMember } from '@perun-web-apps/perun/openapi';
4+
5+
@Pipe({
6+
name: 'memberCheckboxLabel',
7+
})
8+
export class MemberCheckboxLabelPipe implements PipeTransform {
9+
constructor(private translate: TranslateService) {}
10+
11+
transform(value: RichMember): string {
12+
if (value.membershipType === 'INDIRECT') {
13+
return this.translate.instant('MEMBERS_LIST.CHECKBOX_TOOLTIP_INDIRECT') as string;
14+
}
15+
const attr = value.memberAttributes.find((obj) => obj.friendlyName === 'isLifecycleAlterable');
16+
if (attr) {
17+
return attr.value
18+
? ''
19+
: (this.translate.instant('MEMBERS_LIST.CHECKBOX_TOOLTIP_UNALTERABLE') as string);
20+
}
21+
return '';
22+
}
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
import { RichMember } from '@perun-web-apps/perun/openapi';
3+
4+
@Pipe({
5+
name: 'memberListCheckboxDisabled',
6+
})
7+
export class MemberListCheckboxDisabledPipe implements PipeTransform {
8+
transform(value: RichMember): boolean {
9+
if (value.membershipType === 'INDIRECT') {
10+
return true;
11+
}
12+
const attr = value.memberAttributes.find((obj) => obj.friendlyName === 'isLifecycleAlterable');
13+
if (attr) {
14+
return !attr.value;
15+
}
16+
return false;
17+
}
18+
}

libs/perun/pipes/src/lib/perun-pipes.module.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { MemberEmailPipe } from './member-email.pipe';
1717
import { MemberLoginsPipe } from './member-logins.pipe';
1818
import { GroupExpirationPipe } from './group-expiration.pipe';
1919
import { MemberOrganizationPipe } from './member-organization.pipe';
20+
import { MemberListCheckboxDisabledPipe } from './member-list-checkbox-disabled.pipe';
21+
import { MemberCheckboxLabelPipe } from './member-checkbox-label.pipe';
2022
import { ParseDatePipe } from './parse-date.pipe';
2123
import { TechnicalOwnersPipe } from './technical-owners.pipe';
2224
import { FilterUniqueObjectsPipe } from './filter-unique-objects.pipe';
@@ -54,6 +56,8 @@ import { GroupMembersActionButtonDisabledTooltipPipe } from './group-members-act
5456
MemberEmailPipe,
5557
MemberLoginsPipe,
5658
MemberOrganizationPipe,
59+
MemberListCheckboxDisabledPipe,
60+
MemberCheckboxLabelPipe,
5761
GroupExpirationPipe,
5862
ParseDatePipe,
5963
TechnicalOwnersPipe,
@@ -92,6 +96,8 @@ import { GroupMembersActionButtonDisabledTooltipPipe } from './group-members-act
9296
MemberLoginsPipe,
9397
GroupExpirationPipe,
9498
MemberOrganizationPipe,
99+
MemberListCheckboxDisabledPipe,
100+
MemberCheckboxLabelPipe,
95101
ParseDatePipe,
96102
TechnicalOwnersPipe,
97103
FilterUniqueObjectsPipe,

libs/perun/urns/src/lib/perun-urns.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export class Urns {
66
static MEMBER_DEF_ORGANIZATION = 'urn:perun:member:attribute-def:def:organization';
77
static MEMBER_DEF_MAIL = 'urn:perun:member:attribute-def:def:mail';
88
static MEMBER_CORE_ID = 'urn:perun:member:attribute-def:core:id';
9+
static MEMBER_LIFECYCLE_ALTERABLE = 'urn:perun:member:attribute-def:virt:isLifecycleAlterable';
910

1011
// Vo
1112
static VO_DEF_EXPIRATION_RULES = 'urn:perun:vo:attribute-def:def:membershipExpirationRules';

0 commit comments

Comments
 (0)