diff --git a/changes/changelog.d/859.enhancement b/changes/changelog.d/859.enhancement new file mode 100644 index 0000000000000000000000000000000000000000..91c16ddafd9d59f5671d0dcf74e669534b12df1a --- /dev/null +++ b/changes/changelog.d/859.enhancement @@ -0,0 +1 @@ +Added ability to reject library follows from notifications screen (#859) \ No newline at end of file diff --git a/front/src/components/notifications/NotificationRow.vue b/front/src/components/notifications/NotificationRow.vue index 95f8e36440f486d1e7916b813a2301639e3efbd8..047c7b999db505cd88a356f3510f8db337d2f67b 100644 --- a/front/src/components/notifications/NotificationRow.vue +++ b/front/src/components/notifications/NotificationRow.vue @@ -8,10 +8,14 @@ </router-link> <template v-else v-html="notificationData.message"></template> - <template v-if="notificationData.action"> - <div @click="handleAction(notificationData.action.handler)" :class="['ui', 'basic', 'tiny', notificationData.action.buttonClass || '', 'button']"> - <i v-if="notificationData.action.icon" :class="[notificationData.action.icon, 'icon']" /> - {{ notificationData.action.label }} + <template v-if="notificationData.acceptFollow"> + <div @click="handleAction(notificationData.acceptFollow.handler)" :class="['ui', 'basic', 'tiny', notificationData.acceptFollow.buttonClass || '', 'button']"> + <i v-if="notificationData.acceptFollow.icon" :class="[notificationData.acceptFollow.icon, 'icon']" /> + {{ notificationData.acceptFollow.label }} + </div> + <div @click="handleAction(notificationData.rejectFollow.handler)" :class="['ui', 'basic', 'tiny', notificationData.rejectFollow.buttonClass || '', 'button']"> + <i v-if="notificationData.rejectFollow.icon" :class="[notificationData.rejectFollow.icon, 'icon']" /> + {{ notificationData.rejectFollow.label }} </div> </template> </td> @@ -38,10 +42,12 @@ export default { labels () { let libraryFollowMessage = this.$pgettext('Content/Notifications/Paragraph', '%{ username } followed your library "%{ library }"') let libraryAcceptFollowMessage = this.$pgettext('Content/Notifications/Paragraph', '%{ username } accepted your follow on library "%{ library }"') + let libraryRejectMessage = this.$pgettext('Content/Notifications/Paragraph', 'You rejected %{ username }'s request to follow "%{ library }"') let libraryPendingFollowMessage = this.$pgettext('Content/Notifications/Paragraph', '%{ username } wants to follow your library "%{ library }"') return { libraryFollowMessage, libraryAcceptFollowMessage, + libraryRejectMessage, libraryPendingFollowMessage, markRead: this.$pgettext('Content/Notifications/Button.Tooltip/Verb', 'Mark as read'), markUnread: this.$pgettext('Content/Notifications/Button.Tooltip/Verb', 'Mark as unread'), @@ -56,21 +62,31 @@ export default { let a = this.item.activity if (a.type === 'Follow') { if (a.object && a.object.type === 'music.Library') { - let action = null + let acceptFollow = null + let rejectFollow = null let message = null - if (!a.related_object.approved) { + if (a.related_object.approved === null) { message = this.labels.libraryPendingFollowMessage - action = { + acceptFollow = { buttonClass: 'green', icon: 'check', label: this.$pgettext('Content/*/Button.Label/Verb', 'Approve'), handler: () => { self.approveLibraryFollow(a.related_object) } + }, + rejectFollow = { + buttonClass: 'red', + icon: 'x', + label: this.$pgettext('Content/*/Button.Label/Verb', 'Reject'), + handler: () => { self.rejectLibraryFollow(a.related_object) } } - } else { + } else if (a.related_object.approved) { message = this.labels.libraryFollowMessage + } else { + message = this.labels.libraryRejectMessage } return { - action, + acceptFollow, + rejectFollow, detailUrl: {name: 'content.libraries.detail', params: {id: a.object.uuid}}, message: this.$gettextInterpolate( message, @@ -107,6 +123,14 @@ export default { follow.approved = true }) }, + rejectLibraryFollow (follow) { + let self = this + let action = 'reject' + axios.post(`federation/follows/library/${follow.uuid}/${action}/`).then((response) => { + follow.isLoading = false + follow.approved = false + }) + }, markRead (value) { let self = this let action = 'accept'