Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Create the Content Report flow (#720)
Dhruv Bhanushali8edecc6b3c9d
diff --git a/src/assets/icons/radiomark.svg b/src/assets/icons/radiomark.svgnew file mode 100644index 000000000..edf6296ca--- /dev/null+++ b/src/assets/icons/radiomark.svg@@ -0,0 +1,5 @@+<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">+ <g id="icon">+ <circle cx="12" cy="12" r="7.2" fill="currentColor"/>+ </g>+</svg>diff --git a/src/components/VCheckbox.vue b/src/components/VCheckbox/VCheckbox.vuesimilarity index 99%rename from src/components/VCheckbox.vuerename to src/components/VCheckbox/VCheckbox.vueindex 7ef170800..afa581385 100644--- a/src/components/VCheckbox.vue+++ b/src/components/VCheckbox/VCheckbox.vue@@ -13,7 +13,7 @@focusable="false"width="20"height="20"- role="img"+ aria-hidden="true"/><!-- @slot The checkbox label --><slot /></label>diff --git a/src/components/meta/VCheckbox.stories.js b/src/components/VCheckbox/meta/VCheckbox.stories.jssimilarity index 94%rename from src/components/meta/VCheckbox.stories.jsrename to src/components/VCheckbox/meta/VCheckbox.stories.jsindex aa07690c8..e5e1a12f9 100644--- a/src/components/meta/VCheckbox.stories.js+++ b/src/components/VCheckbox/meta/VCheckbox.stories.js@@ -1,5 +1,5 @@-import VCheckbox from '~/components/VCheckbox'-import VLicense from '~/components/License/VLicense'+import VCheckbox from '~/components/VCheckbox/VCheckbox.vue'+import VLicense from '~/components/License/VLicense.vue'export default {title: 'Components/VCheckbox',diff --git a/src/components/VContentReport/VContentReportButton.vue b/src/components/VContentReport/VContentReportButton.vuenew file mode 100644index 000000000..6fd01e5c0--- /dev/null+++ b/src/components/VContentReport/VContentReportButton.vue@@ -0,0 +1,40 @@+<template>+ <VButton+ variant="plain"+ class="report-button font-semibold text-dark-charcoal"+ >+ <span class="md:hidden">{{+ $t('media-details.content-report.short')+ }}</span>+ <span class="hidden md:inline">{{+ $t('media-details.content-report.long')+ }}</span>+ <VIcon :icon-path="icons.flag" class="ms-2" />+ </VButton>+</template>++<script>+import { defineComponent } from '@nuxtjs/composition-api'++import VIcon from '~/components/VIcon/VIcon.vue'++import flagIcon from '~/assets/icons/flag.svg'++export default defineComponent({+ name: 'VContentReportButton',+ components: { VIcon },+ setup() {+ return {+ icons: {+ flag: flagIcon,+ },+ }+ },+})+</script>++<style scoped>+.report-button {+ @apply px-0;+}+</style>diff --git a/src/components/VContentReport/VContentReportForm.vue b/src/components/VContentReport/VContentReportForm.vueindex 8bd272bae..3e381a93e 100644--- a/src/components/VContentReport/VContentReportForm.vue+++ b/src/components/VContentReport/VContentReportForm.vue@@ -1,180 +1,184 @@<template>- <div id="content-report-form" class="p-4">- <button- :aria-label="$t('photo-details.aria.close-form')"- class="button close-button is-text tiny float-right block bg-white"- type="button"- @click="closeForm"- >- <VIcon :icon-path="closeIcon" />- </button>- <VDmcaNotice- v-if="showDmcaForm"- :image-url="image.foreign_landing_url"- :provider="providerName"- :dmca-form-url="dmcaFormUrl"- @back-click="onBackClick"- />- <VDoneMessage- v-else-if="isDone"- :image-url="image.foreign_landing_url"- :provider="providerName"- />- <VReportError v-else-if="reportFailed" @back-click="backToReportStart" />-- <VOtherIssueForm- v-else-if="showOtherForm"- @back-click="onBackClick"- @send-report="sendContentReport"- />- <form v-else>- <h5 class="b-header mb-4">- {{ $t('photo-details.content-report.title') }}- </h5>- <fieldset class="mb-4 flex flex-col">- <legend class="mb-4">- {{ $t('photo-details.content-report.issue') }}- </legend>- <label- v-for="reason in reasons"- :key="reason"- :for="reason"- class="ms-2 mb-2"- >- <input+ <div id="content-report-form" class="w-80 p-6">+ <div v-if="status === statuses.SENT">+ <p class="font-semibold text-2xl mb-4">+ {{ $t('media-details.content-report.success.title') }}+ </p>+ <i18n+ path="media-details.content-report.success.note"+ class="text-sm"+ tag="p"+ >+ <template #source>+ <a+ :href="media.url"+ class="text-pink hover:underline"+ target="_blank"+ rel="noopener"+ >{{ providerName }}</a+ >+ </template>+ </i18n>+ </div>++ <div v-else-if="status === statuses.FAILED">+ <p class="font-semibold text-2xl mb-4">+ {{ $t('media-details.content-report.failure.title') }}+ </p>+ <p class="text-sm">+ {{ $t('media-details.content-report.failure.note') }}+ </p>+ </div>++ <!-- Main form -->+ <div v-else>+ <div class="font-semibold text-2xl mb-4">+ {{ $t('media-details.content-report.long') }}+ </div>++ <p class="text-sm mb-4">+ {{ $t('media-details.content-report.form.disclaimer') }}+ </p>++ <form class="text-sm">+ <fieldset class="flex flex-col">+ <legend class="font-semibold mb-4">+ {{ $t('media-details.content-report.form.question') }}+ </legend>+ <VRadio+ v-for="reason in reasons":id="reason"- v-model="reasonSelected"- type="radio"- name="type"+ :key="reason"+ v-model="selectedReason"+ class="mb-4"+ name="reason":value="reason"+ >+ {{ $t(`media-details.content-report.form.${reason}.option`) }}+ </VRadio>+ </fieldset>++ <div class="mb-4 min-h-[7rem]">+ <VDmcaNotice+ v-if="selectedReason === reasons.DMCA"+ :provider="providerName"+ :foreign-landing-url="media.foreign_landing_url"/>- {{ $t(`photo-details.content-report.reasons.${reason}`) }}- </label>- </fieldset>+ <VReportDescForm+ v-else+ key="other"+ v-model="description"+ :reason="selectedReason"+ :is-required="selectedReason === reasons.OTHER"+ />+ </div>- <p class="caption font-semibold text-gray mb-4">- {{ $t('photo-details.content-report.caption') }}- </p>+ <div class="flex flex-row items-center justify-end gap-4">+ <VButton variant="tertiary" @click="handleCancel">+ {{ $t('media-details.content-report.form.cancel') }}+ </VButton>- <VButton- :disabled="!reasonSelected"- variant="secondary"- class="float-end bg-trans-blue"- @click="onIssueSelected"- >- {{ $t('photo-details.content-report.next') }}- </VButton>- </form>+ <VButton+ v-if="selectedReason === reasons.DMCA"+ key="dmca"+ as="a"+ variant="secondary"+ :href="DMCA_FORM_URL"+ target="_blank"+ rel="noopener noreferrer"+ >+ {{ $t('media-details.content-report.form.dmca.open') }}+ <VIcon :size="4" class="ms-1" :icon-path="icons.externalLink" />+ </VButton>+ <VButton+ v-else+ key="non-dmca"+ :disabled="isSubmitDisabled"+ :focusable-when-disabled="true"+ variant="secondary"+ @click="handleSubmit"+ >+ {{ $t('media-details.content-report.form.submit') }}+ </VButton>+ </div>+ </form>+ </div></div></template><script>import { computed, defineComponent, ref } from '@nuxtjs/composition-api'-import VDmcaNotice from './VDmcaNotice'-import VOtherIssueForm from './VOtherIssueForm'-import VDoneMessage from './VDoneMessage'-import VReportError from './VReportError'-import ReportService from '~/data/report-service'-import closeIcon from '~/assets/icons/close.svg'-import VIcon from '~/components/VIcon/VIcon.vue'import VButton from '~/components/VButton.vue'+import VRadio from '~/components/VRadio/VRadio.vue'+import VDmcaNotice from '~/components/VContentReport/VDmcaNotice.vue'+import VReportDescForm from '~/components/VContentReport/VReportDescForm.vue'++import ReportService from '~/data/report-service'++import { reasons, statuses, DMCA_FORM_URL } from '~/constants/content-report'-const dmcaFormUrl =- 'https://docs.google.com/forms/d/e/1FAIpQLSd0I8GsEbGQLdaX4K_F6V2NbHZqN137WMZgnptUpzwd-kbDKA/viewform'-const reasons = {- DMCA: 'dmca',- MATURE: 'mature',- OTHER: 'other',-}-const statuses = {- SENT: 'sent',- FAILED: 'failed',- ADDING_DETAILS: 'adding_details',- OPEN: 'open',- CLOSED: 'closed',-}+import externalLinkIcon from '~/assets/icons/external-link.svg'export default defineComponent({name: 'VContentReportForm',components: {- VDoneMessage,- VDmcaNotice,- VReportError,- VOtherIssueForm,VButton,- VIcon,+ VRadio,+ VDmcaNotice,+ VReportDescForm,},- props: ['image', 'providerName', 'reportService'],- setup(props, { emit }) {- const reportStatus = ref(statuses.OPEN)+ props: ['media', 'providerName', 'reportService', 'closeFn'],+ setup(props) {+ const service = props.reportService || ReportService+/** @type {import('@nuxtjs/composition-api').Ref<string|null>} */- const reasonSelected = ref(null)+ const status = ref(statuses.WIP)+ const selectedReason = ref(reasons.DMCA)+ const description = ref('')- const service = props.reportService || ReportService- const onIssueSelected = () => {- if (- reasonSelected.value &&- ![reasons.OTHER, reasons.DMCA].includes(reasonSelected.value)- ) {- sendContentReport()- } else {- reportStatus.value = statuses.ADDING_DETAILS- }- }- const onBackClick = () => {- reportStatus.value = statuses.OPEN- }- const backToReportStart = () => {- reasonSelected.value = null- reportStatus.value = statuses.OPEN+ /* Buttons */+ const handleCancel = () => {+ selectedReason.value = null+ description.value = ''+ props.closeFn()}- const sendContentReport = async ({ description = '' } = {}) => {++ const isSubmitDisabled = computed(+ () =>+ selectedReason.value === reasons.OTHER && description.value.length < 20+ )+ const handleSubmit = async () => {+ if (selectedReason.value === reasons.DMCA) return+ // Submit reporttry {await service.sendReport({- identifier: props.image.id,- reason: reasonSelected.value,- description,+ identifier: props.media.identifier,+ reason: selectedReason.value,+ description: description.value,})- reportStatus.value = statuses.SENT+ status.value = statuses.SENT} catch (error) {- reportStatus.value = statuses.FAILED+ status.value = statuses.FAILED}}- const closeForm = () => {- reportStatus.value = statuses.CLOSED- emit('close-form')- }- const reportFailed = computed(() => reportStatus.value === statuses.FAILED)- const isDone = computed(- () =>- reportStatus.value === statuses.SENT &&- !(reasonSelected.value === reasons.DMCA)- )- const showOtherForm = computed(- () =>- reportStatus.value === statuses.ADDING_DETAILS &&- reasonSelected.value === reasons.OTHER- )- const showDmcaForm = computed(- () =>- reportStatus.value === statuses.ADDING_DETAILS &&- reasonSelected.value === reasons.DMCA- )+return {- reasonSelected,- closeIcon,- dmcaFormUrl,- isDone,- reportFailed,- closeForm,- onIssueSelected,- onBackClick,- sendContentReport,- backToReportStart,- showOtherForm,- showDmcaForm,- reasons: Object.values(reasons),+ icons: {+ externalLink: externalLinkIcon,+ },+ reasons,+ statuses,+ DMCA_FORM_URL,++ selectedReason,+ status,+ description,++ handleCancel,++ isSubmitDisabled,+ handleSubmit,}},})diff --git a/src/components/VContentReport/VContentReportPopover.vue b/src/components/VContentReport/VContentReportPopover.vuenew file mode 100644index 000000000..ecbbf1fa6--- /dev/null+++ b/src/components/VContentReport/VContentReportPopover.vue@@ -0,0 +1,62 @@+<template>+ <VPopover+ ref="popoverEl"+ :hide-on-click-outside="false"+ placement="bottom-end"+ >+ <template #trigger="{ a11yProps }">+ <VContentReportButton v-bind="a11yProps" />+ </template>+ <template #default="{ close }">+ <div class="relative">+ <VIconButton+ class="absolute top-0 end-0 border-none"+ size="search-medium"+ :icon-props="{ iconPath: icons.closeSmall }"+ @click="close"+ />+ <VContentReportForm+ :close-fn="close"+ :media="media"+ :provider-name="providerName"+ />+ </div>+ </template>+ </VPopover>+</template>++<script>+import { computed, useStore, defineComponent } from '@nuxtjs/composition-api'++import VPopover from '~/components/VPopover/VPopover.vue'+import VContentReportButton from '~/components/VContentReport/VContentReportButton.vue'++import flagIcon from '~/assets/icons/flag.svg'+import closeSmallIcon from '~/assets/icons/close-small.svg'++export default defineComponent({+ name: 'VContentReportPopover',+ components: { VPopover, VContentReportButton },+ props: {+ /**+ * the media item to report; This can either be an audio track or an image.+ */+ media: {+ type: Object,+ },+ },+ setup(props) {+ const store = useStore()++ const getProviderName = (nameCode) =>+ store.getters['provider/getProviderName'](nameCode)+ const providerName = computed(() => getProviderName(props.media.provider))++ return {+ icons: { flag: flagIcon, closeSmall: closeSmallIcon },++ providerName,+ }+ },+})+</script>diff --git a/src/components/VContentReport/VDmcaNotice.vue b/src/components/VContentReport/VDmcaNotice.vueindex 0d80eea48..009bcf07e 100644--- a/src/components/VContentReport/VDmcaNotice.vue+++ b/src/components/VContentReport/VDmcaNotice.vue@@ -1,79 +1,58 @@<template>- <div>- <i18n- path="photo-details.content-report.dmca.content"- tag="p"- class="block px-6 mt-10 text-center"- >- <template #link>- <a- :aria-label="$t('photo-details.aria.dmca')"- :href="dmcaFormUrl"- target="_blank"- rel="noopener"- >{{ $t('photo-details.content-report.dmca.link') }}</a- >- </template>- </i18n>-- <i18n- path="photo-details.content-report.provider"- tag="p"- class="block px-6 mt-4 text-center"- >- <template #link>- <a- :aria-label="- $t('photo-details.aria.provider-report-form', { provider })- "- :href="imageUrl"- target="_blank"- rel="noopener"- >{{ provider }}</a- >- </template>- </i18n>-- <VButton- type="button"- variant="action-button"- size="small"- @click="onBackClick"- >- <VIcon :icon-path="chevronLeftIcon" class="me-2" />- {{ $t('photo-details.content-report.back') }}- </VButton>- </div>+ <i18n+ class="dmca-notice"+ path="media-details.content-report.form.dmca.note"+ tag="p"+ >+ <template #form>+ <a+ :aria-label="$t('media-details.content-report.form.dmca.form')"+ :href="DMCA_FORM_URL"+ class="text-pink hover:underline"+ target="_blank"+ rel="noopener"+ >{{ $t('media-details.content-report.form.dmca.form') }}</a+ >+ </template>+ <template #source>+ <a+ :href="foreignLandingUrl"+ class="text-pink hover:underline"+ target="_blank"+ rel="noopener noreferrer"+ >{{ provider }}</a+ >+ </template>+ </i18n></template><script>import { defineComponent } from '@nuxtjs/composition-api'-import VButton from '~/components/VButton.vue'-import VIcon from '~/components/VIcon/VIcon.vue'-import chevronLeftIcon from '~/assets/icons/chevron-left.svg'++import { DMCA_FORM_URL } from '~/constants/content-report'export default defineComponent({- name: 'DmcaNotice',- components: { VButton, VIcon },+ name: 'VDmcaNotice',props: {- dmcaFormUrl: {- type: String,- required: true,- },- imageUrl: {+ /**+ * the foreign landing URL for the media item+ */+ foreignLandingUrl: {type: String,required: true,},+ /**+ * the name of the provider of the media item+ */provider: {type: String,required: true,},},- setup(_, { emit }) {- const onBackClick = () => {- emit('back-click')+ setup() {+ return {+ DMCA_FORM_URL,}- return { chevronLeftIcon, onBackClick }},})</script>diff --git a/src/components/VContentReport/VDoneMessage.vue b/src/components/VContentReport/VDoneMessage.vuedeleted file mode 100644index 3d5da618f..000000000--- a/src/components/VContentReport/VDoneMessage.vue+++ /dev/null@@ -1,31 +0,0 @@-<template>- <div class="my-10">- <span class="block px-6 text-center">- {{ $t('photo-details.content-report.thanks') }}- </span>- <i18n- path="photo-details.content-report.provider"- tag="span"- class="block px-6 mt-10 text-center"- >- <template #link>- <a- :aria-label="- $t('photo-details.aria.provider-report-form', { provider })- "- :href="imageUrl"- target="_blank"- rel="noopener"- >{{ provider }}</a- >- </template>- </i18n>- </div>-</template>--<script>-export default {- name: 'DoneMessage',- props: ['imageUrl', 'provider'],-}-</script>diff --git a/src/components/VContentReport/VOtherIssueForm.vue b/src/components/VContentReport/VOtherIssueForm.vuedeleted file mode 100644index c9706f987..000000000--- a/src/components/VContentReport/VOtherIssueForm.vue+++ /dev/null@@ -1,72 +0,0 @@-<template>- <form class="other-form">- <h4 class="b-header">- {{ $t('photo-details.content-report.title') }}- </h4>- <label for="description" class="mb-2">- {{ $t('photo-details.content-report.issue-description') }}- <textarea- id="description"- v-model="description"- class="reason p-2 font-semibold border border-dark-charcoal w-full h-24 text-sm"- :placeholder="$t('photo-details.content-report.placeholder')"- />- </label>-- <div class="flex flex-row justify-between align-end mt-4">- <VButton- type="button"- variant="action-button"- size="small"- @click="onBackClick"- >- <VIcon :icon-path="chevronLeftIcon" class="me-2" />- {{ $t('photo-details.content-report.back') }}- </VButton>-- <VButton- :disabled="!isValid"- variant="secondary"- class="float-right bg-trans-blue"- @click="sendContentReport"- >- {{ $t('photo-details.content-report.submit') }}- </VButton>- </div>- </form>-</template>--<script>-import { computed, defineComponent, ref } from '@nuxtjs/composition-api'-import chevronLeftIcon from '~/assets/icons/chevron-left.svg'-import VButton from '~/components/VButton.vue'-import VIcon from '~/components/VIcon/VIcon.vue'--export default defineComponent({- name: 'OtherIssueForm',- components: {- VButton,- VIcon,- },- setup(_, { emit }) {- const onBackClick = () => {- emit('back-click')- }- const description = ref('')- const descriptionHasMoreThan20Chars = computed(- () => description.value.length >= 20- )-- const sendContentReport = () =>- emit('send-report', { description: description.value })- return {- chevronLeftIcon,- description,- isValid: descriptionHasMoreThan20Chars,-- onBackClick,- sendContentReport,- }- },-})-</script>diff --git a/src/components/VContentReport/VReportDescForm.vue b/src/components/VContentReport/VReportDescForm.vuenew file mode 100644index 000000000..b4722298d--- /dev/null+++ b/src/components/VContentReport/VReportDescForm.vue@@ -0,0 +1,63 @@+<template>+ <label class="other-form block" for="description">+ <span class="flex flex-row justify-between items-center">+ <span>{{ $t('media-details.content-report.form.other.note') }}</span>+ <span>{{+ $t(`media-details.content-report.form.${reason}.sub-label`)+ }}</span>+ </span>+ <textarea+ id="description"+ v-model="text"+ class="h-20 w-full border border-dark-charcoal-20 placeholder-dark-charcoal-70 mt-2 p-2"+ :placeholder="+ $t(`media-details.content-report.form.${reason}.placeholder`)+ "+ :required="isRequired"+ :minlength="isRequired ? 20 : 0"+ maxlength="500"+ />+ </label>+</template>++<script>+import { computed, defineComponent } from '@nuxtjs/composition-api'+import { reasons } from '~/constants/content-report'++export default defineComponent({+ name: 'VReportDescForm',+ model: {+ prop: 'content',+ event: 'input',+ },+ props: {+ /**+ * the contents of the textarea+ */+ content: {+ type: String,+ default: '',+ },+ /**+ * the reason selected for reporting the content+ */+ reason: {+ type: String,+ validator: (val) => Object.values(reasons).includes(val),+ },+ },+ setup(props, { emit }) {+ const text = computed({+ get: () => props.content,+ set: (val) => emit('input', val),+ })++ const isRequired = computed(() => props.reason === reasons.OTHER)++ return {+ isRequired,+ text,+ }+ },+})+</script>diff --git a/src/components/VContentReport/VReportError.vue b/src/components/VContentReport/VReportError.vuedeleted file mode 100644index 2ae32ad41..000000000--- a/src/components/VContentReport/VReportError.vue+++ /dev/null@@ -1,26 +0,0 @@-<template>- <div>- <span class="block px-6 mt-10 text-center">- {{ $t('photo-details.content-report.submission-error') }}- </span>- <button class="button is-text tiny mt-4" type="button" @click="onBackClick">- <VIcon :icon-path="chevronLeftIcon" class="me-2" />- {{ $t('photo-details.content-report.back') }}- </button>- </div>-</template>--<script>-import { defineComponent } from '@nuxtjs/composition-api'-import VIcon from '~/components/VIcon/VIcon.vue'-import chevronLeftIcon from '~/assets/icons/chevron-left.svg'--export default defineComponent({- name: 'VReportError',- components: { VIcon },- setup(_, { emit }) {- const onBackClick = () => emit('back-click')- return { chevronLeftIcon, onBackClick }- },-})-</script>diff --git a/src/components/VContentReport/meta/VContentReportPopover.stories.mdx b/src/components/VContentReport/meta/VContentReportPopover.stories.mdxnew file mode 100644index 000000000..783fa8b1e--- /dev/null+++ b/src/components/VContentReport/meta/VContentReportPopover.stories.mdx@@ -0,0 +1,41 @@+import {+ ArgsTable,+ Canvas,+ Description,+ Meta,+ Story,+} from '@storybook/addon-docs'++import VContentReportPopover from '~/components/VContentReport/VContentReportPopover.vue'++<Meta+ title="Components/VContentReportPopover"+ component={VContentReportPopover}+/>++export const Template = (args, { argTypes }) => ({+ template: `<VContentReportPopover v-bind="$props" class="float-right"/>`,+ components: { VContentReportPopover },+ props: Object.keys(argTypes),+})++# VContentReportPopover++<Description of={VContentReportPopover} />++<ArgsTable of={VContentReportPopover} />++<Canvas>+ <Story+ name="Default"+ args={{+ media: {+ identifier: '0aff3595-8168-440b-83ff-7a80b65dea42',+ foreign_landing_url: 'https://wordpress.org/openverse/',+ provider: 'provider',+ },+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>diff --git a/src/components/VFilters/VFilterChecklist.vue b/src/components/VFilters/VFilterChecklist.vueindex abbda2620..a6f1bab49 100644--- a/src/components/VFilters/VFilterChecklist.vue+++ b/src/components/VFilters/VFilterChecklist.vue@@ -43,7 +43,7 @@import helpIcon from '~/assets/icons/help.svg'import VLicenseExplanationTooltip from '~/components/VFilters/VLicenseExplanationTooltip.vue'-import VCheckbox from '~/components/VCheckbox.vue'+import VCheckbox from '~/components/VCheckbox/VCheckbox.vue'import VLicense from '~/components/License/VLicense.vue'import VIcon from '~/components/VIcon/VIcon.vue'diff --git a/src/components/VImageDetails/VImageDetails.vue b/src/components/VImageDetails/VImageDetails.vueindex 000ea5648..eff78ccd9 100644--- a/src/components/VImageDetails/VImageDetails.vue+++ b/src/components/VImageDetails/VImageDetails.vue@@ -4,15 +4,7 @@<h3 class="text-2xl md:text-3xl">{{ $t('image-details.information.title') }}</h3>- <span- class="flex flex-row justify-end items-center text-sr text-dark-charcoal-70 font-semibold"- >- <span class="hidden md:inline">{{- $t('image-details.report.large')- }}</span>- <span class="md:hidden">{{ $t('image-details.report.short') }}</span>- <FlagSvg class="ms-2"- /></span>+ <VContentReportPopover :media="image" /></div><dl><div>@@ -50,11 +42,8 @@<script>import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'-import FlagSvg from '~/assets/icons/flag.svg?inline'-const VImageDetails = defineComponent({name: 'VImageDetails',- components: { FlagSvg },props: {image: {type: Object,diff --git a/src/components/VPopover/VPopover.vue b/src/components/VPopover/VPopover.vueindex 23e091558..7c3aca0f9 100644--- a/src/components/VPopover/VPopover.vue+++ b/src/components/VPopover/VPopover.vue@@ -111,7 +111,7 @@ export default defineComponent({/*** the z-index to apply to the popover content*/- zIndex: { type: Number },+ zIndex: { type: Number, default: 999 },},emits: [/**diff --git a/src/components/VPopover/VPopoverContent.vue b/src/components/VPopover/VPopoverContent.vueindex afd4a1b05..0b2ad9daa 100644--- a/src/components/VPopover/VPopoverContent.vue+++ b/src/components/VPopover/VPopoverContent.vue@@ -2,7 +2,7 @@<divv-if="visible"ref="popoverRef"- :class="[$style.popover, { [`z-${zIndex}`]: zIndex !== undefined }]"+ :class="[$style.popover, { [`z-[${zIndex}]`]: zIndex !== undefined }]":aria-hidden="!visible":tabindex="typeof $props.tabindex !== 'undefined' ? $props.tabindex : -1"v-on="$listeners"@@ -59,6 +59,6 @@ export default defineComponent({<style module>.popover {- @apply bg-white border border-light-gray rounded-sm max-w-max whitespace-nowrap shadow;+ @apply bg-white border border-light-gray rounded-sm max-w-max shadow;}</style>diff --git a/src/components/VRadio/VRadio.vue b/src/components/VRadio/VRadio.vuenew file mode 100644index 000000000..f93136ee3--- /dev/null+++ b/src/components/VRadio/VRadio.vue@@ -0,0 +1,86 @@+<template>+ <label :for="id" class="radio-label relative flex leading-5">+ <input+ :id="id"+ v-bind="$attrs"+ :value="value"+ class="radio appearance-none relative flex-shrink-0 bg-white w-5 h-5 border border-dark-charcoal rounded-full me-3 transition-colors focus:outline-none focus:ring focus:ring-offset-2 focus:ring-primary disabled:bg-dark-charcoal-10 disabled:border-dark-charcoal-40"+ type="radio"+ :checked="isChecked"+ @input="handleInput"+ />+ <Radiomark+ class="radiomark absolute start-0 w-5 h-5 text-dark-charcoal opacity-0 transition-opacity"+ focusable="false"+ width="20"+ height="20"+ aria-hidden="true"+ />+ <!-- @slot Label content goes here -->+ <slot />+ </label>+</template>++<script>+import { computed } from '@nuxtjs/composition-api'++import Radiomark from '~/assets/icons/radiomark.svg?inline'++/**+ * Renders a radio input field, useful for choosing one of a few options that+ * can all be presented on the screen at once.+ */+export default {+ name: 'VRadio',+ components: { Radiomark },+ inheritAttrs: false,+ model: {+ prop: 'modelValue',+ event: 'change',+ },+ props: {+ /**+ * the input `id` property; This is used to connect the label to the radio.+ */+ id: {+ type: String,+ required: true,+ },+ /**+ * the value associated with this radio input+ */+ value: {+ type: String,+ required: true,+ },+ /**+ * the value of the `v-model` associated with the radio group+ */+ modelValue: {+ type: String,+ default: '',+ },+ },+ setup(props, { emit }) {+ const isChecked = computed(() => props.value === props.modelValue)+ const handleInput = () => {+ emit('change', props.value)+ }++ return {+ isChecked,+ handleInput,+ }+ },+}+</script>++<style scoped>+.radio:checked ~ .radiomark {+ @apply opacity-100;+}++.radio:disabled ~ .radiomark {+ @apply text-dark-charcoal-70;+}+</style>diff --git a/src/components/VRadio/meta/VRadio.stories.mdx b/src/components/VRadio/meta/VRadio.stories.mdxnew file mode 100644index 000000000..bdaf2295e--- /dev/null+++ b/src/components/VRadio/meta/VRadio.stories.mdx@@ -0,0 +1,95 @@+import {+ ArgsTable,+ Canvas,+ Description,+ Meta,+ Story,+} from '@storybook/addon-docs'++import VRadio from '~/components/VRadio/VRadio.vue'++<Meta+ title="Components/VRadio"+ components={VRadio}+ argTypes={{+ change: {+ action: 'change',+ },+ }}+/>++export const Template = (args, { argTypes }) => ({+ template: `+ <div>+ <VRadio v-bind="$props" v-on="$props">Label text</VRadio>+ </div>+ `,+ components: { VRadio },+ props: Object.keys(argTypes),+})++# VRadio++<Description of={VRadio} />++<ArgsTable of={VRadio} />++<Canvas>+ <Story+ name="Default"+ args={{+ id: 'default',+ value: 'value',+ modelValue: 'modelValue', // if same as value, radio is checked+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>++## Attributes++The component is a transparent wrapper over `<input>` so all attributes of the+input element can be applied to it, e.g. `disabled`. It is recommended not to+change the type as the field is specifically designed as a radio.++<Canvas>+ <Story+ name="Disabled"+ args={{+ id: 'disabled',+ value: 'value',+ modelValue: 'modelValue', // if same as value, radio is checked+ disabled: true,+ }}+ >+ {Template.bind({})}+ </Story>+</Canvas>++## v-model++The recommended way to use it is with `v-model` mapping to a `String`. Ideally+you would have more than one `VRadio` in a `<form>` with the same `name`+attribute and mapped to the same `v-model` variable.++export const vModelTemplate = (args, { argTypes }) => ({+ template: `+ <div>+ <form class="flex flex-col gap-2 mb-2">+ <VRadio id="a" name="test" value="A" v-model="picked">A</VRadio>+ <VRadio id="b" name="test" value="B" v-model="picked">B</VRadio>+ </form>+ {{ picked ?? 'None' }}+ </div>+ `,+ data() {+ return { picked: null }+ },+ components: { VRadio },+ props: Object.keys(argTypes),+})++<Canvas>+ <Story name="v-model">{vModelTemplate.bind({})}</Story>+</Canvas>diff --git a/src/constants/content-report.js b/src/constants/content-report.jsnew file mode 100644index 000000000..025cf9d5b--- /dev/null+++ b/src/constants/content-report.js@@ -0,0 +1,14 @@+export const reasons = Object.freeze({+ DMCA: 'dmca',+ MATURE: 'mature',+ OTHER: 'other',+})++export const statuses = Object.freeze({+ SENT: 'sent',+ FAILED: 'failed',+ WIP: 'wip',+})++export const DMCA_FORM_URL =+ 'https://docs.google.com/forms/d/e/1FAIpQLSd0I8GsEbGQLdaX4K_F6V2NbHZqN137WMZgnptUpzwd-kbDKA/viewform'diff --git a/src/layouts/default.vue b/src/layouts/default.vueindex d31d892d8..66751cba6 100644--- a/src/layouts/default.vue+++ b/src/layouts/default.vue@@ -1,5 +1,5 @@<template>- <div class="app grid h-screen overflow-hidden">+ <div class="app grid h-screen overflow-hidden relative"><VTeleportTarget name="skip-to-content" /><MigrationNotice v-show="isReferredFromCc" /><TranslationStatusBanner />diff --git a/src/locales/en.json b/src/locales/en.jsonindex 851dc08f5..1efed95aa 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -493,8 +493,39 @@"image-info": "Image information","audio-info": "Audio information","content-report": {- "report": "Report",- "title": "Report this content"+ "short": "Report",+ "long": "Report this content",+ "form": {+ "disclaimer": "For security purposes, Openverse collects and retains anonymized IP addresses of those who complete and submit this form.",+ "question": "What is the reason?",+ "dmca": {+ "option": "Infringes copyright",+ "note": "You must fill out this {form} to report copyright infringement. No action will be taken until this form is filled out and submitted. We recommend doing the same at the source, {source}.",+ "form": "DMCA form",+ "open": "Open form"+ },+ "mature": {+ "option": "Contains mature content",+ "sub-label": "Optional",+ "placeholder": "Optionally, provide a description."+ },+ "other": {+ "option": "Other",+ "note": "Describe the issue.",+ "sub-label": "Required",+ "placeholder": "Please enter at least 20 characters."+ },+ "submit": "Report",+ "cancel": "Cancel"+ },+ "success": {+ "title": "Report submitted successfully",+ "note": "Thank you for reporting this content. We recommend doing the same at the source, {source}."+ },+ "failure": {+ "title": "Report could not be submitted",+ "note": "Something went wrong, please try again after some time."+ }}},"image-details": {@@ -510,10 +541,6 @@"pixels": "pixels","unknown": "Unknown"},- "report": {- "short": "Report",- "large": "Report this content"- },"related-images": "Related images","aria": {"creator-url": "Author {creator}"diff --git a/src/locales/po-files/openverse.pot b/src/locales/po-files/openverse.potindex 81b44bc65..7a5823bcf 100644--- a/src/locales/po-files/openverse.pot+++ b/src/locales/po-files/openverse.pot@@ -4,7 +4,7 @@ msgid ""msgstr """Project-Id-Version: Openverse \n""Report-Msgid-Bugs-To: https://github.com/wordpress/openverse/issues \n"-"POT-Creation-Date: 2022-02-01T19:06:38+00:00\n"+"POT-Creation-Date: 2022-02-09T12:36:10+00:00\n""MIME-Version: 1.0\n""Content-Type: text/plain; charset=UTF-8\n""Content-Transfer-Encoding: 8bit\n"@@ -389,47 +389,37 @@ msgctxt "image-details.aria.creator-url"msgid "Author ###creator###"msgstr ""-#: src/components/VImageDetails/VImageDetails.vue:13-msgctxt "image-details.report.short"-msgid "Report"-msgstr ""--#: src/components/VImageDetails/VImageDetails.vue:11-msgctxt "image-details.report.large"-msgid "Report this content"-msgstr ""-#: src/components/VImageDetails/VImageDetails.vue:5msgctxt "image-details.information.title"msgid "Image information"msgstr ""-#: src/components/VImageDetails/VImageDetails.vue:19+#: src/components/VImageDetails/VImageDetails.vue:11msgctxt "image-details.information.type"msgid "Type"msgstr ""-#: src/components/VImageDetails/VImageDetails.vue:23+#: src/components/VImageDetails/VImageDetails.vue:15msgctxt "image-details.information.provider"msgid "Provider"msgstr ""-#: src/components/VImageDetails/VImageDetails.vue:39+#: src/components/VImageDetails/VImageDetails.vue:31msgctxt "image-details.information.dimensions"msgid "Dimensions"msgstr ""-#: src/components/VImageDetails/VImageDetails.vue:27+#: src/components/VImageDetails/VImageDetails.vue:19msgctxt "image-details.information.source"msgid "Source"msgstr ""-#: src/components/VImageDetails/VImageDetails.vue:43+#: src/components/VImageDetails/VImageDetails.vue:35msgctxt "image-details.information.pixels"msgid "pixels"msgstr ""-#: src/components/VImageDetails/VImageDetails.vue:83+#: src/components/VImageDetails/VImageDetails.vue:72msgctxt "image-details.information.unknown"msgid "Unknown"msgstr ""@@ -459,14 +449,106 @@ msgctxt "media-details.audio-info"msgid "Audio information"msgstr ""-msgctxt "media-details.content-report.report"+#: src/components/VContentReport/VContentReportButton.vue:7+msgctxt "media-details.content-report.short"msgid "Report"msgstr ""-msgctxt "media-details.content-report.title"+#: src/components/VContentReport/VContentReportButton.vue:10+msgctxt "media-details.content-report.long"msgid "Report this content"msgstr ""+#: src/components/VContentReport/VContentReportForm.vue:26+msgctxt "media-details.content-report.failure.title"+msgid "Report could not be submitted"+msgstr ""++#: src/components/VContentReport/VContentReportForm.vue:29+msgctxt "media-details.content-report.failure.note"+msgid "Something went wrong, please try again after some time."+msgstr ""++#: src/components/VContentReport/VContentReportForm.vue:5+msgctxt "media-details.content-report.success.title"+msgid "Report submitted successfully"+msgstr ""++#. Do not translate words between ### ###.+#: src/components/VContentReport/VContentReportForm.vue:7+msgctxt "media-details.content-report.success.note"+msgid "Thank you for reporting this content. We recommend doing the same at the source, ###source###."+msgstr ""++#: src/components/VContentReport/VContentReportForm.vue:40+msgctxt "media-details.content-report.form.disclaimer"+msgid "For security purposes, Openverse collects and retains anonymized IP addresses of those who complete and submit this form."+msgstr ""++#: src/components/VContentReport/VContentReportForm.vue:46+msgctxt "media-details.content-report.form.question"+msgid "What is the reason?"+msgstr ""++#: src/components/VContentReport/VContentReportForm.vue:101+msgctxt "media-details.content-report.form.submit"+msgid "Report"+msgstr ""++#: src/components/VContentReport/VContentReportForm.vue:78+msgctxt "media-details.content-report.form.cancel"+msgid "Cancel"+msgstr ""++msgctxt "media-details.content-report.form.other.option"+msgid "Other"+msgstr ""++#: src/components/VContentReport/VReportDescForm.vue:4+msgctxt "media-details.content-report.form.other.note"+msgid "Describe the issue."+msgstr ""++msgctxt "media-details.content-report.form.other.sub-label"+msgid "Required"+msgstr ""++msgctxt "media-details.content-report.form.other.placeholder"+msgid "Please enter at least 20 characters."+msgstr ""++msgctxt "media-details.content-report.form.mature.option"+msgid "Contains mature content"+msgstr ""++msgctxt "media-details.content-report.form.mature.sub-label"+msgid "Optional"+msgstr ""++msgctxt "media-details.content-report.form.mature.placeholder"+msgid "Optionally, provide a description."+msgstr ""++msgctxt "media-details.content-report.form.dmca.option"+msgid "Infringes copyright"+msgstr ""++#. Do not translate words between ### ###.+#: src/components/VContentReport/VDmcaNotice.vue:2+msgctxt "media-details.content-report.form.dmca.note"+msgid "You must fill out this ###form### to report copyright infringement. No action will be taken until this form is filled out and submitted. We recommend doing the same at the source, ###source###."+msgstr ""++#: src/components/VContentReport/VDmcaNotice.vue:9+msgctxt "media-details.content-report.form.dmca.form"+msgid "DMCA form"+msgstr ""++#: src/components/VContentReport/VContentReportForm.vue:90+msgctxt "media-details.content-report.form.dmca.open"+msgid "Open form"+msgstr ""+#. Do not translate words between ### ###.#: src/pages/image/_id.vue:59msgctxt "media-details.aria.creator-url"@@ -1915,7 +1997,7 @@ msgctxt "hero.brand"msgid "Openverse"msgstr ""-#: src/pages/index.vue:21+#: src/pages/index.vue:33msgctxt "hero.subtitle"msgid "Browse through over 600 million items to reuse"msgstr ""@@ -1943,38 +2025,38 @@ msgid "I want something I can"msgstr ""#. Do not translate words between ### ###.-#: src/pages/index.vue:51+#: src/pages/index.vue:63msgctxt "hero.disclaimer.content"msgid "All Openverse content is under a ###license### or is in the public domain."msgstr ""-#: src/pages/index.vue:60+#: src/pages/index.vue:72msgctxt "hero.disclaimer.license"msgid "Creative Commons license"msgstr ""-#: src/pages/index.vue:36+#: src/pages/index.vue:48msgctxt "hero.search.placeholder"msgid "Search for content"msgstr ""-#: src/layouts/error.vue:18+#: src/components/VFourOhFour.vue:21msgctxt "404.title"msgid "The content you’re looking for seems to have disappeared."msgstr ""#. Do not translate words between ### ###.-#: src/layouts/error.vue:21+#: src/components/VFourOhFour.vue:24msgctxt "404.main"msgid "Go to ###link### or search for something similar from the field below."msgstr ""-#: src/layouts/error.vue:4+#: src/components/VFourOhFour.vue:4msgctxt "404.link-title"msgid "Openverse"msgstr ""-#: src/layouts/error.vue:34+#: src/components/VFourOhFour.vue:37msgctxt "404.search-placeholder"msgid "Search for content to reuse"msgstr ""diff --git a/tailwind.safelist.txt b/tailwind.safelist.txtindex 359d2cdce..18a8f0ff2 100644--- a/tailwind.safelist.txt+++ b/tailwind.safelist.txt@@ -10,3 +10,4 @@ h-5h-6z-20+z-[999]diff --git a/test/unit/specs/components/ContentReport/content-report-form.spec.js b/test/unit/specs/components/ContentReport/content-report-form.spec.jsindex 03f5f7b73..57d30ee3f 100644--- a/test/unit/specs/components/ContentReport/content-report-form.spec.js+++ b/test/unit/specs/components/ContentReport/content-report-form.spec.js@@ -10,14 +10,6 @@ const i18n = new VueI18n({messages,})-const getCloseButton = () =>- screen.getByRole('button', {- name: /close-form/i,- })-const getNextButton = () =>- screen.getByRole('button', {- name: /next/i,- })const getDmcaInput = () =>screen.getByRole('radio', {name: /dmca/i,@@ -30,6 +22,25 @@ const getOtherInput = () =>screen.getByRole('radio', {name: /other/i,})+const getCancelButton = () =>+ screen.getByRole('button', {+ name: /cancel/i,+ })+const getReportButton = () =>+ screen.getByRole('button', {+ name: /submit/i,+ })++// When DMCA selected+const getReportLink = () =>+ screen.getByRole('link', {+ name: /dmca\.open/i,+ })+// When other selected+const getDescriptionTextarea = () =>+ screen.getByRole('textbox', {+ name: /other\.note/i,+ })describe('VContentReportForm', () => {let props = null@@ -39,8 +50,12 @@ describe('VContentReportForm', () => {beforeEach(() => {props = {- image: { id: 1, url: 'http://foo.bar' },- providerName: 'provider',+ media: {+ identifier: '0aff3595-8168-440b-83ff-7a80b65dea42',+ foreign_landing_url: 'https://wordpress.org/openverse/',+ provider: 'provider',+ },+ providerName: 'Provider',reportService: reportServiceProp,}@@ -55,21 +70,20 @@ describe('VContentReportForm', () => {it('should contain the correct contents', async () => {await render(VContentReportForm, options)- getCloseButton()getDmcaInput()getMatureInput()getOtherInput()- getNextButton()+ getCancelButton()+ getReportLink()})it('should render thank you note when report is sent', async () => {const { getByText } = render(VContentReportForm, options)await fireEvent.click(getMatureInput())- await fireEvent.click(getNextButton())+ await fireEvent.click(getReportButton())- // Thank you message with a link to provider- getByText('photo-details.content-report.thanks')- getByText('photo-details.content-report.provider')+ // Submission successful message+ getByText('media-details.content-report.success.note')})it('should render error message if report sending fails', async () => {@@ -77,34 +91,28 @@ describe('VContentReportForm', () => {const { getByText } = render(VContentReportForm, options)await fireEvent.click(getMatureInput())- await fireEvent.click(getNextButton())+ await fireEvent.click(getReportButton())// Submission error message- getByText('photo-details.content-report.submission-error')- getByText('photo-details.content-report.back')+ getByText('media-details.content-report.failure.note')})- it('should render dmca notice', async () => {+ it('should render DMCA notice', async () => {const { getByText } = render(VContentReportForm, options)await fireEvent.click(getDmcaInput())- await fireEvent.click(getNextButton())// Notice with link to provider- getByText(/dmca/i)- getByText('photo-details.content-report.provider')+ getByText('media-details.content-report.form.dmca.note')+ getReportLink()})- it('should render other type form', async () => {- const { getByRole, getByText } = render(VContentReportForm, options)+ it('should render other description form', async () => {+ const { getByText } = render(VContentReportForm, options)await fireEvent.click(getOtherInput())- await fireEvent.click(getNextButton())// Report form with a submit button- getByText('photo-details.content-report.issue-description')- getByRole('textbox', {- name: /description/i,- })- getByRole('button', { name: 'photo-details.content-report.submit' })+ getByText('media-details.content-report.form.other.note')+ getDescriptionTextarea()})it('should dispatch SEND_CONTENT_REPORT on next when mature is selected', async () => {@@ -112,39 +120,28 @@ describe('VContentReportForm', () => {options.propsData.reportService = serviceMockrender(VContentReportForm, options)await fireEvent.click(getMatureInput())- await fireEvent.click(getNextButton())+ await fireEvent.click(getReportButton())expect(serviceMock.sendReport).toHaveBeenCalledWith({- identifier: props.image.id,+ identifier: props.media.identifier,reason: 'mature',description: '',})})- it('should not dispatch SEND_CONTENT_REPORT on next when dmca is selected', async () => {- const serviceMock = { sendReport: jest.fn() }- options.propsData.reportService = serviceMock-- render(VContentReportForm, options)- await fireEvent.click(getDmcaInput())- await fireEvent.click(getNextButton())-- expect(serviceMock.sendReport).toBeCalledTimes(0)- })-it('should dispatch SEND_CONTENT_REPORT on other form submit', async () => {const serviceMock = { sendReport: jest.fn() }options.propsData.reportService = serviceMock- const { getByRole } = render(VContentReportForm, options)+ render(VContentReportForm, options)await fireEvent.click(getOtherInput())- await fireEvent.click(getNextButton())const description = 'description that has more than 20 characters'- await fireEvent.update(getByRole('textbox'), description)- await fireEvent.click(getByRole('button', { name: /submit/i }))+ await fireEvent.update(getDescriptionTextarea(), description)++ await fireEvent.click(getReportButton())expect(serviceMock.sendReport).toHaveBeenCalledWith({- identifier: props.image.id,+ identifier: props.media.identifier,reason: 'other',description,})@@ -153,21 +150,10 @@ describe('VContentReportForm', () => {it('should not send other report if description is short', async () => {options.propsData.reportService = { sendReport: jest.fn() }- const { getByRole } = render(VContentReportForm, options)+ render(VContentReportForm, options)await fireEvent.click(getOtherInput())- await fireEvent.click(getNextButton())-- const description = 'short'- await fireEvent.update(getByRole('textbox'), description)-- expect(getByRole('button', { name: /submit/i })).toBeDisabled()- // Even though the button is disabled, if we `fireEvent.click`, the report- // in this test is sent- // expect(serviceMock.sendReport).toHaveBeenCalledWith({- // identifier: props.image.id,- // reason: 'other',- // description,- // })+ const description = 'less than 20 chars'+ await fireEvent.update(getDescriptionTextarea(), description)})})diff --git a/test/unit/specs/components/v-checkbox.spec.js b/test/unit/specs/components/v-checkbox.spec.jsindex 40bfe4f99..2d5f4385d 100644--- a/test/unit/specs/components/v-checkbox.spec.js+++ b/test/unit/specs/components/v-checkbox.spec.js@@ -1,6 +1,6 @@import Vue from 'vue'import { fireEvent, render, screen } from '@testing-library/vue'-import VCheckbox from '~/components/VCheckbox'+import VCheckbox from '~/components/VCheckbox/VCheckbox'import VLicense from '~/components/License/VLicense'const TestWrapperStringLabel = ({