Skip to content

Commit 7b34719

Browse files
authored
hosting: "Reset to onboarding" support-only action (#5659)
* Reset to onboarding button * Lint * Intl
1 parent d2abeb4 commit 7b34719

3 files changed

Lines changed: 120 additions & 0 deletions

File tree

  • apps/frontend/src
  • packages/api-client/src/modules/archon/servers

apps/frontend/src/locales/en-US/index.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,9 @@
13131313
"hosting.loader.failed-to-repair": {
13141314
"message": "Failed to repair server"
13151315
},
1316+
"hosting.loader.failed-to-reset-to-onboarding": {
1317+
"message": "Failed to reset server to onboarding"
1318+
},
13161319
"hosting.loader.failed-to-save-settings": {
13171320
"message": "Failed to save installation settings"
13181321
},
@@ -1334,6 +1337,24 @@
13341337
"hosting.loader.reset-server-description": {
13351338
"message": "Removes all data on your server, including your worlds, mods, and configuration files. Backups will remain and can be restored."
13361339
},
1340+
"hosting.loader.reset-to-onboarding-button": {
1341+
"message": "Reset to onboarding"
1342+
},
1343+
"hosting.loader.reset-to-onboarding-modal-description": {
1344+
"message": "This will send the server back into onboarding so setup can be completed again. Are you sure you want to continue?"
1345+
},
1346+
"hosting.loader.reset-to-onboarding-modal-title": {
1347+
"message": "Reset to onboarding"
1348+
},
1349+
"hosting.loader.reset-to-onboarding-success-description": {
1350+
"message": "The server has been returned to the onboarding flow."
1351+
},
1352+
"hosting.loader.reset-to-onboarding-success-title": {
1353+
"message": "Server reset to onboarding"
1354+
},
1355+
"hosting.loader.support-options-title": {
1356+
"message": "Support options"
1357+
},
13371358
"hosting.plan.out-of-stock": {
13381359
"message": "Out of stock"
13391360
},

apps/frontend/src/pages/hosting/manage/[id]/options/loader.vue

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
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">
@@ -28,6 +36,24 @@
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'
3763
import {
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
111167
const 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+
159218
const editingPlatform = ref(server.value?.loader?.toLowerCase() ?? 'vanilla')
160219
const editingGameVersion = ref(server.value?.mc_version ?? '')
220+
const resetToOnboardingModal = ref<InstanceType<typeof ConfirmModal>>()
221+
const isResettingToOnboarding = ref(false)
161222
162223
const 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>

packages/api-client/src/modules/archon/servers/v1.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,16 @@ export class ArchonServersV1Module extends AbstractModule {
5454
method: 'DELETE',
5555
})
5656
}
57+
58+
/**
59+
* Reset a world to onboarding
60+
* POST /v1/servers/:id/worlds/:wid/onboard
61+
*/
62+
public async resetToOnboarding(serverId: string, worldId: string): Promise<void> {
63+
await this.client.request(`/servers/${serverId}/worlds/${worldId}/onboard`, {
64+
api: 'archon',
65+
version: 1,
66+
method: 'POST',
67+
})
68+
}
5769
}

0 commit comments

Comments
 (0)