Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ const monetizationOptions = [
const patch = computed<Labrinth.Projects.v3.EditProjectRequest>(() => {
const result: Labrinth.Projects.v3.EditProjectRequest = {}
if (visibility.value !== currentVisibility.value) {
if (hasPublishedStatus.value) result.status = visibility.value
else result.requested_status = visibility.value
result.visibility = visibility.value === 'approved' ? 'listed' : visibility.value
}
if (
!project.value?.minecraft_server &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,7 @@ const replyMutation = useMutation({
const assertCurrent = () => {
if (props.thread.id !== threadId) throw new Error(formatMessage(messages.changedThread))
}
const reason = replyBody.value.trim() || undefined
if (replyBody.value.trim()) {
const reply = {
threadId,
Expand Down Expand Up @@ -910,7 +911,7 @@ const replyMutation = useMutation({
queryKey: ['project', projectId, 'validation'],
})
assertCurrent()
if (status !== null) return (await props.setStatus(status)) !== false
if (status !== null) return (await props.setStatus(status, reason)) !== false
return true
},
onError: (error) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export async function submitProjectForReview(
projectId: string,
client: Pick<AbstractModrinthClient, 'labrinth'>,
): Promise<Labrinth.Projects.v3.Project> {
await client.labrinth.projects_v3.edit(projectId, { status: 'processing' })
await client.labrinth.projects_v3.setReviewState(projectId, { review_status: 'in_review' })
return await client.labrinth.projects_v3.get(projectId)
}
8 changes: 6 additions & 2 deletions apps/frontend/src/pages/[type]/[project]/moderation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ import {
} from '~/composables/link-network-validation/submission'
import { getProjectLink, isApproved, isRejected, isUnderReview } from '~/helpers/projects.js'
import { isThreadIssueVerified, verifyThreadIssuesForApproval } from '~/helpers/thread-issues'
import { toReviewStatus } from '~/providers/project-review/review-decision'

defineEmits(['on-download', 'delete-version'])

Expand Down Expand Up @@ -528,7 +529,7 @@ function updateThread(newThread: Labrinth.Threads.v3.Thread | null | undefined)
)
}

async function setStatus(status: Labrinth.Projects.v2.ProjectStatus) {
async function setStatus(status: Labrinth.Projects.v2.ProjectStatus, reason?: string) {
if (status === 'processing') {
return await setProcessing()
}
Expand All @@ -541,7 +542,10 @@ async function setStatus(status: Labrinth.Projects.v2.ProjectStatus) {
await verifyThreadIssuesForApproval(threadId, client, () => {
if (project.value.id !== projectId) throw new Error(formatMessage(messages.projectChanged))
})
await client.labrinth.projects_v3.edit(projectId, { status })
await client.labrinth.projects_v3.setReviewState(projectId, {
review_status: toReviewStatus(status),
reason,
})
await invalidate()
await queryClient.invalidateQueries({ queryKey: ['thread', threadId] })
return true
Expand Down
11 changes: 5 additions & 6 deletions apps/frontend/src/pages/[type]/[project]/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -522,12 +522,11 @@ const basePatchData = computed(() => {
if (summary.value !== project.value.summary) {
data.summary = summary.value.trim()
}
if (tags.value.approvedStatuses.includes(project.value.status)) {
if (visibility.value !== project.value.status) {
data.status = visibility.value
}
} else if (visibility.value !== project.value.requested_status) {
data.requested_status = visibility.value
const currentVisibility = tags.value.approvedStatuses.includes(project.value.status)
? project.value.status
: project.value.requested_status
if (visibility.value !== currentVisibility) {
data.visibility = visibility.value === 'approved' ? 'listed' : visibility.value
}

if (project.value.monetization_status !== 'force-demonetized') {
Expand Down
26 changes: 24 additions & 2 deletions apps/frontend/src/providers/project-review/review-decision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ export class ReviewIssuesError extends Error {
}
}

export function toReviewStatus(
status: Labrinth.Projects.v2.ProjectStatus,
): Labrinth.Projects.v3.ReviewStatus {
switch (status) {
case 'processing':
return 'in_review'
case 'approved':
case 'unlisted':
case 'private':
return 'approved'
case 'draft':
case 'rejected':
case 'withheld':
return status
default:
throw new Error(`Cannot set review state from project status: ${status}`)
}
}

/** Applies a review's findings and optional status change. */
export async function applyReviewDecision(
decision: ReviewDecision,
Expand All @@ -33,6 +52,7 @@ export async function applyReviewDecision(
onMessageSent: () => void,
): Promise<void> {
const threads = client.labrinth.threads_v3
const reason = decision.body.trim() || undefined
const approving =
decision.status !== undefined && ['approved', 'unlisted', 'private'].includes(decision.status)
async function updateFacets() {
Expand All @@ -48,10 +68,12 @@ export async function applyReviewDecision(
if (decision.techReviewVerdict) {
await client.labrinth.tech_review_internal.submitProject(decision.projectId, {
verdict: decision.techReviewVerdict,
reason,
})
} else if (decision.status) {
await client.labrinth.projects_v3.edit(decision.projectId, {
status: decision.status,
await client.labrinth.projects_v3.setReviewState(decision.projectId, {
review_status: toReviewStatus(decision.status),
reason,
})
}
assertCurrent()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading