fix: misc server projects fixes (#5537)
* fix: add server to instance modal opens slow * fix: creators section org doesnt display for project pages in app * feat: separate modpacks and servers tabs in instances library
This commit is contained in:
@@ -37,17 +37,21 @@ defineExpose({
|
|||||||
searchFilter.value = ''
|
searchFilter.value = ''
|
||||||
|
|
||||||
const profilesVal = await list().catch(handleError)
|
const profilesVal = await list().catch(handleError)
|
||||||
for (const profile of profilesVal) {
|
await Promise.allSettled(
|
||||||
profile.adding = false
|
profilesVal.map(async (profile) => {
|
||||||
profile.added = false
|
profile.adding = false
|
||||||
|
profile.added = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const worlds = await get_profile_worlds(profile.path)
|
const worlds = await get_profile_worlds(profile.path)
|
||||||
profile.added = worlds.some((w) => w.type === 'server' && w.address === serverAddress.value)
|
profile.added = worlds.some(
|
||||||
} catch {
|
(w) => w.type === 'server' && w.address === serverAddress.value,
|
||||||
// Ignore - will show as not added
|
)
|
||||||
}
|
} catch {
|
||||||
}
|
// Ignore - will show as not added
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
profiles.value = profilesVal
|
profiles.value = profilesVal
|
||||||
modal.value.show()
|
modal.value.show()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import GridDisplay from '@/components/GridDisplay.vue'
|
import GridDisplay from '@/components/GridDisplay.vue'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import GridDisplay from '@/components/GridDisplay.vue'
|
import GridDisplay from '@/components/GridDisplay.vue'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import { PlusIcon } from '@modrinth/assets'
|
import { PlusIcon } from '@modrinth/assets'
|
||||||
import { Button, injectNotificationManager } from '@modrinth/ui'
|
import { Button, injectNotificationManager } from '@modrinth/ui'
|
||||||
import { inject, onUnmounted, ref, shallowRef } from 'vue'
|
import { inject, onUnmounted, ref, shallowRef } from 'vue'
|
||||||
@@ -41,7 +41,8 @@ onUnmounted(() => {
|
|||||||
<NavTabs
|
<NavTabs
|
||||||
:links="[
|
:links="[
|
||||||
{ label: 'All instances', href: `/library` },
|
{ label: 'All instances', href: `/library` },
|
||||||
{ label: 'Downloaded', href: `/library/downloaded` },
|
{ label: 'Modpacks', href: `/library/modpacks` },
|
||||||
|
{ label: 'Servers', href: `/library/servers` },
|
||||||
{ label: 'Custom', href: `/library/custom` },
|
{ label: 'Custom', href: `/library/custom` },
|
||||||
{ label: 'Shared with me', href: `/library/shared`, shown: false },
|
{ label: 'Shared with me', href: `/library/shared`, shown: false },
|
||||||
{ label: 'Saved', href: `/library/saved`, shown: false },
|
{ label: 'Saved', href: `/library/saved`, shown: false },
|
||||||
|
|||||||
47
apps/app-frontend/src/pages/library/Modpacks.vue
Normal file
47
apps/app-frontend/src/pages/library/Modpacks.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, watchEffect } from 'vue'
|
||||||
|
|
||||||
|
import GridDisplay from '@/components/GridDisplay.vue'
|
||||||
|
import { get_project_v3_many } from '@/helpers/cache.js'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
instances: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const serverProjectIds = ref(new Set())
|
||||||
|
|
||||||
|
const linkedInstances = computed(() => props.instances.filter((i) => i.linked_data))
|
||||||
|
|
||||||
|
watchEffect(async () => {
|
||||||
|
const projectIds = [
|
||||||
|
...new Set(linkedInstances.value.map((i) => i.linked_data?.project_id).filter(Boolean)),
|
||||||
|
]
|
||||||
|
if (projectIds.length === 0) {
|
||||||
|
serverProjectIds.value = new Set()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const projects = await get_project_v3_many(projectIds, 'must_revalidate')
|
||||||
|
serverProjectIds.value = new Set(
|
||||||
|
projects.filter((p) => p?.minecraft_server != null).map((p) => p.id),
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
serverProjectIds.value = new Set()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const filteredInstances = computed(() =>
|
||||||
|
linkedInstances.value.filter((i) => !serverProjectIds.value.has(i.linked_data?.project_id)),
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<GridDisplay
|
||||||
|
v-if="filteredInstances && filteredInstances.length > 0"
|
||||||
|
label="Instances"
|
||||||
|
:instances="filteredInstances"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<script setup>
|
<script setup lang="ts">
|
||||||
import GridDisplay from '@/components/GridDisplay.vue'
|
import GridDisplay from '@/components/GridDisplay.vue'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
|
|||||||
47
apps/app-frontend/src/pages/library/Servers.vue
Normal file
47
apps/app-frontend/src/pages/library/Servers.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, watchEffect } from 'vue'
|
||||||
|
|
||||||
|
import GridDisplay from '@/components/GridDisplay.vue'
|
||||||
|
import { get_project_v3_many } from '@/helpers/cache.js'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
instances: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const serverProjectIds = ref(new Set())
|
||||||
|
|
||||||
|
const linkedInstances = computed(() => props.instances.filter((i) => i.linked_data))
|
||||||
|
|
||||||
|
watchEffect(async () => {
|
||||||
|
const projectIds = [
|
||||||
|
...new Set(linkedInstances.value.map((i) => i.linked_data?.project_id).filter(Boolean)),
|
||||||
|
]
|
||||||
|
if (projectIds.length === 0) {
|
||||||
|
serverProjectIds.value = new Set()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const projects = await get_project_v3_many(projectIds, 'must_revalidate')
|
||||||
|
serverProjectIds.value = new Set(
|
||||||
|
projects.filter((p) => p?.minecraft_server != null).map((p) => p.id),
|
||||||
|
)
|
||||||
|
} catch {
|
||||||
|
serverProjectIds.value = new Set()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const filteredInstances = computed(() =>
|
||||||
|
linkedInstances.value.filter((i) => serverProjectIds.value.has(i.linked_data?.project_id)),
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<GridDisplay
|
||||||
|
v-if="filteredInstances && filteredInstances.length > 0"
|
||||||
|
label="Instances"
|
||||||
|
:instances="filteredInstances"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import Custom from './Custom.vue'
|
import Custom from './Custom.vue'
|
||||||
import Downloaded from './Downloaded.vue'
|
import Downloaded from './Downloaded.vue'
|
||||||
import Index from './Index.vue'
|
import Index from './Index.vue'
|
||||||
|
import Modpacks from './Modpacks.vue'
|
||||||
import Overview from './Overview.vue'
|
import Overview from './Overview.vue'
|
||||||
|
import Servers from './Servers.vue'
|
||||||
|
|
||||||
export { Custom, Downloaded, Index, Overview }
|
export { Custom, Downloaded, Index, Modpacks, Overview, Servers }
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
/>
|
/>
|
||||||
<ProjectSidebarTags :project="data" class="project-sidebar-section" />
|
<ProjectSidebarTags :project="data" class="project-sidebar-section" />
|
||||||
<ProjectSidebarCreators
|
<ProjectSidebarCreators
|
||||||
:organization="null"
|
:organization="organization"
|
||||||
:members="members"
|
:members="members"
|
||||||
:org-link="(slug) => `https://modrinth.com/organization/${slug}`"
|
:org-link="(slug) => `https://modrinth.com/organization/${slug}`"
|
||||||
:user-link="(username) => `https://modrinth.com/user/${username}`"
|
:user-link="(username) => `https://modrinth.com/user/${username}`"
|
||||||
@@ -244,6 +244,7 @@ import ContextMenu from '@/components/ui/ContextMenu.vue'
|
|||||||
import InstanceIndicator from '@/components/ui/InstanceIndicator.vue'
|
import InstanceIndicator from '@/components/ui/InstanceIndicator.vue'
|
||||||
import NavTabs from '@/components/ui/NavTabs.vue'
|
import NavTabs from '@/components/ui/NavTabs.vue'
|
||||||
import {
|
import {
|
||||||
|
get_organization,
|
||||||
get_project,
|
get_project,
|
||||||
get_project_v3,
|
get_project_v3,
|
||||||
get_team,
|
get_team,
|
||||||
@@ -282,6 +283,7 @@ const data = shallowRef(null)
|
|||||||
const versions = shallowRef([])
|
const versions = shallowRef([])
|
||||||
const members = shallowRef([])
|
const members = shallowRef([])
|
||||||
const categories = shallowRef([])
|
const categories = shallowRef([])
|
||||||
|
const organization = shallowRef(null)
|
||||||
const instance = ref(null)
|
const instance = ref(null)
|
||||||
const instanceProjects = ref(null)
|
const instanceProjects = ref(null)
|
||||||
|
|
||||||
@@ -387,6 +389,10 @@ async function fetchProjectData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (project.organization) {
|
||||||
|
organization.value = await get_organization(project.organization).catch(handleError)
|
||||||
|
}
|
||||||
|
|
||||||
isServerProject.value = projectV3.value?.minecraft_server != null
|
isServerProject.value = projectV3.value?.minecraft_server != null
|
||||||
serverStatusOnline.value = !!projectV3.value?.minecraft_java_server?.ping?.data
|
serverStatusOnline.value = !!projectV3.value?.minecraft_java_server?.ping?.data
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,16 @@ export default new createRouter({
|
|||||||
name: 'Downloaded',
|
name: 'Downloaded',
|
||||||
component: Library.Downloaded,
|
component: Library.Downloaded,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'modpacks',
|
||||||
|
name: 'Modpacks',
|
||||||
|
component: Library.Modpacks,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'servers',
|
||||||
|
name: 'LibraryServers',
|
||||||
|
component: Library.Servers,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'custom',
|
path: 'custom',
|
||||||
name: 'Custom',
|
name: 'Custom',
|
||||||
|
|||||||
Reference in New Issue
Block a user