You've already forked AstralRinth
forked from didirus/AstralRinth
Improve editing project versions (#4933)
* add edit versions dropdown menu * implement improved edit version with individual edit stages * make changelog bigger * update button styles * remove hover button when hover on row * bring editing versions back to project settings * bring back gallery edit and upload in project page * fix progress value * fix admonition import * fix v3 upload for modpacks * fix modpack loader display for editing version and better open edit/create modal handling * fix currentMember prop * fix modpack loader displaying incorrectly * fix max length * fix version url after making an edit to version and fix delete * small max height fix * hide edit dependencies for modpack * pnpm run fix * fix import * add tooltip * update icons * update copy and create version button style
This commit is contained in:
@@ -4,7 +4,12 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { Labrinth } from '@modrinth/api-client'
|
||||
import { injectProjectPageContext, MultiStageModal } from '@modrinth/ui'
|
||||
import {
|
||||
injectModrinthClient,
|
||||
injectNotificationManager,
|
||||
injectProjectPageContext,
|
||||
MultiStageModal,
|
||||
} from '@modrinth/ui'
|
||||
import type { ComponentExposed } from 'vue-component-type-helpers'
|
||||
|
||||
import {
|
||||
@@ -20,15 +25,53 @@ provideManageVersionContext(ctx)
|
||||
const { newDraftVersion, setProjectType } = ctx
|
||||
|
||||
const { projectV2 } = injectProjectPageContext()
|
||||
const { addNotification } = injectNotificationManager()
|
||||
const { labrinth } = injectModrinthClient()
|
||||
|
||||
function showCreateVersionModal(version: Labrinth.Versions.v3.DraftVersion | null = null) {
|
||||
async function openEditVersionModal(versionId: string, projectId: string, stageId?: string | null) {
|
||||
try {
|
||||
const versionData = await labrinth.versions_v3.getVersion(versionId)
|
||||
|
||||
const draftVersionData: Labrinth.Versions.v3.DraftVersion = {
|
||||
project_id: projectId,
|
||||
version_id: versionId,
|
||||
name: versionData.name ?? '',
|
||||
version_number: versionData.version_number ?? '',
|
||||
changelog: versionData.changelog ?? '',
|
||||
game_versions: versionData.game_versions ?? [],
|
||||
version_type: versionData.version_type ?? 'release',
|
||||
loaders: versionData.loaders ?? [],
|
||||
dependencies: versionData.dependencies ?? [],
|
||||
existing_files: versionData.files ?? [],
|
||||
environment: versionData.environment,
|
||||
}
|
||||
|
||||
if (projectV2.value.project_type === 'modpack' && draftVersionData.loaders.includes('mrpack')) {
|
||||
draftVersionData.loaders.push(...(versionData.mrpack_loaders ?? []))
|
||||
}
|
||||
|
||||
openCreateVersionModal(draftVersionData, stageId)
|
||||
} catch (err: any) {
|
||||
addNotification({
|
||||
title: 'An error occurred',
|
||||
text: err.data ? err.data.description : err,
|
||||
type: 'error',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function openCreateVersionModal(
|
||||
version: Labrinth.Versions.v3.DraftVersion | null = null,
|
||||
stageId: string | null = null,
|
||||
) {
|
||||
newDraftVersion(projectV2.value.id, version)
|
||||
setProjectType(projectV2.value)
|
||||
modal.value?.setStage(0)
|
||||
modal.value?.setStage(stageId ?? 0)
|
||||
modal.value?.show()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show: showCreateVersionModal,
|
||||
openEditVersionModal,
|
||||
openCreateVersionModal,
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user