refactor(front): notifications
This commit is contained in:
parent
00e5c4dc14
commit
5df9e6ab30
|
@ -9,6 +9,11 @@ import { useStore } from '~/store'
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
|
import Alert from '~/components/ui/Alert.vue'
|
||||||
|
import Button from '~/components/ui/Button.vue'
|
||||||
|
import Layout from '~/components/ui/Layout.vue'
|
||||||
|
import Spacer from '~/components/ui/Spacer.vue'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
initialItem: Notification
|
initialItem: Notification
|
||||||
}
|
}
|
||||||
|
@ -79,13 +84,13 @@ const notificationData = computed(() => {
|
||||||
user: activity.object.target?.full_username }),
|
user: activity.object.target?.full_username }),
|
||||||
acceptFollow: {
|
acceptFollow: {
|
||||||
buttonClass: 'success',
|
buttonClass: 'success',
|
||||||
icon: 'check',
|
icon: 'bi-check',
|
||||||
label: t('components.notifications.NotificationRow.button.approve'),
|
label: t('components.notifications.NotificationRow.button.approve'),
|
||||||
handler: () => approveUserFollow(userFollow)
|
handler: () => approveUserFollow(userFollow)
|
||||||
},
|
},
|
||||||
rejectFollow: {
|
rejectFollow: {
|
||||||
buttonClass: 'danger',
|
buttonClass: 'danger',
|
||||||
icon: 'x',
|
icon: 'bi-x',
|
||||||
label: t('components.notifications.NotificationRow.button.reject'),
|
label: t('components.notifications.NotificationRow.button.reject'),
|
||||||
handler: () => rejectUserFollow(userFollow)
|
handler: () => rejectUserFollow(userFollow)
|
||||||
}
|
}
|
||||||
|
@ -175,14 +180,19 @@ const rejectUserFollow = async (follow: components["schemas"]["Follow"]) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<tr :class="[{'disabled-row': item.is_read}]">
|
<Alert
|
||||||
<td>
|
:class="[{'disabled-row': item.is_read}]"
|
||||||
|
:green="item.is_read"
|
||||||
|
:yellow="!item.is_read"
|
||||||
|
>
|
||||||
|
<Layout
|
||||||
|
flex
|
||||||
|
gap-8
|
||||||
|
>
|
||||||
<actor-link
|
<actor-link
|
||||||
class="user"
|
class="user"
|
||||||
:actor="item.activity.actor"
|
:actor="item.activity.actor"
|
||||||
/>
|
/>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<!-- TODO: Make sure `notificationData.detailUrl` has a type that satisfies `RouteLocationRaw` -->
|
<!-- TODO: Make sure `notificationData.detailUrl` has a type that satisfies `RouteLocationRaw` -->
|
||||||
<!-- @vue-ignore -->
|
<!-- @vue-ignore -->
|
||||||
<router-link
|
<router-link
|
||||||
|
@ -203,52 +213,53 @@ const rejectUserFollow = async (follow: components["schemas"]["Follow"]) => {
|
||||||
v-else
|
v-else
|
||||||
:html="notificationData.message"
|
:html="notificationData.message"
|
||||||
/>
|
/>
|
||||||
<template v-if="notificationData.acceptFollow">
|
<Spacer grow />
|
||||||
|
<human-date :date="item.activity.creation_date" />
|
||||||
<button
|
<Button
|
||||||
:class="['ui', 'basic', 'tiny', notificationData.acceptFollow.buttonClass || '', 'button']"
|
|
||||||
@click="handleAction(notificationData.acceptFollow?.handler)"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
v-if="notificationData.acceptFollow.icon"
|
|
||||||
:class="[notificationData.acceptFollow.icon, 'icon']"
|
|
||||||
/>
|
|
||||||
{{ notificationData.acceptFollow.label }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
:class="['ui', 'basic', 'tiny', notificationData.rejectFollow.buttonClass || '', 'button']"
|
|
||||||
@click="handleAction(notificationData.rejectFollow?.handler)"
|
|
||||||
>
|
|
||||||
<i
|
|
||||||
v-if="notificationData.rejectFollow.icon"
|
|
||||||
:class="[notificationData.rejectFollow.icon, 'icon']"
|
|
||||||
/>
|
|
||||||
{{ notificationData.rejectFollow.label }}
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
</td>
|
|
||||||
<td><human-date :date="item.activity.creation_date" /></td>
|
|
||||||
<td class="read collapsing">
|
|
||||||
<a
|
|
||||||
v-if="item.is_read"
|
v-if="item.is_read"
|
||||||
href=""
|
href=""
|
||||||
:aria-label="labels.markUnread"
|
:aria-label="labels.markUnread"
|
||||||
class="discrete link"
|
class="discrete link"
|
||||||
:title="labels.markUnread"
|
:title="labels.markUnread"
|
||||||
|
icon="bi-arrow-clockwise"
|
||||||
|
yellow
|
||||||
|
square-small
|
||||||
@click.prevent="read = false"
|
@click.prevent="read = false"
|
||||||
>
|
/>
|
||||||
<i class="redo icon" />
|
<Button
|
||||||
</a>
|
|
||||||
<a
|
|
||||||
v-else
|
v-else
|
||||||
href=""
|
href=""
|
||||||
:aria-label="labels.markRead"
|
:aria-label="labels.markRead"
|
||||||
class="discrete link"
|
class="discrete link"
|
||||||
:title="labels.markRead"
|
:title="labels.markRead"
|
||||||
|
icon="bi-check"
|
||||||
|
green
|
||||||
|
square-small
|
||||||
@click.prevent="read = true"
|
@click.prevent="read = true"
|
||||||
|
/>
|
||||||
|
</Layout>
|
||||||
|
<Spacer />
|
||||||
|
<template
|
||||||
|
v-if="notificationData.acceptFollow"
|
||||||
|
#actions
|
||||||
|
>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
:class="['ui', 'basic', 'tiny', notificationData.acceptFollow.buttonClass || '', 'button']"
|
||||||
|
:icon="notificationData.acceptFollow.icon"
|
||||||
|
green
|
||||||
|
@click="handleAction(notificationData.acceptFollow?.handler)"
|
||||||
>
|
>
|
||||||
<i class="check icon" />
|
{{ notificationData.acceptFollow.label }}
|
||||||
</a>
|
</Button>
|
||||||
</td>
|
<Button
|
||||||
</tr>
|
:class="['ui', 'basic', 'tiny', notificationData.rejectFollow.buttonClass || '', 'button']"
|
||||||
|
:icon="notificationData.rejectFollow.icon"
|
||||||
|
red
|
||||||
|
@click="handleAction(notificationData.rejectFollow?.handler)"
|
||||||
|
>
|
||||||
|
{{ notificationData.rejectFollow.label }}
|
||||||
|
</Button>
|
||||||
|
</template>
|
||||||
|
</Alert>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -20,7 +20,6 @@ import Header from '~/components/ui/Header.vue'
|
||||||
import Toggle from '~/components/ui/Toggle.vue'
|
import Toggle from '~/components/ui/Toggle.vue'
|
||||||
import Button from '~/components/ui/Button.vue'
|
import Button from '~/components/ui/Button.vue'
|
||||||
import Alert from '~/components/ui/Alert.vue'
|
import Alert from '~/components/ui/Alert.vue'
|
||||||
import Table from '~/components/ui/Table.vue'
|
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const supportMessage = useMarkdown(() => store.state.instance.settings.instance.support_message.value)
|
const supportMessage = useMarkdown(() => store.state.instance.settings.instance.support_message.value)
|
||||||
|
@ -248,8 +247,9 @@ const markAllAsRead = async () => {
|
||||||
|
|
||||||
<Loader v-if="isLoading" />
|
<Loader v-if="isLoading" />
|
||||||
|
|
||||||
<Table
|
<Layout
|
||||||
v-else-if="notifications.count > 0"
|
v-else-if="notifications.count > 0"
|
||||||
|
stack
|
||||||
:grid-template-columns="['auto', 'auto', 'auto', 'auto']"
|
:grid-template-columns="['auto', 'auto', 'auto', 'auto']"
|
||||||
>
|
>
|
||||||
<notification-row
|
<notification-row
|
||||||
|
@ -257,7 +257,7 @@ const markAllAsRead = async () => {
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:initial-item="item"
|
:initial-item="item"
|
||||||
/>
|
/>
|
||||||
</Table>
|
</Layout>
|
||||||
<p v-else-if="additionalNotifications === 0">
|
<p v-else-if="additionalNotifications === 0">
|
||||||
{{ t('views.Notifications.empty.notifications') }}
|
{{ t('views.Notifications.empty.notifications') }}
|
||||||
</p>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue