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:
@@ -477,6 +477,7 @@ export namespace Labrinth {
|
||||
downloads: number
|
||||
files: VersionFile[]
|
||||
environment?: Labrinth.Projects.v3.Environment
|
||||
mrpack_loaders?: string[]
|
||||
}
|
||||
|
||||
export interface DraftVersionFile {
|
||||
@@ -514,6 +515,7 @@ export namespace Labrinth {
|
||||
primary_file?: string
|
||||
file_types?: Record<string, Labrinth.Versions.v3.FileType | null>
|
||||
environment?: Labrinth.Projects.v3.Environment
|
||||
mrpack_loaders?: string[]
|
||||
}
|
||||
|
||||
export type ModifyVersionRequest = Partial<
|
||||
|
||||
@@ -139,6 +139,7 @@ export class LabrinthVersionsV3Module extends AbstractModule {
|
||||
public async createVersion(
|
||||
draftVersion: Labrinth.Versions.v3.DraftVersion,
|
||||
versionFiles: Labrinth.Versions.v3.DraftVersionFile[],
|
||||
projectType: Labrinth.Projects.v2.ProjectType | null = null,
|
||||
): Promise<Labrinth.Versions.v3.Version> {
|
||||
const formData = new FormData()
|
||||
|
||||
@@ -164,13 +165,18 @@ export class LabrinthVersionsV3Module extends AbstractModule {
|
||||
changelog: draftVersion.changelog,
|
||||
dependencies: draftVersion.dependencies || [],
|
||||
game_versions: draftVersion.game_versions,
|
||||
loaders: draftVersion.loaders,
|
||||
version_type: draftVersion.version_type,
|
||||
featured: !!draftVersion.featured,
|
||||
file_parts: fileParts,
|
||||
file_types: fileTypeMap,
|
||||
primary_file: fileParts[0],
|
||||
environment: draftVersion.environment,
|
||||
loaders: draftVersion.loaders,
|
||||
}
|
||||
|
||||
if (projectType === 'modpack') {
|
||||
data.mrpack_loaders = draftVersion.loaders
|
||||
data.loaders = ['mrpack']
|
||||
}
|
||||
|
||||
formData.append('data', JSON.stringify(data))
|
||||
@@ -181,7 +187,7 @@ export class LabrinthVersionsV3Module extends AbstractModule {
|
||||
|
||||
const newVersion = await this.client.request<Labrinth.Versions.v3.Version>(`/version`, {
|
||||
api: 'labrinth',
|
||||
version: 2,
|
||||
version: 3,
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
timeout: 120000,
|
||||
@@ -190,10 +196,6 @@ export class LabrinthVersionsV3Module extends AbstractModule {
|
||||
},
|
||||
})
|
||||
|
||||
await this.modifyVersion(newVersion.id, {
|
||||
environment: draftVersion.environment,
|
||||
})
|
||||
|
||||
return newVersion
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,13 @@
|
||||
</template>
|
||||
|
||||
<progress
|
||||
v-if="currentStage?.nonProgressStage !== true"
|
||||
v-if="nonProgressStage !== true"
|
||||
:value="progressValue"
|
||||
max="100"
|
||||
class="w-full h-1 appearance-none border-none absolute top-0 left-0"
|
||||
></progress>
|
||||
|
||||
<div class="sm:w-[512px]">
|
||||
<component :is="currentStage?.stageContent" />
|
||||
</div>
|
||||
<component :is="currentStage?.stageContent" />
|
||||
|
||||
<template #actions>
|
||||
<div
|
||||
@@ -81,7 +79,7 @@ export interface StageConfigInput<T> {
|
||||
stageContent: Component
|
||||
title: MaybeCtxFn<T, string>
|
||||
skip?: MaybeCtxFn<T, boolean>
|
||||
nonProgressStage?: boolean
|
||||
nonProgressStage?: MaybeCtxFn<T, boolean>
|
||||
leftButtonConfig: MaybeCtxFn<T, StageButtonConfig | null>
|
||||
rightButtonConfig: MaybeCtxFn<T, StageButtonConfig | null>
|
||||
}
|
||||
@@ -174,9 +172,15 @@ const rightButtonConfig = computed(() => {
|
||||
return resolveCtxFn(stage.rightButtonConfig, props.context)
|
||||
})
|
||||
|
||||
const nonProgressStage = computed(() => {
|
||||
const stage = currentStage.value
|
||||
if (!stage) return false
|
||||
return resolveCtxFn(stage.nonProgressStage, props.context)
|
||||
})
|
||||
|
||||
const progressValue = computed(() => {
|
||||
const isProgressStage = (stage: StageConfigInput<T>) => {
|
||||
if (stage.nonProgressStage) return false
|
||||
if (resolveCtxFn(stage.nonProgressStage, props.context)) return false
|
||||
const skip = stage.skip ? resolveCtxFn(stage.skip, props.context) : false
|
||||
return !skip
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
@update:query="updateQuery"
|
||||
/>
|
||||
|
||||
<ButtonStyled v-if="openModal" color="green">
|
||||
<ButtonStyled v-if="openModal" :color="createVersionButtonSecondary ? 'standard' : 'green'">
|
||||
<button @click="openModal"><PlusIcon /> Create version</button>
|
||||
</ButtonStyled>
|
||||
|
||||
@@ -238,6 +238,7 @@ const props = withDefaults(
|
||||
gameVersions: GameVersionTag[]
|
||||
versionLink?: (version: Version) => string
|
||||
openModal?: () => void
|
||||
createVersionButtonSecondary?: boolean
|
||||
}>(),
|
||||
{
|
||||
baseId: undefined,
|
||||
|
||||
Reference in New Issue
Block a user