Skip to content

Commit

Permalink
Merge pull request #673 from mikadamczyk/EZP-29700
Browse files Browse the repository at this point in the history
EZP-29700: Syntax error after logging out
  • Loading branch information
Łukasz Serwatka authored Oct 9, 2018
2 parents 0150c5a + b417d5a commit 8bc715c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/bundle/Resources/config/bazinga_js_translation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ active_domains:
- 'universal_discovery_widget'
- 'alloy_editor'
- 'fieldtypes_edit'
- 'notifications'
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(function(global, doc, eZ, React, ReactDOM, Translator) {
let currentPageLink = null;
let getNotificationsStatusErrorShowed = false;
const SELECTOR_MODAL_ITEM = '.ez-notifications-modal__item';
const SELECTOR_MODAL_RESULTS = '.ez-notifications-modal__results';
const SELECTOR_MODAL_TITLE = '.modal-title';
Expand All @@ -10,9 +11,8 @@
const CLASS_MODAL_LOADING = 'ez-notifications-modal--loading';
const INTERVAL = 30000;
const modal = doc.querySelector('.ez-notifications-modal');
const showErrorNotification = eZ.helpers.notification.showErrorNotification;
const getJsonFromResponse = eZ.helpers.request.getJsonFromResponse;
const getTextFromResponse = eZ.helpers.request.getTextFromResponse;
const { showErrorNotification, showWarningNotification } = eZ.helpers.notification;
const { getJsonFromResponse, getTextFromResponse } = eZ.helpers.request;
const markAsRead = (notification, response) => {
if (response.status === 'success') {
notification.classList.add('ez-notifications-modal__item--read');
Expand Down Expand Up @@ -68,8 +68,28 @@
.then((notificationsInfo) => {
setPendingNotificationCount(notificationsInfo);
updateModalTitleTotalInfo(notificationsInfo.total);
getNotificationsStatusErrorShowed = false;
})
.catch(console.error);
.catch(onGetNotificationsStatusFailure);
};

/**
* Handle a failure while getting notifications status
*
* @method onGetNotificationsStatusFailure
*/
const onGetNotificationsStatusFailure = (error) => {
const message = Translator.trans(
/* @Desc("Cannot update notifications count") */ 'notifications.modal.message.error',
{ error: error.message },
'notifications'
);

if (!getNotificationsStatusErrorShowed) {
showWarningNotification(message);
}

getNotificationsStatusErrorShowed = true;
};
const updateModalTitleTotalInfo = (notificationsCount) => {
const modalTitle = modal.querySelector(SELECTOR_MODAL_TITLE);
Expand Down
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/notifications.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
<target state="new">Notifications</target>
<note>key: notifications</note>
</trans-unit>
<trans-unit id="79036b8a9fecbed5d0c14a94c5639d611c6ab6d1" resname="notifications.modal.message.error">
<source>Cannot update notifications count</source>
<target state="new">Cannot update notifications count</target>
<note>key: notifications.modal.message.error</note>
</trans-unit>
</body>
</file>
</xliff>

0 comments on commit 8bc715c

Please sign in to comment.