Commit d668294f authored by Phil Hughes's avatar Phil Hughes

spec fixes

parent fa2af5e0
import _ from 'underscore'; import _ from 'underscore';
const hideFlash = (flashEl) => { const hideFlash = (flashEl) => {
flashEl.style.transition = 'opacity .3s'; // eslint-disable-line no-param-reassign Object.assign(flashEl.style, {
flashEl.style.opacity = '0'; // eslint-disable-line no-param-reassign transition: 'opacity .3s',
opacity: '0',
});
flashEl.addEventListener('transitionend', () => { flashEl.addEventListener('transitionend', () => {
flashEl.remove(); flashEl.remove();
...@@ -33,8 +35,11 @@ const createFlashEl = (message, type) => ` ...@@ -33,8 +35,11 @@ const createFlashEl = (message, type) => `
</div> </div>
`; `;
const Flash = function Flash(message, type = 'alert', parent = document, actionConfig = null) { const createFlash = function createFlash(message, type = 'alert', parent = document, actionConfig = null) {
const flashContainer = parent.querySelector('.flash-container'); const flashContainer = parent.querySelector('.flash-container');
if (!flashContainer) return null;
flashContainer.innerHTML = createFlashEl(message, type); flashContainer.innerHTML = createFlashEl(message, type);
const flashEl = flashContainer.querySelector(`.flash-${type}`); const flashEl = flashContainer.querySelector(`.flash-${type}`);
...@@ -61,8 +66,8 @@ const Flash = function Flash(message, type = 'alert', parent = document, actionC ...@@ -61,8 +66,8 @@ const Flash = function Flash(message, type = 'alert', parent = document, actionC
}; };
export { export {
Flash as default, createFlash as default,
createFlashEl, createFlashEl,
hideFlash, hideFlash,
}; };
window.Flash = Flash; window.Flash = createFlash;
...@@ -354,7 +354,7 @@ export default class Notes { ...@@ -354,7 +354,7 @@ export default class Notes {
Object.keys(noteEntity.commands_changes).length > 0) { Object.keys(noteEntity.commands_changes).length > 0) {
$notesList.find('.system-note.being-posted').remove(); $notesList.find('.system-note.being-posted').remove();
} }
this.addFlash(noteEntity.errors.commands_only, 'notice', this.parentTimeline); // TODO: CHECK THIS! this.addFlash(noteEntity.errors.commands_only, 'notice', this.parentTimeline.get(0));
this.refresh(); this.refresh();
} }
return; return;
...@@ -593,7 +593,7 @@ export default class Notes { ...@@ -593,7 +593,7 @@ export default class Notes {
} else if ($form.hasClass('js-discussion-note-form')) { } else if ($form.hasClass('js-discussion-note-form')) {
formParentTimeline = $form.closest('.discussion-notes').find('.notes'); formParentTimeline = $form.closest('.discussion-notes').find('.notes');
} }
return this.addFlash('Your comment could not be submitted! Please check your network connection and try again.', 'alert', formParentTimeline); return this.addFlash('Your comment could not be submitted! Please check your network connection and try again.', 'alert', formParentTimeline.get(0));
} }
updateNoteError($parentTimeline) { updateNoteError($parentTimeline) {
......
...@@ -181,7 +181,7 @@ describe('IntegrationSettingsForm', () => { ...@@ -181,7 +181,7 @@ describe('IntegrationSettingsForm', () => {
deferred.reject(); deferred.reject();
expect($('.flash-container .flash-text').text()).toEqual(errorMessage); expect($('.flash-container .flash-text').text().trim()).toEqual(errorMessage);
}); });
it('should always call `toggleSubmitBtnState` with `false` once request is completed', () => { it('should always call `toggleSubmitBtnState` with `false` once request is completed', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment