mirror of
https://github.com/modrinth/code.git
synced 2026-09-03 13:36:48 +00:00
fix: reset to onboarding flow not waiting
This commit is contained in:
@@ -121,7 +121,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Info -->
|
<!-- Info -->
|
||||||
<div class="flex flex-col gap-2.5 pb-10">
|
<div class="flex flex-col gap-2.5">
|
||||||
<div class="text-lg m-0 font-semibold text-contrast">Info</div>
|
<div class="text-lg m-0 font-semibold text-contrast">Info</div>
|
||||||
<div class="flex flex-col gap-2.5 rounded-xl bg-surface-2 p-4">
|
<div class="flex flex-col gap-2.5 rounded-xl bg-surface-2 p-4">
|
||||||
<div
|
<div
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="isSiteAdmin" class="flex flex-col gap-2.5">
|
<div v-if="isSiteAdmin" class="flex flex-col gap-2.5">
|
||||||
<span class="font-semibold text-contrast">
|
<span class="text-lg font-semibold text-contrast">
|
||||||
{{ formatMessage(messages.supportZoneLabel) }}
|
{{ formatMessage(messages.supportZoneLabel) }}
|
||||||
</span>
|
</span>
|
||||||
<div class="flex flex-col gap-4 rounded-2xl border border-solid border-surface-5 p-4">
|
<div class="flex flex-col gap-4 rounded-2xl border border-solid border-surface-5 p-4">
|
||||||
@@ -157,7 +157,11 @@
|
|||||||
:disabled="supportResetToOnboardingDisabled"
|
:disabled="supportResetToOnboardingDisabled"
|
||||||
@click="showResetToOnboardingModal"
|
@click="showResetToOnboardingModal"
|
||||||
>
|
>
|
||||||
<RotateCounterClockwiseIcon class="size-5" />
|
<SpinnerIcon
|
||||||
|
v-if="resetToOnboardingMutation.isPending.value"
|
||||||
|
class="size-5 animate-spin"
|
||||||
|
/>
|
||||||
|
<RotateCounterClockwiseIcon v-else class="size-5" />
|
||||||
{{ formatMessage(messages.resetToOnboardingButton) }}
|
{{ formatMessage(messages.resetToOnboardingButton) }}
|
||||||
</button>
|
</button>
|
||||||
</ButtonStyled>
|
</ButtonStyled>
|
||||||
@@ -182,8 +186,8 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Labrinth } from '@modrinth/api-client'
|
import type { Labrinth } from '@modrinth/api-client'
|
||||||
import { RotateCounterClockwiseIcon } from '@modrinth/assets'
|
import { RotateCounterClockwiseIcon, SpinnerIcon } from '@modrinth/assets'
|
||||||
import { useQuery, useQueryClient } from '@tanstack/vue-query'
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
|
||||||
import { useStorage } from '@vueuse/core'
|
import { useStorage } from '@vueuse/core'
|
||||||
import { computed, ref, watch } from 'vue'
|
import { computed, ref, watch } from 'vue'
|
||||||
|
|
||||||
@@ -218,7 +222,6 @@ const advancedActionTooltip = computed(() =>
|
|||||||
const serverName = ref(data.value?.name)
|
const serverName = ref(data.value?.name)
|
||||||
const serverSubdomain = ref(data.value?.net?.domain ?? '')
|
const serverSubdomain = ref(data.value?.net?.domain ?? '')
|
||||||
const resetToOnboardingModal = ref<InstanceType<typeof ConfirmModal>>()
|
const resetToOnboardingModal = ref<InstanceType<typeof ConfirmModal>>()
|
||||||
const isResettingToOnboarding = ref(false)
|
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
supportZoneLabel: {
|
supportZoneLabel: {
|
||||||
@@ -271,12 +274,6 @@ const isValidSubdomain = computed(() => isValidLengthSubdomain.value && isValidC
|
|||||||
const isUpdating = ref(false)
|
const isUpdating = ref(false)
|
||||||
const isValidServerName = computed(() => (serverName.value?.length ?? 0) > 0)
|
const isValidServerName = computed(() => (serverName.value?.length ?? 0) > 0)
|
||||||
const isSiteAdmin = computed(() => serverSettings.currentUserRole.value === 'admin')
|
const isSiteAdmin = computed(() => serverSettings.currentUserRole.value === 'admin')
|
||||||
const supportResetToOnboardingDisabled = computed(
|
|
||||||
() => isResettingToOnboarding.value || !canResetServer.value,
|
|
||||||
)
|
|
||||||
const supportResetToOnboardingTooltip = computed(() =>
|
|
||||||
!canResetServer.value ? permissionDeniedMessage.value : undefined,
|
|
||||||
)
|
|
||||||
|
|
||||||
// Preferences
|
// Preferences
|
||||||
const preferences = {
|
const preferences = {
|
||||||
@@ -513,19 +510,20 @@ function showResetToOnboardingModal() {
|
|||||||
resetToOnboardingModal.value?.show()
|
resetToOnboardingModal.value?.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function confirmResetToOnboarding() {
|
const resetToOnboardingMutation = useMutation({
|
||||||
if (supportResetToOnboardingDisabled.value) return
|
mutationFn: async () => {
|
||||||
|
|
||||||
try {
|
|
||||||
isResettingToOnboarding.value = true
|
|
||||||
await client.archon.servers_v1.resetToOnboarding(serverId)
|
await client.archon.servers_v1.resetToOnboarding(serverId)
|
||||||
modrinthServersConsole.clear()
|
|
||||||
try {
|
try {
|
||||||
await client.kyros.logs_v1.clear()
|
await client.kyros.logs_v1.clear()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to clear server logs:', error)
|
console.error('Failed to clear server logs:', error)
|
||||||
}
|
}
|
||||||
data.value.flows = { intro: true }
|
},
|
||||||
|
onSuccess: async () => {
|
||||||
|
modrinthServersConsole.clear()
|
||||||
|
if (data.value) {
|
||||||
|
data.value.flows = { ...data.value.flows, intro: true }
|
||||||
|
}
|
||||||
await invalidateServerState()
|
await invalidateServerState()
|
||||||
addNotification({
|
addNotification({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
@@ -533,14 +531,27 @@ async function confirmResetToOnboarding() {
|
|||||||
text: formatMessage(messages.resetToOnboardingSuccessDescription),
|
text: formatMessage(messages.resetToOnboardingSuccessDescription),
|
||||||
})
|
})
|
||||||
serverSettings.closeModal?.()
|
serverSettings.closeModal?.()
|
||||||
} catch (err) {
|
},
|
||||||
|
onError: (error) => {
|
||||||
addNotification({
|
addNotification({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
text: err instanceof Error ? err.message : formatMessage(messages.failedToResetToOnboarding),
|
text:
|
||||||
|
error instanceof Error ? error.message : formatMessage(messages.failedToResetToOnboarding),
|
||||||
})
|
})
|
||||||
} finally {
|
},
|
||||||
isResettingToOnboarding.value = false
|
})
|
||||||
}
|
|
||||||
|
const supportResetToOnboardingDisabled = computed(
|
||||||
|
() => resetToOnboardingMutation.isPending.value || !canResetServer.value,
|
||||||
|
)
|
||||||
|
const supportResetToOnboardingTooltip = computed(() =>
|
||||||
|
!canResetServer.value ? permissionDeniedMessage.value : undefined,
|
||||||
|
)
|
||||||
|
|
||||||
|
function confirmResetToOnboarding() {
|
||||||
|
if (supportResetToOnboardingDisabled.value) return
|
||||||
|
|
||||||
|
resetToOnboardingMutation.mutate()
|
||||||
}
|
}
|
||||||
|
|
||||||
function invalidateServerState() {
|
function invalidateServerState() {
|
||||||
|
|||||||
Reference in New Issue
Block a user