1
0

Handle project type on per version basis for multi-type projects (#4945)

* infer project type by draft version loader

* fix detecting modpack project type when editing

* fix no loaders check

* pnpm run fix
This commit is contained in:
Truman Gao
2025-12-21 13:13:41 -08:00
committed by GitHub
parent cace1a54cd
commit 53ec2c5306
4 changed files with 114 additions and 91 deletions

View File

@@ -22,7 +22,7 @@ const modal = useTemplateRef<ComponentExposed<typeof MultiStageModal>>('modal')
const ctx = createManageVersionContext(modal)
provideManageVersionContext(ctx)
const { newDraftVersion, setProjectType } = ctx
const { newDraftVersion } = ctx
const { projectV2 } = injectProjectPageContext()
const { addNotification } = injectNotificationManager()
@@ -62,7 +62,6 @@ function openCreateVersionModal(
stageId: string | null = null,
) {
newDraftVersion(projectV2.value.id, version)
setProjectType(projectV2.value)
modal.value?.setStage(stageId ?? 0)
modal.value?.show()
}

View File

@@ -103,9 +103,7 @@ const {
existingFilesToDelete,
setPrimaryFile,
setInferredVersionData,
setProjectType,
editingVersion,
projectType,
} = injectManageVersionContext()
const addDetectedData = async () => {
@@ -125,17 +123,9 @@ const addDetectedData = async () => {
...draftVersion.value,
...mappedInferredData,
}
setProjectType(projectV2.value, primaryFile)
} catch (err) {
console.error('Error parsing version file data', err)
}
if (projectType.value === 'resourcepack') {
draftVersion.value.loaders = ['minecraft']
} else if (projectType.value === 'modpack' && draftVersion.value.loaders?.length === 0) {
draftVersion.value.loaders = ['minecraft']
}
}
// add detected data when the primary file changes

View File

@@ -42,7 +42,7 @@
<script lang="ts" setup>
import { XIcon } from '@modrinth/assets'
import { ButtonStyled, injectProjectPageContext, TagItem } from '@modrinth/ui'
import { ButtonStyled, TagItem } from '@modrinth/ui'
import { formatCategory } from '@modrinth/utils'
import { injectManageVersionContext } from '~/providers/version/manage-version-modal'
@@ -51,10 +51,9 @@ import LoaderPicker from '../components/LoaderPicker.vue'
const generatedState = useGeneratedState()
const { projectV2 } = injectProjectPageContext()
const loaders = computed(() => generatedState.value.loaders)
const { draftVersion, setProjectType } = injectManageVersionContext()
const { draftVersion } = injectManageVersionContext()
const toggleLoader = (loader: string) => {
if (draftVersion.value.loaders.includes(loader)) {
@@ -62,11 +61,9 @@ const toggleLoader = (loader: string) => {
} else {
draftVersion.value.loaders = [...draftVersion.value.loaders, loader]
}
setProjectType(projectV2.value)
}
const onClearAll = () => {
draftVersion.value.loaders = []
setProjectType(projectV2.value)
}
</script>