Skip to content

Commit e272e6a

Browse files
committed
Remove prerelease option, add version types
Realized that SBLT uses beta and that it would be quite bad if the files would be hidden Version types allow you to use non semver versions and mark your versions as beta/alpha. That being said, it won't sort it and you'll have to depend on upload date.
1 parent 83cadac commit e272e6a

11 files changed

Lines changed: 132 additions & 30 deletions

File tree

backend/app/Http/Controllers/FileController.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public function index(FilteredRequest $request, Mod $mod)
4141
{
4242
$val = $request->val([
4343
'version' => 'string|nullable',
44-
'prerelease' => 'boolean|nullable',
4544
'include_incomplete' => 'boolean|nullable',
4645
]);
4746

@@ -57,11 +56,6 @@ public function index(FilteredRequest $request, Mod $mod)
5756
}
5857
}
5958

60-
$preRelease = Arr::pull($val, 'prerelease', true);
61-
if (!$preRelease) {
62-
$query->whereRaw("(get_semver_prerelease (semver_version) = '') IS NOT FALSE");
63-
}
64-
6559
$includeIncomplete = Arr::pull($val, 'include_incomplete', false);
6660
if (!$includeIncomplete) {
6761
$query->where("completed", true);
@@ -231,6 +225,7 @@ public function store(FileRequest $request, Mod $mod)
231225
// This is not the actual name of the file stored in our storage
232226
'name' => isset($uploadedFile) ? explode('.', $uploadedFile->getClientOriginalName())[0] : explode('.', $val['name'])[0],
233227
'desc' => $val['desc'],
228+
'version_type' => $val['version_type'] ?? 'release',
234229
'user_id' => $this->userId(),
235230
'file' => $name ?? '', // This is though
236231
'type' => $type ?? '',
@@ -314,6 +309,8 @@ public function update(FileRequest $request, File $file)
314309
$file->mod->bump();
315310
}
316311

312+
$val['image_id'] = $imageId;
313+
317314
if (array_key_exists('display_order', $val)) {
318315
$val['display_order'] ??= 0;
319316
}

backend/app/Http/Requests/FileRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function rules(): array
2727
'name' => 'string|min_strict:1|max:100',
2828
'label' => 'string|nullable|max:100',
2929
'desc' => 'string|nullable|max:1000',
30+
'version_type' => 'string|in:release,beta,alpha|nullable',
3031
'version' => 'string|nullable|max:255',
3132
'display_order' => 'integer|min:-1000|max:1000|nullable',
3233
'image_id' => 'int|nullable|exists:images,id'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('files', function (Blueprint $table) {
15+
$table->enum('version_type', ['release', 'beta', 'alpha'])->default('release');
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('files', function (Blueprint $table) {
25+
$table->dropColumn('version_type');
26+
});
27+
}
28+
};

