Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #240 from WordPress/non-image-feature-flag
Browse files Browse the repository at this point in the history
Add feature flag for non-image media types
  • Loading branch information
zackkrida authored Sep 17, 2021
2 parents bfe72da + 0c280dc commit 88383ea
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
2 changes: 2 additions & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export const env = {
filterStorageKey: 'openverse-filter-visibility',
notificationStorageKey: 'openverse-show-notification',
enableInternalAnalytics: process.env.ENABLE_INTERNAL_ANALYTICS || false,
/** Feature flag to enable non-image media */
allMediaFeature: process.env.ALL_MEDIA_FEATURE || true,
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/HeroSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
onSubmit() {
this.$store.commit(SET_QUERY, { query: { q: this.form.searchTerm } })
const newPath = this.localePath({
path: '/search',
path: process.env.allMediaFeature ? '/search' : '/search/image',
query: {
q: this.form.searchTerm,
...filtersToQueryData(this.$store.state.filters, ALL_MEDIA),
Expand Down
6 changes: 5 additions & 1 deletion src/components/SearchTypeTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ import { queryStringToSearchType } from '~/utils/search-query-transform'
export default {
name: 'SearchTypeTabs',
data() {
let contentTypes = [IMAGE, AUDIO, VIDEO]
if (process.env.allMediaFeature) {
contentTypes.unshift(ALL_MEDIA)
}
return {
contentTypes: [ALL_MEDIA, IMAGE, AUDIO, VIDEO],
contentTypes,
}
},
computed: {
Expand Down
15 changes: 13 additions & 2 deletions src/pages/search/audio.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<template>
<div id="tab-audio" role="tabpanel" aria-labelledby="audio">
<AudioResultsList :query="query" @onLoadMoreAudios="onLoadMoreAudios" />
<MetaSearchForm type="audio" :query="query" :supported="true" />
<AudioResultsList
v-if="supported"
:query="query"
@onLoadMoreAudios="onLoadMoreAudios"
/>
<MetaSearchForm type="audio" :query="query" :supported="supported" />
</div>
</template>

Expand All @@ -11,6 +15,12 @@ import { AUDIO } from '~/constants/media'
export default {
name: 'AudioSearch',
data() {
return {
// Only show audio results if non-image results are supported
supported: process.env.allMediaFeature,
}
},
computed: {
query() {
return this.$store.state.query
Expand All @@ -21,6 +31,7 @@ export default {
},
methods: {
onLoadMoreAudios(searchParams) {
if (!this.supported) return
this.$emit('onLoadMoreItems', searchParams)
},
},
Expand Down
26 changes: 15 additions & 11 deletions src/store-modules/filter-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ export const mediaFilterKeys = {
'searchBy',
'mature',
],
audio: [
'licenses',
'licenseTypes',
'audioCategories',
'audioExtensions',
'durations',
'audioProviders',
'searchBy',
'mature',
],
audio: process.env.allMediaFeature
? [
'licenses',
'licenseTypes',
'audioCategories',
'audioExtensions',
'durations',
'audioProviders',
'searchBy',
'mature',
]
: [],
video: [],
all: ['licenses', 'licenseTypes', 'searchBy', 'mature'],
}
Expand All @@ -58,7 +60,9 @@ export const mediaSpecificFilters = {
'sizes',
'imageProviders',
],
audio: ['audioCategories', 'audioExtensions', 'durations', 'audioProviders'],
audio: process.env.allMediaFeature
? ['audioCategories', 'audioExtensions', 'durations', 'audioProviders']
: [],
video: [],
}

Expand Down

0 comments on commit 88383ea

Please sign in to comment.