You've already forked AstralRinth
forked from didirus/AstralRinth
Allow admins to edit collections on frontend (#3207)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<ModalConfirm
|
<ConfirmModal
|
||||||
v-if="auth.user && auth.user.id === creator.id"
|
v-if="canEdit"
|
||||||
ref="deleteModal"
|
ref="deleteModal"
|
||||||
:title="formatMessage(messages.deleteModalTitle)"
|
:title="formatMessage(messages.deleteModalTitle)"
|
||||||
:description="formatMessage(messages.deleteModalDescription)"
|
:description="formatMessage(messages.deleteModalDescription)"
|
||||||
@@ -387,12 +387,13 @@ import {
|
|||||||
Avatar,
|
Avatar,
|
||||||
Button,
|
Button,
|
||||||
commonMessages,
|
commonMessages,
|
||||||
|
ConfirmModal,
|
||||||
} from "@modrinth/ui";
|
} from "@modrinth/ui";
|
||||||
|
|
||||||
|
import { isAdmin } from "@modrinth/utils";
|
||||||
import WorldIcon from "assets/images/utils/world.svg";
|
import WorldIcon from "assets/images/utils/world.svg";
|
||||||
import UpToDate from "assets/images/illustrations/up_to_date.svg";
|
import UpToDate from "assets/images/illustrations/up_to_date.svg";
|
||||||
import { addNotification } from "~/composables/notifs.js";
|
import { addNotification } from "~/composables/notifs.js";
|
||||||
import ModalConfirm from "~/components/ui/ModalConfirm.vue";
|
|
||||||
import NavRow from "~/components/ui/NavRow.vue";
|
import NavRow from "~/components/ui/NavRow.vue";
|
||||||
import ProjectCard from "~/components/ui/ProjectCard.vue";
|
import ProjectCard from "~/components/ui/ProjectCard.vue";
|
||||||
import AdPlaceholder from "~/components/ui/AdPlaceholder.vue";
|
import AdPlaceholder from "~/components/ui/AdPlaceholder.vue";
|
||||||
@@ -596,7 +597,7 @@ useSeoMeta({
|
|||||||
const canEdit = computed(
|
const canEdit = computed(
|
||||||
() =>
|
() =>
|
||||||
auth.value.user &&
|
auth.value.user &&
|
||||||
auth.value.user.id === collection.value.user &&
|
(auth.value.user.id === collection.value.user || isAdmin(auth.value.user)) &&
|
||||||
collection.value.id !== "following",
|
collection.value.id !== "following",
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -685,7 +686,11 @@ async function deleteCollection() {
|
|||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
apiVersion: 3,
|
apiVersion: 3,
|
||||||
});
|
});
|
||||||
await navigateTo("/dashboard/collections");
|
if (auth.value.user.id === collection.value.user) {
|
||||||
|
await navigateTo("/dashboard/collections");
|
||||||
|
} else {
|
||||||
|
await navigateTo(`/user/${collection.value.user}/collections`);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
addNotification({
|
addNotification({
|
||||||
group: "main",
|
group: "main",
|
||||||
|
|||||||
@@ -8,4 +8,8 @@ export const isStaff = (user) => {
|
|||||||
return user && STAFF_ROLES.includes(user.role)
|
return user && STAFF_ROLES.includes(user.role)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isAdmin = (user) => {
|
||||||
|
return user && user.role === 'admin'
|
||||||
|
}
|
||||||
|
|
||||||
export const STAFF_ROLES = ['moderator', 'admin']
|
export const STAFF_ROLES = ['moderator', 'admin']
|
||||||
|
|||||||
Reference in New Issue
Block a user