Project wireup (#80)

* Remove unneeded style

* Base modpack wire up

* Run lint

* Thats not supposed to be there

* Remove errant class

* Fix safety

* Username => ID

* fix id missing

* Fix bug with clicking

* remove unnecessary

* Update Versions.vue

* Addressed changes

* Lintttt
This commit is contained in:
Adrian O.V
2023-04-12 22:29:40 -04:00
committed by GitHub
parent 06ace174e6
commit bb126c0545
9 changed files with 111 additions and 52 deletions
+17 -6
View File
@@ -29,7 +29,7 @@
</Categories>
<hr class="card-divider" />
<div class="button-group">
<Button color="primary" class="instance-button" @click="install">
<Button color="primary" class="instance-button" @click="install(versions[0].id)">
<DownloadIcon />
Install
</Button>
@@ -173,9 +173,11 @@
:versions="versions"
:members="members"
:dependencies="dependencies"
:install="install"
/>
</div>
</div>
<InstallConfirmModal ref="confirmModal" />
</template>
<script setup>
@@ -209,15 +211,18 @@ import {
} from '@/assets/external'
import { get_categories, get_loaders } from '@/helpers/tags'
import { install as pack_install } from '@/helpers/pack'
import { list } from '@/helpers/profile'
import dayjs from 'dayjs'
import relativeTime from 'dayjs/plugin/relativeTime'
import { ofetch } from 'ofetch'
import { useRoute, useRouter } from 'vue-router'
import { ref, shallowRef, watch } from 'vue'
import InstallConfirmModal from '@/components/ui/InstallConfirmModal.vue'
const route = useRoute()
const router = useRouter()
const confirmModal = ref(null)
const loaders = ref(await get_loaders())
const categories = ref(await get_categories())
const [data, versions, members, dependencies] = await Promise.all([
@@ -236,12 +241,18 @@ watch(
dayjs.extend(relativeTime)
async function install() {
async function install(version) {
if (data.value.project_type === 'modpack') {
let id = await pack_install(versions.value[0].id)
let router = useRouter()
await router.push({ path: `/instance/${encodeURIComponent(id)}` })
const packs = Object.values(await list())
if (
packs.length === 0 ||
!packs.map((value) => value.metadata).find((pack) => pack.linked_project_id === data.value.id)
) {
let id = await pack_install(version)
await router.push({ path: `/instance/${encodeURIComponent(id)}` })
} else {
confirmModal.value.show(version)
}
}
}
</script>