Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Always show search title, even when search has no results (#685)

Olga Bulat27c3d7617b56
diff --git a/src/components/VItemGroup/VItem.vue b/src/components/VItemGroup/VItem.vue
index 4b0119c42..fc75bca08 100644
--- a/src/components/VItemGroup/VItem.vue
+++ b/src/components/VItemGroup/VItem.vue
@@ -114,7 +114,6 @@ export default defineComponent({
const isFocused = ref(false)
const isInPopover = inject(VPopoverContentContextKey, false)
const contextProps = inject(VItemGroupContextKey)
- console.log('vitem', contextProps)
if (isInPopover && contextProps.bordered) {
warn('Bordered popover items are not supported')
diff --git a/src/components/VSearchGrid.vue b/src/components/VSearchGrid.vue
index beaa2cdd8..9075e2f84 100644
--- a/src/components/VSearchGrid.vue
+++ b/src/components/VSearchGrid.vue
@@ -1,7 +1,7 @@
<template>
<section class="">
<header
- v-if="query.q && isSupported && !noresult"
+ v-if="query.q && isSupported"
class="mt-4"
:class="isAllView ? 'mb-10' : 'mb-8'"
>
@@ -26,29 +26,12 @@
</template>
<script>
-import { computed, useContext } from '@nuxtjs/composition-api'
-import { ALL_MEDIA, AUDIO, IMAGE } from '~/constants/media'
+import { computed } from '@nuxtjs/composition-api'
+import { resultsCount } from '~/composables/use-i18n-utilities'
+import { supportedContentTypes } from '~/constants/media'
import VMetaSearchForm from '~/components/VMetaSearch/VMetaSearchForm.vue'
-const i18nKeys = {
- [ALL_MEDIA]: {
- noResult: 'browse-page.all-no-results',
- result: 'browse-page.all-result-count',
- more: 'browse-page.all-result-count-more',
- },
- [AUDIO]: {
- noResult: 'browse-page.audio-no-results',
- result: 'browse-page.audio-result-count',
- more: 'browse-page.audio-result-count-more',
- },
- [IMAGE]: {
- noResult: 'browse-page.image-no-results',
- result: 'browse-page.image-result-count',
- more: 'browse-page.image-result-count-more',
- },
-}
-
export default {
name: 'VSearchGrid',
components: { VMetaSearchForm },
@@ -74,14 +57,6 @@ export default {
},
},
setup(props) {
- const { i18n } = useContext()
- const shouldShowMeta = computed(() => {
- return (
- props.supported &&
- props.query.q.trim() !== '' &&
- !props.fetchState.isFetching
- )
- })
/**
* The translated string showing how many results were found for
* this media type.
@@ -90,13 +65,7 @@ export default {
*/
const mediaCount = computed(() => {
if (!props.supported) return
-
- const count = props.resultsCount
- const countKey =
- count === 0 ? 'noResult' : count >= 10000 ? 'more' : 'result'
- const i18nKey = i18nKeys[props.query.mediaType][countKey]
- const localeCount = count.toLocaleString(i18n.locale)
- return i18n.tc(i18nKey, count, { localeCount })
+ return resultsCount(props.resultsCount, props.query.mediaType)
})
const noresult = computed(() => {
@@ -107,7 +76,7 @@ export default {
: false
})
const isSupported = computed(() => {
- return props.searchType === 'all' ? true : props.supported
+ return supportedContentTypes.includes(props.searchType)
})
const metaSearchFormType = computed(() => {
return props.searchType === 'all' ? 'image' : props.searchType
@@ -119,7 +88,6 @@ export default {
return {
mediaCount,
noresult,
- shouldShowMeta,
isSupported,
metaSearchFormType,
isAllView,