diff --git a/packages/ui/src/components/project/ProjectCombobox.vue b/packages/ui/src/components/project/ProjectCombobox.vue index dd616f6f80..fca01c813f 100644 --- a/packages/ui/src/components/project/ProjectCombobox.vue +++ b/packages/ui/src/components/project/ProjectCombobox.vue @@ -32,12 +32,13 @@ export type ProjectType = | 'plugin' | 'server' -interface SearchHit { +export interface SearchHit { project_id: string title: string icon_url?: string project_type: string slug: string + author?: string } const props = withDefaults( @@ -83,6 +84,10 @@ const searchResultsCache = ref>(new Map()) const { labrinth } = injectModrinthClient() +function isAllowedProjectType(projectType: string): boolean { + return !props.projectTypes || props.projectTypes.includes(projectType as ProjectType) +} + const userProjectHits = ref([]) const userProjectsFuse = ref | null>(null) @@ -163,7 +168,7 @@ watch( } else { try { const project = await labrinth.projects_v2.get(newId) - if (project) { + if (project && isAllowedProjectType(project.project_type)) { hit = { project_id: project.id, title: project.title, @@ -178,6 +183,9 @@ watch( return } } + if (hit && !isAllowedProjectType(hit.project_type)) { + hit = null + } selectedProject.value = hit if (hit && !options.value.some((o) => o.value === hit!.project_id)) { @@ -220,7 +228,11 @@ const search = async (query: string) => { const uniqueHits: SearchHit[] = [] for (const hit of allHits) { - if (!seenIds.has(hit.project_id) && !excludeSet.has(hit.project_id)) { + if ( + isAllowedProjectType(hit.project_type) && + !seenIds.has(hit.project_id) && + !excludeSet.has(hit.project_id) + ) { seenIds.add(hit.project_id) uniqueHits.push(hit) searchResultsCache.value.set(hit.project_id, hit) diff --git a/packages/ui/src/components/search/SearchDependsOnFilter.vue b/packages/ui/src/components/search/SearchDependsOnFilter.vue new file mode 100644 index 0000000000..0c9cec243b --- /dev/null +++ b/packages/ui/src/components/search/SearchDependsOnFilter.vue @@ -0,0 +1,315 @@ + + + diff --git a/packages/ui/src/components/search/SearchFilterControl.vue b/packages/ui/src/components/search/SearchFilterControl.vue index 72389cbf5f..755e787922 100644 --- a/packages/ui/src/components/search/SearchFilterControl.vue +++ b/packages/ui/src/components/search/SearchFilterControl.vue @@ -37,13 +37,16 @@