2022-07-20 22:44:19 +00:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { BackendError } from '~/types'
|
|
|
|
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
import { useGettext } from 'vue3-gettext'
|
|
|
|
import { useStore } from '~/store'
|
|
|
|
|
|
|
|
import SemanticModal from '~/components/semantic/Modal.vue'
|
|
|
|
import useLogger from '~/composables/useLogger'
|
|
|
|
|
|
|
|
|
|
|
|
const logger = useLogger()
|
|
|
|
const { $pgettext } = useGettext()
|
|
|
|
|
|
|
|
const store = useStore()
|
|
|
|
const show = computed({
|
|
|
|
get: () => store.state.moderation.showFilterModal,
|
|
|
|
set: (value) => {
|
|
|
|
store.commit('moderation/showFilterModal', value)
|
|
|
|
errors.value = []
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const type = computed(() => store.state.moderation.filterModalTarget.type)
|
|
|
|
const target = computed(() => store.state.moderation.filterModalTarget.target)
|
|
|
|
|
|
|
|
const errors = ref([] as string[])
|
|
|
|
const isLoading = ref(false)
|
|
|
|
|
|
|
|
const hide = async () => {
|
|
|
|
isLoading.value = true
|
|
|
|
|
|
|
|
const payload = {
|
|
|
|
target: {
|
|
|
|
type: type.value,
|
|
|
|
id: target.value?.id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
const response = await axios.post('moderation/content-filters/', payload)
|
|
|
|
logger.info(`Successfully hidden ${type.value} ${target.value?.id}`)
|
|
|
|
show.value = false
|
|
|
|
store.state.moderation.lastUpdate = new Date()
|
|
|
|
store.commit('moderation/contentFilter', response.data)
|
|
|
|
store.commit('ui/addMessage', {
|
|
|
|
content: $pgettext('*/Moderation/Message', 'Content filter successfully added'),
|
|
|
|
date: new Date()
|
|
|
|
})
|
|
|
|
} catch (error) {
|
|
|
|
logger.error(`Error while hiding ${type.value} ${target.value?.id}`)
|
|
|
|
errors.value = (error as BackendError).backendErrors
|
|
|
|
}
|
|
|
|
|
|
|
|
isLoading.value = false
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2019-02-14 09:49:06 +00:00
|
|
|
<template>
|
2022-07-20 22:44:19 +00:00
|
|
|
<semantic-modal v-model:show="show">
|
2020-07-03 12:20:47 +00:00
|
|
|
<h4 class="header">
|
2019-02-14 09:49:06 +00:00
|
|
|
<translate
|
|
|
|
v-if="type === 'artist'"
|
2019-03-08 11:37:02 +00:00
|
|
|
translate-context="Popup/Moderation/Title/Verb"
|
2022-07-20 22:44:19 +00:00
|
|
|
:translate-params="{name: target?.name}"
|
2021-12-06 10:35:20 +00:00
|
|
|
>
|
|
|
|
Do you want to hide content from artist "%{ name }"?
|
|
|
|
</translate>
|
2020-07-03 12:20:47 +00:00
|
|
|
</h4>
|
2019-02-14 09:49:06 +00:00
|
|
|
<div class="scrolling content">
|
|
|
|
<div class="description">
|
2021-12-06 10:35:20 +00:00
|
|
|
<div
|
|
|
|
v-if="errors.length > 0"
|
|
|
|
role="alert"
|
|
|
|
class="ui negative message"
|
|
|
|
>
|
|
|
|
<h4 class="header">
|
|
|
|
<translate translate-context="Popup/Moderation/Error message">
|
|
|
|
Error while creating filter
|
|
|
|
</translate>
|
|
|
|
</h4>
|
2019-02-14 09:49:06 +00:00
|
|
|
<ul class="list">
|
2021-12-06 10:35:20 +00:00
|
|
|
<li
|
|
|
|
v-for="(error, key) in errors"
|
|
|
|
:key="key"
|
|
|
|
>
|
|
|
|
{{ error }}
|
|
|
|
</li>
|
2019-02-14 09:49:06 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<template v-if="type === 'artist'">
|
|
|
|
<p>
|
2019-03-08 11:37:02 +00:00
|
|
|
<translate translate-context="Popup/Moderation/Paragraph">
|
2019-09-02 16:17:23 +00:00
|
|
|
You will not see tracks, albums and user activity linked to this artist any more:
|
2019-02-14 09:49:06 +00:00
|
|
|
</translate>
|
|
|
|
</p>
|
|
|
|
<ul>
|
2021-12-06 10:35:20 +00:00
|
|
|
<li>
|
|
|
|
<translate translate-context="Popup/Moderation/List item">
|
|
|
|
In other users favorites and listening history
|
|
|
|
</translate>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<translate translate-context="Popup/Moderation/List item">
|
|
|
|
In "Recently added" widget
|
|
|
|
</translate>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<translate translate-context="Popup/Moderation/List item">
|
|
|
|
In artists and album listings
|
|
|
|
</translate>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<translate translate-context="Popup/Moderation/List item">
|
|
|
|
In radio suggestions
|
|
|
|
</translate>
|
|
|
|
</li>
|
2019-02-14 09:49:06 +00:00
|
|
|
</ul>
|
|
|
|
<p>
|
2019-03-08 11:37:02 +00:00
|
|
|
<translate translate-context="Popup/Moderation/Paragraph">
|
2019-09-02 16:17:23 +00:00
|
|
|
You can manage and update your filters any time from your account settings.
|
2019-02-14 09:49:06 +00:00
|
|
|
</translate>
|
|
|
|
</p>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="actions">
|
2021-12-06 10:35:20 +00:00
|
|
|
<button class="ui basic cancel button">
|
|
|
|
<translate translate-context="*/*/Button.Label/Verb">
|
|
|
|
Cancel
|
|
|
|
</translate>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
:class="['ui', 'success', {loading: isLoading}, 'button']"
|
|
|
|
@click="hide"
|
|
|
|
>
|
|
|
|
<translate translate-context="Popup/*/Button.Label">
|
|
|
|
Hide content
|
|
|
|
</translate>
|
|
|
|
</button>
|
2019-02-14 09:49:06 +00:00
|
|
|
</div>
|
2022-07-20 22:44:19 +00:00
|
|
|
</semantic-modal>
|
2019-02-14 09:49:06 +00:00
|
|
|
</template>
|