You've already forked AstralRinth
forked from didirus/AstralRinth
* Migrate to Nuxt 3 * Update vercel config * remove tsconfig comment * Changelog experiment + working proj pages * Fix package json * Prevent vercel complaining * fix deploy (hopefully) * Tag generator * Switch to yarn * Vercel pls 🙏 * Fix tag generation bug * Make (most) non-logged in pages work * fix base build * Linting + state * Eradicate axios, make most user pages work * Fix checkbox state being set incorrectly * Make most things work * Final stretch * Finish (most) things * Move to update model value * Fix modal text getting blurred from transforms (#964) * Adjust nav-link border radius when focused (#961) * Transition between animation states on TextLogo (#955) * Transition between animation states on TextLogo * Remove unused refs * Fixes from review * Disable tabbing to pagination arrows when disabled (#972) * Make position of the "no results" text on grid/gallery views consistent (fixes #963) (#965) * Fix position of the "no results" text on grid view * fix padding * Remove extra margin on main page, fixes #957 (#959) * Fix layout shift and placeholder line height (#973) * Fix a lot of issues * Fix more nuxt 3 issues * fix not all versions showing up (temp) * inline inter css file * More nuxt 3 fixes * [skip ci] broken- backup changes * Change modpack warnings to blue instead of red (#991) * Fix some hydration issues * Update nuxt * Fix some images not showing * Add pagination to versions page + fix lag * Make changelog page consistent with versions page * sync before merge * Delete old file * Fix actions failing * update branch * Fixes navbar transition animation. (#1012) * Fixes navbar transition animation. * Fixes Y-axis animation. Fixes mobile menu. Removes highlightjs prop. * Changes xss call to renderString. * Fixes renderString call. * Removes unnecessary styling. * Reverts mobile nav change. * Nuxt 3 Lazy Loading Search (#1022) * Uses lazyFetch for results. onSearchChange refreshes. Adds loading circle. * Removes console.log * Preserves old page when paging. * Diagnosing filtering bugs. * Fix single facet filtering * Implements useAuth in settings/account. * tiny ssr fix * Updating nuxt.config checklist. * Implements useAuth in revenue, moneitzation, and dashboard index pages. * Fixes setups. * Eliminates results when path changes. Adds animated logo. * Ensures loading animation renders on search page. --------- Co-authored-by: Jai A <jaiagr+gpg@pm.me> * Fix navigation issues * Square button fix (#1023) * Removes checklist from nuxt.config. * Modifies Nuxt CI to build after linting. * Fixes prettierignore file. * bug fixes * Update whitelist domains * Page improvements, fix CLS * Fix a lot of things * Fix project type redirect * Fix 404 errors * Fix user settings + hydration error * Final fixes * fix(creator-section): border radius on icons not aligning with bg (#1027) Co-authored-by: MagnusHJensen <magnus.holm.jensen@lego.dk> * Improvements to the mobile navbar (#984) * Transition between animation states on TextLogo * Remove unused refs * Fixes from review * Improvements to the mobile nav menu * fix avatar alt text * Nevermind, got confused for a moment * Tab bar, menu layout improvements * Highlight search icon when menu is open * Update layouts/default.vue Co-authored-by: Magnus Jensen <magnushjensen.mail@gmail.com> * Fix some issues * Use caret instead * Run prettier * Add create a project --------- Co-authored-by: Magnus Jensen <magnushjensen.mail@gmail.com> Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com> Co-authored-by: Jai A <jaiagr+gpg@pm.me> * Fix mobile menu issues * More issues * Fix lint --------- Co-authored-by: Kaeden Murphy <kmurphy@kaedenmurphy.dev> Co-authored-by: triphora <emmaffle@modrinth.com> Co-authored-by: Zach Baird <30800863+ZachBaird@users.noreply.github.com> Co-authored-by: stairman06 <36215135+stairman06@users.noreply.github.com> Co-authored-by: Zachary Baird <zdb1994@yahoo.com> Co-authored-by: Magnus Jensen <magnushjensen.mail@gmail.com> Co-authored-by: MagnusHJensen <magnus.holm.jensen@lego.dk>
334 lines
8.7 KiB
Vue
334 lines
8.7 KiB
Vue
<template>
|
|
<div>
|
|
<ModalModeration
|
|
ref="modal"
|
|
:project="currentProject"
|
|
:status="currentStatus"
|
|
:on-close="onModalClose"
|
|
/>
|
|
<div class="normal-page">
|
|
<div class="normal-page__sidebar">
|
|
<aside class="universal-card">
|
|
<h1>Moderation</h1>
|
|
<NavStack>
|
|
<NavStackItem link="/moderation" label="All" />
|
|
<NavStackItem
|
|
v-for="type in moderationTypes"
|
|
:key="type"
|
|
:link="'/moderation/' + type"
|
|
:label="$formatProjectType(type) + 's'"
|
|
/>
|
|
</NavStack>
|
|
</aside>
|
|
</div>
|
|
<div class="normal-page__content">
|
|
<div class="project-list display-mode--list">
|
|
<ProjectCard
|
|
v-for="project in $route.params.type !== undefined
|
|
? projects.filter((x) => x.project_type === $route.params.type)
|
|
: projects"
|
|
:id="project.slug || project.id"
|
|
:key="project.id"
|
|
:name="project.title"
|
|
:description="project.description"
|
|
:created-at="project.published"
|
|
:updated-at="project.updated"
|
|
:icon-url="project.icon_url"
|
|
:categories="project.categories"
|
|
:client-side="project.client_side"
|
|
:server-side="project.server_side"
|
|
:type="project.project_type"
|
|
:color="project.color"
|
|
:moderation="true"
|
|
>
|
|
<button
|
|
class="iconified-button"
|
|
@click="
|
|
setProjectStatus(
|
|
project,
|
|
project.requested_status ? project.requested_status : 'approved'
|
|
)
|
|
"
|
|
>
|
|
<CheckIcon />
|
|
Approve
|
|
</button>
|
|
<button class="iconified-button" @click="setProjectStatus(project, 'withheld')">
|
|
<UnlistIcon />
|
|
Withhold
|
|
</button>
|
|
<button class="iconified-button" @click="setProjectStatus(project, 'rejected')">
|
|
<CrossIcon />
|
|
Reject
|
|
</button>
|
|
</ProjectCard>
|
|
</div>
|
|
<div
|
|
v-if="$route.params.type === 'report' || $route.params.type === undefined"
|
|
class="reports"
|
|
>
|
|
<div v-for="(item, index) in reports" :key="index" class="card report">
|
|
<div class="info">
|
|
<div class="title">
|
|
<h3>
|
|
{{ item.item_type }}
|
|
<nuxt-link :to="item.url">
|
|
{{ item.item_id }}
|
|
</nuxt-link>
|
|
</h3>
|
|
reported by
|
|
<a :href="`/user/${item.reporter}`">{{ item.reporter }}</a>
|
|
</div>
|
|
<div class="markdown-body" v-html="renderHighlightedString(item.body)" />
|
|
<Badge :type="`Marked as ${item.report_type}`" color="orange" />
|
|
</div>
|
|
<div class="actions">
|
|
<button class="iconified-button" @click="deleteReport(index)">
|
|
<TrashIcon /> Delete report
|
|
</button>
|
|
<span
|
|
v-tooltip="$dayjs(item.created).format('[Created at] YYYY-MM-DD [at] HH:mm A')"
|
|
class="stat"
|
|
>
|
|
<CalendarIcon />
|
|
Created {{ fromNow(item.created) }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div v-if="reports.length === 0 && projects.length === 0" class="error">
|
|
<Security class="icon" />
|
|
<br />
|
|
<span class="text">You are up-to-date!</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import ProjectCard from '~/components/ui/ProjectCard'
|
|
import Badge from '~/components/ui/Badge'
|
|
|
|
import CheckIcon from '~/assets/images/utils/check.svg'
|
|
import UnlistIcon from '~/assets/images/utils/eye-off.svg'
|
|
import CrossIcon from '~/assets/images/utils/x.svg'
|
|
import TrashIcon from '~/assets/images/utils/trash.svg'
|
|
import CalendarIcon from '~/assets/images/utils/calendar.svg'
|
|
import Security from '~/assets/images/illustrations/security.svg'
|
|
import NavStack from '~/components/ui/NavStack'
|
|
import NavStackItem from '~/components/ui/NavStackItem'
|
|
import ModalModeration from '~/components/ui/ModalModeration'
|
|
import { renderHighlightedString } from '~/helpers/highlight'
|
|
|
|
export default defineNuxtComponent({
|
|
components: {
|
|
ModalModeration,
|
|
NavStack,
|
|
NavStackItem,
|
|
ProjectCard,
|
|
CheckIcon,
|
|
CrossIcon,
|
|
UnlistIcon,
|
|
Badge,
|
|
Security,
|
|
TrashIcon,
|
|
CalendarIcon,
|
|
},
|
|
async setup() {
|
|
const data = useNuxtApp()
|
|
|
|
definePageMeta({
|
|
middleware: 'auth',
|
|
})
|
|
|
|
const [projects, reports] = await Promise.all([
|
|
useBaseFetch('moderation/projects', data.$defaultHeaders()),
|
|
useBaseFetch('report', data.$defaultHeaders()),
|
|
])
|
|
|
|
const newReports = await Promise.all(
|
|
reports.map(async (report) => {
|
|
try {
|
|
report.item_id = report.item_id?.replace
|
|
? report.item_id.replace(/"/g, '')
|
|
: report.item_id
|
|
let url = ''
|
|
|
|
if (report.item_type === 'user') {
|
|
const user = await useBaseFetch(`user/${report.item_id}`, data.$defaultHeaders())
|
|
url = `/user/${user.username}`
|
|
report.item_id = user.username
|
|
} else if (report.item_type === 'project') {
|
|
const project = await useBaseFetch(`project/${report.item_id}`, data.$defaultHeaders())
|
|
report.item_id = project.slug || report.item_id
|
|
url = `/${project.project_type}/${report.item_id}`
|
|
} else if (report.item_type === 'version') {
|
|
const version = await useBaseFetch(`version/${report.item_id}`, data.$defaultHeaders())
|
|
const project = await useBaseFetch(
|
|
`project/${version.project_id}`,
|
|
data.$defaultHeaders()
|
|
)
|
|
report.item_id = version.version_number || report.item_id
|
|
url = `/${project.project_type}/${project.slug || project.id}/version/${report.item_id}`
|
|
}
|
|
|
|
report.reporter = (
|
|
await useBaseFetch(`user/${report.reporter}`, data.$defaultHeaders())
|
|
).username
|
|
|
|
return {
|
|
...report,
|
|
moderation_type: 'report',
|
|
url,
|
|
}
|
|
} catch (err) {
|
|
return {
|
|
...report,
|
|
url: 'error',
|
|
moderation_type: 'report',
|
|
}
|
|
}
|
|
})
|
|
)
|
|
|
|
return {
|
|
projects: shallowRef(projects),
|
|
reports: ref(newReports),
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
currentProject: null,
|
|
currentStatus: null,
|
|
}
|
|
},
|
|
head: {
|
|
title: 'Moderation - Modrinth',
|
|
},
|
|
computed: {
|
|
moderationTypes() {
|
|
const obj = {}
|
|
|
|
for (const project of this.projects) {
|
|
obj[project.project_type] = true
|
|
}
|
|
|
|
if (this.reports.length > 0) {
|
|
obj.report = true
|
|
}
|
|
|
|
return Object.keys(obj)
|
|
},
|
|
},
|
|
methods: {
|
|
renderHighlightedString,
|
|
setProjectStatus(project, status) {
|
|
this.currentProject = project
|
|
this.currentStatus = status
|
|
|
|
this.$refs.modal.show()
|
|
},
|
|
onModalClose() {
|
|
this.projects.splice(
|
|
this.projects.findIndex((x) => this.currentProject.id === x.id),
|
|
1
|
|
)
|
|
this.currentProject = null
|
|
},
|
|
async deleteReport(index) {
|
|
startLoading()
|
|
|
|
try {
|
|
await useBaseFetch(`report/${this.reports[index].id}`, {
|
|
method: 'DELETE',
|
|
...this.$defaultHeaders(),
|
|
})
|
|
this.reports.splice(index, 1)
|
|
} catch (err) {
|
|
console.error(err)
|
|
this.$notify({
|
|
group: 'main',
|
|
title: 'An error occurred',
|
|
text: err.data.description,
|
|
type: 'error',
|
|
})
|
|
}
|
|
|
|
stopLoading()
|
|
},
|
|
},
|
|
})
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
h1 {
|
|
color: var(--color-text-dark);
|
|
}
|
|
|
|
.report {
|
|
display: flex;
|
|
flex-direction: row;
|
|
justify-content: space-between;
|
|
gap: 1rem;
|
|
padding: 1rem;
|
|
|
|
> div {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.75rem;
|
|
}
|
|
|
|
.info {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
|
|
.title {
|
|
display: flex;
|
|
align-items: baseline;
|
|
gap: 0.25rem;
|
|
flex-wrap: wrap;
|
|
|
|
h3 {
|
|
margin: 0;
|
|
text-transform: capitalize;
|
|
|
|
a {
|
|
text-transform: none;
|
|
}
|
|
}
|
|
|
|
a {
|
|
text-decoration: underline;
|
|
}
|
|
}
|
|
}
|
|
|
|
.actions {
|
|
min-width: fit-content;
|
|
|
|
.iconified-button {
|
|
margin-left: auto;
|
|
width: fit-content;
|
|
}
|
|
|
|
.stat {
|
|
margin-top: auto;
|
|
display: flex;
|
|
align-items: center;
|
|
grid-gap: 0.5rem;
|
|
|
|
svg {
|
|
width: 1em;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@media screen and (min-width: 1024px) {
|
|
.page-contents {
|
|
max-width: 800px;
|
|
}
|
|
}
|
|
</style>
|