BigW Consortium Gitlab

Commit c2f0f8d7 by Constance Okoghenun Committed by Jacob Schatz

Refactored merge_requests/show path in dispatcher.js

parent b2761d17
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */ /* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */
import MergeRequest from './merge_request';
import Flash from './flash'; import Flash from './flash';
import GfmAutoComplete from './gfm_auto_complete'; import GfmAutoComplete from './gfm_auto_complete';
import ZenMode from './zen_mode';
import initNotes from './init_notes';
import initIssuableSidebar from './init_issuable_sidebar';
import { convertPermissionToBoolean } from './lib/utils/common_utils'; import { convertPermissionToBoolean } from './lib/utils/common_utils';
import GlFieldErrors from './gl_field_errors'; import GlFieldErrors from './gl_field_errors';
import Shortcuts from './shortcuts'; import Shortcuts from './shortcuts';
import ShortcutsIssuable from './shortcuts_issuable';
import Diff from './diff';
import SearchAutocomplete from './search_autocomplete'; import SearchAutocomplete from './search_autocomplete';
var Dispatcher; var Dispatcher;
...@@ -262,17 +256,10 @@ var Dispatcher; ...@@ -262,17 +256,10 @@ var Dispatcher;
.catch(fail); .catch(fail);
break; break;
case 'projects:merge_requests:show': case 'projects:merge_requests:show':
new Diff(); import('./pages/projects/merge_requests/show')
new ZenMode(); .then(callDefault)
.catch(fail);
initIssuableSidebar(); shortcut_handler = true;
initNotes();
const mrShowNode = document.querySelector('.merge-request');
window.mergeRequest = new MergeRequest({
action: mrShowNode.dataset.mrAction,
});
shortcut_handler = new ShortcutsIssuable(true);
break; break;
case 'dashboard:activity': case 'dashboard:activity':
import('./pages/dashboard/activity') import('./pages/dashboard/activity')
......
/* global autosize */ import autosize from 'autosize';
import GfmAutoComplete from './gfm_auto_complete'; import GfmAutoComplete from './gfm_auto_complete';
import dropzoneInput from './dropzone_input'; import dropzoneInput from './dropzone_input';
import textUtils from './lib/utils/text_markdown'; import textUtils from './lib/utils/text_markdown';
......
import MergeRequest from '~/merge_request';
import ZenMode from '~/zen_mode';
import initNotes from '~/init_notes';
import initIssuableSidebar from '~/init_issuable_sidebar';
import ShortcutsIssuable from '~/shortcuts_issuable';
import Diff from '~/diff';
import { handleLocationHash } from '~/lib/utils/common_utils';
export default () => {
new Diff(); // eslint-disable-line no-new
new ZenMode(); // eslint-disable-line no-new
initIssuableSidebar(); // eslint-disable-line no-new
initNotes(); // eslint-disable-line no-new
const mrShowNode = document.querySelector('.merge-request');
window.mergeRequest = new MergeRequest({
action: mrShowNode.dataset.mrAction,
});
new ShortcutsIssuable(true); // eslint-disable-line no-new
handleLocationHash();
};
import Autosize from 'autosize'; import autosize from 'autosize';
import GLForm from '~/gl_form'; import GLForm from '~/gl_form';
import '~/lib/utils/text_utility'; import '~/lib/utils/text_utility';
import '~/lib/utils/common_utils'; import '~/lib/utils/common_utils';
window.autosize = Autosize;
describe('GLForm', () => { describe('GLForm', () => {
describe('when instantiated', function () { describe('when instantiated', function () {
beforeEach((done) => { beforeEach((done) => {
...@@ -13,14 +11,12 @@ describe('GLForm', () => { ...@@ -13,14 +11,12 @@ describe('GLForm', () => {
spyOn($.prototype, 'off').and.returnValue(this.textarea); spyOn($.prototype, 'off').and.returnValue(this.textarea);
spyOn($.prototype, 'on').and.returnValue(this.textarea); spyOn($.prototype, 'on').and.returnValue(this.textarea);
spyOn($.prototype, 'css'); spyOn($.prototype, 'css');
spyOn(window, 'autosize');
this.glForm = new GLForm(this.form); this.glForm = new GLForm(this.form, false);
setTimeout(() => { setTimeout(() => {
$.prototype.off.calls.reset(); $.prototype.off.calls.reset();
$.prototype.on.calls.reset(); $.prototype.on.calls.reset();
$.prototype.css.calls.reset(); $.prototype.css.calls.reset();
window.autosize.calls.reset();
done(); done();
}); });
}); });
...@@ -43,10 +39,6 @@ describe('GLForm', () => { ...@@ -43,10 +39,6 @@ describe('GLForm', () => {
expect($.prototype.on).toHaveBeenCalledWith('mouseup.autosize', jasmine.any(Function)); expect($.prototype.on).toHaveBeenCalledWith('mouseup.autosize', jasmine.any(Function));
}); });
it('should autosize the textarea', () => {
expect(window.autosize).toHaveBeenCalledWith(jasmine.any(Object));
});
it('should set the resize css property to vertical', () => { it('should set the resize css property to vertical', () => {
expect($.prototype.css).toHaveBeenCalledWith('resize', 'vertical'); expect($.prototype.css).toHaveBeenCalledWith('resize', 'vertical');
}); });
...@@ -74,7 +66,7 @@ describe('GLForm', () => { ...@@ -74,7 +66,7 @@ describe('GLForm', () => {
spyOn($.prototype, 'data'); spyOn($.prototype, 'data');
spyOn($.prototype, 'outerHeight').and.returnValue(200); spyOn($.prototype, 'outerHeight').and.returnValue(200);
spyOn(window, 'outerHeight').and.returnValue(400); spyOn(window, 'outerHeight').and.returnValue(400);
spyOn(window.autosize, 'destroy'); spyOn(autosize, 'destroy');
this.glForm.destroyAutosize(); this.glForm.destroyAutosize();
}); });
...@@ -88,7 +80,7 @@ describe('GLForm', () => { ...@@ -88,7 +80,7 @@ describe('GLForm', () => {
}); });
it('should call autosize destroy', () => { it('should call autosize destroy', () => {
expect(window.autosize.destroy).toHaveBeenCalledWith(this.textarea); expect(autosize.destroy).toHaveBeenCalledWith(this.textarea);
}); });
it('should set the data-height attribute', () => { it('should set the data-height attribute', () => {
...@@ -107,9 +99,9 @@ describe('GLForm', () => { ...@@ -107,9 +99,9 @@ describe('GLForm', () => {
it('should return undefined if the data-height equals the outerHeight', () => { it('should return undefined if the data-height equals the outerHeight', () => {
spyOn($.prototype, 'outerHeight').and.returnValue(200); spyOn($.prototype, 'outerHeight').and.returnValue(200);
spyOn($.prototype, 'data').and.returnValue(200); spyOn($.prototype, 'data').and.returnValue(200);
spyOn(window.autosize, 'destroy'); spyOn(autosize, 'destroy');
expect(this.glForm.destroyAutosize()).toBeUndefined(); expect(this.glForm.destroyAutosize()).toBeUndefined();
expect(window.autosize.destroy).not.toHaveBeenCalled(); expect(autosize.destroy).not.toHaveBeenCalled();
}); });
}); });
}); });
......
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