[Groups] Allow to promote/demote to moderator
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
27a75cd0df
commit
375e6d2bef
|
@ -142,19 +142,22 @@
|
||||||
<b-table-column field="actions" :label="$t('Actions')" v-slot="props">
|
<b-table-column field="actions" :label="$t('Actions')" v-slot="props">
|
||||||
<div class="buttons" v-if="props.row.actor.id !== currentActor.id">
|
<div class="buttons" v-if="props.row.actor.id !== currentActor.id">
|
||||||
<b-button
|
<b-button
|
||||||
v-if="props.row.role === MemberRole.MEMBER"
|
v-if="[MemberRole.MEMBER, MemberRole.MODERATOR].includes(props.row.role)"
|
||||||
@click="promoteMember(props.row.id)"
|
@click="promoteMember(props.row)"
|
||||||
|
icon-left="chevron-double-up"
|
||||||
>{{ $t("Promote") }}</b-button
|
>{{ $t("Promote") }}</b-button
|
||||||
>
|
>
|
||||||
<b-button
|
<b-button
|
||||||
v-if="props.row.role === MemberRole.ADMINISTRATOR"
|
v-if="[MemberRole.ADMINISTRATOR, MemberRole.MODERATOR].includes(props.row.role)"
|
||||||
@click="demoteMember(props.row.id)"
|
@click="demoteMember(props.row)"
|
||||||
|
icon-left="chevron-double-down"
|
||||||
>{{ $t("Demote") }}</b-button
|
>{{ $t("Demote") }}</b-button
|
||||||
>
|
>
|
||||||
<b-button
|
<b-button
|
||||||
v-if="props.row.role === MemberRole.MEMBER"
|
v-if="props.row.role === MemberRole.MEMBER"
|
||||||
@click="removeMember(props.row.id)"
|
@click="removeMember(props.row.id)"
|
||||||
type="is-danger"
|
type="is-danger"
|
||||||
|
icon-left="exit-to-app"
|
||||||
>{{ $t("Remove") }}</b-button
|
>{{ $t("Remove") }}</b-button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
@ -329,12 +332,24 @@ export default class GroupMembers extends Vue {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
promoteMember(memberId: string): Promise<void> {
|
promoteMember(member: IMember): void {
|
||||||
return this.updateMember(memberId, MemberRole.ADMINISTRATOR);
|
if (!member.id) return;
|
||||||
|
if (member.role === MemberRole.MODERATOR) {
|
||||||
|
this.updateMember(member.id, MemberRole.ADMINISTRATOR);
|
||||||
|
}
|
||||||
|
if (member.role === MemberRole.MEMBER) {
|
||||||
|
this.updateMember(member.id, MemberRole.MODERATOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
demoteMember(memberId: string): Promise<void> {
|
demoteMember(member: IMember): void {
|
||||||
return this.updateMember(memberId, MemberRole.MEMBER);
|
if (!member.id) return;
|
||||||
|
if (member.role === MemberRole.MODERATOR) {
|
||||||
|
this.updateMember(member.id, MemberRole.MEMBER);
|
||||||
|
}
|
||||||
|
if (member.role === MemberRole.ADMINISTRATOR) {
|
||||||
|
this.updateMember(member.id, MemberRole.MODERATOR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateMember(memberId: string, role: MemberRole): Promise<void> {
|
async updateMember(memberId: string, role: MemberRole): Promise<void> {
|
||||||
|
|
Loading…
Reference in a new issue