feat: instances v2 (#6431)

* feat: base of instances v2

* feat: use old profiles with compat layer

* prototype: instances v2

* fix: install_from using profile

* fix: skins migration fix

* fix: frontend still using profile path

* fix: add update proj multiselect guard

* fix: cargo fmt

* fix: content missing fields

* feat: break up app-lib/api/instance.rs

* fix: check_content_updates mismatch

* fix: updater modal cleanup w/new structure

* feat: better update all handling

* fix: remove preview_update_all

* fix: feedback on bulk update + lint

* fix: rem transitions

* fix: change to jsonb

* feat: app db backup after update

* fix: lint

* fix: sqlx prepare + use sqlx macros

* fix: lint

* fix: bugs

* feat: defuck the installing process up

* fix: bug of hell

* fix: shear

* fix: fmt

* fix: install progress spacing + change mc/content/overrides to bytes

* fix: lint

* fix: prepr

* fix: navtabs anim not working in app

* fix: worlds.vue improvements + browse page fixes

* feat: optimise queries + adapter fns

* fix: lint

* fix: lint

* feat: shared modrinth-content-management crate (#6469)

* feat: disable warnings setting

* feat: add instances shortcuts (#6329)

* Add modrinth://launch deep link to start a profile

Support external profile launching via modrinth://launch/{profile_path} for integrations such as Stream Deck.

* Change route to /launch/profile/{id} for future extensibility

* fix: ensure profile path is url decoded

* fix: URL-decode profile path from deep link

* fix: use urlencoding crate for URL decoding

* feat: implement app instance shortcuts

* feat: change windows shortcut creation to use windows api instead

* feat: implement creating a shortcut launching world/server

* format

* fmt

* fix multiline inline tables

* pnpm prepr

* feat: move create shortcut to last item

* refactor: split up shortcuts.rs for individual platforms

* refactor: turn profile launch url into url type

* use string literal and add safety comment

* pt2

* refactor: rename anything that's profile into instance

* update mac shortcut

---------

Co-authored-by: DJCheesusReal <134006619+DJCheesusReal@users.noreply.github.com>

---------

Co-authored-by: Truman Gao <106889354+tdgao@users.noreply.github.com>
Co-authored-by: DJCheesusReal <134006619+DJCheesusReal@users.noreply.github.com>
This commit is contained in:
Calum H.
2026-06-25 21:19:29 +00:00
committed by GitHub
co-authored by DJCheesusReal Truman Gao
parent ef4044534f
commit 734720e11e
353 changed files with 24745 additions and 9771 deletions
@@ -55,6 +55,11 @@ async function handleBack() {
if (!context) return
if (selectedCount.value > 0 && !isInstallingSelected.value) {
if (context.skipNonEssentialWarnings) {
await handleSelectedProjectsLeaveResult('discard', context)
return
}
const result = await selectedProjectsLeaveModal.value?.prompt()
await handleSelectedProjectsLeaveResult(result ?? 'cancel', context)
return
@@ -36,6 +36,7 @@ export interface BrowseInstallContext {
onBack?: () => boolean | void | Promise<boolean | void>
selectedProjects?: BrowseSelectedProject[]
isInstallingSelected?: boolean
skipNonEssentialWarnings?: boolean
installProgress?: {
completed: number
total: number
@@ -46,6 +46,10 @@ const messages = defineMessages({
id: 'content.selection-bar.bulk.updating-waiting',
defaultMessage: 'Updating {contentType}...',
},
bulkUpdatingCount: {
id: 'content.selection-bar.bulk.updating-count',
defaultMessage: 'Updating {count, number} {contentType}',
},
bulkDeleting: {
id: 'content.selection-bar.bulk.deleting',
defaultMessage: 'Deleting {progress}/{total} {contentType}...',
@@ -54,6 +58,18 @@ const messages = defineMessages({
id: 'content.selection-bar.bulk.deleting-waiting',
defaultMessage: 'Deleting {contentType}...',
},
bulkEnablingCount: {
id: 'content.selection-bar.bulk.enabling-count',
defaultMessage: 'Enabling {count, number} {contentType}',
},
bulkDisablingCount: {
id: 'content.selection-bar.bulk.disabling-count',
defaultMessage: 'Disabling {count, number} {contentType}',
},
bulkDeletingCount: {
id: 'content.selection-bar.bulk.deleting-count',
defaultMessage: 'Deleting {count, number} {contentType}',
},
allAlreadyEnabled: {
id: 'content.selection-bar.all-already-enabled',
defaultMessage: 'All selected content is already enabled',
@@ -74,6 +90,8 @@ interface Props {
bulkProgress?: number
bulkTotal?: number
bulkWaiting?: boolean
bulkStatusMessage?: string | null
bulkItemCount?: number
ariaLabel?: string
getItemId?: (item: ContentItem) => string
}
@@ -87,6 +105,8 @@ const props = withDefaults(defineProps<Props>(), {
bulkProgress: 0,
bulkTotal: 0,
bulkWaiting: false,
bulkStatusMessage: null,
bulkItemCount: 0,
ariaLabel: undefined,
getItemId: undefined,
})
@@ -114,7 +134,22 @@ const allDisabled = computed(() => props.selectedItems.every((m) => !m.enabled))
const allEnabled = computed(() => props.selectedItems.every((m) => m.enabled))
const selectedCountText = computed(() => {
const count = props.selectedItems.length || props.bulkTotal
const count = props.isBulkOperating
? props.bulkItemCount || props.bulkTotal || props.selectedItems.length
: props.selectedItems.length || props.bulkTotal
if (props.isBulkOperating && props.bulkOperation) {
const messageMap = {
enable: messages.bulkEnablingCount,
disable: messages.bulkDisablingCount,
update: messages.bulkUpdatingCount,
delete: messages.bulkDeletingCount,
}
return formatMessage(messageMap[props.bulkOperation], {
count,
contentType: formatContentTypeSentence(formatMessage, props.contentTypeLabel, count),
})
}
if (props.contentTypeLabel) {
return formatMessage(messages.selectedCount, {
count,
@@ -125,6 +160,7 @@ const selectedCountText = computed(() => {
})
const bulkProgressMessage = computed(() => {
if (props.bulkStatusMessage) return props.bulkStatusMessage
if (!props.bulkOperation) return ''
const messageMap = {
enable: props.bulkWaiting ? messages.bulkEnablingWaiting : messages.bulkEnabling,
@@ -256,7 +256,7 @@ import {
UploadIcon,
XIcon,
} from '@modrinth/assets'
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import AutoLink from '#ui/components/base/AutoLink.vue'
import Avatar from '#ui/components/base/Avatar.vue'
@@ -481,6 +481,15 @@ function resetState() {
selectedGameVersion.value = preferred ?? defaultVersion
}
watch(
() => props.loading,
(loading, wasLoading) => {
if (wasLoading && !loading) {
tab.value = props.defaultTab ?? 'existing'
}
},
)
function handleHide() {
emit('cancel')
}
@@ -31,7 +31,7 @@
formatMessage(messages.loadingVersions)
}}</span>
</div>
<template v-else>
<div v-else class="min-h-full">
<div class="flex flex-col gap-1.5" role="listbox">
<button
v-for="version in filteredVersions"
@@ -87,7 +87,7 @@
>
{{ formatMessage(messages.noVersionsFound) }}
</div>
</template>
</div>
</div>
<div
@@ -120,8 +120,8 @@
<div class="w-px bg-divider" />
<div class="flex-1 flex flex-col min-w-0 relative bg-surface-1" aria-live="polite">
<template v-if="selectedVersion">
<div class="flex-1 flex flex-col min-w-0 min-h-0 relative bg-surface-1" aria-live="polite">
<div v-if="selectedVersion" class="flex-1 flex flex-col min-w-0 min-h-0 relative">
<div class="bg-bg p-4">
<div class="flex flex-col gap-1.5">
<div class="flex items-center justify-between">
@@ -157,7 +157,7 @@
<div class="h-px bg-divider" />
<div class="flex-1 bg-bg p-4 overflow-y-auto">
<div class="flex-1 min-h-0 bg-bg p-4 overflow-y-auto">
<div
v-if="loadingChangelog"
class="flex flex-col items-center justify-center h-full gap-2"
@@ -180,7 +180,14 @@
<div
class="absolute bottom-0 left-0 right-0 h-14 bg-gradient-to-t from-bg to-transparent pointer-events-none"
/>
</template>
</div>
<div
v-else-if="loading || loadingChangelog || props.versions.length > 0"
class="flex-1 flex flex-col items-center justify-center h-full gap-2 text-secondary bg-bg"
>
<SpinnerIcon class="h-6 w-6 animate-spin" />
<span class="text-sm">{{ formatMessage(messages.loadingChangelog) }}</span>
</div>
<div v-else class="flex-1 flex items-center justify-center text-secondary bg-bg">
{{ formatMessage(messages.selectVersionPrompt) }}
</div>
@@ -284,7 +291,7 @@ import {
renderHighlightedString,
} from '@modrinth/utils'
import { useTimeoutFn } from '@vueuse/core'
import { computed, ref, watch } from 'vue'
import { computed, ref, toRef } from 'vue'
import Avatar from '#ui/components/base/Avatar.vue'
import ButtonStyled from '#ui/components/base/ButtonStyled.vue'
@@ -301,6 +308,9 @@ import {
versionMatchesCompatibilityTarget,
} from '#ui/utils/version-compatibility'
import { useContentUpdaterFiltering } from './use-content-updater-filtering'
import { useContentUpdaterSelection } from './use-content-updater-selection'
const { formatMessage } = useVIntl()
const debug = useDebugLogger('ContentUpdaterModal')
const tags = injectTags(null)
@@ -473,52 +483,19 @@ const incompatibleUpdateModal = ref<InstanceType<typeof ConfirmModal>>()
const searchQuery = ref('')
const hideIncompatibleState = ref(true)
const switchMode = ref(false)
const selectedVersion = ref<Labrinth.Versions.v2.Version | null>(null)
const pendingIncompatibleUpdate = ref<{
version: Labrinth.Versions.v2.Version
event: MouseEvent
} | null>(null)
const suppressCancelOnHide = ref(false)
// Store the initial version ID to select when versions become available
const pendingInitialVersionId = ref<string | undefined>(undefined)
const pinnedInitialVersionId = ref<string | undefined>(undefined)
watch(
() => props.versions,
(newVersions) => {
// If we have a selected version, check if it was updated with new data (e.g., changelog)
if (selectedVersion.value) {
const updatedVersion = newVersions.find((v) => v.id === selectedVersion.value?.id)
if (updatedVersion && updatedVersion !== selectedVersion.value) {
selectedVersion.value = updatedVersion
}
}
// Handle initial selection when versions first arrive
if (newVersions.length > 0 && !selectedVersion.value && pendingInitialVersionId.value) {
const pendingFound = newVersions.find((v) => v.id === pendingInitialVersionId.value)
debug('versions watcher: initial selection', {
pendingInitialVersionId: pendingInitialVersionId.value,
foundPending: !!pendingFound,
currentVersionId: props.currentVersionId,
currentInList: newVersions.some((v) => v.id === props.currentVersionId),
totalVersions: newVersions.length,
loaderDistribution: [...new Set(newVersions.flatMap((v) => v.loaders))],
gameVersionDistribution: [...new Set(newVersions.flatMap((v) => v.game_versions))].slice(
0,
10,
),
})
const version = pendingFound ?? newVersions[0]
selectedVersion.value = version
if (version) {
emit('versionSelect', version)
}
pendingInitialVersionId.value = undefined
}
},
{ deep: true },
)
const { selectedVersion, pinnedInitialVersionId, selectVersion, resetInitialSelection } =
useContentUpdaterSelection({
versions: toRef(props, 'versions'),
currentVersionId: toRef(props, 'currentVersionId'),
onVersionSelect: (version) => emit('versionSelect', version),
debug,
})
function isVersionCompatible(version: Labrinth.Versions.v2.Version): boolean {
const compatible = versionMatchesCompatibilityTarget(version, {
@@ -551,41 +528,17 @@ const isDowngrade = computed(() => {
)
})
const filteredVersions = computed(() => {
let versions = [...props.versions]
if (searchQuery.value) {
const query = searchQuery.value.toLowerCase()
versions = versions.filter(
(v) =>
v.name.toLowerCase().includes(query) ||
v.version_number.toLowerCase().includes(query) ||
(incompatibilityWarningMode.value &&
[...v.loaders, ...v.game_versions].some((value) => value.toLowerCase().includes(query))),
)
}
const beforeFilterCount = versions.length
if (!incompatibilityWarningMode.value && !isModpack.value && hideIncompatibleState.value) {
versions = versions.filter(
(version) =>
version.id === props.currentVersionId ||
version.id === selectedVersion.value?.id ||
version.id === pinnedInitialVersionId.value ||
isVersionCompatible(version),
)
}
debug('filteredVersions computed', {
totalVersions: props.versions.length,
afterSearchFilter: beforeFilterCount,
afterCompatibilityFilter: versions.length,
hiddenByCompatibility: beforeFilterCount - versions.length,
hideIncompatible: hideIncompatibleState.value,
filteringCompatibility: !isModpack.value && hideIncompatibleState.value,
})
return versions
const filteredVersions = useContentUpdaterFiltering({
versions: toRef(props, 'versions'),
searchQuery,
isModpack,
incompatibilityWarningMode,
hideIncompatibleState,
selectedVersion,
pinnedInitialVersionId,
currentVersionId: toRef(props, 'currentVersionId'),
isVersionCompatible,
debug,
})
function shouldShowBadge(version: Labrinth.Versions.v2.Version): boolean {
@@ -682,9 +635,7 @@ function handleVersionMouseLeave() {
function handleVersionSelect(version: Labrinth.Versions.v2.Version) {
if (prefetchTimeout) prefetchTimeout.stop()
selectedVersion.value = version
// Emit event so parent can fetch full version data with changelog
emit('versionSelect', version)
selectVersion(version)
}
function handleUpdate(event: MouseEvent) {
@@ -772,7 +723,6 @@ function show(initialVersionId?: string, options?: { switchMode?: boolean }) {
searchQuery.value = ''
hideIncompatibleState.value = incompatibilityWarningMode.value ? false : !isModpack.value
pendingIncompatibleUpdate.value = null
pinnedInitialVersionId.value = initialVersionId
switchMode.value = options?.switchMode ?? false
debug('show() called', {
@@ -791,25 +741,9 @@ function show(initialVersionId?: string, options?: { switchMode?: boolean }) {
foundInList: !!currentInList,
allVersionIds: props.versions.map((v) => v.id),
})
if (initialVersionId) {
selectedVersion.value =
props.versions.find((v) => v.id === initialVersionId) ?? props.versions[0]
} else {
selectedVersion.value = props.versions[0]
}
pendingInitialVersionId.value = undefined
if (selectedVersion.value) {
emit('versionSelect', selectedVersion.value)
}
} else {
selectedVersion.value = null
pendingInitialVersionId.value = initialVersionId
debug('show(): no versions yet, deferring selection', {
pendingInitialVersionId: initialVersionId,
})
}
resetInitialSelection(initialVersionId)
modal.value?.show()
}
@@ -0,0 +1,68 @@
import type { Labrinth } from '@modrinth/api-client'
import type { ComputedRef, Ref } from 'vue'
import { computed } from 'vue'
type UseContentUpdaterFilteringOptions = {
versions: Readonly<Ref<Labrinth.Versions.v2.Version[]>>
searchQuery: Ref<string>
isModpack: ComputedRef<boolean>
incompatibilityWarningMode: ComputedRef<boolean>
hideIncompatibleState: Ref<boolean>
selectedVersion: Ref<Labrinth.Versions.v2.Version | null>
pinnedInitialVersionId: Ref<string | undefined>
currentVersionId: Readonly<Ref<string>>
isVersionCompatible: (version: Labrinth.Versions.v2.Version) => boolean
debug: (message: string, data?: Record<string, unknown>) => void
}
export function useContentUpdaterFiltering({
versions: sourceVersions,
searchQuery,
isModpack,
incompatibilityWarningMode,
hideIncompatibleState,
selectedVersion,
pinnedInitialVersionId,
currentVersionId,
isVersionCompatible,
debug,
}: UseContentUpdaterFilteringOptions) {
return computed(() => {
let versions = [...sourceVersions.value]
if (searchQuery.value) {
const query = searchQuery.value.toLowerCase()
versions = versions.filter(
(v) =>
v.name.toLowerCase().includes(query) ||
v.version_number.toLowerCase().includes(query) ||
(incompatibilityWarningMode.value &&
[...v.loaders, ...v.game_versions].some((value) =>
value.toLowerCase().includes(query),
)),
)
}
const beforeFilterCount = versions.length
if (!incompatibilityWarningMode.value && !isModpack.value && hideIncompatibleState.value) {
versions = versions.filter(
(version) =>
version.id === currentVersionId.value ||
version.id === selectedVersion.value?.id ||
version.id === pinnedInitialVersionId.value ||
isVersionCompatible(version),
)
}
debug('filteredVersions computed', {
totalVersions: sourceVersions.value.length,
afterSearchFilter: beforeFilterCount,
afterCompatibilityFilter: versions.length,
hiddenByCompatibility: beforeFilterCount - versions.length,
hideIncompatible: hideIncompatibleState.value,
filteringCompatibility: !isModpack.value && hideIncompatibleState.value,
})
return versions
})
}
@@ -0,0 +1,88 @@
import type { Labrinth } from '@modrinth/api-client'
import type { Ref } from 'vue'
import { ref, watch } from 'vue'
type UseContentUpdaterSelectionOptions = {
versions: Readonly<Ref<Labrinth.Versions.v2.Version[]>>
currentVersionId: Readonly<Ref<string>>
onVersionSelect: (version: Labrinth.Versions.v2.Version) => void
debug: (message: string, data?: Record<string, unknown>) => void
}
export function useContentUpdaterSelection({
versions,
currentVersionId,
onVersionSelect,
debug,
}: UseContentUpdaterSelectionOptions) {
const selectedVersion = ref<Labrinth.Versions.v2.Version | null>(null)
const pendingInitialVersionId = ref<string | undefined>(undefined)
const pinnedInitialVersionId = ref<string | undefined>(undefined)
watch(
versions,
(newVersions) => {
if (selectedVersion.value) {
const updatedVersion = newVersions.find((v) => v.id === selectedVersion.value?.id)
if (updatedVersion && updatedVersion !== selectedVersion.value) {
selectedVersion.value = updatedVersion
}
}
if (newVersions.length > 0 && !selectedVersion.value && pendingInitialVersionId.value) {
const pendingFound = newVersions.find((v) => v.id === pendingInitialVersionId.value)
debug('versions watcher: initial selection', {
pendingInitialVersionId: pendingInitialVersionId.value,
foundPending: !!pendingFound,
currentVersionId: currentVersionId.value,
currentInList: newVersions.some((v) => v.id === currentVersionId.value),
totalVersions: newVersions.length,
loaderDistribution: [...new Set(newVersions.flatMap((v) => v.loaders))],
gameVersionDistribution: [...new Set(newVersions.flatMap((v) => v.game_versions))].slice(
0,
10,
),
})
const version = pendingFound ?? newVersions[0]
selectedVersion.value = version
if (version) {
onVersionSelect(version)
}
pendingInitialVersionId.value = undefined
}
},
{ deep: true },
)
function selectVersion(version: Labrinth.Versions.v2.Version) {
selectedVersion.value = version
onVersionSelect(version)
}
function resetInitialSelection(initialVersionId?: string) {
pinnedInitialVersionId.value = initialVersionId
if (versions.value.length > 0) {
selectedVersion.value = initialVersionId
? (versions.value.find((v) => v.id === initialVersionId) ?? versions.value[0])
: versions.value[0]
pendingInitialVersionId.value = undefined
if (selectedVersion.value) {
onVersionSelect(selectedVersion.value)
}
} else {
selectedVersion.value = null
pendingInitialVersionId.value = initialVersionId
debug('show(): no versions yet, deferring selection', {
pendingInitialVersionId: initialVersionId,
})
}
}
return {
selectedVersion,
pinnedInitialVersionId,
selectVersion,
resetInitialSelection,
}
}
@@ -8,6 +8,7 @@ export { default as ConfirmModpackUpdateModal } from './components/modals/Confir
export { default as ConfirmReinstallModal } from './components/modals/ConfirmReinstallModal.vue'
export { default as ConfirmRepairModal } from './components/modals/ConfirmRepairModal.vue'
export { default as ConfirmUnlinkModal } from './components/modals/ConfirmUnlinkModal.vue'
export { default as ContentUpdaterModal } from './components/modals/content-updater-modal/index.vue'
export { default as ContentDependencyWarningModal } from './components/modals/ContentDependencyWarningModal.vue'
export type {
ContentInstallInstance,
@@ -15,7 +16,6 @@ export type {
ContentInstallProjectOwner,
} from './components/modals/ContentInstallModal.vue'
export { default as ContentInstallModal } from './components/modals/ContentInstallModal.vue'
export { default as ContentUpdaterModal } from './components/modals/ContentUpdaterModal.vue'
export type { ModpackContentModalState } from './components/modals/ModpackContentModal.vue'
export { default as ModpackContentModal } from './components/modals/ModpackContentModal.vue'
export { default as ContentCardLayout } from './layout.vue'
@@ -45,7 +45,7 @@ import {
useContentSelection,
} from './composables'
import { injectContentManager } from './providers/content-manager'
import type { ContentCardTableItem, ContentItem } from './types'
import type { BulkOperationStatus, ContentCardTableItem, ContentItem } from './types'
const { formatMessage } = useVIntl()
const debug = useDebugLogger('ContentPageLayout')
@@ -151,6 +151,7 @@ const messages = defineMessages({
})
const ctx = injectContentManager()
const skipNonEssentialWarnings = computed(() => ctx.skipNonEssentialWarnings?.value ?? false)
function getItemId(item: ContentItem) {
return ctx.getItemId?.(item) ?? item.file_path ?? item.file_name ?? item.id
@@ -247,6 +248,8 @@ if (ctx.isBulkOperating) {
const { isChanging, markChanging, unmarkChanging } = useChangingItems()
const bulkWaiting = ref(false)
const bulkStatusMessage = ref<string | null>(null)
const bulkItemCount = ref(0)
const refreshing = ref(false)
async function handleRefresh() {
@@ -387,7 +390,7 @@ async function promptDeleteItems(items: ContentItem[], event?: MouseEvent) {
}
function showDeletionConfirmation(event?: MouseEvent) {
if (event?.shiftKey && !ctx.isBusy.value) {
if ((event?.shiftKey || skipNonEssentialWarnings.value) && !ctx.isBusy.value) {
confirmDelete()
} else {
confirmDeletionModal.value?.show()
@@ -448,6 +451,8 @@ async function confirmDelete() {
if (ctx.bulkDeleteItems && itemsToDelete.length > 1) {
isBulkOperating.value = true
bulkOperation.value = 'delete'
bulkProgress.value = 0
bulkTotal.value = itemsToDelete.length
bulkWaiting.value = true
try {
await ctx.bulkDeleteItems(itemsToDelete)
@@ -456,6 +461,8 @@ async function confirmDelete() {
clearSelection()
isBulkOperating.value = false
bulkOperation.value = null
bulkProgress.value = 0
bulkTotal.value = 0
bulkWaiting.value = false
}
return
@@ -506,6 +513,8 @@ async function bulkEnable() {
if (ctx.bulkEnableItems) {
isBulkOperating.value = true
bulkOperation.value = 'enable'
bulkProgress.value = 0
bulkTotal.value = items.length
bulkWaiting.value = true
try {
await ctx.bulkEnableItems(items)
@@ -513,6 +522,8 @@ async function bulkEnable() {
clearSelection()
isBulkOperating.value = false
bulkOperation.value = null
bulkProgress.value = 0
bulkTotal.value = 0
bulkWaiting.value = false
}
return
@@ -527,6 +538,8 @@ async function bulkDisable() {
if (ctx.bulkDisableItems) {
isBulkOperating.value = true
bulkOperation.value = 'disable'
bulkProgress.value = 0
bulkTotal.value = items.length
bulkWaiting.value = true
try {
await ctx.bulkDisableItems(items)
@@ -534,6 +547,8 @@ async function bulkDisable() {
clearSelection()
isBulkOperating.value = false
bulkOperation.value = null
bulkProgress.value = 0
bulkTotal.value = 0
bulkWaiting.value = false
}
return
@@ -555,15 +570,19 @@ function handleSwitchVersionById(id: string) {
// Bulk updating
const confirmBulkUpdateModal = ref<InstanceType<typeof ConfirmBulkUpdateModal>>()
const pendingBulkUpdateItems = ref<ContentItem[]>([])
const pendingBulkUpdateAll = ref(false)
const hasBulkUpdateSupport = computed(() => !!(ctx.bulkUpdateItem || ctx.bulkUpdateItems))
const hasBulkUpdateSupport = computed(
() => !!(ctx.bulkUpdateAll || ctx.bulkUpdateItem || ctx.bulkUpdateItems),
)
function promptUpdateAll(event?: MouseEvent) {
if (!hasBulkUpdateSupport.value) return
const items = ctx.items.value.filter((item) => item.has_update)
if (items.length === 0) return
pendingBulkUpdateItems.value = items
if (event?.shiftKey && !ctx.isBusy.value) {
pendingBulkUpdateAll.value = true
if ((event?.shiftKey || skipNonEssentialWarnings.value) && !ctx.isBusy.value) {
confirmBulkUpdate()
} else {
confirmBulkUpdateModal.value?.show()
@@ -575,7 +594,8 @@ function promptUpdateSelected(event?: MouseEvent) {
const items = selectedItems.value.filter((item) => item.has_update)
if (items.length === 0) return
pendingBulkUpdateItems.value = items
if (event?.shiftKey && !ctx.isBusy.value) {
pendingBulkUpdateAll.value = false
if ((event?.shiftKey || skipNonEssentialWarnings.value) && !ctx.isBusy.value) {
confirmBulkUpdate()
} else {
confirmBulkUpdateModal.value?.show()
@@ -587,22 +607,61 @@ async function confirmBulkUpdate() {
const items = pendingBulkUpdateItems.value
if (items.length === 0 || !hasBulkUpdateSupport.value) return
if (ctx.bulkUpdateItems) {
isBulkOperating.value = true
bulkOperation.value = 'update'
bulkWaiting.value = true
try {
await ctx.bulkUpdateItems(items)
} finally {
clearSelection()
isBulkOperating.value = false
bulkOperation.value = null
bulkWaiting.value = false
const setBulkStatus = (status: BulkOperationStatus) => {
bulkStatusMessage.value = status.message ?? null
bulkProgress.value = status.progress ?? bulkProgress.value
bulkTotal.value = status.total ?? bulkTotal.value
bulkWaiting.value = status.waiting ?? false
}
try {
if (pendingBulkUpdateAll.value && ctx.bulkUpdateAll) {
isBulkOperating.value = true
bulkOperation.value = 'update'
bulkProgress.value = 0
bulkTotal.value = items.length
bulkItemCount.value = items.length
bulkStatusMessage.value = null
bulkWaiting.value = true
try {
await ctx.bulkUpdateAll(setBulkStatus)
} finally {
clearSelection()
isBulkOperating.value = false
bulkOperation.value = null
bulkProgress.value = 0
bulkTotal.value = 0
bulkItemCount.value = 0
bulkStatusMessage.value = null
bulkWaiting.value = false
}
} else if (ctx.bulkUpdateItems) {
isBulkOperating.value = true
bulkOperation.value = 'update'
bulkProgress.value = 0
bulkTotal.value = items.length
bulkItemCount.value = items.length
bulkStatusMessage.value = null
bulkWaiting.value = true
try {
await ctx.bulkUpdateItems(items)
} finally {
clearSelection()
isBulkOperating.value = false
bulkOperation.value = null
bulkProgress.value = 0
bulkTotal.value = 0
bulkItemCount.value = 0
bulkStatusMessage.value = null
bulkWaiting.value = false
}
} else if (ctx.bulkUpdateItem) {
await runBulk('update', items, ctx.bulkUpdateItem, { onComplete: clearSelection })
}
} else if (ctx.bulkUpdateItem) {
await runBulk('update', items, ctx.bulkUpdateItem, { onComplete: clearSelection })
} finally {
pendingBulkUpdateItems.value = []
pendingBulkUpdateAll.value = false
}
pendingBulkUpdateItems.value = []
}
const confirmUnlinkModal = ref<InstanceType<typeof ConfirmUnlinkModal>>()
@@ -883,6 +942,8 @@ const confirmUnlinkModal = ref<InstanceType<typeof ConfirmUnlinkModal>>()
:bulk-progress="bulkProgress"
:bulk-total="bulkTotal"
:bulk-waiting="bulkWaiting"
:bulk-status-message="bulkStatusMessage"
:bulk-item-count="bulkItemCount"
:aria-label="formatMessage(commonMessages.selectionActionsLabel)"
:get-item-id="getItemId"
@clear="clearSelection"
@@ -5,6 +5,7 @@ import type { Option as OverflowMenuOption } from '#ui/components/base/OverflowM
import { createContext } from '#ui/providers/create-context'
import type {
BulkOperationStatus,
ContentCardTableItem,
ContentItem,
ContentModpackCardCategory,
@@ -46,6 +47,7 @@ export interface ContentManagerContext {
// Guards
isBusy: Ref<boolean> | ComputedRef<boolean>
busyMessage?: Ref<string | null> | ComputedRef<string | null>
skipNonEssentialWarnings?: Ref<boolean> | ComputedRef<boolean>
disableAddContent?: Ref<boolean> | ComputedRef<boolean>
disableAddContentTooltip?: string
@@ -70,6 +72,7 @@ export interface ContentManagerContext {
// Update support (optional per-platform)
hasUpdateSupport: boolean
updateItem?: (id: string) => void
bulkUpdateAll?: (onProgress?: (status: BulkOperationStatus) => void) => Promise<void>
bulkUpdateItem?: (item: ContentItem) => Promise<void>
bulkUpdateItems?: (items: ContentItem[]) => Promise<void>
@@ -46,6 +46,13 @@ export interface ContentCardTableItem {
export type ContentCardTableSortColumn = 'project' | 'version'
export type ContentCardTableSortDirection = 'asc' | 'desc'
export interface BulkOperationStatus {
message?: string
progress?: number
total?: number
waiting?: boolean
}
/** Content item returned from the app backend API - maps to ContentCardTableItem for display */
export interface ContentItem extends Omit<
ContentCardTableItem,
@@ -222,6 +222,7 @@ import FloatingActionBar from '#ui/components/base/FloatingActionBar.vue'
import { defineMessages, useVIntl } from '#ui/composables/i18n'
import { useStickyObserver } from '#ui/composables/sticky-observer'
import { useVirtualScroll } from '#ui/composables/virtual-scroll'
import { injectFilePicker } from '#ui/providers/file-picker'
import { injectNotificationManager } from '#ui/providers/web-notifications'
import { commonMessages } from '#ui/utils/common-messages'
import { getFileExtension } from '#ui/utils/file-extensions'
@@ -295,6 +296,7 @@ defineProps<{
const { addNotification } = injectNotificationManager()
const ctx = injectFileManager()
const filePicker = injectFilePicker(null)
const editorComponent = shallowRef<Component | null>(null)
import('vue3-ace-editor').then(async (mod) => {
@@ -601,8 +603,24 @@ function handleDropError(error: unknown) {
})
}
function initiateFileUpload() {
async function initiateFileUpload() {
if (isBusy.value) return
if (filePicker?.pickFiles) {
try {
const picked = await filePicker.pickFiles({ multiple: true })
if (picked.length > 0) {
ctx.uploadFiles(picked.map((item) => item.file))
}
} catch (error) {
addNotification({
title: formatMessage(commonMessages.uploadFailedLabel),
text: error instanceof Error ? error.message : undefined,
type: 'error',
})
}
return
}
const input = document.createElement('input')
input.type = 'file'
input.multiple = true
@@ -1,5 +1,5 @@
<template>
<NewModal ref="modal" :header="header" :closable="true" no-padding>
<NewModal ref="modal" :header="header" :closable="true" :disable-close="disableClose" no-padding>
<div class="max-w-[500px]">
<div class="flex flex-col gap-4 p-4">
<Admonition :type="hasUnknownContent ? 'warning' : 'info'" :header="admonitionHeader">
@@ -80,7 +80,7 @@
</div>
<template #actions>
<div class="flex justify-between gap-2">
<div class="flex justify-between gap-2 pt-4">
<div>
<ButtonStyled v-if="showReportButton" color="red" type="transparent">
<button @click="emit('report')">
@@ -132,6 +132,7 @@ const props = defineProps<{
showReportButton?: boolean
showBackupCreator?: boolean
removedLabel?: string
disableClose?: boolean
}>()
const emit = defineEmits<{
@@ -33,7 +33,7 @@ import ConfirmModpackUpdateModal from '../content-tab/components/modals/ConfirmM
import ConfirmReinstallModal from '../content-tab/components/modals/ConfirmReinstallModal.vue'
import ConfirmRepairModal from '../content-tab/components/modals/ConfirmRepairModal.vue'
import ConfirmUnlinkModal from '../content-tab/components/modals/ConfirmUnlinkModal.vue'
import ContentUpdaterModal from '../content-tab/components/modals/ContentUpdaterModal.vue'
import ContentUpdaterModal from '../content-tab/components/modals/content-updater-modal/index.vue'
import ContentDiffModal from './components/ContentDiffModal.vue'
import IncompatibleContentModal from './components/IncompatibleContentModal.vue'
import { useInstallationForm } from './composables'
@@ -43,6 +43,7 @@ import type { LoaderVersionEntry } from './types'
const { formatMessage } = useVIntl()
const ctx = injectInstallationSettings()
const debug = useDebugLogger('InstallationSettingsLayout')
const skipNonEssentialWarnings = computed(() => ctx.skipNonEssentialWarnings?.value ?? false)
const availablePlatforms = computed(() =>
Array.isArray(ctx.availablePlatforms) ? ctx.availablePlatforms : ctx.availablePlatforms.value,
)
@@ -203,6 +204,8 @@ const isLocalFile = computed(() => {
return typeof val === 'boolean' ? val : val.value
})
const isLinkedModpack = computed(() => showModpackVersionActions.value || isLocalFile.value)
function handleModpackUpdateRequest(version: Labrinth.Versions.v2.Version, event?: MouseEvent) {
debug('handleModpackUpdateRequest: start', {
versionId: version.id,
@@ -226,7 +229,7 @@ function handleModpackUpdateRequest(version: Labrinth.Versions.v2.Version, event
isUpdateDowngrade.value ||
versionChangesGameVersion(version, ctx.updaterModalProps.value.currentGameVersion)
if (event?.shiftKey || !shouldShowWarning) {
if (event?.shiftKey || skipNonEssentialWarnings.value || !shouldShowWarning) {
debug('handleModpackUpdateRequest: confirming without warning', {
isUpdateDowngrade: isUpdateDowngrade.value,
shouldShowWarning,
@@ -243,6 +246,25 @@ function handleModpackUpdateRequest(version: Labrinth.Versions.v2.Version, event
modpackUpdateModal.value?.show()
}
function handleSwapModpack() {
debug('handleSwapModpack: start', { snapshot: stateSnapshot() })
if (ctx.isBusy.value) {
debug('handleSwapModpack: ignored busy')
return
}
form.cancelEditing()
ctx.swapModpack?.()
debug('handleSwapModpack: invoked ctx.swapModpack')
}
function handleModpackPrimaryAction() {
if (showModpackVersionActions.value) {
form.handleChangeModpackVersion()
} else {
handleSwapModpack()
}
}
function handleModpackUpdateConfirm() {
debug('handleModpackUpdateConfirm: start', {
pendingVersionId: pendingUpdateVersion.value?.id,
@@ -350,6 +372,10 @@ function handleShowRepairModal() {
snapshot: stateSnapshot(),
refs: modalRefsSnapshot(),
})
if (skipNonEssentialWarnings.value) {
handleRepair()
return
}
repairModal.value?.show()
nextTick(() => {
debug('handleShowRepairModal: after nextTick', {
@@ -365,7 +391,7 @@ function handleShowUnlinkModal(event: MouseEvent) {
snapshot: stateSnapshot(),
refs: modalRefsSnapshot(),
})
if (event.shiftKey) {
if (event.shiftKey || skipNonEssentialWarnings.value) {
handleUnlink()
return
}
@@ -629,12 +655,12 @@ const messages = defineMessages({
</div>
</div>
<div class="flex flex-wrap gap-2">
<ButtonStyled v-if="showModpackVersionActions">
<ButtonStyled v-if="showModpackVersionActions || isLocalFile">
<button
v-tooltip="ctx.isBusy.value ? ctx.busyMessage?.value : undefined"
class="!shadow-none"
:disabled="ctx.isBusy.value"
@click="form.handleChangeModpackVersion()"
@click="handleModpackPrimaryAction"
>
<ArrowLeftRightIcon class="size-5" />
{{ formatMessage(commonMessages.changeVersionButton) }}
@@ -649,7 +675,7 @@ const messages = defineMessages({
{{
formatMessage(messages.linkedInstanceTitle, {
projectType: formatMessage(
showModpackVersionActions ? messages.modpackLabel : messages.serverProjectLabel,
isLinkedModpack ? messages.modpackLabel : messages.serverProjectLabel,
),
})
}}
@@ -665,9 +691,7 @@ const messages = defineMessages({
<UnlinkIcon class="size-5" />
{{
formatMessage(
showModpackVersionActions
? commonMessages.unlinkModpackButton
: messages.unlinkButton,
isLinkedModpack ? commonMessages.unlinkModpackButton : messages.unlinkButton,
)
}}
</button>
@@ -678,7 +702,7 @@ const messages = defineMessages({
formatMessage(messages.unlinkDescription, {
type: formatMessage(ctx.isServer ? messages.serverLabel : messages.instanceLabel),
projectType: formatMessage(
showModpackVersionActions ? messages.modpackLabel : messages.serverLabel,
isLinkedModpack ? messages.modpackLabel : messages.serverLabel,
),
})
}}
@@ -17,6 +17,7 @@ export interface InstallationSettingsContext {
isLinked: ComputedRef<boolean>
isBusy: Ref<boolean> | ComputedRef<boolean>
busyMessage?: Ref<string | null> | ComputedRef<string | null>
skipNonEssentialWarnings?: Ref<boolean> | ComputedRef<boolean>
modpack: Ref<InstallationModpackData | null> | ComputedRef<InstallationModpackData | null>
@@ -36,6 +37,7 @@ export interface InstallationSettingsContext {
save: (platform: string, gameVersion: string, loaderVersionId: string | null) => Promise<void>
repair: () => Promise<void>
reinstallModpack: () => Promise<void>
swapModpack?: () => Promise<void>
unlinkModpack: () => Promise<void>
getCachedModpackVersions: () => Labrinth.Versions.v2.Version[] | null
@@ -26,13 +26,15 @@ import {
} from '#ui/utils/server-content-installing'
import { versionChangesGameVersion } from '#ui/utils/version-compatibility'
import type { BrowseInstallPlan } from '../../../shared/browse-tab/composables/install-logic'
import {
flushStoredServerAddonInstallQueue,
getStoredServerAddonInstallQueue,
getTargetInstallPreferences,
} from '../../../shared/browse-tab/composables/install-logic'
import ConfirmModpackUpdateModal from '../../../shared/content-tab/components/modals/ConfirmModpackUpdateModal.vue'
import ConfirmUnlinkModal from '../../../shared/content-tab/components/modals/ConfirmUnlinkModal.vue'
import ContentUpdaterModal from '../../../shared/content-tab/components/modals/ContentUpdaterModal.vue'
import ContentUpdaterModal from '../../../shared/content-tab/components/modals/content-updater-modal/index.vue'
import ModpackContentModal from '../../../shared/content-tab/components/modals/ModpackContentModal.vue'
import ContentPageLayout from '../../../shared/content-tab/layout.vue'
import type { ContentModpackData } from '../../../shared/content-tab/providers/content-manager'
@@ -359,6 +361,57 @@ function getAddonInstallKeys(addons: Archon.Content.v1.Addon[]) {
return keys
}
function getInstalledProjectIds() {
return new Set(
(contentQuery.data.value?.addons ?? [])
.map((addon) => addon.project_id)
.filter((projectId): projectId is string => !!projectId),
)
}
function toResolvePreferences(
preferences?: BrowseInstallPlan['preferences'],
): Labrinth.Content.v3.ResolutionPreferences {
return {
game_versions: preferences?.gameVersions,
loaders: preferences?.loaders,
}
}
async function resolveStoredServerAddonPlans(plans: BrowseInstallPlan[]) {
const existingProjectIds = getInstalledProjectIds()
const resolvedAddons: Array<{ project_id: string; version_id: string }> = []
for (const plan of plans) {
const target = getTargetInstallPreferences(
{
gameVersion: server.value?.mc_version,
loader: server.value?.loader,
},
plan.contentType,
)
const resolved = await client.labrinth.content_v3.resolve({
project_id: plan.projectId,
version_id: plan.versionId,
content_type: plan.contentType as Labrinth.Content.v3.ContentType,
selected: toResolvePreferences(plan.preferences),
target: toResolvePreferences(target),
existing_project_ids: Array.from(existingProjectIds),
})
for (const item of [resolved.primary, ...resolved.dependencies]) {
if (existingProjectIds.has(item.project_id)) continue
existingProjectIds.add(item.project_id)
resolvedAddons.push({
project_id: item.project_id,
version_id: item.version_id,
})
}
}
return resolvedAddons
}
function addonMatchesPendingInstall(
addon: Archon.Content.v1.Addon,
pendingInstall: PendingServerContentInstall,
@@ -418,15 +471,12 @@ async function flushStoredServerInstalls() {
const result = await flushStoredServerAddonInstallQueue({
serverId,
worldId: wid,
install: (plans) =>
client.archon.content_v1.addAddons(
serverId,
wid,
plans.map((plan) => ({
project_id: plan.projectId,
version_id: plan.versionId,
})),
),
install: async (plans) => {
const addons = await resolveStoredServerAddonPlans(plans)
if (addons.length > 0) {
await client.archon.content_v1.addAddons(serverId, wid, addons)
}
},
})
if (!result.ok) {