Skip to content
Merged
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 @@ -107,8 +107,8 @@
<LinkIcon />
</button>
</ButtonStyled>
<ButtonStyled v-tooltip="'Begin review'" circular color="orange">
<button @click="openProjectForReview">
<ButtonStyled circular color="orange">
<button v-tooltip="'Begin review'" @click="openProjectForReview">
<ScaleIcon />
</button>
</ButtonStyled>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,26 +358,44 @@

<div v-else-if="generatedMessage" class="flex items-center gap-2">
<ButtonStyled>
<button @click="goBackToStages">
<button :disabled="loadingModerationDecision" @click="goBackToStages">
<LeftArrowIcon aria-hidden="true" />
Edit
</button>
</ButtonStyled>
<ButtonStyled color="red">
<button @click="sendMessage('rejected')">
<XIcon aria-hidden="true" />
<button :disabled="loadingModerationDecision" @click="sendMessage('rejected')">
<SpinnerIcon
v-if="moderationDecision === 'rejected'"
class="animate-spin"
aria-hidden="true"
/>
<XIcon v-else aria-hidden="true" />
Reject
</button>
</ButtonStyled>
<ButtonStyled color="orange">
<button @click="sendMessage('withheld')">
<EyeOffIcon aria-hidden="true" />
<button :disabled="loadingModerationDecision" @click="sendMessage('withheld')">
<SpinnerIcon
v-if="moderationDecision === 'withheld'"
class="animate-spin"
aria-hidden="true"
/>
<LinkIcon v-else aria-hidden="true" />
Withhold
</button>
</ButtonStyled>
<ButtonStyled color="green">
<button @click="sendMessage(projectV2.requested_status ?? 'approved')">
<CheckIcon aria-hidden="true" />
<button
:disabled="loadingModerationDecision"
@click="sendMessage(approveSendStatus)"
>
<SpinnerIcon
v-if="moderationDecision === approveSendStatus"
class="animate-spin"
aria-hidden="true"
/>
<CheckIcon v-else aria-hidden="true" />
Approve
</button>
</ButtonStyled>
Expand Down Expand Up @@ -428,14 +446,15 @@ import {
BrushCleaningIcon,
CheckIcon,
DropdownIcon,
EyeOffIcon,
FileTextIcon,
KeyboardIcon,
LeftArrowIcon,
LinkIcon,
ListBulletedIcon,
LockIcon,
RightArrowIcon,
ScaleIcon,
SpinnerIcon,
ToggleLeftIcon,
ToggleRightIcon,
XIcon,
Expand Down Expand Up @@ -760,6 +779,12 @@ const message = ref(
)
const generatedMessage = ref(persistedGeneratedMessage.generated === true)
const loadingMessage = ref(false)
const moderationDecision = ref<ProjectStatus | null>(null)
const loadingModerationDecision = computed(() => moderationDecision.value !== null)
const approveSendStatus = computed<ProjectStatus>(() => {
const requested = projectV2.value.requested_status
return requested ?? 'approved'
})
const done = ref(false)

function persistGeneratedMessageState() {
Expand Down Expand Up @@ -1074,6 +1099,7 @@ function resetProgress() {
done.value = false
clearGeneratedMessageState()
loadingMessage.value = false
moderationDecision.value = null

localStorage.removeItem(`modpack-permissions-${projectV2.value.id}`)
localStorage.removeItem(`modpack-permissions-index-${projectV2.value.id}`)
Expand Down Expand Up @@ -1190,7 +1216,7 @@ function handleKeybinds(event: KeyboardEvent) {
tryResetProgress: resetProgress,
tryExitModeration: handleExit,

tryApprove: () => sendMessage(projectV2.value.requested_status ?? 'approved'),
tryApprove: () => sendMessage(approveSendStatus.value),
tryReject: () => sendMessage('rejected'),
tryWithhold: () => sendMessage('withheld'),
tryEditMessage: goBackToStages,
Expand Down Expand Up @@ -1977,6 +2003,7 @@ async function sendMessage(status: ProjectStatus) {
return
}

moderationDecision.value = status
try {
await useBaseFetch(`project/${projectId}`, {
method: 'PATCH',
Expand Down Expand Up @@ -2026,6 +2053,8 @@ async function sendMessage(status: ProjectStatus) {
text: 'Failed to submit moderation decision. Please try again.',
type: 'error',
})
} finally {
moderationDecision.value = null
}
}

Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/components/base/Badge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
<CheckIcon aria-hidden="true" /> {{ formatMessage(messages.approvedLabel) }}
</template>
<template v-else-if="type === 'unlisted'">
<EyeOffIcon aria-hidden="true" /> {{ formatMessage(messages.unlistedLabel) }}
<LinkIcon aria-hidden="true" /> {{ formatMessage(messages.unlistedLabel) }}
</template>
<template v-else-if="type === 'withheld'">
<EyeOffIcon aria-hidden="true" /> {{ formatMessage(messages.withheldLabel) }}
<LinkIcon aria-hidden="true" /> {{ formatMessage(messages.withheldLabel) }}
</template>
<template v-else-if="type === 'private'">
<LockIcon aria-hidden="true" /> {{ formatMessage(messages.privateLabel) }}
Expand Down Expand Up @@ -89,9 +89,9 @@ import {
BugIcon,
CalendarIcon,
CheckIcon,
EyeOffIcon,
FileTextIcon,
GlobeIcon,
LinkIcon,
LockIcon,
ModrinthIcon,
ScaleIcon,
Expand Down
Loading