working acceptance + download

This commit is contained in:
thesuzerain committed 2024-01-30 19:14:47 -08:00
1 parent 719aded698
commit 1018d05e36
7 files changed
+97 -55

No files matched your search

@@ -1,10 +1,8 @@
<script setup>
import { Modal, Button } from 'omorphia'
import { ref } from 'vue'
import { useFetch } from '@/helpers/fetch.js'
import SearchCard from '@/components/ui/SearchCard.vue'
import { handleError } from '@/store/notifications.js'
import { share_accept, share_install } from '@/helpers/shared_profiles.js'
import { share_accept, share_install, share_get_link_id } from '@/helpers/shared_profiles.js'
const confirmModal = ref(null)
const linkId = ref(null)
@@ -12,13 +10,11 @@ const sharedProfile = ref(null)
defineExpose({
async show(event) {
linkId.value = event.id
sharedProfile.value = await useFetch(
`https://staging-api.modrinth.com/_internal/share/${encodeURIComponent(event.id)}`,
'shared profile'
)
console.log('showing accept shared profile modal', event)
linkId.value = event.link
sharedProfile.value = await share_get_link_id(linkId.value).catch(handleError)
confirmModal.value.show()
console.log('sharedProfile')
},
})
@@ -30,18 +26,12 @@ async function install() {
</script>
<template>
<Modal ref="confirmModal" :header="`Install ${project?.title}`">
<Modal ref="confirmModal" :header="`Install ${sharedProfile?.name}`">
<div class="modal-body">
<SearchCard
:project="project"
class="project-card"
:categories="categories"
@open="confirmModal.hide()"
/>
<div class="button-row">
<div class="markdown-body">
<p>
Installing <code>{{ sharedProfile.id }}</code> from user {{ sharedProfile.owner_id }}
Installing <code>{{ sharedProfile.name }}</code> from user {{ sharedProfile.owner_id }}
</p>
</div>
<div class="button-group">
+9 -3
View File
@@ -15,9 +15,15 @@ export async function share_generate(path) {
return await invoke('plugin:profile_share|profile_share_generate_share_link', { path })
}
/// Gets the shared profile from the link id
// This is done without accepting it- so would not include any link information, and is only usable for basic info
export async function share_get_link_id(link) {
return await invoke('plugin:profile_share|profile_share_get_link_id', { link })
}
/// Accepts a shared profile link
export async function share_accept(link) {
return await invoke('plugin:profile_share|profile_share_accept', { link })
return await invoke('plugin:profile_share|profile_share_accept_share_link', { link })
}
/// Removes users from a shared profile
@@ -31,8 +37,8 @@ export async function remove_links(path, links) {
}
/// Install a pack from a shared profile id
export async function share_install(id) {
return await invoke('plugin:profile_share|profile_share_install', { id })
export async function share_install(sharedProfileId) {
return await invoke('plugin:profile_share|profile_share_install', { sharedProfileId })
}
// get all user profiles that are available to the currentt user
+5
View File
@@ -29,10 +29,15 @@ const raw_invoke = async (plugin, fn, args) => {
return await invoke('plugin:' + plugin + '|' + fn, args)
}
}
const test_command = async (command) => {
return await raw_invoke('utils', 'test_command', {command })
}
isDev()
.then((dev) => {
if (dev) {
window.raw_invoke = raw_invoke
window.test_command = test_command
}
})
.catch((err) => {
+3 -7
View File
@@ -492,9 +492,6 @@
</div>
</div>
<div v-if="installedSharedProfileData.is_owned" class="adjacent-input">
your project
{{ props.instance.sync_update_version }}
:)
<label for="share-sync">
<span class="label__title">Sync shared profile</span>
<span class="label__description" v-if="props.instance.sync_update_version?.is_synced">
@@ -511,9 +508,7 @@
<GlobeIcon /> Revert
</Button>
</div>
<div v-else>
not yours
{{ props.instance.sync_update_version }}
<div v-else class="adjacent-input">
<label for="share-sync">
<span class="label__title">Sync shared profile</span>
<span class="label__description" v-if="props.instance.sync_update_version?.is_synced">
@@ -523,10 +518,11 @@
You are not up to date with the shared profile. Click the button to update your instance.
</span>
</label>
<Button id="share-sync-sync" @click="inboundSyncSharedProfile">
<Button id="share-sync-sync" @click="inboundSyncSharedProfile" :disabled="props.instance.sync_update_version?.is_synced">
<GlobeIcon /> Sync
</Button>
</div>
{{ props.instance.sync_update_version }}
</Card>
<Card>
<div class="label">