From 45306a55f1c513f5a275ec0ad389fdaa8f710aa6 Mon Sep 17 00:00:00 2001 From: tdgao Date: Fri, 3 Jul 2026 13:08:27 -0700 Subject: [PATCH] fix: additional files label --- .../ui/ProjectDownloadModal/index.vue | 65 +++++++++++++------ 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/apps/frontend/src/components/ui/ProjectDownloadModal/index.vue b/apps/frontend/src/components/ui/ProjectDownloadModal/index.vue index 94d239aa8a..76a9479fde 100644 --- a/apps/frontend/src/components/ui/ProjectDownloadModal/index.vue +++ b/apps/frontend/src/components/ui/ProjectDownloadModal/index.vue @@ -37,31 +37,44 @@ @download="onDownload" />
-

+

{{ formatMessage(messages.additionalFilesTitle) }}

@@ -85,18 +98,21 @@ import type { Labrinth } from '@modrinth/api-client' import { DownloadIcon, FileIcon } from '@modrinth/assets' import { Avatar, + ButtonStyled, type CdnDownloadReason, defineMessages, + fileTypeMessages, injectModrinthClient, NewModal, ServersPromo, + TagItem, truncatedTooltip, useDebugLogger, useVIntl, } from '@modrinth/ui' import type { DisplayProjectType } from '@modrinth/utils' import { useQuery } from '@tanstack/vue-query' -import { computed, nextTick, onUnmounted, ref, watch } from 'vue' +import { type ComponentPublicInstance, computed, nextTick, onUnmounted, ref, watch } from 'vue' import { navigateTo } from '#app' import { saveFeatureFlags } from '~/composables/featureFlags.ts' @@ -163,6 +179,7 @@ const debug = useDebugLogger('DownloadModal') const modal = ref(null) const downloadTitleRef = ref(null) +const additionalFileNameRefs = ref>({}) const modalOpen = ref(false) const showProjectId = ref(null) const showOptions = ref(getDefaultShowOptions()) @@ -274,14 +291,20 @@ const messages = defineMessages({ }, }) -const fileTypeLabels: Partial> = { - 'required-resource-pack': 'Resourcepack', - 'optional-resource-pack': 'Resourcepack', - unknown: 'File', +function fileTypeLabel(type?: Labrinth.Versions.v3.FileType | null) { + return formatMessage(fileTypeMessages[type ?? 'unknown'] ?? fileTypeMessages.unknown) } -function fileTypeLabel(type?: Labrinth.Versions.v3.FileType) { - return fileTypeLabels[type ?? 'unknown'] || 'File' +function additionalFileKey(file: Labrinth.Versions.v3.VersionFile) { + return file.hashes?.sha1 ?? file.filename +} + +function setAdditionalFileNameRef( + file: Labrinth.Versions.v3.VersionFile, + element: Element | ComponentPublicInstance | null, +) { + additionalFileNameRefs.value[additionalFileKey(file)] = + element instanceof HTMLElement ? element : null } function getProjectTypeForUrl(