From a72bbf2f583197af22af12e27e461c31501fa245 Mon Sep 17 00:00:00 2001 From: Awais Ansari Date: Thu, 3 Aug 2023 16:15:47 +0500 Subject: [PATCH 1/4] feat: remove other channels then web preferences --- src/index.scss | 30 ++++---- .../NotificationPreferenceApp.jsx | 8 +-- .../NotificationPreferenceRow.jsx | 70 +++++++++---------- .../NotificationPreferences.jsx | 4 +- src/notification-preferences/messages.js | 8 +-- 5 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/index.scss b/src/index.scss index 9e590df..b8b07d1 100755 --- a/src/index.scss +++ b/src/index.scss @@ -69,20 +69,26 @@ $fa-font-path: "~font-awesome/fonts"; font-size: 32px; } -.notification-course-title { - line-height: 28px; - font-weight: 700; - font-size: 18px; -} - .px-2\.25 { padding-left: 0.625rem; } -.notification-help-text { - font-size: 14px; - font-weight: 400; - line-height: 28px; - height: 28px; - color: #707070; +.notification-preferences { + input[type="checkbox"] { + margin-right: 0; + } + + .header-label { + font-size: 14px; + font-weight: 400; + line-height: 28px; + height: 28px; + color: #707070; + } + + .notification-course-title { + line-height: 28px; + font-weight: 700; + font-size: 18px; + } } diff --git a/src/notification-preferences/NotificationPreferenceApp.jsx b/src/notification-preferences/NotificationPreferenceApp.jsx index bd106c6..0b5d1e6 100644 --- a/src/notification-preferences/NotificationPreferenceApp.jsx +++ b/src/notification-preferences/NotificationPreferenceApp.jsx @@ -55,12 +55,10 @@ const NotificationPreferenceApp = ({ appId }) => {
-
- {intl.formatMessage(messages.notificationHelpType)} +
+ {intl.formatMessage(messages.typeLabel)} - {intl.formatMessage(messages.notificationHelpWeb)} - {intl.formatMessage(messages.notificationHelpEmail)} - {intl.formatMessage(messages.notificationHelpPush)} + {intl.formatMessage(messages.webLabel)}
diff --git a/src/notification-preferences/NotificationPreferenceRow.jsx b/src/notification-preferences/NotificationPreferenceRow.jsx index 4276623..c76192c 100644 --- a/src/notification-preferences/NotificationPreferenceRow.jsx +++ b/src/notification-preferences/NotificationPreferenceRow.jsx @@ -41,45 +41,41 @@ const NotificationPreferenceRow = ({ appId, preferenceName }) => {
{intl.formatMessage(messages.notificationTitle, { text: preferenceName })} - { - preference.info !== '' && ( - - {preference.info} - - )} - > - - - - - ) - } + {preference.info !== '' && ( + + {preference.info} + + )} + > + + + + + )} - { - ['web', 'email', 'push'].map((channel) => ( - - - - )) - } + {['web'].map((channel) => ( + + + + ))}
); diff --git a/src/notification-preferences/NotificationPreferences.jsx b/src/notification-preferences/NotificationPreferences.jsx index b388de8..28b9f9d 100644 --- a/src/notification-preferences/NotificationPreferences.jsx +++ b/src/notification-preferences/NotificationPreferences.jsx @@ -56,14 +56,14 @@ const NotificationPreferences = () => { } return ( - +

{intl.formatMessage(messages.notificationHeading)}

- + {course?.name} diff --git a/src/notification-preferences/messages.js b/src/notification-preferences/messages.js index e12ac5a..963a056 100644 --- a/src/notification-preferences/messages.js +++ b/src/notification-preferences/messages.js @@ -33,13 +33,13 @@ export const messages = defineMessages({ }`, description: 'Display text for Notification Types', }, - notificationHelpType: { - id: 'notification.preference.help.type', + typeLabel: { + id: 'notification.preference.type.label', defaultMessage: 'Type', description: 'Display text for type', }, - notificationHelpWeb: { - id: 'notification.preference.help.web', + webLabel: { + id: 'notification.preference.web,label', defaultMessage: 'Web', description: 'Display text for web', }, From e8f754c10b66fffc99fd505ab031c2edea4156d3 Mon Sep 17 00:00:00 2001 From: Awais Ansari Date: Thu, 3 Aug 2023 18:01:13 +0500 Subject: [PATCH 2/4] style: update the notification preferences page style according to figma --- .../NotificationPreferenceApp.jsx | 10 +++++----- .../NotificationPreferenceRow.jsx | 15 ++++++++------- .../NotificationPreferences.jsx | 6 +++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/notification-preferences/NotificationPreferenceApp.jsx b/src/notification-preferences/NotificationPreferenceApp.jsx index 0b5d1e6..389ccf2 100644 --- a/src/notification-preferences/NotificationPreferenceApp.jsx +++ b/src/notification-preferences/NotificationPreferenceApp.jsx @@ -40,11 +40,11 @@ const NotificationPreferenceApp = ({ appId }) => { return ( -
- +
+ {intl.formatMessage(messages.notificationAppTitle, { key: appId })} - + { />
-
+
@@ -61,7 +61,7 @@ const NotificationPreferenceApp = ({ appId }) => { {intl.formatMessage(messages.webLabel)}
-
+
{ preferences }
diff --git a/src/notification-preferences/NotificationPreferenceRow.jsx b/src/notification-preferences/NotificationPreferenceRow.jsx index c76192c..e5f9055 100644 --- a/src/notification-preferences/NotificationPreferenceRow.jsx +++ b/src/notification-preferences/NotificationPreferenceRow.jsx @@ -38,8 +38,8 @@ const NotificationPreferenceRow = ({ appId, preferenceName }) => { const tooltipId = `${preferenceName}-tooltip`; return ( -
- +
+
{intl.formatMessage(messages.notificationTitle, { text: preferenceName })} {preference.info !== '' && ( { )} - - +
+
{['web'].map((channel) => ( - { onChange={onToggle} disabled={nonEditable.includes(channel)} /> - +
))} - +
); }; diff --git a/src/notification-preferences/NotificationPreferences.jsx b/src/notification-preferences/NotificationPreferences.jsx index 28b9f9d..c558fdc 100644 --- a/src/notification-preferences/NotificationPreferences.jsx +++ b/src/notification-preferences/NotificationPreferences.jsx @@ -61,11 +61,11 @@ const NotificationPreferences = () => { {intl.formatMessage(messages.notificationHeading)}
-
+
- + - + {course?.name}
From de6e3c20106a43bdd3865dba21b83665ef614131 Mon Sep 17 00:00:00 2001 From: Awais Ansari Date: Fri, 4 Aug 2023 15:54:11 +0500 Subject: [PATCH 3/4] feat: add feedback widget for notification preferences --- public/index.html | 151 ++++++++++++++++-- .../FeedbackWrapper.jsx | 13 ++ .../NotificationPreferences.jsx | 2 + 3 files changed, 156 insertions(+), 10 deletions(-) create mode 100644 src/notification-preferences/FeedbackWrapper.jsx diff --git a/public/index.html b/public/index.html index 4b27b1f..9847191 100755 --- a/public/index.html +++ b/public/index.html @@ -1,17 +1,148 @@ - + - Account | <%= process.env.SITE_NAME %> - - - - <% if (process.env.OPTIMIZELY_PROJECT_ID) { %> - - <% } %> + Account | <%= process.env.SITE_NAME %> + + + + <% if (process.env.OPTIMIZELY_PROJECT_ID) { %> + + <% } %> + + +
diff --git a/src/notification-preferences/FeedbackWrapper.jsx b/src/notification-preferences/FeedbackWrapper.jsx new file mode 100644 index 0000000..44e6795 --- /dev/null +++ b/src/notification-preferences/FeedbackWrapper.jsx @@ -0,0 +1,13 @@ +/* eslint-disable no-undef */ +import { useEffect } from 'react'; +import { logError } from '@edx/frontend-platform/logging'; + +export default function useFeedbackWrapper() { + useEffect(() => { + try { + window.usabilla_live = lightningjs.require('usabilla_live', '//w.usabilla.com/2655de034958.js'); + } catch (err) { + logError(err); + } + }, []); +} diff --git a/src/notification-preferences/NotificationPreferences.jsx b/src/notification-preferences/NotificationPreferences.jsx index c558fdc..869ed67 100644 --- a/src/notification-preferences/NotificationPreferences.jsx +++ b/src/notification-preferences/NotificationPreferences.jsx @@ -22,8 +22,10 @@ import { SUCCESS_STATUS, } from '../constants'; import { NotFoundPage } from '../account-settings'; +import useFeedbackWrapper from './FeedbackWrapper'; const NotificationPreferences = () => { + useFeedbackWrapper(); const { courseId } = useParams(); const dispatch = useDispatch(); const intl = useIntl(); From 7f8086545c59bdcbfc2028636d5b0e8b247f2892 Mon Sep 17 00:00:00 2001 From: Awais Ansari Date: Mon, 7 Aug 2023 15:00:05 +0500 Subject: [PATCH 4/4] test: define lightningjs in window object --- src/hooks.js | 12 ++++++++++++ src/notification-preferences/FeedbackWrapper.jsx | 13 ------------- .../NotificationPreferences.jsx | 2 +- .../NotificationPreferences.test.jsx | 1 + 4 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 src/notification-preferences/FeedbackWrapper.jsx diff --git a/src/hooks.js b/src/hooks.js index 69dd638..5731997 100644 --- a/src/hooks.js +++ b/src/hooks.js @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { logError } from '@edx/frontend-platform/logging'; import { IDLE_STATUS, LOADING_STATUS, SUCCESS_STATUS, FAILURE_STATUS, @@ -53,3 +54,14 @@ export function useRedirect() { return redirect; } + +export function useFeedbackWrapper() { + useEffect(() => { + try { + // eslint-disable-next-line no-undef + window.usabilla_live = lightningjs?.require('usabilla_live', '//w.usabilla.com/2655de034958.js'); + } catch (error) { + logError('Error loading usabilla_live', error); + } + }, []); +} diff --git a/src/notification-preferences/FeedbackWrapper.jsx b/src/notification-preferences/FeedbackWrapper.jsx deleted file mode 100644 index 44e6795..0000000 --- a/src/notification-preferences/FeedbackWrapper.jsx +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint-disable no-undef */ -import { useEffect } from 'react'; -import { logError } from '@edx/frontend-platform/logging'; - -export default function useFeedbackWrapper() { - useEffect(() => { - try { - window.usabilla_live = lightningjs.require('usabilla_live', '//w.usabilla.com/2655de034958.js'); - } catch (err) { - logError(err); - } - }, []); -} diff --git a/src/notification-preferences/NotificationPreferences.jsx b/src/notification-preferences/NotificationPreferences.jsx index 869ed67..51b003d 100644 --- a/src/notification-preferences/NotificationPreferences.jsx +++ b/src/notification-preferences/NotificationPreferences.jsx @@ -22,7 +22,7 @@ import { SUCCESS_STATUS, } from '../constants'; import { NotFoundPage } from '../account-settings'; -import useFeedbackWrapper from './FeedbackWrapper'; +import { useFeedbackWrapper } from '../hooks'; const NotificationPreferences = () => { useFeedbackWrapper(); diff --git a/src/notification-preferences/NotificationPreferences.test.jsx b/src/notification-preferences/NotificationPreferences.test.jsx index e709c06..c358b66 100644 --- a/src/notification-preferences/NotificationPreferences.test.jsx +++ b/src/notification-preferences/NotificationPreferences.test.jsx @@ -109,6 +109,7 @@ describe('Notification Preferences', () => { }), })); auth.getAuthenticatedUser = jest.fn(() => ({ userId: 3 })); + window.lightningjs = null; }); afterEach(() => jest.clearAllMocks());