From d6237dfc596558f503ed63a0b45f43a6797fe16d Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Sun, 1 Mar 2020 17:47:08 +0530 Subject: [PATCH] Feature: Add UI to update email notification preferences (#579) --- .../specs/userNotificationSettings.spec.js | 13 ++ .../dashboard/api/userNotificationSettings.js | 14 +++ .../dashboard/i18n/locale/en/settings.json | 8 ++ .../settings/profile/EmailNotifications.vue | 114 ++++++++++++++++++ .../dashboard/settings/profile/Index.vue | 6 +- app/javascript/dashboard/store/index.js | 4 +- .../userNotificationSettings/actions.spec.js | 69 +++++++++++ .../userNotificationSettings/getters.spec.js | 33 +++++ .../mutations.spec.js | 30 +++++ .../store/modules/userNotificationSettings.js | 77 ++++++++++++ .../dashboard/store/mutation-types.js | 4 + 11 files changed, 369 insertions(+), 3 deletions(-) create mode 100644 app/javascript/dashboard/api/specs/userNotificationSettings.spec.js create mode 100644 app/javascript/dashboard/api/userNotificationSettings.js create mode 100644 app/javascript/dashboard/routes/dashboard/settings/profile/EmailNotifications.vue create mode 100644 app/javascript/dashboard/store/modules/specs/userNotificationSettings/actions.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/userNotificationSettings/getters.spec.js create mode 100644 app/javascript/dashboard/store/modules/specs/userNotificationSettings/mutations.spec.js create mode 100644 app/javascript/dashboard/store/modules/userNotificationSettings.js diff --git a/app/javascript/dashboard/api/specs/userNotificationSettings.spec.js b/app/javascript/dashboard/api/specs/userNotificationSettings.spec.js new file mode 100644 index 000000000..f65f1c3a3 --- /dev/null +++ b/app/javascript/dashboard/api/specs/userNotificationSettings.spec.js @@ -0,0 +1,13 @@ +import userNotificationSettings from '../userNotificationSettings'; +import ApiClient from '../ApiClient'; + +describe('#AgentAPI', () => { + it('creates correct instance', () => { + expect(userNotificationSettings).toBeInstanceOf(ApiClient); + expect(userNotificationSettings).toHaveProperty('get'); + expect(userNotificationSettings).toHaveProperty('show'); + expect(userNotificationSettings).toHaveProperty('create'); + expect(userNotificationSettings).toHaveProperty('update'); + expect(userNotificationSettings).toHaveProperty('delete'); + }); +}); diff --git a/app/javascript/dashboard/api/userNotificationSettings.js b/app/javascript/dashboard/api/userNotificationSettings.js new file mode 100644 index 000000000..15cea8942 --- /dev/null +++ b/app/javascript/dashboard/api/userNotificationSettings.js @@ -0,0 +1,14 @@ +/* global axios */ +import ApiClient from './ApiClient'; + +class UserNotificationSettings extends ApiClient { + constructor() { + super('user/notification_settings'); + } + + update(params) { + return axios.patch(`${this.url}`, params); + } +} + +export default new UserNotificationSettings(); diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index 858fc7e0e..683490afe 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -18,6 +18,14 @@ "TITLE": "Password", "NOTE": "Updating your password would reset your logins in multiple devices." }, + "EMAIL_NOTIFICATIONS_SECTION" : { + "TITLE": "Email Notifications", + "NOTE": "Update your email notification preferences here", + "CONVERSATION_ASSIGNMENT": "Send email notifications when a conversation is assigned to me", + "CONVERSATION_CREATION": "Send email notifications when a new conversation is created", + "UPDATE_SUCCESS": "Your email notification preferences are updated successfully", + "UPDATE_ERROR": "There is an error while updating the preferences, please try again" + }, "PROFILE_IMAGE":{ "LABEL": "Profile Image" }, diff --git a/app/javascript/dashboard/routes/dashboard/settings/profile/EmailNotifications.vue b/app/javascript/dashboard/routes/dashboard/settings/profile/EmailNotifications.vue new file mode 100644 index 000000000..b4053745c --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/profile/EmailNotifications.vue @@ -0,0 +1,114 @@ + + + + + diff --git a/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue index 088da8a00..d3f98739e 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/profile/Index.vue @@ -82,7 +82,7 @@ - + -