mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 00:55:25 +00:00
fix navtabs issues and unify project lists (#7245)
* fix navtabs issues and unify project lists * move page navtab logic to component
This commit is contained in:
@@ -25,8 +25,8 @@ export async function get_user_profile(userId: string): Promise<Labrinth.Users.v
|
||||
return await invoke<Labrinth.Users.v3.User>('plugin:users|get_user_profile', { userId })
|
||||
}
|
||||
|
||||
export async function get_user_projects(userId: string): Promise<Labrinth.Projects.v2.Project[]> {
|
||||
return await invoke<Labrinth.Projects.v2.Project[]>('plugin:users|get_user_projects', {
|
||||
export async function get_user_projects(userId: string): Promise<Labrinth.Projects.v3.Project[]> {
|
||||
return await invoke<Labrinth.Projects.v3.Project[]>('plugin:users|get_user_projects', {
|
||||
userId,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,19 +11,20 @@
|
||||
>
|
||||
<template #project-actions="{ project }">
|
||||
<Button
|
||||
v-if="project.minecraft_server == null"
|
||||
type="outlined"
|
||||
class="!text-brand [&>svg]:!text-brand !shadow-[inset_0_0_0_1px_var(--color-brand)]"
|
||||
:disabled="isProjectInstalling(project.id)"
|
||||
@click.stop="installProject(project)"
|
||||
>
|
||||
<SpinnerIcon v-if="isProjectInstalling(project.id)" class="animate-spin" />
|
||||
<DownloadIcon v-else-if="project.project_type === 'modpack'" />
|
||||
<DownloadIcon v-else-if="project.project_types.includes('modpack')" />
|
||||
<PlusIcon v-else />
|
||||
{{
|
||||
formatMessage(
|
||||
isProjectInstalling(project.id)
|
||||
? commonMessages.installingLabel
|
||||
: project.project_type === 'modpack'
|
||||
: project.project_types.includes('modpack')
|
||||
? commonMessages.installButton
|
||||
: messages.installToInstance,
|
||||
)
|
||||
@@ -96,7 +97,7 @@ function setProjectInstalling(projectId: string, installing: boolean): void {
|
||||
installingProjectIds.value = next
|
||||
}
|
||||
|
||||
async function installProject(project: Labrinth.Projects.v2.Project): Promise<void> {
|
||||
async function installProject(project: Labrinth.Projects.v3.Project): Promise<void> {
|
||||
if (isProjectInstalling(project.id)) return
|
||||
|
||||
setProjectInstalling(project.id, true)
|
||||
@@ -130,14 +131,19 @@ const userProfile = provideUserProfile({
|
||||
unblockUser: unblock_user,
|
||||
})
|
||||
|
||||
const userId = computed(() => {
|
||||
const value = route.params.user
|
||||
return Array.isArray(value) ? (value[0] ?? '') : (value ?? '')
|
||||
})
|
||||
const projectType = computed(() => {
|
||||
const value = route.params.projectType
|
||||
return Array.isArray(value) ? value[0] : value
|
||||
})
|
||||
function readRouteParam(param: unknown): string | undefined {
|
||||
const value = Array.isArray(param) ? param[0] : param
|
||||
return typeof value === 'string' && value.length > 0 ? value : undefined
|
||||
}
|
||||
|
||||
const userId = ref(readRouteParam(route.params.user) ?? '')
|
||||
watch(
|
||||
() => readRouteParam(route.params.user),
|
||||
(next) => {
|
||||
if (next) userId.value = next
|
||||
},
|
||||
)
|
||||
const projectType = computed(() => readRouteParam(route.params.projectType))
|
||||
|
||||
function getCachedUserSummary(id: string) {
|
||||
return queryClient.getQueryData<Labrinth.Users.v3.User>(['users', 'summary', id])
|
||||
|
||||
Reference in New Issue
Block a user