Skip to content

Commit

Permalink
rename some async notifier symbols to just notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
FireLemons committed Sep 27, 2023
1 parent 9f24e58 commit 1bfe68a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/shared/notifier.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
}

#async-notifications {
#notifications {
bottom: 2em;
display: flex;
flex-direction: column;
Expand Down
24 changes: 12 additions & 12 deletions app/javascript/__tests__/notifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
require('jest')
const Notifier = require('../src/notifier.js')

let asyncNotificationsElement
let notificationsElement
let notifier

beforeEach(() => {
document.body.innerHTML = `<div id="async-notifications">
document.body.innerHTML = `<div id="notifications">
<div id="async-waiting-indicator" style="display: none">
Saving <div class="load-spinner"></div>
</div>
Expand All @@ -17,8 +17,8 @@ beforeEach(() => {
</div>`

$(document).ready(() => {
asyncNotificationsElement = $('#async-notifications')
notifier = new Notifier(asyncNotificationsElement)
notificationsElement = $('#notifications')
notifier = new Notifier(notificationsElement)
})
})

Expand All @@ -30,7 +30,7 @@ describe('notify', () => {
try {
notifier.notify(notificationMessage, 'info')

const successMessages = asyncNotificationsElement.find('.async-success-indicator')
const successMessages = notificationsElement.find('.async-success-indicator')

// Notifications contain the "Saved" message and the new message
expect(successMessages.length).toBe(2)
Expand All @@ -49,7 +49,7 @@ describe('notify', () => {
try {
notifier.notify(notificationMessage, 'error')

const failureMessages = asyncNotificationsElement.find('.async-failure-indicator')
const failureMessages = notificationsElement.find('.async-failure-indicator')

expect(failureMessages.length).toBe(1)
expect(failureMessages[0].innerHTML).toContain(notificationMessage)
Expand All @@ -60,25 +60,25 @@ describe('notify', () => {
})
})

test('notify should append a dismissable message to the async-notifications widget', (done) => {
test('notify should append a dismissable message to the notifications widget', (done) => {
$(document).ready(() => {
try {
notifier.notify('', 'error')
notifier.notify('', 'info')

let failureMessages = asyncNotificationsElement.find('.async-failure-indicator')
let successMessages = asyncNotificationsElement.find('.async-success-indicator')
let failureMessages = notificationsElement.find('.async-failure-indicator')
let successMessages = notificationsElement.find('.async-success-indicator')

expect(failureMessages.length).toBe(1)
expect(successMessages.length).toBe(2)

failureMessages.children('button').click()
failureMessages = asyncNotificationsElement.find('.async-failure-indicator')
failureMessages = notificationsElement.find('.async-failure-indicator')

expect(failureMessages.length).toBe(0)

$(successMessages[1]).children('button').click()
successMessages = asyncNotificationsElement.find('.async-success-indicator')
successMessages = notificationsElement.find('.async-success-indicator')

expect(successMessages.length).toBe(1)

Expand Down Expand Up @@ -199,7 +199,7 @@ describe('stopAsyncOperation', () => {
notifier.startAsyncOperation()
notifier.stopAsyncOperation(errorMessage)

const failureMessages = asyncNotificationsElement.find('.async-failure-indicator')
const failureMessages = notificationsElement.find('.async-failure-indicator')

expect(failureMessages.length).toBe(1)
expect(failureMessages[0].innerHTML).toContain(errorMessage)
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/all_casa_admin/patch_notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ $(() => { // JQuery's callback for the DOM loading
}

try {
const asyncNotificationsElement = $('#async-notifications')
const asyncNotificationsElement = $('#notifications')
pageNotifier = new AsyncNotifier(asyncNotificationsElement)

$('#new-patch-note button').on('click', patchNoteFunctions.onCreate)
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/src/case_emancipation.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ $(() => { // JQuery's callback for the DOM loading
return
}

const asyncNotificationsElement = $('#async-notifications')
emancipationPage.notifier = new Notifier(asyncNotificationsElement)
const notificationsElement = $('#notifications')
emancipationPage.notifier = new Notifier(notificationsElement)

$('.category-collapse-icon').on('click', function () {
const categoryCollapseIcon = $(this)
Expand Down
8 changes: 4 additions & 4 deletions app/javascript/src/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global alert */
/* global $ */
const AsyncNotifier = require('./notifier')
const Notifier = require('./notifier')
let pageNotifier

const defineCaseContactsTable = function () {
Expand All @@ -14,10 +14,10 @@ const defineCaseContactsTable = function () {
}

$(() => { // JQuery's callback for the DOM loading
const asyncNotificationsElement = $('#async-notifications')
const notificationsElement = $('#notifications')

if (asyncNotificationsElement.length) {
pageNotifier = new AsyncNotifier(asyncNotificationsElement)
if (notificationsElement.length) {
pageNotifier = new Notifier(notificationsElement)
}

$.fn.dataTable.ext.search.push(
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_notifier.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="async-notifications">
<div id="notifications">
<div id="async-waiting-indicator" style="display: none">
Saving <i class="load-spinner"></i>
</div>
Expand Down

0 comments on commit 1bfe68a

Please sign in to comment.