Skip to content

Commit 0ac15a3

Browse files
committed
Remove old prop and fix error with card actions on pages with instance context
1 parent 60abdf4 commit 0ac15a3

File tree

3 files changed

+38
-27
lines changed

3 files changed

+38
-27
lines changed

apps/app-frontend/src/components/ui/ProjectCardActions.vue

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,10 @@ const installing = ref(false)
3232
3333
const installed: Ref<boolean> = ref(false)
3434
35-
checkInstallStatus()
36-
3735
function checkInstallStatus() {
3836
if (props.instanceContent) {
39-
installed.value = Object.values(props.instanceContent).some((content) => {
40-
if (content.metadata?.project_id === projectId.value) {
41-
return true
42-
}
43-
})
37+
installed.value = Object.values(props.instanceContent)
38+
.some((content) => content.metadata?.project_id === projectId.value)
4439
}
4540
}
4641
@@ -64,7 +59,9 @@ async function install(toInstance: boolean) {
6459
6560
const modpack = computed(() => props.project.project_type === 'modpack')
6661
67-
const projectWebUrl = computed(() => `https://modrinth.com/${props.project.project_type}/${props.project.slug}`)
62+
const projectWebUrl = computed(
63+
() => `https://modrinth.com/${props.project.project_type}/${props.project.slug}`,
64+
)
6865
6966
const tooltip = defineMessages({
7067
installing: {
@@ -88,23 +85,41 @@ const messages = defineMessages({
8885
},
8986
})
9087
91-
const projectId = computed(() => isSearchResult(props.project) ? props.project.project_id : props.project.id)
88+
const projectId = computed(() =>
89+
isSearchResult(props.project) ? props.project.project_id : props.project.id,
90+
)
9291
9392
const copyText = (text: string) => {
94-
navigator.clipboard.writeText(text);
93+
navigator.clipboard.writeText(text)
9594
}
95+
96+
checkInstallStatus()
9697
</script>
9798

9899
<template>
99100
<ButtonStyled color="brand">
100-
<button v-tooltip="installing ? formatMessage(tooltip.installing) : installed ? formatMessage(tooltip.installed) : null" :disabled="installing || installed" @click="() => install(true)">
101+
<button
102+
v-tooltip="
103+
installing
104+
? formatMessage(tooltip.installing)
105+
: installed
106+
? formatMessage(tooltip.installed)
107+
: null
108+
"
109+
:disabled="installing || installed"
110+
@click="() => install(true)"
111+
>
101112
<SpinnerIcon v-if="installing" />
102113
<CheckIcon v-else-if="installed" />
103114
<DownloadIcon v-else />
104-
{{ formatMessage(
105-
installing ? commonMessages.installingButton :
106-
installed ? commonMessages.installedButton :
107-
commonMessages.installButton)
115+
{{
116+
formatMessage(
117+
installing
118+
? commonMessages.installingButton
119+
: installed
120+
? commonMessages.installedButton
121+
: commonMessages.installButton,
122+
)
108123
}}
109124
</button>
110125
</ButtonStyled>
@@ -164,12 +179,8 @@ const copyText = (text: string) => {
164179
<template #install-elsewhere>
165180
<DownloadIcon /> {{ formatMessage(commonMessages.installToButton) }}
166181
</template>
167-
<template #versions>
168-
<VersionIcon /> {{ formatMessage(messages.viewVersions) }}
169-
</template>
170-
<template #gallery>
171-
<ImageIcon /> {{ formatMessage(messages.viewGallery) }}
172-
</template>
182+
<template #versions> <VersionIcon /> {{ formatMessage(messages.viewVersions) }} </template>
183+
<template #gallery> <ImageIcon /> {{ formatMessage(messages.viewGallery) }} </template>
173184
<template #open-link>
174185
<ExternalIcon /> {{ formatMessage(commonMessages.openInBrowserButton) }}
175186
</template>

apps/frontend/src/pages/search/[searchProjectType].vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@
282282
:categories="result.display_categories"
283283
:link="`/${projectType.id}/${result.slug ? result.slug : result.project_id}`"
284284
:creator-link="`/user/${result.author}`"
285-
:platform-tags="tags.loaders"
286285
>
287286
<template v-if="false" #actions> </template>
288287
</NewProjectCard>

packages/ui/src/components/project/ProjectsList.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
<NewProjectCard
4545
:project="project"
4646
:link="projectLink(project)"
47-
:platform-tags="platformTags"
4847
:experimental-colors="experimentalColors"
4948
:date-type="sortBy.id === 'published' ? 'published' : 'updated'"
5049
>
@@ -75,7 +74,7 @@
7574
<script setup lang="ts">
7675
import { useVIntl, defineMessages, defineMessage } from '@vintl/vintl'
7776
import { XCircleIcon, SearchIcon, XIcon } from '@modrinth/assets'
78-
import type { PlatformTag, Project, VirtualProjectType } from '@modrinth/utils'
77+
import type { Project, VirtualProjectType } from '@modrinth/utils'
7978
import NewProjectCard from './NewProjectCard.vue'
8079
import { ref, computed, type Ref } from 'vue'
8180
import { Button, DropdownSelect } from '../index'
@@ -121,11 +120,9 @@ const props = withDefaults(
121120
defineProps<{
122121
projects: Project[]
123122
projectLink: (project: Project) => Linkish
124-
platformTags?: PlatformTag[]
125123
experimentalColors?: boolean
126124
}>(),
127125
{
128-
platformTags: undefined,
129126
experimentalColors: false,
130127
},
131128
)
@@ -136,14 +133,18 @@ const sortedProjects = computed(() => props.projects.slice().sort(sortBy.value.s
136133
137134
const projectType: Ref<VirtualProjectType | null> = ref(null)
138135
136+
const PROJECT_TYPES_ORDER = ['mod', 'resourcepack', 'datapack', 'shader', 'modpack', 'plugin']
137+
139138
const availableProjectTypes = computed(() => {
140139
const types = new Set<VirtualProjectType>()
141140
142141
for (const project of sortedProjects.value) {
143142
types.add(project.project_type)
144143
}
145144
146-
return [...types]
145+
const typesArray = [...types]
146+
typesArray.sort((a, b) => PROJECT_TYPES_ORDER.indexOf(a) - PROJECT_TYPES_ORDER.indexOf(b))
147+
return typesArray
147148
})
148149
149150
const filteredProjects = computed(() =>

0 commit comments

Comments
 (0)