Disable updating/deleting group posts and discussions for non-moderators

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2020-10-22 09:37:30 +02:00
parent 739516d2fd
commit e754e1172a
7 changed files with 39 additions and 18 deletions

View File

@@ -44,10 +44,19 @@ export default class GroupMixin extends Vue {
person!: IPerson;
get isCurrentActorAGroupAdmin(): boolean {
return this.hasCurrentActorThisRole(MemberRole.ADMINISTRATOR);
}
get isCurrentActorAGroupModerator(): boolean {
return this.hasCurrentActorThisRole([MemberRole.MODERATOR, MemberRole.ADMINISTRATOR]);
}
hasCurrentActorThisRole(givenRole: string | string[]): boolean {
const roles = Array.isArray(givenRole) ? givenRole : [givenRole];
return (
this.person &&
this.person.memberships.elements.some(
({ parent: { id }, role }) => id === this.group.id && role === MemberRole.ADMINISTRATOR
({ parent: { id }, role }) => id === this.group.id && roles.includes(role)
)
);
}