Skip to content

Commit

Permalink
Merge pull request #912 from openedx/aansari/code-refactoring
Browse files Browse the repository at this point in the history
refactor: removed disable eslint and created channels constant
  • Loading branch information
awais-ansari authored Oct 18, 2023
2 parents 966b59b + f866771 commit 9cccf09
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/notification-preferences/NotificationCourses.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
LOADING_STATUS,
SUCCESS_STATUS,
} from '../constants';
import { messages } from './messages';
import messages from './messages';
import { NotFoundPage } from '../account-settings';
import { useFeedbackWrapper } from '../hooks';

Expand Down
2 changes: 1 addition & 1 deletion src/notification-preferences/NotificationPreferenceApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
import { useIntl } from '@edx/frontend-platform/i18n';
import { Collapsible } from '@edx/paragon';
import { messages } from './messages';
import messages from './messages';
import ToggleSwitch from './ToggleSwitch';
import {
selectPreferenceAppToggleValue,
Expand Down
7 changes: 4 additions & 3 deletions src/notification-preferences/NotificationPreferenceRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import { useDispatch, useSelector } from 'react-redux';
import { useIntl } from '@edx/frontend-platform/i18n';
import { Icon, OverlayTrigger, Tooltip } from '@edx/paragon';
import { InfoOutline } from '@edx/paragon/icons';
import { messages } from './messages';
import messages from './messages';
import ToggleSwitch from './ToggleSwitch';
import {
selectPreference,
selectPreferenceNonEditableChannels,
selectSelectedCourseId,
selectNotificationPreferencesStatus,
} from './data/selectors';
import NOTIFICATION_CHANNELS from './data/constants';
import { updatePreferenceToggle } from './data/thunks';
import { LOADING_STATUS } from '../constants';

Expand Down Expand Up @@ -53,7 +54,7 @@ const NotificationPreferenceRow = ({ appId, preferenceName }) => {
<Tooltip id={tooltipId}>
{preference.info}
</Tooltip>
)}
)}
>
<span className="ml-2">
<Icon src={InfoOutline} />
Expand All @@ -62,7 +63,7 @@ const NotificationPreferenceRow = ({ appId, preferenceName }) => {
)}
</div>
<div className="d-flex align-items-center">
{['web'].map((channel) => (
{NOTIFICATION_CHANNELS.map((channel) => (
<div
id={`${preferenceName}-${channel}`}
className={classNames(
Expand Down
22 changes: 11 additions & 11 deletions src/notification-preferences/NotificationPreferences.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
selectCourseList,
} from './data/selectors';
import { fetchCourseList, fetchCourseNotificationPreferences } from './data/thunks';
import { messages } from './messages';
import messages from './messages';
import NotificationPreferenceApp from './NotificationPreferenceApp';
import {
FAILURE_STATUS,
Expand Down Expand Up @@ -67,7 +67,7 @@ const NotificationPreferences = () => {
destination="https://edx.readthedocs.io/projects/open-edx-learner-guide/en/latest/sfd_notifications/managing_notifications.html"
target="_blank"
rel="noopener noreferrer"
className="text-decoration-underline"
className="text-decoration-underline ml-1"
>
{intl.formatMessage(messages.notificationPreferenceGuideLink)}
</Hyperlink>
Expand All @@ -83,15 +83,15 @@ const NotificationPreferences = () => {
</div>
{preferencesList}
{isLoading && (
<div className="d-flex">
<Spinner
variant="primary"
animation="border"
className="mx-auto my-auto"
size="lg"
data-testid="loading-spinner"
/>
</div>
<div className="d-flex">
<Spinner
variant="primary"
animation="border"
className="mx-auto my-auto"
size="lg"
data-testid="loading-spinner"
/>
</div>
)}
</div>
</Container>
Expand Down
3 changes: 3 additions & 0 deletions src/notification-preferences/data/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const NOTIFICATION_CHANNELS = ['web'];

export default NOTIFICATION_CHANNELS;
27 changes: 14 additions & 13 deletions src/notification-preferences/messages.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { defineMessages } from '@edx/frontend-platform/i18n';

// eslint-disable-next-line import/prefer-default-export
export const messages = defineMessages({
const messages = defineMessages({
notificationHeading: {
id: 'notification.preference.heading',
defaultMessage: 'Notifications',
Expand All @@ -10,21 +9,21 @@ export const messages = defineMessages({
notificationAppTitle: {
id: 'notification.preference.app.title',
defaultMessage: `{
key, select,
discussion {Discussions}
coursework {Course Work}
other {{key}}
key, select,
discussion {Discussions}
coursework {Course Work}
other {{key}}
}`,
description: 'Display text for Notification Types',
},
notificationTitle: {
id: 'notification.preference.title',
defaultMessage: `{
text, select,
core {Core notifications}
newDiscussionPost {New discussion posts}
newQuestionPost {New question posts}
other {{text}}
text, select,
core {Core notifications}
newDiscussionPost {New discussion posts}
newQuestionPost {New question posts}
other {{text}}
}`,
description: 'Display text for Notification Types',
},
Expand All @@ -34,7 +33,7 @@ export const messages = defineMessages({
description: 'Display text for type',
},
webLabel: {
id: 'notification.preference.web,label',
id: 'notification.preference.web.label',
defaultMessage: 'Web',
description: 'Display text for web',
},
Expand All @@ -60,7 +59,9 @@ export const messages = defineMessages({
},
notificationPreferenceGuideBody: {
id: 'notification.preference.guide.body',
defaultMessage: 'Notifications for certain activities are enabled by default, ',
defaultMessage: 'Notifications for certain activities are enabled by default,',
description: 'Body of the notification preferences for learner guide',
},
});

export default messages;

0 comments on commit 9cccf09

Please sign in to comment.