2020-02-18 07:57:00 +00:00
|
|
|
<template>
|
2020-06-25 09:36:35 +00:00
|
|
|
<div>
|
|
|
|
<nav class="breadcrumb" aria-label="breadcrumbs">
|
2020-08-14 09:32:23 +00:00
|
|
|
<ul v-if="group">
|
2020-06-25 09:36:35 +00:00
|
|
|
<li>
|
2020-07-09 15:24:28 +00:00
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
name: RouteName.GROUP,
|
|
|
|
params: { preferredUsername: usernameWithDomain(group) },
|
|
|
|
}"
|
|
|
|
>{{ group.name }}</router-link
|
|
|
|
>
|
2020-06-25 09:36:35 +00:00
|
|
|
</li>
|
|
|
|
<li>
|
2020-07-09 15:24:28 +00:00
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
name: RouteName.GROUP_SETTINGS,
|
|
|
|
params: { preferredUsername: usernameWithDomain(group) },
|
|
|
|
}"
|
|
|
|
>{{ $t("Settings") }}</router-link
|
|
|
|
>
|
2020-06-25 09:36:35 +00:00
|
|
|
</li>
|
|
|
|
<li class="is-active">
|
2020-07-09 15:24:28 +00:00
|
|
|
<router-link
|
|
|
|
:to="{
|
|
|
|
name: RouteName.GROUP_MEMBERS_SETTINGS,
|
|
|
|
params: { preferredUsername: usernameWithDomain(group) },
|
|
|
|
}"
|
|
|
|
>{{ $t("Members") }}</router-link
|
|
|
|
>
|
2020-06-25 09:36:35 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</nav>
|
2021-11-02 18:47:54 +00:00
|
|
|
<b-loading :active="$apollo.loading" />
|
2020-11-30 09:24:11 +00:00
|
|
|
<section
|
|
|
|
class="container section"
|
|
|
|
v-if="group && isCurrentActorAGroupAdmin"
|
|
|
|
>
|
2020-06-25 09:36:35 +00:00
|
|
|
<form @submit.prevent="inviteMember">
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-field
|
|
|
|
:label="$t('Invite a new member')"
|
|
|
|
custom-class="add-relay"
|
2021-09-07 15:52:34 +00:00
|
|
|
label-for="new-member-field"
|
2020-11-30 09:24:11 +00:00
|
|
|
horizontal
|
|
|
|
>
|
2020-10-02 08:46:58 +00:00
|
|
|
<b-field
|
|
|
|
grouped
|
|
|
|
expanded
|
|
|
|
size="is-large"
|
|
|
|
:type="inviteError ? 'is-danger' : null"
|
|
|
|
:message="inviteError"
|
|
|
|
>
|
2020-06-25 09:36:35 +00:00
|
|
|
<p class="control">
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-input
|
2021-09-07 15:52:34 +00:00
|
|
|
id="new-member-field"
|
2020-11-30 09:24:11 +00:00
|
|
|
v-model="newMemberUsername"
|
|
|
|
:placeholder="$t('Ex: someone@mobilizon.org')"
|
|
|
|
/>
|
2020-06-25 09:36:35 +00:00
|
|
|
</p>
|
|
|
|
<p class="control">
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-button type="is-primary" native-type="submit">{{
|
|
|
|
$t("Invite member")
|
|
|
|
}}</b-button>
|
2020-06-25 09:36:35 +00:00
|
|
|
</p>
|
|
|
|
</b-field>
|
2020-02-18 07:57:00 +00:00
|
|
|
</b-field>
|
2020-06-25 09:36:35 +00:00
|
|
|
</form>
|
|
|
|
<h1>{{ $t("Group Members") }} ({{ group.members.total }})</h1>
|
2021-09-07 15:52:34 +00:00
|
|
|
<b-field
|
|
|
|
:label="$t('Status')"
|
|
|
|
horizontal
|
|
|
|
label-for="group-members-status-filter"
|
|
|
|
>
|
|
|
|
<b-select v-model="roles" id="group-members-status-filter">
|
2020-07-09 15:24:28 +00:00
|
|
|
<option value="">
|
|
|
|
{{ $t("Everything") }}
|
|
|
|
</option>
|
|
|
|
<option :value="MemberRole.ADMINISTRATOR">
|
|
|
|
{{ $t("Administrator") }}
|
|
|
|
</option>
|
|
|
|
<option :value="MemberRole.MODERATOR">
|
|
|
|
{{ $t("Moderator") }}
|
|
|
|
</option>
|
|
|
|
<option :value="MemberRole.MEMBER">
|
|
|
|
{{ $t("Member") }}
|
|
|
|
</option>
|
|
|
|
<option :value="MemberRole.INVITED">
|
|
|
|
{{ $t("Invited") }}
|
|
|
|
</option>
|
|
|
|
<option :value="MemberRole.NOT_APPROVED">
|
|
|
|
{{ $t("Not approved") }}
|
|
|
|
</option>
|
|
|
|
<option :value="MemberRole.REJECTED">
|
|
|
|
{{ $t("Rejected") }}
|
|
|
|
</option>
|
|
|
|
</b-select>
|
|
|
|
</b-field>
|
|
|
|
<b-table
|
2020-11-06 10:34:32 +00:00
|
|
|
v-if="members"
|
|
|
|
:data="members.elements"
|
2020-07-09 15:24:28 +00:00
|
|
|
ref="queueTable"
|
|
|
|
:loading="this.$apollo.loading"
|
|
|
|
paginated
|
|
|
|
backend-pagination
|
2020-11-06 10:34:32 +00:00
|
|
|
:current-page.sync="page"
|
2020-07-09 15:24:28 +00:00
|
|
|
:pagination-simple="true"
|
|
|
|
:aria-next-label="$t('Next page')"
|
|
|
|
:aria-previous-label="$t('Previous page')"
|
|
|
|
:aria-page-label="$t('Page')"
|
|
|
|
:aria-current-label="$t('Current page')"
|
2020-11-06 10:34:32 +00:00
|
|
|
:total="members.total"
|
2020-07-09 15:24:28 +00:00
|
|
|
:per-page="MEMBERS_PER_PAGE"
|
|
|
|
backend-sorting
|
|
|
|
:default-sort-direction="'desc'"
|
|
|
|
:default-sort="['insertedAt', 'desc']"
|
2020-11-06 10:34:32 +00:00
|
|
|
@page-change="triggerLoadMoreMemberPageChange"
|
2020-07-09 15:24:28 +00:00
|
|
|
@sort="(field, order) => $emit('sort', field, order)"
|
|
|
|
>
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-table-column
|
|
|
|
field="actor.preferredUsername"
|
|
|
|
:label="$t('Member')"
|
|
|
|
v-slot="props"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
<article class="media">
|
2020-11-30 09:24:11 +00:00
|
|
|
<figure
|
|
|
|
class="media-left image is-48x48"
|
|
|
|
v-if="props.row.actor.avatar"
|
|
|
|
>
|
|
|
|
<img
|
|
|
|
class="is-rounded"
|
|
|
|
:src="props.row.actor.avatar.url"
|
2021-09-07 15:52:34 +00:00
|
|
|
:alt="props.row.actor.avatar.alt || ''"
|
2020-11-30 09:24:11 +00:00
|
|
|
/>
|
2020-08-18 13:50:50 +00:00
|
|
|
</figure>
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-icon
|
|
|
|
class="media-left"
|
|
|
|
v-else
|
|
|
|
size="is-large"
|
|
|
|
icon="account-circle"
|
|
|
|
/>
|
2020-08-18 13:50:50 +00:00
|
|
|
<div class="media-content">
|
|
|
|
<div class="content">
|
2020-11-30 09:24:11 +00:00
|
|
|
<span v-if="props.row.actor.name">{{
|
|
|
|
props.row.actor.name
|
|
|
|
}}</span
|
2020-08-18 13:50:50 +00:00
|
|
|
><br />
|
2021-09-07 15:52:34 +00:00
|
|
|
<span class="is-size-7 has-text-grey-dark"
|
2020-08-18 13:50:50 +00:00
|
|
|
>@{{ usernameWithDomain(props.row.actor) }}</span
|
|
|
|
>
|
2020-07-09 15:24:28 +00:00
|
|
|
</div>
|
2020-08-18 13:50:50 +00:00
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
</b-table-column>
|
|
|
|
<b-table-column field="role" :label="$t('Role')" v-slot="props">
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-tag
|
|
|
|
type="is-primary"
|
|
|
|
v-if="props.row.role === MemberRole.ADMINISTRATOR"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
{{ $t("Administrator") }}
|
|
|
|
</b-tag>
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-tag
|
|
|
|
type="is-primary"
|
|
|
|
v-else-if="props.row.role === MemberRole.MODERATOR"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
{{ $t("Moderator") }}
|
|
|
|
</b-tag>
|
|
|
|
<b-tag v-else-if="props.row.role === MemberRole.MEMBER">
|
|
|
|
{{ $t("Member") }}
|
|
|
|
</b-tag>
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-tag
|
|
|
|
type="is-warning"
|
|
|
|
v-else-if="props.row.role === MemberRole.NOT_APPROVED"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
{{ $t("Not approved") }}
|
|
|
|
</b-tag>
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-tag
|
|
|
|
type="is-danger"
|
|
|
|
v-else-if="props.row.role === MemberRole.REJECTED"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
{{ $t("Rejected") }}
|
|
|
|
</b-tag>
|
2020-11-30 09:24:11 +00:00
|
|
|
<b-tag
|
|
|
|
type="is-warning"
|
|
|
|
v-else-if="props.row.role === MemberRole.INVITED"
|
|
|
|
>
|
2020-08-18 13:50:50 +00:00
|
|
|
{{ $t("Invited") }}
|
|
|
|
</b-tag>
|
|
|
|
</b-table-column>
|
|
|
|
<b-table-column field="insertedAt" :label="$t('Date')" v-slot="props">
|
|
|
|
<span class="has-text-centered">
|
|
|
|
{{ props.row.insertedAt | formatDateString }}<br />{{
|
|
|
|
props.row.insertedAt | formatTimeString
|
|
|
|
}}
|
|
|
|
</span>
|
|
|
|
</b-table-column>
|
|
|
|
<b-table-column field="actions" :label="$t('Actions')" v-slot="props">
|
2020-10-02 08:46:58 +00:00
|
|
|
<div class="buttons" v-if="props.row.actor.id !== currentActor.id">
|
2020-08-20 08:54:58 +00:00
|
|
|
<b-button
|
2020-11-30 09:24:11 +00:00
|
|
|
v-if="
|
|
|
|
[MemberRole.MEMBER, MemberRole.MODERATOR].includes(
|
|
|
|
props.row.role
|
|
|
|
)
|
|
|
|
"
|
2020-10-06 13:38:53 +00:00
|
|
|
@click="promoteMember(props.row)"
|
|
|
|
icon-left="chevron-double-up"
|
2020-08-20 08:54:58 +00:00
|
|
|
>{{ $t("Promote") }}</b-button
|
|
|
|
>
|
|
|
|
<b-button
|
2020-11-30 09:24:11 +00:00
|
|
|
v-if="
|
|
|
|
[MemberRole.ADMINISTRATOR, MemberRole.MODERATOR].includes(
|
|
|
|
props.row.role
|
|
|
|
)
|
|
|
|
"
|
2020-10-06 13:38:53 +00:00
|
|
|
@click="demoteMember(props.row)"
|
|
|
|
icon-left="chevron-double-down"
|
2020-08-20 08:54:58 +00:00
|
|
|
>{{ $t("Demote") }}</b-button
|
|
|
|
>
|
|
|
|
<b-button
|
|
|
|
v-if="props.row.role === MemberRole.MEMBER"
|
|
|
|
@click="removeMember(props.row.id)"
|
|
|
|
type="is-danger"
|
2020-10-06 13:38:53 +00:00
|
|
|
icon-left="exit-to-app"
|
2020-08-20 08:54:58 +00:00
|
|
|
>{{ $t("Remove") }}</b-button
|
|
|
|
>
|
|
|
|
</div>
|
2020-08-18 13:50:50 +00:00
|
|
|
</b-table-column>
|
2020-07-09 15:24:28 +00:00
|
|
|
<template slot="empty">
|
2021-01-14 18:17:12 +00:00
|
|
|
<empty-content icon="account" inline>
|
|
|
|
{{ $t("No member matches the filters") }}
|
|
|
|
</empty-content>
|
2020-07-09 15:24:28 +00:00
|
|
|
</template>
|
|
|
|
</b-table>
|
2020-06-25 09:36:35 +00:00
|
|
|
</section>
|
2021-11-02 18:47:54 +00:00
|
|
|
<b-message v-else-if="!$apollo.loading && group">
|
2020-10-09 13:26:37 +00:00
|
|
|
{{ $t("You are not an administrator for this group.") }}
|
|
|
|
</b-message>
|
2020-06-25 09:36:35 +00:00
|
|
|
</div>
|
2020-02-18 07:57:00 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-09 13:26:37 +00:00
|
|
|
import { Component, Watch } from "vue-property-decorator";
|
|
|
|
import GroupMixin from "@/mixins/group";
|
|
|
|
import { mixins } from "vue-class-component";
|
2020-10-15 12:23:55 +00:00
|
|
|
import { FETCH_GROUP } from "@/graphql/group";
|
2020-11-27 18:27:44 +00:00
|
|
|
import { MemberRole } from "@/types/enums";
|
|
|
|
import { IMember } from "@/types/actor/member.model";
|
2020-02-18 07:57:00 +00:00
|
|
|
import RouteName from "../../router/name";
|
2020-11-30 09:24:11 +00:00
|
|
|
import {
|
|
|
|
INVITE_MEMBER,
|
|
|
|
GROUP_MEMBERS,
|
|
|
|
REMOVE_MEMBER,
|
|
|
|
UPDATE_MEMBER,
|
|
|
|
} from "../../graphql/member";
|
2020-11-06 10:34:32 +00:00
|
|
|
import { usernameWithDomain } from "../../types/actor";
|
2021-01-14 18:17:12 +00:00
|
|
|
import EmptyContent from "@/components/Utils/EmptyContent.vue";
|
2020-02-18 07:57:00 +00:00
|
|
|
|
2020-10-15 12:23:55 +00:00
|
|
|
@Component({
|
|
|
|
apollo: {
|
|
|
|
members: {
|
|
|
|
query: GROUP_MEMBERS,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
name: this.$route.params.preferredUsername,
|
2020-11-06 10:34:32 +00:00
|
|
|
page: this.page,
|
2020-10-15 12:23:55 +00:00
|
|
|
limit: this.MEMBERS_PER_PAGE,
|
|
|
|
roles: this.roles,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
update: (data) => data.group.members,
|
|
|
|
},
|
|
|
|
},
|
2021-01-14 18:17:12 +00:00
|
|
|
components: {
|
|
|
|
EmptyContent,
|
|
|
|
},
|
2021-05-25 14:21:29 +00:00
|
|
|
metaInfo() {
|
|
|
|
return {
|
|
|
|
title: this.$t("Group Members") as string,
|
|
|
|
};
|
|
|
|
},
|
2020-10-15 12:23:55 +00:00
|
|
|
})
|
2020-10-09 13:26:37 +00:00
|
|
|
export default class GroupMembers extends mixins(GroupMixin) {
|
2020-10-02 08:46:58 +00:00
|
|
|
loading = true;
|
2020-02-18 07:57:00 +00:00
|
|
|
|
|
|
|
newMemberUsername = "";
|
|
|
|
|
2020-10-02 08:46:58 +00:00
|
|
|
inviteError = "";
|
|
|
|
|
2020-07-09 15:24:28 +00:00
|
|
|
MemberRole = MemberRole;
|
|
|
|
|
|
|
|
roles: MemberRole | "" = "";
|
|
|
|
|
2020-10-02 08:46:58 +00:00
|
|
|
RouteName = RouteName;
|
|
|
|
|
2020-11-06 10:34:32 +00:00
|
|
|
page = parseInt((this.$route.query.page as string) || "1", 10);
|
2020-07-09 15:24:28 +00:00
|
|
|
|
|
|
|
MEMBERS_PER_PAGE = 10;
|
|
|
|
|
|
|
|
usernameWithDomain = usernameWithDomain;
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
mounted(): void {
|
2020-07-09 15:24:28 +00:00
|
|
|
const roleQuery = this.$route.query.role as string;
|
|
|
|
if (Object.values(MemberRole).includes(roleQuery as MemberRole)) {
|
|
|
|
this.roles = roleQuery as MemberRole;
|
|
|
|
}
|
2020-11-06 10:34:32 +00:00
|
|
|
this.page = parseInt((this.$route.query.page as string) || "1", 10);
|
2020-07-09 15:24:28 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
async inviteMember(): Promise<void> {
|
2020-10-02 08:46:58 +00:00
|
|
|
try {
|
2020-11-06 10:34:32 +00:00
|
|
|
this.inviteError = "";
|
|
|
|
const { roles, MEMBERS_PER_PAGE, group, page } = this;
|
|
|
|
const variables = {
|
|
|
|
name: usernameWithDomain(group),
|
|
|
|
page,
|
|
|
|
limit: MEMBERS_PER_PAGE,
|
|
|
|
roles,
|
|
|
|
};
|
|
|
|
console.log("variables", variables);
|
2020-10-02 08:46:58 +00:00
|
|
|
await this.$apollo.mutate<{ inviteMember: IMember }>({
|
|
|
|
mutation: INVITE_MEMBER,
|
|
|
|
variables: {
|
|
|
|
groupId: this.group.id,
|
|
|
|
targetActorUsername: this.newMemberUsername,
|
|
|
|
},
|
2020-10-15 12:23:55 +00:00
|
|
|
refetchQueries: [
|
2020-11-06 10:34:32 +00:00
|
|
|
{
|
|
|
|
query: GROUP_MEMBERS,
|
|
|
|
variables,
|
|
|
|
},
|
2020-10-15 12:23:55 +00:00
|
|
|
],
|
2020-10-02 08:46:58 +00:00
|
|
|
});
|
2020-10-15 12:23:55 +00:00
|
|
|
this.$notifier.success(
|
|
|
|
this.$t("{username} was invited to {group}", {
|
|
|
|
username: this.newMemberUsername,
|
|
|
|
group: this.group.name || usernameWithDomain(this.group),
|
|
|
|
}) as string
|
|
|
|
);
|
2020-10-02 08:46:58 +00:00
|
|
|
this.newMemberUsername = "";
|
2021-09-29 16:20:33 +00:00
|
|
|
} catch (error: any) {
|
2020-10-02 08:46:58 +00:00
|
|
|
console.error(error);
|
|
|
|
if (error.graphQLErrors && error.graphQLErrors.length > 0) {
|
|
|
|
this.inviteError = error.graphQLErrors[0].message;
|
|
|
|
}
|
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
2020-07-09 15:24:28 +00:00
|
|
|
|
|
|
|
@Watch("page")
|
2020-11-06 10:34:32 +00:00
|
|
|
triggerLoadMoreMemberPageChange(page: string): void {
|
|
|
|
this.$router.replace({
|
|
|
|
name: RouteName.GROUP_MEMBERS_SETTINGS,
|
|
|
|
query: { ...this.$route.query, page },
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Watch("roles")
|
|
|
|
triggerLoadMoreMemberRoleChange(roles: string): void {
|
|
|
|
this.$router.replace({
|
|
|
|
name: RouteName.GROUP_MEMBERS_SETTINGS,
|
|
|
|
query: { ...this.$route.query, roles },
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async loadMoreMembers(): Promise<void> {
|
|
|
|
const { roles, MEMBERS_PER_PAGE, group, page } = this;
|
|
|
|
await this.$apollo.queries.members.fetchMore({
|
2020-07-09 15:24:28 +00:00
|
|
|
// New variables
|
2020-11-06 10:34:32 +00:00
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
name: usernameWithDomain(group),
|
|
|
|
page,
|
|
|
|
limit: MEMBERS_PER_PAGE,
|
|
|
|
roles,
|
|
|
|
};
|
2020-07-09 15:24:28 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2020-08-14 09:32:23 +00:00
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
async removeMember(memberId: string): Promise<void> {
|
2020-11-06 10:34:32 +00:00
|
|
|
const { roles, MEMBERS_PER_PAGE, group, page } = this;
|
2021-03-31 08:06:36 +00:00
|
|
|
const variables = {
|
|
|
|
name: usernameWithDomain(group),
|
|
|
|
page,
|
|
|
|
limit: MEMBERS_PER_PAGE,
|
|
|
|
roles,
|
|
|
|
};
|
2020-10-15 12:23:55 +00:00
|
|
|
try {
|
|
|
|
await this.$apollo.mutate<{ removeMember: IMember }>({
|
|
|
|
mutation: REMOVE_MEMBER,
|
|
|
|
variables: {
|
|
|
|
groupId: this.group.id,
|
|
|
|
memberId,
|
|
|
|
},
|
|
|
|
refetchQueries: [
|
2020-11-06 10:34:32 +00:00
|
|
|
{
|
|
|
|
query: GROUP_MEMBERS,
|
2021-03-31 08:06:36 +00:00
|
|
|
variables,
|
2020-11-06 10:34:32 +00:00
|
|
|
},
|
2020-10-15 12:23:55 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
this.$notifier.success(
|
|
|
|
this.$t("The member was removed from the group {group}", {
|
|
|
|
username: this.newMemberUsername,
|
|
|
|
group: this.group.name || usernameWithDomain(this.group),
|
|
|
|
}) as string
|
|
|
|
);
|
2021-09-29 16:20:33 +00:00
|
|
|
} catch (error: any) {
|
2020-10-15 12:23:55 +00:00
|
|
|
console.error(error);
|
|
|
|
if (error.graphQLErrors && error.graphQLErrors.length > 0) {
|
|
|
|
this.$notifier.error(error.graphQLErrors[0].message);
|
|
|
|
}
|
|
|
|
}
|
2020-08-14 09:32:23 +00:00
|
|
|
}
|
2020-08-20 08:54:58 +00:00
|
|
|
|
2020-10-06 13:38:53 +00:00
|
|
|
promoteMember(member: IMember): void {
|
|
|
|
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);
|
|
|
|
}
|
2020-08-20 08:54:58 +00:00
|
|
|
}
|
|
|
|
|
2020-10-06 13:38:53 +00:00
|
|
|
demoteMember(member: IMember): void {
|
|
|
|
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);
|
|
|
|
}
|
2020-08-20 08:54:58 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 07:53:48 +00:00
|
|
|
async updateMember(memberId: string, role: MemberRole): Promise<void> {
|
2020-10-02 08:46:58 +00:00
|
|
|
try {
|
|
|
|
await this.$apollo.mutate<{ updateMember: IMember }>({
|
|
|
|
mutation: UPDATE_MEMBER,
|
|
|
|
variables: {
|
|
|
|
memberId,
|
|
|
|
role,
|
|
|
|
},
|
2020-10-15 12:23:55 +00:00
|
|
|
refetchQueries: [
|
2020-11-30 09:24:11 +00:00
|
|
|
{
|
|
|
|
query: FETCH_GROUP,
|
|
|
|
variables: { name: this.$route.params.preferredUsername },
|
|
|
|
},
|
2020-10-15 12:23:55 +00:00
|
|
|
],
|
2020-10-02 08:46:58 +00:00
|
|
|
});
|
2020-10-15 12:23:55 +00:00
|
|
|
let successMessage;
|
|
|
|
switch (role) {
|
|
|
|
case MemberRole.MODERATOR:
|
|
|
|
successMessage = "The member role was updated to moderator";
|
|
|
|
break;
|
|
|
|
case MemberRole.ADMINISTRATOR:
|
|
|
|
successMessage = "The member role was updated to administrator";
|
|
|
|
break;
|
|
|
|
case MemberRole.MEMBER:
|
|
|
|
default:
|
|
|
|
successMessage = "The member role was updated to simple member";
|
|
|
|
}
|
|
|
|
this.$notifier.success(this.$t(successMessage) as string);
|
2021-09-29 16:20:33 +00:00
|
|
|
} catch (error: any) {
|
2020-10-02 08:46:58 +00:00
|
|
|
console.error(error);
|
|
|
|
if (error.graphQLErrors && error.graphQLErrors.length > 0) {
|
|
|
|
this.$notifier.error(error.graphQLErrors[0].message);
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 08:54:58 +00:00
|
|
|
}
|
2020-02-18 07:57:00 +00:00
|
|
|
}
|
|
|
|
</script>
|