You've already forked AstralRinth
forked from didirus/AstralRinth
* Make theseus capable of logging messages from the `log` crate * Move update checking entirely into JS and open a modal if an update is available * Fix formatjs on Windows and run formatjs * Add in the buttons and body * Fix lint * Show update size in modal * Fix update not being rechecked if the update modal was directly dismissed * Slight UI tweaks * Fix lint * Implement skipping the update * Implement the Update Now button * Implement updating at next exit * Turn download progress into an error bar on failure * Restore 5 minute update check instead of 30 seconds * Fix PendingUpdateData being seen as a unit struct * Fix lint * Make CI also lint updater code * feat: create AppearingProgressBar component * feat: polish update available modal * feat: add error handling * Open changelog with tauri-plugin-opener * Run intl:extract * Update completion toasts (#3978) * Use single LAUNCHER_USER_AGENT constant for all user agents * Fix build on Mac * Request the update size with HEAD instead of GET * UI tweaks * lint * Fix lint * fix: hide modal header & add "Hide update reminder" button w/ tooltip * Run intl:extract * fix: lint issues * fix: merge issues * notifications.js no longer exists * Add metered network checking * Add a timeout to macOS is_network_metered * Fix tauri.conf.json * vibe debugging * Set a dispatch queue * Have a popup that asks you if you'd like to disable automatic file downloads if you're on a metered network * Move UpdateModal to modal package * Fix lint * Add a toggle for automatic downloads * Fix type Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com> Signed-off-by: Josiah Glosson <soujournme@gmail.com> * Redo updating UI and experience * lint * fix unlistener issue * remove unneeded translation keys * Fix expose issue * temp disable cranelift, tweak some messages * change version back * Clean up App.vue * move toast to top right * update reload icon * Fixed the bug!!!!!!!!!!!! * improve messages * intl:extract * Add liquid glass icon file * not you! * use dependency injection * lint on apple icon * Fix imports, move download size to button * change update check back to 5 mins * lint + move to providers * intl:extract --------- Signed-off-by: Cal H. <hendersoncal117@gmail.com> Signed-off-by: Josiah Glosson <soujournme@gmail.com> Co-authored-by: Calum <calum@modrinth.com> Co-authored-by: Prospector <prospectordev@gmail.com> Co-authored-by: Cal H. <hendersoncal117@gmail.com> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com> Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com>
264 lines
7.2 KiB
Vue
264 lines
7.2 KiB
Vue
<template>
|
|
<NewModal ref="mrpackModal" header="Uploading mrpack" :closable="!isLoading" @show="onShow">
|
|
<div class="flex flex-col gap-4 md:w-[600px]">
|
|
<AppearingProgressBar :max-value="totalBytes" :current-value="uploadedBytes" />
|
|
|
|
<Transition
|
|
enter-active-class="transition-all duration-300 ease-out"
|
|
enter-from-class="opacity-0 max-h-0"
|
|
enter-to-class="opacity-100 max-h-20"
|
|
leave-active-class="transition-all duration-200 ease-in"
|
|
leave-from-class="opacity-100 max-h-20"
|
|
leave-to-class="opacity-0 max-h-0"
|
|
>
|
|
<div v-if="!isLoading" class="flex flex-col gap-4">
|
|
<p
|
|
v-if="isMrpackModalSecondPhase"
|
|
:style="{
|
|
lineHeight: isMrpackModalSecondPhase ? '1.5' : undefined,
|
|
marginBottom: isMrpackModalSecondPhase ? '-12px' : '0',
|
|
marginTop: isMrpackModalSecondPhase ? '-4px' : '-2px',
|
|
}"
|
|
>
|
|
This will reinstall your server and erase all data. You may want to back up your server
|
|
before proceeding. Are you sure you want to continue?
|
|
</p>
|
|
<div v-if="!isMrpackModalSecondPhase" class="flex flex-col gap-4">
|
|
<div class="mx-auto flex flex-row items-center gap-4">
|
|
<div
|
|
class="grid size-16 place-content-center rounded-2xl border-[2px] border-solid border-button-border bg-button-bg shadow-sm"
|
|
>
|
|
<UploadIcon class="size-10" />
|
|
</div>
|
|
<ArrowBigRightDashIcon class="size-10" />
|
|
<div
|
|
class="grid size-16 place-content-center rounded-2xl border-[2px] border-solid border-button-border bg-table-alternateRow shadow-sm"
|
|
>
|
|
<ServerIcon class="size-10" />
|
|
</div>
|
|
</div>
|
|
<div class="flex w-full flex-col gap-2 rounded-2xl bg-table-alternateRow p-4">
|
|
<div class="text-sm font-bold text-contrast">Upload mrpack</div>
|
|
<input
|
|
type="file"
|
|
accept=".mrpack"
|
|
class=""
|
|
:disabled="isLoading"
|
|
@change="uploadMrpack"
|
|
/>
|
|
</div>
|
|
|
|
<div class="flex w-full flex-col gap-2 rounded-2xl bg-table-alternateRow p-4">
|
|
<div class="flex w-full flex-row items-center justify-between">
|
|
<label class="w-full text-lg font-bold text-contrast" for="hard-reset">
|
|
Erase all data
|
|
</label>
|
|
<input
|
|
id="hard-reset"
|
|
v-model="hardReset"
|
|
class="switch stylized-toggle shrink-0"
|
|
type="checkbox"
|
|
/>
|
|
</div>
|
|
<div>
|
|
Removes all data on your server, including your worlds, mods, and configuration
|
|
files, then reinstalls it with the selected version.
|
|
</div>
|
|
<div class="font-bold">
|
|
This does not affect your backups, which are stored off-site.
|
|
</div>
|
|
</div>
|
|
|
|
<BackupWarning :backup-link="`/servers/manage/${props.server?.serverId}/backups`" />
|
|
</div>
|
|
<div class="mt-4 flex justify-start gap-4">
|
|
<ButtonStyled :color="isDangerous ? 'red' : 'brand'">
|
|
<button
|
|
v-tooltip="backupInProgress ? backupInProgress.tooltip : undefined"
|
|
:disabled="canInstall || !!backupInProgress"
|
|
@click="handleReinstall"
|
|
>
|
|
<RightArrowIcon />
|
|
{{
|
|
isMrpackModalSecondPhase
|
|
? 'Erase and install'
|
|
: loadingServerCheck
|
|
? 'Loading...'
|
|
: isDangerous
|
|
? 'Erase and install'
|
|
: 'Install'
|
|
}}
|
|
</button>
|
|
</ButtonStyled>
|
|
<ButtonStyled>
|
|
<button
|
|
:disabled="isLoading"
|
|
@click="
|
|
() => {
|
|
if (isMrpackModalSecondPhase) {
|
|
isMrpackModalSecondPhase = false
|
|
} else {
|
|
hide()
|
|
}
|
|
}
|
|
"
|
|
>
|
|
<XIcon />
|
|
{{ isMrpackModalSecondPhase ? 'Go back' : 'Cancel' }}
|
|
</button>
|
|
</ButtonStyled>
|
|
</div>
|
|
</div>
|
|
</Transition>
|
|
</div>
|
|
</NewModal>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {
|
|
ArrowBigRightDashIcon,
|
|
RightArrowIcon,
|
|
ServerIcon,
|
|
UploadIcon,
|
|
XIcon,
|
|
} from '@modrinth/assets'
|
|
import {
|
|
AppearingProgressBar,
|
|
BackupWarning,
|
|
ButtonStyled,
|
|
injectNotificationManager,
|
|
NewModal,
|
|
} from '@modrinth/ui'
|
|
import { ModrinthServersFetchError } from '@modrinth/utils'
|
|
import { onMounted, onUnmounted } from 'vue'
|
|
|
|
import type { ModrinthServer } from '~/composables/servers/modrinth-servers'
|
|
import type { BackupInProgressReason } from '~/pages/servers/manage/[id].vue'
|
|
|
|
const { addNotification } = injectNotificationManager()
|
|
|
|
const handleBeforeUnload = (event: BeforeUnloadEvent) => {
|
|
if (isLoading.value) {
|
|
event.preventDefault()
|
|
return 'Upload in progress. Are you sure you want to leave?'
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
window.addEventListener('beforeunload', handleBeforeUnload)
|
|
})
|
|
|
|
onUnmounted(() => {
|
|
window.removeEventListener('beforeunload', handleBeforeUnload)
|
|
})
|
|
|
|
const props = defineProps<{
|
|
server: ModrinthServer
|
|
backupInProgress?: BackupInProgressReason
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
reinstall: [any?]
|
|
}>()
|
|
|
|
const mrpackModal = ref()
|
|
const isMrpackModalSecondPhase = ref(false)
|
|
const hardReset = ref(false)
|
|
const isLoading = ref(false)
|
|
const loadingServerCheck = ref(false)
|
|
const mrpackFile = ref<File | null>(null)
|
|
const uploadedBytes = ref(0)
|
|
const totalBytes = ref(0)
|
|
|
|
const isDangerous = computed(() => hardReset.value)
|
|
const canInstall = computed(() => !mrpackFile.value || isLoading.value || loadingServerCheck.value)
|
|
|
|
const uploadMrpack = (event: Event) => {
|
|
const target = event.target as HTMLInputElement
|
|
if (!target.files || target.files.length === 0) {
|
|
return
|
|
}
|
|
mrpackFile.value = target.files[0]
|
|
}
|
|
|
|
const handleReinstall = async () => {
|
|
if (hardReset.value && !isMrpackModalSecondPhase.value) {
|
|
isMrpackModalSecondPhase.value = true
|
|
return
|
|
}
|
|
|
|
if (!mrpackFile.value) {
|
|
addNotification({
|
|
title: 'No file selected',
|
|
text: 'Choose a .mrpack file before installing.',
|
|
type: 'error',
|
|
})
|
|
return
|
|
}
|
|
|
|
isLoading.value = true
|
|
uploadedBytes.value = 0
|
|
totalBytes.value = mrpackFile.value.size
|
|
|
|
const { onProgress, promise } = props.server.general.reinstallFromMrpack(
|
|
mrpackFile.value,
|
|
hardReset.value,
|
|
)
|
|
|
|
onProgress(({ loaded, total }) => {
|
|
uploadedBytes.value = loaded
|
|
totalBytes.value = total
|
|
})
|
|
|
|
try {
|
|
await promise
|
|
|
|
emit('reinstall', {
|
|
loader: 'mrpack',
|
|
lVersion: '',
|
|
mVersion: '',
|
|
})
|
|
|
|
await nextTick()
|
|
window.scrollTo(0, 0)
|
|
hide()
|
|
} catch (error) {
|
|
if (error instanceof ModrinthServersFetchError && error.statusCode === 429) {
|
|
addNotification({
|
|
title: 'Cannot upload and install modpack to server',
|
|
text: 'You are being rate limited. Please try again later.',
|
|
type: 'error',
|
|
})
|
|
} else {
|
|
addNotification({
|
|
title: 'Modpack upload and install failed',
|
|
text: 'An unexpected error occurred while uploading/installing. Please try again later.',
|
|
type: 'error',
|
|
})
|
|
}
|
|
} finally {
|
|
isLoading.value = false
|
|
}
|
|
}
|
|
const onShow = () => {
|
|
hardReset.value = false
|
|
isMrpackModalSecondPhase.value = false
|
|
loadingServerCheck.value = false
|
|
isLoading.value = false
|
|
mrpackFile.value = null
|
|
uploadedBytes.value = 0
|
|
totalBytes.value = 0
|
|
}
|
|
|
|
const show = () => mrpackModal.value?.show()
|
|
const hide = () => mrpackModal.value?.hide()
|
|
|
|
defineExpose({ show, hide })
|
|
</script>
|
|
|
|
<style scoped>
|
|
.stylized-toggle:checked::after {
|
|
background: var(--color-accent-contrast) !important;
|
|
}
|
|
</style>
|