Commit 5613c325 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'remove-iife-filtered-search-bundle' into 'master'

Remove IIFE's in filtered_search_bundle.js

See merge request !10730
parents bbd83376 08a09c6b
......@@ -2,8 +2,7 @@ import Filter from '~/droplab/plugins/filter';
require('./filtered_search_dropdown');
(() => {
class DropdownHint extends gl.FilteredSearchDropdown {
class DropdownHint extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input, filter) {
super(droplab, dropdown, input, filter);
this.config = {
......@@ -76,8 +75,7 @@ require('./filtered_search_dropdown');
init() {
this.droplab.addHook(this.input, this.dropdown, [Filter], this.config).init();
}
}
}
window.gl = window.gl || {};
gl.DropdownHint = DropdownHint;
})();
window.gl = window.gl || {};
gl.DropdownHint = DropdownHint;
......@@ -5,8 +5,7 @@ import Filter from '~/droplab/plugins/filter';
require('./filtered_search_dropdown');
(() => {
class DropdownNonUser extends gl.FilteredSearchDropdown {
class DropdownNonUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input, filter, endpoint, symbol) {
super(droplab, dropdown, input, filter);
this.symbol = symbol;
......@@ -45,8 +44,7 @@ require('./filtered_search_dropdown');
this.droplab
.addHook(this.input, this.dropdown, [Ajax, Filter], this.config).init();
}
}
}
window.gl = window.gl || {};
gl.DropdownNonUser = DropdownNonUser;
})();
window.gl = window.gl || {};
gl.DropdownNonUser = DropdownNonUser;
......@@ -4,8 +4,7 @@ import AjaxFilter from '~/droplab/plugins/ajax_filter';
require('./filtered_search_dropdown');
(() => {
class DropdownUser extends gl.FilteredSearchDropdown {
class DropdownUser extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input, filter) {
super(droplab, dropdown, input, filter);
this.config = {
......@@ -65,8 +64,7 @@ require('./filtered_search_dropdown');
init() {
this.droplab.addHook(this.input, this.dropdown, [AjaxFilter], this.config).init();
}
}
}
window.gl = window.gl || {};
gl.DropdownUser = DropdownUser;
})();
window.gl = window.gl || {};
gl.DropdownUser = DropdownUser;
import FilteredSearchContainer from './container';
(() => {
class DropdownUtils {
class DropdownUtils {
static getEscapedText(text) {
let escapedText = text;
const hasSpace = text.indexOf(' ') !== -1;
......@@ -176,8 +175,7 @@ import FilteredSearchContainer from './container';
right,
};
}
}
}
window.gl = window.gl || {};
gl.DropdownUtils = DropdownUtils;
})();
window.gl = window.gl || {};
gl.DropdownUtils = DropdownUtils;
(() => {
const DATA_DROPDOWN_TRIGGER = 'data-dropdown-trigger';
const DATA_DROPDOWN_TRIGGER = 'data-dropdown-trigger';
class FilteredSearchDropdown {
class FilteredSearchDropdown {
constructor(droplab, dropdown, input, filter) {
this.droplab = droplab;
this.hookId = input && input.id;
......@@ -117,8 +116,7 @@
hook.list.render(results);
}
}
}
}
window.gl = window.gl || {};
gl.FilteredSearchDropdown = FilteredSearchDropdown;
})();
window.gl = window.gl || {};
gl.FilteredSearchDropdown = FilteredSearchDropdown;
import DropLab from '~/droplab/drop_lab';
import FilteredSearchContainer from './container';
(() => {
class FilteredSearchDropdownManager {
class FilteredSearchDropdownManager {
constructor(baseEndpoint = '', page) {
this.container = FilteredSearchContainer.container;
this.baseEndpoint = baseEndpoint.replace(/\/$/, '');
......@@ -184,8 +183,7 @@ import FilteredSearchContainer from './container';
destroyDroplab() {
this.droplab.destroy();
}
}
}
window.gl = window.gl || {};
gl.FilteredSearchDropdownManager = FilteredSearchDropdownManager;
})();
window.gl = window.gl || {};
gl.FilteredSearchDropdownManager = FilteredSearchDropdownManager;
......@@ -6,8 +6,7 @@ import RecentSearchesStore from './stores/recent_searches_store';
import RecentSearchesService from './services/recent_searches_service';
import eventHub from './event_hub';
(() => {
class FilteredSearchManager {
class FilteredSearchManager {
constructor(page) {
this.container = FilteredSearchContainer.container;
this.filteredSearchInput = this.container.querySelector('.filtered-search');
......@@ -487,8 +486,7 @@ import eventHub from './event_hub';
this.filteredSearchInput.dispatchEvent(new CustomEvent('input'));
this.search();
}
}
}
window.gl = window.gl || {};
gl.FilteredSearchManager = FilteredSearchManager;
})();
window.gl = window.gl || {};
gl.FilteredSearchManager = FilteredSearchManager;
(() => {
const tokenKeys = [{
const tokenKeys = [{
key: 'author',
type: 'string',
param: 'username',
symbol: '@',
}, {
}, {
key: 'assignee',
type: 'string',
param: 'username',
symbol: '@',
}, {
}, {
key: 'milestone',
type: 'string',
param: 'title',
symbol: '%',
}, {
}, {
key: 'label',
type: 'array',
param: 'name[]',
symbol: '~',
}];
}];
const alternativeTokenKeys = [{
const alternativeTokenKeys = [{
key: 'label',
type: 'string',
param: 'name',
symbol: '~',
}];
}];
const tokenKeysWithAlternative = tokenKeys.concat(alternativeTokenKeys);
const tokenKeysWithAlternative = tokenKeys.concat(alternativeTokenKeys);
const conditions = [{
const conditions = [{
url: 'assignee_id=0',
tokenKey: 'assignee',
value: 'none',
}, {
}, {
url: 'milestone_title=No+Milestone',
tokenKey: 'milestone',
value: 'none',
}, {
}, {
url: 'milestone_title=%23upcoming',
tokenKey: 'milestone',
value: 'upcoming',
}, {
}, {
url: 'milestone_title=%23started',
tokenKey: 'milestone',
value: 'started',
}, {
}, {
url: 'label_name[]=No+Label',
tokenKey: 'label',
value: 'none',
}];
}];
class FilteredSearchTokenKeys {
class FilteredSearchTokenKeys {
static get() {
return tokenKeys;
}
......@@ -93,8 +92,7 @@
return conditions
.find(condition => condition.tokenKey === key && condition.value === value) || null;
}
}
}
window.gl = window.gl || {};
gl.FilteredSearchTokenKeys = FilteredSearchTokenKeys;
})();
window.gl = window.gl || {};
gl.FilteredSearchTokenKeys = FilteredSearchTokenKeys;
require('./filtered_search_token_keys');
(() => {
class FilteredSearchTokenizer {
class FilteredSearchTokenizer {
static processTokens(input) {
const allowedKeys = gl.FilteredSearchTokenKeys.get().map(i => i.key);
// Regex extracts `(token):(symbol)(value)`
......@@ -51,8 +50,7 @@ require('./filtered_search_token_keys');
searchToken,
};
}
}
}
window.gl = window.gl || {};
gl.FilteredSearchTokenizer = FilteredSearchTokenizer;
})();
window.gl = window.gl || {};
gl.FilteredSearchTokenizer = FilteredSearchTokenizer;
......@@ -3,8 +3,7 @@ require('~/filtered_search/filtered_search_tokenizer');
require('~/filtered_search/filtered_search_dropdown');
require('~/filtered_search/dropdown_user');
(() => {
describe('Dropdown User', () => {
describe('Dropdown User', () => {
describe('getSearchInput', () => {
let dropdownUser;
......@@ -67,5 +66,4 @@ require('~/filtered_search/dropdown_user');
window.gon = {};
});
});
});
})();
});
......@@ -3,8 +3,7 @@ require('~/filtered_search/dropdown_utils');
require('~/filtered_search/filtered_search_tokenizer');
require('~/filtered_search/filtered_search_dropdown_manager');
(() => {
describe('Dropdown Utils', () => {
describe('Dropdown Utils', () => {
describe('getEscapedText', () => {
it('should return same word when it has no space', () => {
const escaped = gl.DropdownUtils.getEscapedText('textWithoutSpace');
......@@ -306,5 +305,4 @@ require('~/filtered_search/filtered_search_dropdown_manager');
});
});
});
});
})();
});
......@@ -3,8 +3,7 @@ require('~/filtered_search/filtered_search_visual_tokens');
require('~/filtered_search/filtered_search_tokenizer');
require('~/filtered_search/filtered_search_dropdown_manager');
(() => {
describe('Filtered Search Dropdown Manager', () => {
describe('Filtered Search Dropdown Manager', () => {
describe('addWordToInput', () => {
function getInputValue() {
return document.querySelector('.filtered-search').value;
......@@ -97,5 +96,4 @@ require('~/filtered_search/filtered_search_dropdown_manager');
});
});
});
});
})();
});
......@@ -6,8 +6,7 @@ require('~/filtered_search/filtered_search_dropdown_manager');
require('~/filtered_search/filtered_search_manager');
const FilteredSearchSpecHelper = require('../helpers/filtered_search_spec_helper');
(() => {
describe('Filtered Search Manager', () => {
describe('Filtered Search Manager', () => {
let input;
let manager;
let tokensContainer;
......@@ -272,5 +271,4 @@ const FilteredSearchSpecHelper = require('../helpers/filtered_search_spec_helper
expect(document.querySelector('.filtered-search-box').classList.contains('focus')).toEqual(false);
});
});
});
})();
});
require('~/extensions/array');
require('~/filtered_search/filtered_search_token_keys');
(() => {
describe('Filtered Search Token Keys', () => {
describe('Filtered Search Token Keys', () => {
describe('get', () => {
let tokenKeys;
......@@ -106,5 +105,4 @@ require('~/filtered_search/filtered_search_token_keys');
expect(result).toEqual(conditions[0]);
});
});
});
})();
});
......@@ -2,8 +2,7 @@ require('~/extensions/array');
require('~/filtered_search/filtered_search_token_keys');
require('~/filtered_search/filtered_search_tokenizer');
(() => {
describe('Filtered Search Tokenizer', () => {
describe('Filtered Search Tokenizer', () => {
describe('processTokens', () => {
it('returns for input containing only search value', () => {
const results = gl.FilteredSearchTokenizer.processTokens('searchTerm');
......@@ -131,5 +130,4 @@ require('~/filtered_search/filtered_search_tokenizer');
expect(results.tokens[0].symbol).toBe('~');
});
});
});
})();
});
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