Skip to content

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

Show deprecated licenses (#619)

Olga Bulat5447c3849b6a
diff --git a/src/components/License/VLicense.vue b/src/components/License/VLicense.vue
index 3cb895620..54d894543 100644
--- a/src/components/License/VLicense.vue
+++ b/src/components/License/VLicense.vue
@@ -17,24 +17,21 @@
:size="4"
/>
</div>
- <span
- v-if="!hideName"
- class="name"
- :aria-label="$t(`license-readable-names.${license}`)"
- >
- {{ $t(`license-names.${license}`) }}
+ <span v-if="!hideName" class="name" :aria-label="licenseName.readable">
+ {{ licenseName.full }}
</span>
</div>
</template>
<script>
-import { computed } from '@nuxtjs/composition-api'
+import { computed, useContext } from '@nuxtjs/composition-api'
import VIcon from '~/components/VIcon/VIcon.vue'
import {
ALL_LICENSES,
CC_LICENSES,
+ DEPRECATED_LICENSES,
LICENSE_ICON_MAPPING,
} from '~/constants/license.js'
@@ -79,12 +76,34 @@ export default {
},
},
setup(props) {
- const icons = computed(() =>
- props.license.split(/[-\s]/).map((term) => LICENSE_ICON_MAPPING[term])
+ const { i18n } = useContext()
+ const isDeprecated = computed(() =>
+ DEPRECATED_LICENSES.includes(props.license)
)
+ const icons = computed(() => {
+ if (isDeprecated.value) {
+ return []
+ }
+ return props.license
+ .split(/[-\s]/)
+ .map((term) => LICENSE_ICON_MAPPING[term])
+ })
const isCC = computed(
() => CC_LICENSES.includes(props.license) || props.license === 'cc0'
)
+ /**
+ * @type {import('@nuxtjs/composition-api').ComputedRef<{ readable: string, full: string }>}
+ */
+ const licenseName = computed(() => {
+ if (isDeprecated.value) {
+ return { readable: props.license, full: props.license }
+ } else {
+ return {
+ readable: i18n.t(`license-readable-names.${props.license}`),
+ full: i18n.t(`license-names.${props.license}`),
+ }
+ }
+ })
return {
ccLogo,
@@ -99,6 +118,7 @@ export default {
icons,
isCC,
+ licenseName,
}
},
}
diff --git a/src/constants/license.js b/src/constants/license.js
index 86e44f100..287229a2d 100644
--- a/src/constants/license.js
+++ b/src/constants/license.js
@@ -9,7 +9,13 @@ export const CC_LICENSES = [
export const NON_CC_LICENSES = ['cc0', 'pdm']
-export const ALL_LICENSES = [...CC_LICENSES, ...NON_CC_LICENSES]
+export const DEPRECATED_LICENSES = ['nc-sampling+', 'sampling+']
+
+export const ALL_LICENSES = [
+ ...CC_LICENSES,
+ ...NON_CC_LICENSES,
+ ...DEPRECATED_LICENSES,
+]
export const LICENSE_ICON_MAPPING = {
by: 'by',
diff --git a/test/unit/specs/components/v-license.spec.js b/test/unit/specs/components/v-license.spec.js
index 7253d189e..c8d877cd9 100644
--- a/test/unit/specs/components/v-license.spec.js
+++ b/test/unit/specs/components/v-license.spec.js
@@ -6,6 +6,13 @@ describe('VLicense', () => {
props: {
license: 'by',
},
+ mocks: {
+ $nuxt: {
+ context: {
+ i18n: { t: (val) => val },
+ },
+ },
+ },
}
it('should render the license name and icons', () => {