From 0763cc477f7ef0d8e7be41d6cc33ca759d28d876 Mon Sep 17 00:00:00 2001 From: iamsivin Date: Mon, 12 Feb 2024 13:05:47 +0530 Subject: [PATCH] chore: Add snooze --- .../routes/dashboard/inbox/InboxList.vue | 13 ++++--- .../routes/dashboard/inbox/InboxView.vue | 35 ++++++++++++------- .../dashboard/inbox/components/InboxCard.vue | 28 ++++++++++++++- 3 files changed, 59 insertions(+), 17 deletions(-) diff --git a/app/javascript/dashboard/routes/dashboard/inbox/InboxList.vue b/app/javascript/dashboard/routes/dashboard/inbox/InboxList.vue index c4d5d87e9..857b52ef2 100644 --- a/app/javascript/dashboard/routes/dashboard/inbox/InboxList.vue +++ b/app/javascript/dashboard/routes/dashboard/inbox/InboxList.vue @@ -4,7 +4,7 @@ :class="isOnExpandedLayout ? '' : 'min-w-[360px] max-w-[360px]'" > @@ -19,8 +19,9 @@ @mark-notification-as-read="markNotificationAsRead" @mark-notification-as-unread="markNotificationAsUnRead" @delete-notification="deleteNotification" - @context-menu-open="isContextMenuOpen = true" - @context-menu-close="isContextMenuOpen = false" + @snooze-notification="openSnoozeNotificationModal" + @context-menu-open="isInboxContextMenuOpen = true" + @context-menu-close="isInboxContextMenuOpen = false" />
@@ -76,7 +77,7 @@ export default { status: '', type: '', sortOrder: wootConstants.INBOX_SORT_BY.NEWEST, - isContextMenuOpen: false, + isInboxContextMenuOpen: false, }; }, computed: { @@ -191,6 +192,10 @@ export default { this.type = type; this.sortOrder = sortBy || wootConstants.INBOX_SORT_BY.NEWEST; }, + openSnoozeNotificationModal() { + const ninja = document.querySelector('ninja-keys'); + ninja.open({ parent: 'snooze_notification' }); + }, }, }; diff --git a/app/javascript/dashboard/routes/dashboard/inbox/InboxView.vue b/app/javascript/dashboard/routes/dashboard/inbox/InboxView.vue index cbc473ac4..7926c2540 100644 --- a/app/javascript/dashboard/routes/dashboard/inbox/InboxView.vue +++ b/app/javascript/dashboard/routes/dashboard/inbox/InboxView.vue @@ -17,7 +17,11 @@ @next="onClickNext" @prev="onClickPrev" /> +
+ +
{ diff --git a/app/javascript/dashboard/routes/dashboard/inbox/components/InboxCard.vue b/app/javascript/dashboard/routes/dashboard/inbox/components/InboxCard.vue index f61e8680d..65f5ed4c9 100644 --- a/app/javascript/dashboard/routes/dashboard/inbox/components/InboxCard.vue +++ b/app/javascript/dashboard/routes/dashboard/inbox/components/InboxCard.vue @@ -89,6 +89,7 @@ export default { return { isContextMenuOpen: false, contextMenuPosition: { x: null, y: null }, + activeNotificationId: null, }; }, computed: { @@ -96,7 +97,9 @@ export default { return this.notificationItem?.primary_actor; }, isInboxCardActive() { - return this.$route.params.conversation_id === this.primaryActor?.id; + return ( + Number(this.activeNotificationId) === Number(this.notificationItem?.id) + ); }, inbox() { return this.$store.getters['inboxes/getInbox']( @@ -109,6 +112,12 @@ export default { meta() { return this.primaryActor?.meta; }, + isNotSnoozed() { + return ( + !this.notificationItem?.snoozed_until && + this.$route.params.notification_id + ); + }, assigneeMeta() { return this.meta?.assignee; }, @@ -131,6 +140,12 @@ export default { }, ]; + if (this.isNotSnoozed) { + items.push({ + key: 'snooze', + label: this.$t('INBOX.MENU_ITEM.SNOOZE'), + }); + } if (!this.isUnread) { items.push({ key: 'mark_as_unread', @@ -157,6 +172,14 @@ export default { return ''; }, }, + watch: { + '$route.params.notification_id': { + immediate: true, + handler(newVal) { + this.activeNotificationId = newVal; + }, + }, + }, unmounted() { this.closeContextMenu(); }, @@ -214,6 +237,9 @@ export default { case 'delete': this.$emit('delete-notification', this.notificationItem); break; + case 'snooze': + this.$emit('snooze-notification', this.notificationItem); + break; default: } },