feat: add admontion for dependency that has resource pack to download

This commit is contained in:
tdgao
2026-07-08 14:29:32 -07:00
parent 20e0805682
commit 52ad36b8e6
2 changed files with 35 additions and 3 deletions
@@ -13,7 +13,18 @@
</h3>
</div>
<Admonition v-if="requiredResourcePackAdmonitionVisible" type="info">
{{ formatMessage(messages.requiredResourcePackAdmonition) }}
<IntlFormatted :message-id="messages.requiredResourcePackAdmonition">
<template #folder>
<code class="text-sm">resourcepacks</code class="text-sm">
</template>
</IntlFormatted>
</Admonition>
<Admonition v-if="dependencyResourcePackAdmonitionVisible" type="info">
<IntlFormatted :message-id="messages.dependencyResourcePackAdmonition">
<template #folder>
<code class="text-sm">resourcepacks</code class="text-sm">
</template>
</IntlFormatted>
</Admonition>
<div class="rounded-2xl bg-surface-2 p-2 pl-4 pr-3">
<DownloadDependency
@@ -43,7 +54,7 @@
<script setup lang="ts">
import { InfoIcon } from '@modrinth/assets'
import { Admonition, defineMessages, useVIntl } from '@modrinth/ui'
import { Admonition, defineMessages, IntlFormatted, useVIntl } from '@modrinth/ui'
import { injectDownloadModalProvider } from './download-modal-provider'
import DownloadDependency from './DownloadDependency.vue'
@@ -66,6 +77,7 @@ const emit = defineEmits<{
}>()
const { formatMessage } = useVIntl()
const {
dependencyResourcePackAdmonitionVisible,
duplicateDependencyRowsHidden,
downloadRows,
recommendedRows,
@@ -88,7 +100,12 @@ const messages = defineMessages({
requiredResourcePackAdmonition: {
id: 'project.download.required-resource-pack-admonition',
defaultMessage:
'This data pack also requires a resource pack. Download it and place it in your resourcepacks folder.',
'This data pack also requires a resource pack. Download it and place it in your {folder} folder.',
},
dependencyResourcePackAdmonition: {
id: 'project.download.dependency-resource-pack-admonition',
defaultMessage:
'This project has a dependency with a required resource pack. Download it and place it in your {folder} folder.',
},
})
</script>
@@ -67,6 +67,7 @@ export interface DownloadModalProvider {
recommendedRows: ComputedRef<DownloadDependencyRow[]>
downloadRowsLoaded: ComputedRef<boolean>
requiredResourcePackAdmonitionVisible: ComputedRef<boolean>
dependencyResourcePackAdmonitionVisible: ComputedRef<boolean>
downloadableDependencyFiles: ComputedRef<DownloadableDependencyFile[]>
downloadableDependencyFilesLoaded: ComputedRef<boolean>
preloadDependenciesForSelection: (selection: ProjectDownloadSelection) => Promise<void>
@@ -295,6 +296,10 @@ export function provideDownloadModalProvider(
return selectedDownloadRowsLoaded.value && visibleRequiredResourcePackFiles.value.length > 0
})
const dependencyResourcePackAdmonitionVisible = computed(() => {
return selectedDownloadRowsLoaded.value && hasAdditionalFileRows(visibleDependencyRows.value)
})
const downloadableDependencyFiles = computed<DownloadableDependencyFile[]>(() =>
collectDownloadableDependencyFiles(visibleDependencyRows.value),
)
@@ -481,6 +486,7 @@ export function provideDownloadModalProvider(
recommendedRows,
downloadRowsLoaded,
requiredResourcePackAdmonitionVisible,
dependencyResourcePackAdmonitionVisible,
downloadableDependencyFiles,
downloadableDependencyFilesLoaded,
preloadDependenciesForSelection,
@@ -634,6 +640,15 @@ function hasDuplicateDependencyRows(
return false
}
function hasAdditionalFileRows(rows: DownloadDependencyRow[]): boolean {
for (const row of rows) {
if (row.isAdditionalFile) return true
if (hasAdditionalFileRows(row.dependencies)) return true
}
return false
}
function collectDownloadableDependencyFiles(
rows: DownloadDependencyRow[],
seenHrefs = new Set<string>(),