Add pagination to moderation logs
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -158,51 +158,54 @@ export const CREATE_REPORT_NOTE = gql`
|
||||
`;
|
||||
|
||||
export const LOGS = gql`
|
||||
query {
|
||||
actionLogs {
|
||||
id
|
||||
action
|
||||
actor {
|
||||
query ActionLogs($page: Int, $limit: Int) {
|
||||
actionLogs(page: $page, limit: $limit) {
|
||||
elements {
|
||||
id
|
||||
preferredUsername
|
||||
domain
|
||||
avatar {
|
||||
action
|
||||
actor {
|
||||
id
|
||||
url
|
||||
}
|
||||
}
|
||||
object {
|
||||
... on Report {
|
||||
id
|
||||
}
|
||||
... on ReportNote {
|
||||
report {
|
||||
preferredUsername
|
||||
domain
|
||||
avatar {
|
||||
id
|
||||
url
|
||||
}
|
||||
}
|
||||
... on Event {
|
||||
id
|
||||
title
|
||||
}
|
||||
... on Person {
|
||||
id
|
||||
preferredUsername
|
||||
domain
|
||||
name
|
||||
}
|
||||
... on Group {
|
||||
id
|
||||
preferredUsername
|
||||
domain
|
||||
name
|
||||
}
|
||||
... on User {
|
||||
id
|
||||
email
|
||||
confirmedAt
|
||||
object {
|
||||
... on Report {
|
||||
id
|
||||
}
|
||||
... on ReportNote {
|
||||
report {
|
||||
id
|
||||
}
|
||||
}
|
||||
... on Event {
|
||||
id
|
||||
title
|
||||
}
|
||||
... on Person {
|
||||
id
|
||||
preferredUsername
|
||||
domain
|
||||
name
|
||||
}
|
||||
... on Group {
|
||||
id
|
||||
preferredUsername
|
||||
domain
|
||||
name
|
||||
}
|
||||
... on User {
|
||||
id
|
||||
email
|
||||
confirmedAt
|
||||
}
|
||||
}
|
||||
insertedAt
|
||||
}
|
||||
insertedAt
|
||||
total
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -985,5 +985,7 @@
|
||||
"Unable to update the profile. The avatar picture may be too heavy.": "Unable to update the profile. The avatar picture may be too heavy.",
|
||||
"Unable to create the profile. The avatar picture may be too heavy.": "Unable to create the profile. The avatar picture may be too heavy.",
|
||||
"Error while loading the preview": "Error while loading the preview",
|
||||
"Instance feeds": "Instance feeds"
|
||||
"Instance feeds": "Instance feeds",
|
||||
"{moderator} suspended group {profile}": "{moderator} suspended group {profile}",
|
||||
"{moderator} has unsuspended group {profile}": "{moderator} has unsuspended group {profile}"
|
||||
}
|
||||
|
||||
@@ -1079,5 +1079,7 @@
|
||||
"Unable to update the profile. The avatar picture may be too heavy.": "Impossible de mettre à jour le profil. L'image d'avatar est probablement trop lourde.",
|
||||
"Unable to create the profile. The avatar picture may be too heavy.": "Impossible de créer le profil. L'image d'avatar est probablement trop lourde.",
|
||||
"Error while loading the preview": "Erreur lors du chargement de l'aperçu",
|
||||
"Instance feeds": "Flux de l'instance"
|
||||
"Instance feeds": "Flux de l'instance",
|
||||
"{moderator} suspended group {profile}": "{moderator} a suspendu le groupe {profile}",
|
||||
"{moderator} has unsuspended group {profile}": "{moderator} a annulé la suspension du groupe {profile}"
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<section>
|
||||
<ul v-if="actionLogs.length > 0">
|
||||
<li v-for="log in actionLogs" :key="log.id">
|
||||
<section v-if="actionLogs.total > 0 && actionLogs.elements.length > 0">
|
||||
<ul>
|
||||
<li v-for="log in actionLogs.elements" :key="log.id">
|
||||
<div class="box">
|
||||
<img
|
||||
class="image"
|
||||
@@ -147,7 +147,10 @@
|
||||
<b slot="title">{{ log.object.title }}</b>
|
||||
</i18n>
|
||||
<i18n
|
||||
v-else-if="log.action === ActionLogAction.ACTOR_SUSPENSION"
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.ACTOR_SUSPENSION &&
|
||||
log.object.__typename == 'Person'
|
||||
"
|
||||
tag="span"
|
||||
path="{moderator} suspended profile {profile}"
|
||||
>
|
||||
@@ -169,7 +172,10 @@
|
||||
</router-link>
|
||||
</i18n>
|
||||
<i18n
|
||||
v-else-if="log.action === ActionLogAction.ACTOR_UNSUSPENSION"
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.ACTOR_UNSUSPENSION &&
|
||||
log.object.__typename == 'Person'
|
||||
"
|
||||
tag="span"
|
||||
path="{moderator} has unsuspended profile {profile}"
|
||||
>
|
||||
@@ -190,6 +196,56 @@
|
||||
>{{ displayNameAndUsername(log.object) }}
|
||||
</router-link>
|
||||
</i18n>
|
||||
<i18n
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.ACTOR_SUSPENSION &&
|
||||
log.object.__typename == 'Group'
|
||||
"
|
||||
tag="span"
|
||||
path="{moderator} suspended group {profile}"
|
||||
>
|
||||
<router-link
|
||||
slot="moderator"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>@{{ log.actor.preferredUsername }}</router-link
|
||||
>
|
||||
<router-link
|
||||
slot="profile"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_GROUP_PROFILE,
|
||||
params: { id: log.object.id },
|
||||
}"
|
||||
>{{ displayNameAndUsername(log.object) }}
|
||||
</router-link>
|
||||
</i18n>
|
||||
<i18n
|
||||
v-else-if="
|
||||
log.action === ActionLogAction.ACTOR_UNSUSPENSION &&
|
||||
log.object.__typename == 'Group'
|
||||
"
|
||||
tag="span"
|
||||
path="{moderator} has unsuspended group {profile}"
|
||||
>
|
||||
<router-link
|
||||
slot="moderator"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_PROFILE,
|
||||
params: { id: log.actor.id },
|
||||
}"
|
||||
>@{{ log.actor.preferredUsername }}</router-link
|
||||
>
|
||||
<router-link
|
||||
slot="profile"
|
||||
:to="{
|
||||
name: RouteName.ADMIN_GROUP_PROFILE,
|
||||
params: { id: log.object.id },
|
||||
}"
|
||||
>{{ displayNameAndUsername(log.object) }}
|
||||
</router-link>
|
||||
</i18n>
|
||||
<i18n
|
||||
v-else-if="log.action === ActionLogAction.USER_DELETION"
|
||||
tag="span"
|
||||
@@ -219,20 +275,31 @@
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-else>
|
||||
<b-message type="is-info">{{ $t("No moderation logs yet") }}</b-message>
|
||||
</div>
|
||||
<b-pagination
|
||||
:total="actionLogs.total"
|
||||
v-model="page"
|
||||
:per-page="LOGS_PER_PAGE"
|
||||
:aria-next-label="$t('Next page')"
|
||||
:aria-previous-label="$t('Previous page')"
|
||||
:aria-page-label="$t('Page')"
|
||||
:aria-current-label="$t('Current page')"
|
||||
>
|
||||
</b-pagination>
|
||||
</section>
|
||||
<div v-else>
|
||||
<b-message type="is-info">{{ $t("No moderation logs yet") }}</b-message>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { Component, Vue } from "vue-property-decorator";
|
||||
import { Component, Vue, Watch } from "vue-property-decorator";
|
||||
import { IActionLog } from "@/types/report.model";
|
||||
import { LOGS } from "@/graphql/report";
|
||||
import ReportCard from "@/components/Report/ReportCard.vue";
|
||||
import { ActionLogAction } from "@/types/enums";
|
||||
import RouteName from "../../router/name";
|
||||
import { displayNameAndUsername } from "../../types/actor";
|
||||
import { Paginate } from "@/types/paginate";
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
@@ -242,17 +309,39 @@ import { displayNameAndUsername } from "../../types/actor";
|
||||
actionLogs: {
|
||||
fetchPolicy: "cache-and-network",
|
||||
query: LOGS,
|
||||
variables() {
|
||||
return {
|
||||
page: this.page,
|
||||
limit: this.LOGS_PER_PAGE,
|
||||
};
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
export default class ReportList extends Vue {
|
||||
actionLogs?: IActionLog[] = [];
|
||||
actionLogs?: Paginate<IActionLog> = { total: 0, elements: [] };
|
||||
|
||||
page = parseInt((this.$route.query.page as string) || "1", 10);
|
||||
|
||||
LOGS_PER_PAGE = 10;
|
||||
|
||||
ActionLogAction = ActionLogAction;
|
||||
|
||||
RouteName = RouteName;
|
||||
|
||||
displayNameAndUsername = displayNameAndUsername;
|
||||
|
||||
mounted(): void {
|
||||
this.page = parseInt((this.$route.query.page as string) || "1", 10);
|
||||
}
|
||||
|
||||
@Watch("page")
|
||||
triggerLoadMoreMemberPageChange(page: string): void {
|
||||
this.$router.replace({
|
||||
name: RouteName.REPORT_LOGS,
|
||||
query: { ...this.$route.query, page },
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@@ -265,4 +354,8 @@ img.image {
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
section ul li {
|
||||
margin: 0.5rem auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user