You've already forked AstralRinth
forked from didirus/AstralRinth
* refactor: migrate to common eslint+prettier configs * fix: prettier frontend * feat: config changes * fix: lint issues * fix: lint * fix: type imports * fix: cyclical import issue * fix: lockfile * fix: missing dep * fix: switch to tabs * fix: continue switch to tabs * fix: rustfmt parity * fix: moderation lint issue * fix: lint issues * fix: ui intl * fix: lint issues * Revert "fix: rustfmt parity" This reverts commit cb99d2376c321d813d4b7fc7e2a213bb30a54711. * feat: revert last rs
78 lines
2.0 KiB
Vue
78 lines
2.0 KiB
Vue
<script setup>
|
|
import { DownloadIcon, XIcon } from '@modrinth/assets'
|
|
import { Button, injectNotificationManager } from '@modrinth/ui'
|
|
import { ref } from 'vue'
|
|
|
|
import ModalWrapper from '@/components/ui/modal/ModalWrapper.vue'
|
|
import { trackEvent } from '@/helpers/analytics'
|
|
import { create_profile_and_install as pack_install } from '@/helpers/pack'
|
|
|
|
const { handleError } = injectNotificationManager()
|
|
|
|
const versionId = ref()
|
|
const project = ref()
|
|
const confirmModal = ref(null)
|
|
const installing = ref(false)
|
|
|
|
const onInstall = ref(() => {})
|
|
const onCreateInstance = ref(() => {})
|
|
|
|
defineExpose({
|
|
show: (projectVal, versionIdVal, callback, createInstanceCallback) => {
|
|
project.value = projectVal
|
|
versionId.value = versionIdVal
|
|
installing.value = false
|
|
confirmModal.value.show()
|
|
|
|
onInstall.value = callback
|
|
onCreateInstance.value = createInstanceCallback
|
|
|
|
trackEvent('PackInstallStart')
|
|
},
|
|
})
|
|
|
|
async function install() {
|
|
installing.value = true
|
|
confirmModal.value.hide()
|
|
|
|
await pack_install(
|
|
project.value.id,
|
|
versionId.value,
|
|
project.value.title,
|
|
project.value.icon_url,
|
|
onCreateInstance.value,
|
|
).catch(handleError)
|
|
trackEvent('PackInstall', {
|
|
id: project.value.id,
|
|
version_id: versionId.value,
|
|
title: project.value.title,
|
|
source: 'ConfirmModal',
|
|
})
|
|
|
|
onInstall.value(versionId.value)
|
|
installing.value = false
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<ModalWrapper ref="confirmModal" header="Are you sure?" :on-hide="onInstall">
|
|
<div class="modal-body">
|
|
<p>You already have this modpack installed. Are you sure you want to install it again?</p>
|
|
<div class="input-group push-right">
|
|
<Button @click="() => $refs.confirmModal.hide()"><XIcon />Cancel</Button>
|
|
<Button color="primary" :disabled="installing" @click="install()"
|
|
><DownloadIcon /> {{ installing ? 'Installing' : 'Install' }}</Button
|
|
>
|
|
</div>
|
|
</div>
|
|
</ModalWrapper>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.modal-body {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1rem;
|
|
}
|
|
</style>
|