frontend/app/components/site/pages/edit-mod/edit-mod-file-uploader.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<m-table alt-background>
1414
<template #head>
15+
<th/>
1516
<th/>
1617
<th>{{ $t('version') }}</th>
1718
<th>{{ $t('name') }}</th>
@@ -51,8 +52,9 @@
5152
:storage="storageLeft + currentFile.size"
5253
type="file"
5354
/>
55+
<m-input v-model="currentFile.name" required :label="$t('name')"/>
5456
<m-flex>
55-
<m-input v-model="currentFile.name" required :label="$t('name')"/>
57+
<m-select v-model="currentFile.version_type" :label="$t('version_type')" :options="versionTypes" :text-by="t => $t('version_' + t)"/>
5658
<m-input v-model="currentFile.version" :label="$t('version')"/>
5759
</m-flex>
5860
<md-editor v-model="currentFile.desc" rows="8" :label="$t('description')"/>
@@ -123,6 +125,8 @@ const changeFile = ref<File>();
123125
const canSubmitFile = ref(false);
124126
const forcedOut = ref(false);
125127
128+
const versionTypes = ['release', 'beta', 'alpha'];
129+
126130
const page = ref(1);
127131
128132
onBeforeRouteLeave(async (to, from) => {
@@ -407,6 +411,7 @@ function createNewFile() {
407411
id: 0,
408412
user_id: user!.id,
409413
mod_id: mod.value.id,
414+
version_type: 'release',
410415
size: 0,
411416
name: '',
412417
desc: '',

frontend/app/components/site/pages/edit-mod/edit-mod-files.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</m-flex>
2121
<m-table alt-background>
2222
<template #head>
23+
<th/>
2324
<th/>
2425
<th>{{ $t('version') }}</th>
2526
<th>{{ $t('name') }}</th>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<template>
2+
<div :class="['version-type', `version-type-${file.version_type}`]" :title="$t(`version_${file.version_type}`)">
3+
{{ versionTypeLetter }}
4+
</div>
5+
</template>
6+
7+
<script setup lang="ts">
8+
import type { File } from '~/types/models';
9+
10+
const { file } = defineProps<{
11+
file: File;
12+
}>();
13+
const versionTypeLetter = computed(() => file.version_type.substring(0, 1).toUpperCase());
14+
</script>
15+
16+
<style scoped>
17+
.version-type {
18+
margin-right: auto;
19+
margin-left: auto;
20+
border-radius: var(--content-border-radius);
21+
display: flex;
22+
align-items: center;
23+
justify-content: center;
24+
width: 32px;
25+
height: 32px;
26+
}
27+
28+
.version-type-release {
29+
color: var(--success-color);
30+
background-color: var(--success-bg-color);
31+
}
32+
33+
.version-type-beta {
34+
color: var(--warning-color);
35+
background-color: var(--warning-bg-color);
36+
37+
}
38+
39+
.version-type-alpha {
40+
color: #d48c8c;
41+
background-color: #5d3232;
42+
}
43+
</style>

frontend/app/components/site/pages/mod/mod-download.vue

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<template>
22
<template v-if="table">
33
<tr class="hover:cursor-pointer download-tr" @click="showDetails = !showDetails">
4-
<td :class="{ 'collapse-col': !image }">
4+
<td class="collapse-col">
55
<m-img v-if="image" url-prefix="mods/images" :src="image.file" loading="lazy" width="48" height="48"/>
6+
<mod-file-version-type v-else-if="file.version_type" :file="file"/>
67
</td>
78
<td>
89
<div class="text-ellipsis overflow-hidden" style="max-width: 120px;" :title="file.version">
@@ -38,7 +39,16 @@
3839
<tr :class="{hidden: !showDetails, 'download-tr': showDetails}">
3940
<td colspan="10">
4041
<m-flex class="p-3" column gap="2">
41-
<md-content v-if="file.desc" :text="file.desc" :padding="1" style="max-height: 250px; overflow-y: auto;"/>
42+
<span>
43+
{{ $t(type + '_id') }}: {{ file.id }}
44+
</span>
45+
<span>
46+
{{ $t('version_type') }}: {{ $t(`version_${file.version_type}`) }}
47+
</span>
48+
<template v-if="file.desc">
49+
{{ $t('description') }}:
50+
<md-content :text="file.desc" :padding="1" style="max-height: 250px; overflow-y: auto;"/>
51+
</template>
4252
<m-flex class="items-center" wrap>
4353
<i18n-t keypath="updated_by_user_time_ago" scope="global">
4454
<template #time>
@@ -49,15 +59,15 @@
4959
</template>
5060
</i18n-t>
5161
</m-flex>
52-
{{ $t(type + '_id') }}: {{ file.id }}
5362
</m-flex>
5463
</td>
5564
</tr>
5665
</template>
5766
<m-flex v-else class="list-button" column>
5867
<m-flex class="flex-1 items-center hover:cursor-pointer" gap="3" @click="showDetails = !showDetails">
59-
<m-img v-if="image" url-prefix="mods/images" class="mb-auto" :src="image.file" loading="lazy" width="48" height="48"/>
60-
<m-img v-else src="file-download.webp" class="mb-auto" is-asset width="48" height="48"/>
68+
<m-img v-if="image" url-prefix="mods/images" class="mb-auto" :src="image.file" loading="lazy" width="32" height="32"/>
69+
<mod-file-version-type v-else-if="file.version_type" class="mb-auto" :file="file"/>
70+
6171
<m-flex grow column style="flex: 1;" gap="2">
6272
<m-flex class="items-center whitespace-pre-line">
6373
<strong v-if="file.name" class="items-center" style="word-break: break-word;">{{ file.name }}</strong>
@@ -79,7 +89,16 @@
7989
</m-flex>
8090
</m-flex>
8191
<m-flex :class="{ hidden: !showDetails, 'p-3': true }" column gap="2">
82-
<md-content v-if="file.desc" :text="file.desc" :padding="1" style="max-height: 250px; overflow-y: auto;"/>
92+
<span>
93+
{{ $t(type + '_id') }}: {{ file.id }}
94+
</span>
95+
<span>
96+
{{ $t('version_type') }}: {{ $t(`version_${file.version_type}`) }}
97+
</span>
98+
<template v-if="file.desc">
99+
{{ $t('description') }}:
100+
<md-content :text="file.desc" :padding="1" style="max-height: 250px; overflow-y: auto;"/>
101+
</template>
83102
<m-flex class="items-center" wrap>
84103
<i18n-t keypath="updated_by_user_time_ago" scope="global">
85104
<template #time>
@@ -90,15 +109,14 @@
90109
</template>
91110
</i18n-t>
92111
</m-flex>
93-
{{ $t(type + '_id') }}: {{ file.id }}
94112
</m-flex>
95113
</m-flex>
96114
</template>
97115

98116
<script setup lang="ts">
99117
import type { File, Link, Mod } from '~/types/models';
100118
101-
const props = defineProps<{
119+
const { file, mod } = defineProps<{
102120
file: File & Link;
103121
type: 'file' | 'link';
104122
table?: boolean;
@@ -108,7 +126,8 @@ const props = defineProps<{
108126
const i18n = useI18n();
109127
const showDetails = ref(false);
110128
const locale = computed(() => i18n.locale.value);
111-
const image = computed(() => props.mod.images?.find(image => image.id === props.file.image_id));
129+
const image = computed(() => mod.images?.find(image => image.id === file.image_id));
130+
112131
</script>
113132

114133
<style>

frontend/app/components/site/pages/mod/mod-downloads-tab.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
</m-flex>
1212
</m-flex>
1313
<m-list v-if="files?.meta.total" v-model:page="filesPage" :limit="20" :title="$t('files')" :items="files" :loading="loadingFiles">
14-
<template #buttons>
15-
<m-input v-model="prerelease" :label="$t('include_prerelease')" type="checkbox" class="ml-auto" style="flex: revert;"/>
16-
</template>
1714
<template #items="{ items }">
1815
<m-table alt-background class="downloads-table">
1916
<template #head>

frontend/app/components/site/pages/mod/mod-edit-download.vue

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
<template>
22
<tr>
33
<td>
4-
<input
5-
:checked="(download.id === mod.download_id && mod.download_type == 'file') ? true : undefined"
6-
type="radio"
7-
:disabled="!download.size"
8-
@change="$emit('setPrimaryDownload', type, download)"
9-
>
4+
<m-flex>
5+
<input
6+
:checked="(download.id === mod.download_id && mod.download_type == 'file') ? true : undefined"
7+
type="radio"
8+
:disabled="!download.size"
9+
@change="$emit('setPrimaryDownload', type, download)"
10+
>
11+
</m-flex>
12+
</td>
13+
<td class="collapse-col">
1014
<m-img v-if="image" url-prefix="mods/images" :src="image.file" loading="lazy" width="48" height="48"/>
15+
<mod-file-version-type v-else-if="download.version_type" :file="download"/>
1116
</td>
1217
<td>
13-
<div class="text-ellipsis overflow-hidden" style="max-width: 120px;" :title="download.version">
14-
{{ download.version || 'N/A' }}
15-
</div>
18+
<m-flex class="items-center" gap="3">
19+
<div class="text-ellipsis overflow-hidden" style="max-width: 120px;" :title="download.version">
20+
{{ download.version || 'N/A' }}
21+
</div>
22+
</m-flex>
1623
</td>
1724
<td class="whitespace-pre-line wrap-anywhere" >
1825
<m-flex class="items-center" style="min-width: 80px; max-width: 200px;" wrap>

frontend/app/i18n/locales/en.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"changelog": "Changelog",
2020
"description": "Description",
2121
"version": "Version",
22-
"include_prerelease": "Include Prerelease",
2322
"tags": "Tags",
2423
"filter_out_tags": "Filter Out Tags",
2524
"mods": "Mods",
@@ -727,5 +726,9 @@
727726
"files_are_versions": "Files are Versions",
728727
"files_are_versions_desc": "Turning this on treats your files as versions rather than unrelated files. The primary download (if not set manually) is chosen as the top-most file.",
729728
"custom_version_help": "Sets the version of the mod. If the Files are Versions option is turned on, the mod will try to take the version of the primary file first.",
730-
"file_missing": "Missing File"
729+
"file_missing": "Missing File",
730+
"version_type": "Version Type",
731+
"version_release": "Release",
732+
"version_beta": "Beta",
733+
"version_alpha": "Alpha"
731734
}

0 commit comments

Comments
 (0)