11<template >
22 <div class =" flex flex-col gap-6 rounded-2xl bg-surface-3 p-6" >
3+ <ConfirmModal
4+ ref =" resetToOnboardingModal"
5+ :title =" formatMessage(messages.resetToOnboardingModalTitle)"
6+ :description =" formatMessage(messages.resetToOnboardingModalDescription)"
7+ :proceed-label =" formatMessage(messages.resetToOnboardingButton)"
8+ @proceed =" confirmResetToOnboarding"
9+ />
10+
311 <InstallationSettingsLayout ref =" installationSettingsLayout" >
412 <template #extra >
513 <div class =" flex flex-col gap-2.5" >
2836 />
2937 </template >
3038 </InstallationSettingsLayout >
39+
40+ <div v-if =" isSiteAdmin" class =" flex flex-col gap-2.5" >
41+ <span class =" text-lg font-semibold text-contrast" >
42+ {{ formatMessage(messages.supportOptionsTitle) }}
43+ </span >
44+ <div >
45+ <ButtonStyled color =" red" >
46+ <button
47+ class =" !shadow-none"
48+ :disabled =" !worldId || isResettingToOnboarding"
49+ @click =" resetToOnboardingModal?.show()"
50+ >
51+ <RotateCounterClockwiseIcon class =" size-5" />
52+ {{ formatMessage(messages.resetToOnboardingButton) }}
53+ </button >
54+ </ButtonStyled >
55+ </div >
56+ </div >
3157 </div >
3258</template >
3359
@@ -37,6 +63,7 @@ import { RotateCounterClockwiseIcon } from '@modrinth/assets'
3763import {
3864 ButtonStyled ,
3965 commonMessages ,
66+ ConfirmModal ,
4067 defineMessages ,
4168 formatLoaderLabel ,
4269 injectModrinthClient ,
@@ -106,6 +133,35 @@ const messages = defineMessages({
106133 id: ' hosting.loader.failed-to-unlink' ,
107134 defaultMessage: ' Failed to unlink modpack' ,
108135 },
136+ supportOptionsTitle: {
137+ id: ' hosting.loader.support-options-title' ,
138+ defaultMessage: ' Support options' ,
139+ },
140+ resetToOnboardingButton: {
141+ id: ' hosting.loader.reset-to-onboarding-button' ,
142+ defaultMessage: ' Reset to onboarding' ,
143+ },
144+ resetToOnboardingModalTitle: {
145+ id: ' hosting.loader.reset-to-onboarding-modal-title' ,
146+ defaultMessage: ' Reset to onboarding' ,
147+ },
148+ resetToOnboardingModalDescription: {
149+ id: ' hosting.loader.reset-to-onboarding-modal-description' ,
150+ defaultMessage:
151+ ' This will send the server back into onboarding so setup can be completed again. Are you sure you want to continue?' ,
152+ },
153+ resetToOnboardingSuccessTitle: {
154+ id: ' hosting.loader.reset-to-onboarding-success-title' ,
155+ defaultMessage: ' Server reset to onboarding' ,
156+ },
157+ resetToOnboardingSuccessDescription: {
158+ id: ' hosting.loader.reset-to-onboarding-success-description' ,
159+ defaultMessage: ' The server has been returned to the onboarding flow.' ,
160+ },
161+ failedToResetToOnboarding: {
162+ id: ' hosting.loader.failed-to-reset-to-onboarding' ,
163+ defaultMessage: ' Failed to reset server to onboarding' ,
164+ },
109165})
110166
111167const emit = defineEmits <{
@@ -156,8 +212,13 @@ const modpackVersionsQuery = useQuery({
156212 enabled: computed (() => !! modpack .value ?.spec .project_id ),
157213})
158214
215+ const auth = await useAuth ()
216+ const isSiteAdmin = computed (() => auth .value ?.user ?.role === ' admin' )
217+
159218const editingPlatform = ref (server .value ?.loader ?.toLowerCase () ?? ' vanilla' )
160219const editingGameVersion = ref (server .value ?.mc_version ?? ' ' )
220+ const resetToOnboardingModal = ref <InstanceType <typeof ConfirmModal >>()
221+ const isResettingToOnboarding = ref (false )
161222
162223const modLoaders = [' fabric' , ' forge' , ' quilt' , ' neoforge' ]
163224
@@ -590,4 +651,30 @@ function onBrowseModpacks() {
590651 query: { sid: serverId , from: ' reset-server' , wid: worldId .value },
591652 })
592653}
654+
655+ async function confirmResetToOnboarding() {
656+ if (! worldId .value ) return
657+
658+ try {
659+ isResettingToOnboarding .value = true
660+ await client .archon .servers_v1 .resetToOnboarding (serverId , worldId .value )
661+ server .value .flows = { intro: true }
662+ await Promise .all ([
663+ queryClient .invalidateQueries ({ queryKey: [' servers' , ' detail' , serverId ] }),
664+ queryClient .invalidateQueries ({ queryKey: [' servers' , ' v1' , ' detail' , serverId ] }),
665+ ])
666+ addNotification ({
667+ type: ' success' ,
668+ title: formatMessage (messages .resetToOnboardingSuccessTitle ),
669+ text: formatMessage (messages .resetToOnboardingSuccessDescription ),
670+ })
671+ } catch (err ) {
672+ addNotification ({
673+ type: ' error' ,
674+ text: err instanceof Error ? err .message : formatMessage (messages .failedToResetToOnboarding ),
675+ })
676+ } finally {
677+ isResettingToOnboarding .value = false
678+ }
679+ }
593680 </script >
0 commit comments