Commit e25f15ff authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch 'mg-fix-gl-dropdown-import' into 'master'

[RUN-AS-IF-FOSS] Remove and deprecate gl_dropdown jQuery function

See merge request gitlab-org/gitlab!39897
parents 4cea7868 c34156a9
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class TemplateSelector { export default class TemplateSelector {
constructor({ dropdown, data, pattern, wrapper, editor, $input } = {}) { constructor({ dropdown, data, pattern, wrapper, editor, $input } = {}) {
...@@ -19,7 +19,7 @@ export default class TemplateSelector { ...@@ -19,7 +19,7 @@ export default class TemplateSelector {
} }
initDropdown(dropdown, data) { initDropdown(dropdown, data) {
return $(dropdown).glDropdown({ return initDeprecatedJQueryDropdown($(dropdown), {
data, data,
filterable: true, filterable: true,
selectable: true, selectable: true,
......
import FileTemplateSelector from '../file_template_selector'; import FileTemplateSelector from '../file_template_selector';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class BlobCiYamlSelector extends FileTemplateSelector { export default class BlobCiYamlSelector extends FileTemplateSelector {
constructor({ mediator }) { constructor({ mediator }) {
...@@ -15,7 +16,7 @@ export default class BlobCiYamlSelector extends FileTemplateSelector { ...@@ -15,7 +16,7 @@ export default class BlobCiYamlSelector extends FileTemplateSelector {
initDropdown() { initDropdown() {
// maybe move to super class as well // maybe move to super class as well
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.$dropdown.data('data'), data: this.$dropdown.data('data'),
filterable: true, filterable: true,
selectable: true, selectable: true,
......
import FileTemplateSelector from '../file_template_selector'; import FileTemplateSelector from '../file_template_selector';
import { __ } from '~/locale'; import { __ } from '~/locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class DockerfileSelector extends FileTemplateSelector { export default class DockerfileSelector extends FileTemplateSelector {
constructor({ mediator }) { constructor({ mediator }) {
...@@ -16,7 +17,7 @@ export default class DockerfileSelector extends FileTemplateSelector { ...@@ -16,7 +17,7 @@ export default class DockerfileSelector extends FileTemplateSelector {
initDropdown() { initDropdown() {
// maybe move to super class as well // maybe move to super class as well
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.$dropdown.data('data'), data: this.$dropdown.data('data'),
filterable: true, filterable: true,
selectable: true, selectable: true,
......
import FileTemplateSelector from '../file_template_selector'; import FileTemplateSelector from '../file_template_selector';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class BlobGitignoreSelector extends FileTemplateSelector { export default class BlobGitignoreSelector extends FileTemplateSelector {
constructor({ mediator }) { constructor({ mediator }) {
...@@ -14,7 +15,7 @@ export default class BlobGitignoreSelector extends FileTemplateSelector { ...@@ -14,7 +15,7 @@ export default class BlobGitignoreSelector extends FileTemplateSelector {
} }
initDropdown() { initDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.$dropdown.data('data'), data: this.$dropdown.data('data'),
filterable: true, filterable: true,
selectable: true, selectable: true,
......
import FileTemplateSelector from '../file_template_selector'; import FileTemplateSelector from '../file_template_selector';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class BlobLicenseSelector extends FileTemplateSelector { export default class BlobLicenseSelector extends FileTemplateSelector {
constructor({ mediator }) { constructor({ mediator }) {
...@@ -14,7 +15,7 @@ export default class BlobLicenseSelector extends FileTemplateSelector { ...@@ -14,7 +15,7 @@ export default class BlobLicenseSelector extends FileTemplateSelector {
} }
initDropdown() { initDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.$dropdown.data('data'), data: this.$dropdown.data('data'),
filterable: true, filterable: true,
selectable: true, selectable: true,
......
import FileTemplateSelector from '../file_template_selector'; import FileTemplateSelector from '../file_template_selector';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class MetricsDashboardSelector extends FileTemplateSelector { export default class MetricsDashboardSelector extends FileTemplateSelector {
constructor({ mediator }) { constructor({ mediator }) {
...@@ -14,7 +15,7 @@ export default class MetricsDashboardSelector extends FileTemplateSelector { ...@@ -14,7 +15,7 @@ export default class MetricsDashboardSelector extends FileTemplateSelector {
} }
initDropdown() { initDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.$dropdown.data('data'), data: this.$dropdown.data('data'),
filterable: true, filterable: true,
selectable: true, selectable: true,
......
import FileTemplateSelector from '../file_template_selector'; import FileTemplateSelector from '../file_template_selector';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class FileTemplateTypeSelector extends FileTemplateSelector { export default class FileTemplateTypeSelector extends FileTemplateSelector {
constructor({ mediator, dropdownData }) { constructor({ mediator, dropdownData }) {
...@@ -12,7 +13,7 @@ export default class FileTemplateTypeSelector extends FileTemplateSelector { ...@@ -12,7 +13,7 @@ export default class FileTemplateTypeSelector extends FileTemplateSelector {
} }
initDropdown() { initDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.config.dropdownData, data: this.config.dropdownData,
filterable: false, filterable: false,
selectable: true, selectable: true,
......
...@@ -83,7 +83,7 @@ export default Vue.extend({ ...@@ -83,7 +83,7 @@ export default Vue.extend({
$('.js-issue-board-sidebar', this.$el).each((i, el) => { $('.js-issue-board-sidebar', this.$el).each((i, el) => {
$(el) $(el)
.data('glDropdown') .data('deprecatedJQueryDropdown')
.clearMenu(); .clearMenu();
}); });
} }
...@@ -95,7 +95,7 @@ export default Vue.extend({ ...@@ -95,7 +95,7 @@ export default Vue.extend({
}, },
}, },
created() { created() {
// Get events from glDropdown // Get events from deprecatedJQueryDropdown
eventHub.$on('sidebar.removeAssignee', this.removeAssignee); eventHub.$on('sidebar.removeAssignee', this.removeAssignee);
eventHub.$on('sidebar.addAssignee', this.addAssignee); eventHub.$on('sidebar.addAssignee', this.addAssignee);
eventHub.$on('sidebar.removeAllAssignees', this.removeAllAssignees); eventHub.$on('sidebar.removeAllAssignees', this.removeAllAssignees);
......
...@@ -6,6 +6,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -6,6 +6,7 @@ import axios from '~/lib/utils/axios_utils';
import { deprecatedCreateFlash as flash } from '~/flash'; import { deprecatedCreateFlash as flash } from '~/flash';
import CreateLabelDropdown from '../../create_label'; import CreateLabelDropdown from '../../create_label';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
$(document) $(document)
.off('created.label') .off('created.label')
...@@ -36,7 +37,7 @@ export default function initNewListDropdown() { ...@@ -36,7 +37,7 @@ export default function initNewListDropdown() {
$dropdownToggle.data('projectPath'), $dropdownToggle.data('projectPath'),
); );
$dropdownToggle.glDropdown({ initDeprecatedJQueryDropdown($dropdownToggle, {
data(term, callback) { data(term, callback) {
axios axios
.get($dropdownToggle.attr('data-list-labels-path')) .get($dropdownToggle.attr('data-list-labels-path'))
......
...@@ -6,6 +6,7 @@ import { __ } from '~/locale'; ...@@ -6,6 +6,7 @@ import { __ } from '~/locale';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
import Api from '../../api'; import Api from '../../api';
import { featureAccessLevel } from '~/pages/projects/shared/permissions/constants'; import { featureAccessLevel } from '~/pages/projects/shared/permissions/constants';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default { export default {
name: 'BoardProjectSelect', name: 'BoardProjectSelect',
...@@ -36,7 +37,7 @@ export default { ...@@ -36,7 +37,7 @@ export default {
}, },
}, },
mounted() { mounted() {
$(this.$refs.projectsDropdown).glDropdown({ initDeprecatedJQueryDropdown($(this.$refs.projectsDropdown), {
filterable: true, filterable: true,
filterRemote: true, filterRemote: true,
search: { search: {
......
...@@ -53,7 +53,7 @@ export default class VariableList { ...@@ -53,7 +53,7 @@ export default class VariableList {
}, },
environment_scope: { environment_scope: {
// We can't use a `.js-` class here because // We can't use a `.js-` class here because
// gl_dropdown replaces the <input> and doesn't copy over the class // deprecated_jquery_dropdown replaces the <input> and doesn't copy over the class
// See https://gitlab.com/gitlab-org/gitlab-foss/issues/42458 // See https://gitlab.com/gitlab-org/gitlab-foss/issues/42458
selector: `input[name="${this.formField}[variables_attributes][][environment_scope]"]`, selector: `input[name="${this.formField}[variables_attributes][][environment_scope]"]`,
default: '*', default: '*',
......
...@@ -5,6 +5,7 @@ import { __ } from './locale'; ...@@ -5,6 +5,7 @@ import { __ } from './locale';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { deprecatedCreateFlash as flash } from './flash'; import { deprecatedCreateFlash as flash } from './flash';
import { capitalizeFirstCharacter } from './lib/utils/text_utility'; import { capitalizeFirstCharacter } from './lib/utils/text_utility';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default function initCompareAutocomplete(limitTo = null, clickHandler = () => {}) { export default function initCompareAutocomplete(limitTo = null, clickHandler = () => {}) {
$('.js-compare-dropdown').each(function() { $('.js-compare-dropdown').each(function() {
...@@ -13,7 +14,7 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = ( ...@@ -13,7 +14,7 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = (
const $dropdownContainer = $dropdown.closest('.dropdown'); const $dropdownContainer = $dropdown.closest('.dropdown');
const $fieldInput = $(`input[name="${$dropdown.data('fieldName')}"]`, $dropdownContainer); const $fieldInput = $(`input[name="${$dropdown.data('fieldName')}"]`, $dropdownContainer);
const $filterInput = $('input[type="search"]', $dropdownContainer); const $filterInput = $('input[type="search"]', $dropdownContainer);
$dropdown.glDropdown({ initDeprecatedJQueryDropdown($dropdown, {
data(term, callback) { data(term, callback) {
const params = { const params = {
ref: $dropdown.data('ref'), ref: $dropdown.data('ref'),
......
import { escape } from 'lodash'; import { escape } from 'lodash';
import '~/gl_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class CreateItemDropdown { export default class CreateItemDropdown {
/** /**
...@@ -28,7 +28,7 @@ export default class CreateItemDropdown { ...@@ -28,7 +28,7 @@ export default class CreateItemDropdown {
} }
buildDropdown() { buildDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.getData.bind(this), data: this.getData.bind(this),
filterable: true, filterable: true,
filterRemote: this.getDataRemote, filterRemote: this.getDataRemote,
...@@ -67,12 +67,12 @@ export default class CreateItemDropdown { ...@@ -67,12 +67,12 @@ export default class CreateItemDropdown {
e.preventDefault(); e.preventDefault();
this.refreshData(); this.refreshData();
this.$dropdown.data('glDropdown').selectRowAtIndex(); this.$dropdown.data('deprecatedJQueryDropdown').selectRowAtIndex();
} }
refreshData() { refreshData() {
// Refresh the dropdown's data, which ends up calling `getData` // Refresh the dropdown's data, which ends up calling `getData`
this.$dropdown.data('glDropdown').remote.execute(); this.$dropdown.data('deprecatedJQueryDropdown').remote.execute();
} }
getData(term, callback) { getData(term, callback) {
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
import $ from 'jquery'; import $ from 'jquery';
import { escape } from 'lodash'; import { escape } from 'lodash';
import fuzzaldrinPlus from 'fuzzaldrin-plus'; import fuzzaldrinPlus from 'fuzzaldrin-plus';
import axios from './lib/utils/axios_utils'; import axios from '../lib/utils/axios_utils';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import { isObject } from './lib/utils/type_utility'; import { isObject } from '~/lib/utils/type_utility';
import renderItem from './gl_dropdown/render'; import renderItem from './render';
const BLUR_KEYCODES = [27, 40]; const BLUR_KEYCODES = [27, 40];
...@@ -890,12 +890,11 @@ class GitLabDropdown { ...@@ -890,12 +890,11 @@ class GitLabDropdown {
} }
} }
// eslint-disable-next-line func-names export default function initDeprecatedJQueryDropdown($el, opts) {
$.fn.glDropdown = function(opts) {
// eslint-disable-next-line func-names // eslint-disable-next-line func-names
return this.each(function() { return $el.each(function() {
if (!$.data(this, 'glDropdown')) { if (!$.data(this, 'deprecatedJQueryDropdown')) {
return $.data(this, 'glDropdown', new GitLabDropdown(this, opts)); $.data(this, 'deprecatedJQueryDropdown', new GitLabDropdown(this, opts));
} }
}); });
}; }
...@@ -6,6 +6,7 @@ import { __ } from '~/locale'; ...@@ -6,6 +6,7 @@ import { __ } from '~/locale';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { timeFor, parsePikadayDate, pikadayToString } from './lib/utils/datetime_utility'; import { timeFor, parsePikadayDate, pikadayToString } from './lib/utils/datetime_utility';
import boardsStore from './boards/stores/boards_store'; import boardsStore from './boards/stores/boards_store';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
class DueDateSelect { class DueDateSelect {
constructor({ $dropdown, $loading } = {}) { constructor({ $dropdown, $loading } = {}) {
...@@ -35,7 +36,7 @@ class DueDateSelect { ...@@ -35,7 +36,7 @@ class DueDateSelect {
} }
initGlDropdown() { initGlDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
opened: () => { opened: () => {
const calendar = this.$datePicker.data('pikaday'); const calendar = this.$datePicker.data('pikaday');
calendar.show(); calendar.show();
......
import $ from 'jquery'; import $ from 'jquery';
import { __ } from '~/locale'; import { __ } from '~/locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class TransferDropdown { export default class TransferDropdown {
constructor() { constructor() {
...@@ -16,7 +17,7 @@ export default class TransferDropdown { ...@@ -16,7 +17,7 @@ export default class TransferDropdown {
buildDropdown() { buildDropdown() {
const extraOptions = [{ id: '-1', text: __('No parent group') }, { type: 'divider' }]; const extraOptions = [{ id: '-1', text: __('No parent group') }, { type: 'divider' }];
this.groupDropdown.glDropdown({ initDeprecatedJQueryDropdown(this.groupDropdown, {
selectable: true, selectable: true,
filterable: true, filterable: true,
toggleLabel: item => item.text, toggleLabel: item => item.text,
......
import $ from 'jquery'; import $ from 'jquery';
import { stickyMonitor } from './lib/utils/sticky'; import { stickyMonitor } from './lib/utils/sticky';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default stickyTop => { export default stickyTop => {
stickyMonitor(document.querySelector('.js-diff-files-changed'), stickyTop); stickyMonitor(document.querySelector('.js-diff-files-changed'), stickyTop);
$('.js-diff-stats-dropdown').glDropdown({ initDeprecatedJQueryDropdown($('.js-diff-stats-dropdown'), {
filterable: true, filterable: true,
remoteFilter: false, remoteFilter: false,
}); });
......
import $ from 'jquery'; import $ from 'jquery';
import { __ } from './locale'; import { __ } from './locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default function issueStatusSelect() { export default function issueStatusSelect() {
$('.js-issue-status').each((i, el) => { $('.js-issue-status').each((i, el) => {
const fieldName = $(el).data('fieldName'); const fieldName = $(el).data('fieldName');
return $(el).glDropdown({ initDeprecatedJQueryDropdown($(el), {
selectable: true, selectable: true,
fieldName, fieldName,
toggleLabel(selected, element, instance) { toggleLabel(selected, element, instance) {
......
...@@ -12,6 +12,7 @@ import { deprecatedCreateFlash as flash } from './flash'; ...@@ -12,6 +12,7 @@ import { deprecatedCreateFlash as flash } from './flash';
import ModalStore from './boards/stores/modal_store'; import ModalStore from './boards/stores/modal_store';
import boardsStore from './boards/stores/boards_store'; import boardsStore from './boards/stores/boards_store';
import { isScopedLabel } from '~/lib/utils/common_utils'; import { isScopedLabel } from '~/lib/utils/common_utils';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class LabelsSelect { export default class LabelsSelect {
constructor(els, options = {}) { constructor(els, options = {}) {
...@@ -173,7 +174,7 @@ export default class LabelsSelect { ...@@ -173,7 +174,7 @@ export default class LabelsSelect {
}) })
.catch(() => flash(__('Error saving label update.'))); .catch(() => flash(__('Error saving label update.')));
}; };
$dropdown.glDropdown({ initDeprecatedJQueryDropdown($dropdown, {
showMenuAbove, showMenuAbove,
data(term, callback) { data(term, callback) {
const labelUrl = $dropdown.attr('data-labels'); const labelUrl = $dropdown.attr('data-labels');
...@@ -203,7 +204,7 @@ export default class LabelsSelect { ...@@ -203,7 +204,7 @@ export default class LabelsSelect {
callback(data); callback(data);
if (showMenuAbove) { if (showMenuAbove) {
$dropdown.data('glDropdown').positionMenuAbove(); $dropdown.data('deprecatedJQueryDropdown').positionMenuAbove();
} }
}) })
.catch(() => flash(__('Error fetching labels.'))); .catch(() => flash(__('Error fetching labels.')));
...@@ -348,7 +349,7 @@ export default class LabelsSelect { ...@@ -348,7 +349,7 @@ export default class LabelsSelect {
} else { } else {
if (!$dropdown.hasClass('js-filter-bulk-update')) { if (!$dropdown.hasClass('js-filter-bulk-update')) {
saveLabelData(); saveLabelData();
$dropdown.data('glDropdown').clearMenu(); $dropdown.data('deprecatedJQueryDropdown').clearMenu();
} }
} }
} }
...@@ -455,7 +456,7 @@ export default class LabelsSelect { ...@@ -455,7 +456,7 @@ export default class LabelsSelect {
if ($dropdown.hasClass('js-issue-board-sidebar')) { if ($dropdown.hasClass('js-issue-board-sidebar')) {
const previousSelection = $dropdown.attr('data-selected'); const previousSelection = $dropdown.attr('data-selected');
this.selected = previousSelection ? previousSelection.split(',') : []; this.selected = previousSelection ? previousSelection.split(',') : [];
$dropdown.data('glDropdown').updateLabel(); $dropdown.data('deprecatedJQueryDropdown').updateLabel();
} }
}, },
preserveContext: true, preserveContext: true,
......
...@@ -22,7 +22,6 @@ import { getLocationHash, visitUrl } from './lib/utils/url_utility'; ...@@ -22,7 +22,6 @@ import { getLocationHash, visitUrl } from './lib/utils/url_utility';
// everything else // everything else
import loadAwardsHandler from './awards_handler'; import loadAwardsHandler from './awards_handler';
import { deprecatedCreateFlash as Flash, removeFlashClickListener } from './flash'; import { deprecatedCreateFlash as Flash, removeFlashClickListener } from './flash';
import './gl_dropdown';
import initTodoToggle from './header'; import initTodoToggle from './header';
import initImporterStatus from './importer_status'; import initImporterStatus from './importer_status';
import initLayoutNav from './layout_nav'; import initLayoutNav from './layout_nav';
......
import $ from 'jquery'; import $ from 'jquery';
import { disableButtonIfEmptyField } from '~/lib/utils/common_utils'; import { disableButtonIfEmptyField } from '~/lib/utils/common_utils';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class Members { export default class Members {
constructor() { constructor() {
...@@ -37,7 +38,7 @@ export default class Members { ...@@ -37,7 +38,7 @@ export default class Members {
$('.js-member-permissions-dropdown').each((i, btn) => { $('.js-member-permissions-dropdown').each((i, btn) => {
const $btn = $(btn); const $btn = $(btn);
$btn.glDropdown({ initDeprecatedJQueryDropdown($btn, {
selectable: true, selectable: true,
isSelectable: (selected, $el) => this.dropdownIsSelectable(selected, $el), isSelectable: (selected, $el) => this.dropdownIsSelectable(selected, $el),
fieldName: $btn.data('fieldName'), fieldName: $btn.data('fieldName'),
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import $ from 'jquery'; import $ from 'jquery';
import { template, escape } from 'lodash'; import { template, escape } from 'lodash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import '~/gl_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import Api from '~/api'; import Api from '~/api';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { timeFor, parsePikadayDate, dateInWords } from './lib/utils/datetime_utility'; import { timeFor, parsePikadayDate, dateInWords } from './lib/utils/datetime_utility';
...@@ -69,7 +69,7 @@ export default class MilestoneSelect { ...@@ -69,7 +69,7 @@ export default class MilestoneSelect {
); );
milestoneLinkNoneTemplate = `<span class="no-value">${__('None')}</span>`; milestoneLinkNoneTemplate = `<span class="no-value">${__('None')}</span>`;
} }
return $dropdown.glDropdown({ return initDeprecatedJQueryDropdown($dropdown, {
showMenuAbove, showMenuAbove,
data: (term, callback) => { data: (term, callback) => {
let contextId = $dropdown.get(0).dataset.projectId; let contextId = $dropdown.get(0).dataset.projectId;
...@@ -138,7 +138,7 @@ export default class MilestoneSelect { ...@@ -138,7 +138,7 @@ export default class MilestoneSelect {
callback(extraOptions.concat(data)); callback(extraOptions.concat(data));
if (showMenuAbove) { if (showMenuAbove) {
$dropdown.data('glDropdown').positionMenuAbove(); $dropdown.data('deprecatedJQueryDropdown').positionMenuAbove();
} }
$(`[data-milestone-id="${selectedMilestone}"] > a`).addClass('is-active'); $(`[data-milestone-id="${selectedMilestone}"] > a`).addClass('is-active');
}); });
......
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown';
import Api from './api'; import Api from './api';
import { mergeUrlParams } from './lib/utils/url_utility'; import { mergeUrlParams } from './lib/utils/url_utility';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import { __ } from './locale'; import { __ } from './locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class NamespaceSelect { export default class NamespaceSelect {
constructor(opts) { constructor(opts) {
const isFilter = parseBoolean(opts.dropdown.dataset.isFilter); const isFilter = parseBoolean(opts.dropdown.dataset.isFilter);
const fieldName = opts.dropdown.dataset.fieldName || 'namespace_id'; const fieldName = opts.dropdown.dataset.fieldName || 'namespace_id';
$(opts.dropdown).glDropdown({ initDeprecatedJQueryDropdown($(opts.dropdown), {
filterable: true, filterable: true,
selectable: true, selectable: true,
filterRemote: true, filterRemote: true,
......
/* eslint-disable class-methods-use-this, no-unneeded-ternary */ /* eslint-disable class-methods-use-this, no-unneeded-ternary */
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import UsersSelect from '~/users_select'; import UsersSelect from '~/users_select';
import { isMetaClick } from '~/lib/utils/common_utils'; import { isMetaClick } from '~/lib/utils/common_utils';
...@@ -50,7 +50,7 @@ export default class Todos { ...@@ -50,7 +50,7 @@ export default class Todos {
} }
initFilterDropdown($dropdown, fieldName, searchFields) { initFilterDropdown($dropdown, fieldName, searchFields) {
$dropdown.glDropdown({ initDeprecatedJQueryDropdown($dropdown, {
fieldName, fieldName,
selectable: true, selectable: true,
filterable: searchFields ? true : false, filterable: searchFields ? true : false,
......
import $ from 'jquery'; import $ from 'jquery';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default () => { export default () => {
const $targetProjectDropdown = $('.js-target-project'); const $targetProjectDropdown = $('.js-target-project');
$targetProjectDropdown.glDropdown({ initDeprecatedJQueryDropdown($targetProjectDropdown, {
selectable: true, selectable: true,
fieldName: $targetProjectDropdown.data('fieldName'), fieldName: $targetProjectDropdown.data('fieldName'),
filterable: true, filterable: true,
...@@ -16,7 +17,7 @@ export default () => { ...@@ -16,7 +17,7 @@ export default () => {
$('.mr_target_commit').empty(); $('.mr_target_commit').empty();
const $targetBranchDropdown = $('.js-target-branch'); const $targetBranchDropdown = $('.js-target-branch');
$targetBranchDropdown.data('refsUrl', $el.data('refsUrl')); $targetBranchDropdown.data('refsUrl', $el.data('refsUrl'));
$targetBranchDropdown.data('glDropdown').clearMenu(); $targetBranchDropdown.data('deprecatedJQueryDropdown').clearMenu();
}, },
}); });
}; };
import $ from 'jquery'; import $ from 'jquery';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class TargetBranchDropdown { export default class TargetBranchDropdown {
constructor() { constructor() {
...@@ -10,7 +11,7 @@ export default class TargetBranchDropdown { ...@@ -10,7 +11,7 @@ export default class TargetBranchDropdown {
} }
initDropdown() { initDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.formatBranchesList(), data: this.formatBranchesList(),
filterable: true, filterable: true,
selectable: true, selectable: true,
......
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
const defaultTimezone = { name: 'UTC', offset: 0 }; const defaultTimezone = { name: 'UTC', offset: 0 };
const defaults = { const defaults = {
$inputEl: null, $inputEl: null,
...@@ -42,7 +44,7 @@ export default class TimezoneDropdown { ...@@ -42,7 +44,7 @@ export default class TimezoneDropdown {
} }
initDropdown() { initDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.timezoneData, data: this.timezoneData,
filterable: true, filterable: true,
selectable: true, selectable: true,
......
...@@ -8,6 +8,7 @@ import { serializeForm } from '~/lib/utils/forms'; ...@@ -8,6 +8,7 @@ import { serializeForm } from '~/lib/utils/forms';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { deprecatedCreateFlash as flash } from '~/flash'; import { deprecatedCreateFlash as flash } from '~/flash';
import projectSelect from '../../project_select'; import projectSelect from '../../project_select';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class Project { export default class Project {
constructor() { constructor() {
...@@ -104,7 +105,7 @@ export default class Project { ...@@ -104,7 +105,7 @@ export default class Project {
const action = $form.attr('action'); const action = $form.attr('action');
const linkTarget = mergeUrlParams(serializeForm($form[0]), action); const linkTarget = mergeUrlParams(serializeForm($form[0]), action);
return $dropdown.glDropdown({ return initDeprecatedJQueryDropdown($dropdown, {
data(term, callback) { data(term, callback) {
axios axios
.get($dropdown.data('refsUrl'), { .get($dropdown.data('refsUrl'), {
......
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { deprecatedCreateFlash as Flash } from '~/flash'; import { deprecatedCreateFlash as Flash } from '~/flash';
import Api from '~/api'; import Api from '~/api';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -20,7 +20,7 @@ export default class Search { ...@@ -20,7 +20,7 @@ export default class Search {
this.eventListeners(); this.eventListeners();
refreshCounts(); refreshCounts();
$groupDropdown.glDropdown({ initDeprecatedJQueryDropdown($groupDropdown, {
selectable: true, selectable: true,
filterable: true, filterable: true,
filterRemote: true, filterRemote: true,
...@@ -46,7 +46,7 @@ export default class Search { ...@@ -46,7 +46,7 @@ export default class Search {
clicked: () => Search.submitSearch(), clicked: () => Search.submitSearch(),
}); });
$projectDropdown.glDropdown({ initDeprecatedJQueryDropdown($projectDropdown, {
selectable: true, selectable: true,
filterable: true, filterable: true,
filterRemote: true, filterRemote: true,
......
...@@ -4,6 +4,7 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -4,6 +4,7 @@ import axios from '~/lib/utils/axios_utils';
import { deprecatedCreateFlash as Flash } from '~/flash'; import { deprecatedCreateFlash as Flash } from '~/flash';
import { n__, s__, __ } from '~/locale'; import { n__, s__, __ } from '~/locale';
import { LEVEL_TYPES, LEVEL_ID_PROP, ACCESS_LEVEL_NONE } from './constants'; import { LEVEL_TYPES, LEVEL_ID_PROP, ACCESS_LEVEL_NONE } from './constants';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class AccessDropdown { export default class AccessDropdown {
constructor(options) { constructor(options) {
...@@ -29,7 +30,7 @@ export default class AccessDropdown { ...@@ -29,7 +30,7 @@ export default class AccessDropdown {
initDropdown() { initDropdown() {
const { onSelect, onHide } = this.options; const { onSelect, onHide } = this.options;
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.getData.bind(this), data: this.getData.bind(this),
selectable: true, selectable: true,
filterable: true, filterable: true,
......
import { __ } from '~/locale'; import { __ } from '~/locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class ProtectedTagAccessDropdown { export default class ProtectedTagAccessDropdown {
constructor(options) { constructor(options) {
...@@ -8,7 +9,7 @@ export default class ProtectedTagAccessDropdown { ...@@ -8,7 +9,7 @@ export default class ProtectedTagAccessDropdown {
initDropdown() { initDropdown() {
const { onSelect } = this.options; const { onSelect } = this.options;
this.options.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.options.$dropdown, {
data: this.options.data, data: this.options.data,
selectable: true, selectable: true,
inputId: this.options.$dropdown.data('inputId'), inputId: this.options.$dropdown.data('inputId'),
......
...@@ -23,7 +23,7 @@ export default class ProtectedTagCreate { ...@@ -23,7 +23,7 @@ export default class ProtectedTagCreate {
}); });
// Select default // Select default
$allowedToCreateDropdown.data('glDropdown').selectRowAtIndex(0); $allowedToCreateDropdown.data('deprecatedJQueryDropdown').selectRowAtIndex(0);
// Protected tag dropdown // Protected tag dropdown
this.createItemDropdown = new CreateItemDropdown({ this.createItemDropdown = new CreateItemDropdown({
......
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
class RefSelectDropdown { class RefSelectDropdown {
constructor($dropdownButton, availableRefs) { constructor($dropdownButton, availableRefs) {
const availableRefsValue = const availableRefsValue =
availableRefs || JSON.parse(document.getElementById('availableRefs').innerHTML); availableRefs || JSON.parse(document.getElementById('availableRefs').innerHTML);
$dropdownButton.glDropdown({ initDeprecatedJQueryDropdown($dropdownButton, {
data: availableRefsValue, data: availableRefsValue,
filterable: true, filterable: true,
filterByText: true, filterByText: true,
......
...@@ -13,6 +13,7 @@ import { ...@@ -13,6 +13,7 @@ import {
spriteIcon, spriteIcon,
} from './lib/utils/common_utils'; } from './lib/utils/common_utils';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
/** /**
* Search input in top navigation bar. * Search input in top navigation bar.
...@@ -119,7 +120,7 @@ export class SearchAutocomplete { ...@@ -119,7 +120,7 @@ export class SearchAutocomplete {
} }
createAutocomplete() { createAutocomplete() {
return this.searchInput.glDropdown({ return initDeprecatedJQueryDropdown(this.searchInput, {
filterInputBlur: false, filterInputBlur: false,
filterable: true, filterable: true,
filterRemote: true, filterRemote: true,
...@@ -145,10 +146,10 @@ export class SearchAutocomplete { ...@@ -145,10 +146,10 @@ export class SearchAutocomplete {
if (!term) { if (!term) {
const contents = this.getCategoryContents(); const contents = this.getCategoryContents();
if (contents) { if (contents) {
const glDropdownInstance = this.searchInput.data('glDropdown'); const deprecatedJQueryDropdownInstance = this.searchInput.data('deprecatedJQueryDropdown');
if (glDropdownInstance) { if (deprecatedJQueryDropdownInstance) {
glDropdownInstance.filter.options.callback(contents); deprecatedJQueryDropdownInstance.filter.options.callback(contents);
} }
this.enableAutocomplete(); this.enableAutocomplete();
} }
...@@ -463,7 +464,7 @@ export class SearchAutocomplete { ...@@ -463,7 +464,7 @@ export class SearchAutocomplete {
} }
highlightFirstRow() { highlightFirstRow() {
this.searchInput.data('glDropdown').highlightRowAtIndex(null, 0); this.searchInput.data('deprecatedJQueryDropdown').highlightRowAtIndex(null, 0);
} }
getAvatar(item) { getAvatar(item) {
......
...@@ -62,7 +62,7 @@ export default { ...@@ -62,7 +62,7 @@ export default {
this.addAssignee = this.store.addAssignee.bind(this.store); this.addAssignee = this.store.addAssignee.bind(this.store);
this.removeAllAssignees = this.store.removeAllAssignees.bind(this.store); this.removeAllAssignees = this.store.removeAllAssignees.bind(this.store);
// Get events from glDropdown // Get events from deprecatedJQueryDropdown
eventHub.$on('sidebar.removeAssignee', this.removeAssignee); eventHub.$on('sidebar.removeAssignee', this.removeAssignee);
eventHub.$on('sidebar.addAssignee', this.addAssignee); eventHub.$on('sidebar.addAssignee', this.addAssignee);
eventHub.$on('sidebar.removeAllAssignees', this.removeAllAssignees); eventHub.$on('sidebar.removeAllAssignees', this.removeAllAssignees);
......
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
function isValidProjectId(id) { function isValidProjectId(id) {
return id > 0; return id > 0;
...@@ -27,7 +27,7 @@ class SidebarMoveIssue { ...@@ -27,7 +27,7 @@ class SidebarMoveIssue {
} }
initDropdown() { initDropdown() {
this.$dropdownToggle.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdownToggle, {
search: { search: {
fields: ['name_with_namespace'], fields: ['name_with_namespace'],
}, },
......
import $ from 'jquery'; import $ from 'jquery';
import { __ } from './locale'; import { __ } from './locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default function subscriptionSelect() { export default function subscriptionSelect() {
$('.js-subscription-event').each((i, element) => { $('.js-subscription-event').each((i, element) => {
const fieldName = $(element).data('fieldName'); const fieldName = $(element).data('fieldName');
return $(element).glDropdown({ return initDeprecatedJQueryDropdown($(element), {
selectable: true, selectable: true,
fieldName, fieldName,
toggleLabel(selected, el, instance) { toggleLabel(selected, el, instance) {
......
...@@ -33,7 +33,7 @@ export default class IssuableTemplateSelector extends TemplateSelector { ...@@ -33,7 +33,7 @@ export default class IssuableTemplateSelector extends TemplateSelector {
this.templateWarningEl.find('.js-close-btn').on('click', () => { this.templateWarningEl.find('.js-close-btn').on('click', () => {
// Explicitly check against 0 value // Explicitly check against 0 value
if (this.previousSelectedIndex !== undefined) { if (this.previousSelectedIndex !== undefined) {
this.dropdown.data('glDropdown').selectRowAtIndex(this.previousSelectedIndex); this.dropdown.data('deprecatedJQueryDropdown').selectRowAtIndex(this.previousSelectedIndex);
} else { } else {
this.reset(); this.reset();
} }
...@@ -61,7 +61,7 @@ export default class IssuableTemplateSelector extends TemplateSelector { ...@@ -61,7 +61,7 @@ export default class IssuableTemplateSelector extends TemplateSelector {
} }
setSelectedIndex() { setSelectedIndex() {
this.previousSelectedIndex = this.dropdown.data('glDropdown').selectedIndex; this.previousSelectedIndex = this.dropdown.data('deprecatedJQueryDropdown').selectedIndex;
} }
onDropdownClicked(query) { onDropdownClicked(query) {
......
import $ from 'jquery'; import $ from 'jquery';
import Api from './api'; import Api from './api';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default () => { export default () => {
$('#js-project-dropdown').glDropdown({ initDeprecatedJQueryDropdown($('#js-project-dropdown'), {
data: (term, callback) => { data: (term, callback) => {
Api.projects( Api.projects(
term, term,
......
...@@ -13,6 +13,7 @@ import { s__, __, sprintf } from '../locale'; ...@@ -13,6 +13,7 @@ import { s__, __, sprintf } from '../locale';
import ModalStore from '../boards/stores/modal_store'; import ModalStore from '../boards/stores/modal_store';
import { parseBoolean } from '../lib/utils/common_utils'; import { parseBoolean } from '../lib/utils/common_utils';
import { getAjaxUsersSelectOptions, getAjaxUsersSelectParams } from './utils'; import { getAjaxUsersSelectOptions, getAjaxUsersSelectParams } from './utils';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
// TODO: remove eventHub hack after code splitting refactor // TODO: remove eventHub hack after code splitting refactor
window.emitSidebarEvent = window.emitSidebarEvent || $.noop; window.emitSidebarEvent = window.emitSidebarEvent || $.noop;
...@@ -233,14 +234,14 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -233,14 +234,14 @@ function UsersSelect(currentUser, els, options = {}) {
closingTag: '</a>', closingTag: '</a>',
})}</span> <% } %>`, })}</span> <% } %>`,
); );
return $dropdown.glDropdown({ return initDeprecatedJQueryDropdown($dropdown, {
showMenuAbove, showMenuAbove,
data(term, callback) { data(term, callback) {
return userSelect.users(term, options, users => { return userSelect.users(term, options, users => {
// GitLabDropdownFilter returns this.instance // GitLabDropdownFilter returns this.instance
// GitLabDropdownRemote returns this.options.instance // GitLabDropdownRemote returns this.options.instance
const glDropdown = this.instance || this.options.instance; const deprecatedJQueryDropdown = this.instance || this.options.instance;
glDropdown.options.processData(term, users, callback); deprecatedJQueryDropdown.options.processData(term, users, callback);
}); });
}, },
processData(term, data, callback) { processData(term, data, callback) {
...@@ -349,7 +350,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -349,7 +350,7 @@ function UsersSelect(currentUser, els, options = {}) {
callback(users); callback(users);
if (showMenuAbove) { if (showMenuAbove) {
$dropdown.data('glDropdown').positionMenuAbove(); $dropdown.data('deprecatedJQueryDropdown').positionMenuAbove();
} }
}, },
filterable: true, filterable: true,
...@@ -359,13 +360,13 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -359,13 +360,13 @@ function UsersSelect(currentUser, els, options = {}) {
}, },
selectable: true, selectable: true,
fieldName: $dropdown.data('fieldName'), fieldName: $dropdown.data('fieldName'),
toggleLabel(selected, el, glDropdown) { toggleLabel(selected, el, deprecatedJQueryDropdown) {
const inputValue = glDropdown.filterInput.val(); const inputValue = deprecatedJQueryDropdown.filterInput.val();
if (this.multiSelect && inputValue === '') { if (this.multiSelect && inputValue === '') {
// Remove non-users from the fullData array // Remove non-users from the fullData array
const users = glDropdown.filteredFullData(); const users = deprecatedJQueryDropdown.filteredFullData();
const callback = glDropdown.parseData.bind(glDropdown); const callback = deprecatedJQueryDropdown.parseData.bind(deprecatedJQueryDropdown);
// Update the data model // Update the data model
this.processData(inputValue, users, callback); this.processData(inputValue, users, callback);
......
...@@ -105,7 +105,7 @@ input[type='checkbox']:hover { ...@@ -105,7 +105,7 @@ input[type='checkbox']:hover {
} }
.dropdown-header { .dropdown-header {
// Necessary because glDropdown doesn't support a second style of headers // Necessary because deprecatedJQueryDropdown doesn't support a second style of headers
font-weight: $gl-font-weight-bold; font-weight: $gl-font-weight-bold;
color: $gl-text-color; color: $gl-text-color;
font-size: $gl-font-size; font-size: $gl-font-size;
......
<script> <script>
import { GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlLoadingIcon, GlIcon } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import '~/gl_dropdown';
import UsersSelect from '~/users_select'; import UsersSelect from '~/users_select';
import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue'; import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue';
......
import $ from 'jquery'; import $ from 'jquery';
import { __ } from '~/locale'; import { __ } from '~/locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
export default class CiTemplate { export default class CiTemplate {
constructor() { constructor() {
...@@ -10,7 +11,7 @@ export default class CiTemplate { ...@@ -10,7 +11,7 @@ export default class CiTemplate {
} }
initDropdown() { initDropdown() {
this.$dropdown.glDropdown({ initDeprecatedJQueryDropdown(this.$dropdown, {
data: this.formatDropdownList(), data: this.formatDropdownList(),
selectable: true, selectable: true,
filterable: true, filterable: true,
......
/* eslint-disable no-shadow */ /* eslint-disable no-shadow */
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
function WeightSelect(els, options = {}) { function WeightSelect(els, options = {}) {
const $els = $(els || '.js-weight-select'); const $els = $(els || '.js-weight-select');
...@@ -20,7 +20,7 @@ function WeightSelect(els, options = {}) { ...@@ -20,7 +20,7 @@ function WeightSelect(els, options = {}) {
inputField.val(options.selected); inputField.val(options.selected);
} }
return $dropdown.glDropdown({ return initDeprecatedJQueryDropdown($dropdown, {
selectable: true, selectable: true,
fieldName, fieldName,
toggleLabel(selected, el) { toggleLabel(selected, el) {
...@@ -36,9 +36,9 @@ function WeightSelect(els, options = {}) { ...@@ -36,9 +36,9 @@ function WeightSelect(els, options = {}) {
} }
return ''; return '';
}, },
clicked(glDropdownEvt) { clicked(deprecatedJQueryDropdownEvt) {
const { e } = glDropdownEvt; const { e } = deprecatedJQueryDropdownEvt;
let selected = glDropdownEvt.selectedObj; let selected = deprecatedJQueryDropdownEvt.selectedObj;
const inputField = $dropdown.closest('.selectbox').find(`input[name='${fieldName}']`); const inputField = $dropdown.closest('.selectbox').find(`input[name='${fieldName}']`);
if (options.handleClick) { if (options.handleClick) {
......
import CiTemplate from 'ee/pages/admin/application_settings/ci_cd/ci_template'; import CiTemplate from 'ee/pages/admin/application_settings/ci_cd/ci_template';
import { setHTMLFixture } from 'helpers/fixtures'; import { setHTMLFixture } from 'helpers/fixtures';
import '~/gl_dropdown';
const DROPDOWN_DATA = { const DROPDOWN_DATA = {
Instance: [{ name: 'test', id: 'test' }], Instance: [{ name: 'test', id: 'test' }],
......
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import '~/lib/utils/common_utils'; import '~/lib/utils/common_utils';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
...@@ -9,8 +9,8 @@ jest.mock('~/lib/utils/url_utility', () => ({ ...@@ -9,8 +9,8 @@ jest.mock('~/lib/utils/url_utility', () => ({
visitUrl: jest.fn().mockName('visitUrl'), visitUrl: jest.fn().mockName('visitUrl'),
})); }));
describe('glDropdown', () => { describe('deprecatedJQueryDropdown', () => {
preloadFixtures('static/gl_dropdown.html'); preloadFixtures('static/deprecated_jquery_dropdown.html');
const NON_SELECTABLE_CLASSES = const NON_SELECTABLE_CLASSES =
'.divider, .separator, .dropdown-header, .dropdown-menu-empty-item'; '.divider, .separator, .dropdown-header, .dropdown-menu-empty-item';
...@@ -60,14 +60,12 @@ describe('glDropdown', () => { ...@@ -60,14 +60,12 @@ describe('glDropdown', () => {
id: project => project.id, id: project => project.id,
...extraOpts, ...extraOpts,
}; };
test.dropdownButtonElement = $( test.dropdownButtonElement = $('#js-project-dropdown', test.dropdownContainerElement);
'#js-project-dropdown', initDeprecatedJQueryDropdown(test.dropdownButtonElement, options);
test.dropdownContainerElement,
).glDropdown(options);
} }
beforeEach(() => { beforeEach(() => {
loadFixtures('static/gl_dropdown.html'); loadFixtures('static/deprecated_jquery_dropdown.html');
test.dropdownContainerElement = $('.dropdown.inline'); test.dropdownContainerElement = $('.dropdown.inline');
test.$dropdownMenuElement = $('.dropdown-menu', test.dropdownContainerElement); test.$dropdownMenuElement = $('.dropdown-menu', test.dropdownContainerElement);
test.projectsData = getJSONFixture('static/projects.json'); test.projectsData = getJSONFixture('static/projects.json');
...@@ -248,9 +246,9 @@ describe('glDropdown', () => { ...@@ -248,9 +246,9 @@ describe('glDropdown', () => {
function dropdownWithOptions(options) { function dropdownWithOptions(options) {
const $dropdownDiv = $('<div />'); const $dropdownDiv = $('<div />');
$dropdownDiv.glDropdown(options); initDeprecatedJQueryDropdown($dropdownDiv, options);
return $dropdownDiv.data('glDropdown'); return $dropdownDiv.data('deprecatedJQueryDropdown');
} }
function basicDropdown() { function basicDropdown() {
......
...@@ -7,7 +7,6 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -7,7 +7,6 @@ import axios from '~/lib/utils/axios_utils';
import IssuableContext from '~/issuable_context'; import IssuableContext from '~/issuable_context';
import LabelsSelect from '~/labels_select'; import LabelsSelect from '~/labels_select';
import '~/gl_dropdown';
import 'select2'; import 'select2';
import '~/api'; import '~/api';
import '~/create_label'; import '~/create_label';
......
import $ from 'jquery';
import NamespaceSelect from '~/namespace_select'; import NamespaceSelect from '~/namespace_select';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
describe('NamespaceSelect', () => { jest.mock('~/deprecated_jquery_dropdown');
beforeEach(() => {
jest.spyOn($.fn, 'glDropdown').mockImplementation(() => {});
});
it('initializes glDropdown', () => { describe('NamespaceSelect', () => {
it('initializes deprecatedJQueryDropdown', () => {
const dropdown = document.createElement('div'); const dropdown = document.createElement('div');
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new NamespaceSelect({ dropdown }); new NamespaceSelect({ dropdown });
expect($.fn.glDropdown).toHaveBeenCalled(); expect(initDeprecatedJQueryDropdown).toHaveBeenCalled();
}); });
describe('as input', () => { describe('as input', () => {
let glDropdownOptions; let deprecatedJQueryDropdownOptions;
beforeEach(() => { beforeEach(() => {
const dropdown = document.createElement('div'); const dropdown = document.createElement('div');
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new NamespaceSelect({ dropdown }); new NamespaceSelect({ dropdown });
[[glDropdownOptions]] = $.fn.glDropdown.mock.calls; [[, deprecatedJQueryDropdownOptions]] = initDeprecatedJQueryDropdown.mock.calls;
}); });
it('prevents click events', () => { it('prevents click events', () => {
const dummyEvent = new Event('dummy'); const dummyEvent = new Event('dummy');
jest.spyOn(dummyEvent, 'preventDefault').mockImplementation(() => {}); jest.spyOn(dummyEvent, 'preventDefault').mockImplementation(() => {});
glDropdownOptions.clicked({ e: dummyEvent }); // expect(foo).toContain('test');
deprecatedJQueryDropdownOptions.clicked({ e: dummyEvent });
expect(dummyEvent.preventDefault).toHaveBeenCalled(); expect(dummyEvent.preventDefault).toHaveBeenCalled();
}); });
}); });
describe('as filter', () => { describe('as filter', () => {
let glDropdownOptions; let deprecatedJQueryDropdownOptions;
beforeEach(() => { beforeEach(() => {
const dropdown = document.createElement('div'); const dropdown = document.createElement('div');
dropdown.dataset.isFilter = 'true'; dropdown.dataset.isFilter = 'true';
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new NamespaceSelect({ dropdown }); new NamespaceSelect({ dropdown });
[[glDropdownOptions]] = $.fn.glDropdown.mock.calls; [[, deprecatedJQueryDropdownOptions]] = initDeprecatedJQueryDropdown.mock.calls;
}); });
it('does not prevent click events', () => { it('does not prevent click events', () => {
const dummyEvent = new Event('dummy'); const dummyEvent = new Event('dummy');
jest.spyOn(dummyEvent, 'preventDefault').mockImplementation(() => {}); jest.spyOn(dummyEvent, 'preventDefault').mockImplementation(() => {});
glDropdownOptions.clicked({ e: dummyEvent }); deprecatedJQueryDropdownOptions.clicked({ e: dummyEvent });
expect(dummyEvent.preventDefault).not.toHaveBeenCalled(); expect(dummyEvent.preventDefault).not.toHaveBeenCalled();
}); });
...@@ -58,7 +57,7 @@ describe('NamespaceSelect', () => { ...@@ -58,7 +57,7 @@ describe('NamespaceSelect', () => {
it('sets URL of dropdown items', () => { it('sets URL of dropdown items', () => {
const dummyNamespace = { id: 'eal' }; const dummyNamespace = { id: 'eal' };
const itemUrl = glDropdownOptions.url(dummyNamespace); const itemUrl = deprecatedJQueryDropdownOptions.url(dummyNamespace);
expect(itemUrl).toContain(`namespace_id=${dummyNamespace.id}`); expect(itemUrl).toContain(`namespace_id=${dummyNamespace.id}`);
}); });
......
...@@ -2,7 +2,6 @@ import $ from 'jquery'; ...@@ -2,7 +2,6 @@ import $ from 'jquery';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import Todos from '~/pages/dashboard/todos/index/todos'; import Todos from '~/pages/dashboard/todos/index/todos';
import '~/lib/utils/common_utils'; import '~/lib/utils/common_utils';
import '~/gl_dropdown';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { addDelimiter } from '~/lib/utils/text_utility'; import { addDelimiter } from '~/lib/utils/text_utility';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
......
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown';
import TimezoneDropdown, { import TimezoneDropdown, {
formatUtcOffset, formatUtcOffset,
formatTimezone, formatTimezone,
......
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown';
import AccessDropdown from '~/projects/settings/access_dropdown'; import AccessDropdown from '~/projects/settings/access_dropdown';
import { LEVEL_TYPES } from '~/projects/settings/constants'; import { LEVEL_TYPES } from '~/projects/settings/constants';
......
/* eslint-disable no-unused-expressions, consistent-return, no-param-reassign, default-case, no-return-assign */ /* eslint-disable no-unused-expressions, consistent-return, no-param-reassign, default-case, no-return-assign */
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown';
import AxiosMockAdapter from 'axios-mock-adapter'; import AxiosMockAdapter from 'axios-mock-adapter';
import { mockTracking, unmockTracking } from 'helpers/tracking_helper'; import { mockTracking, unmockTracking } from 'helpers/tracking_helper';
import initSearchAutocomplete from '~/search_autocomplete'; import initSearchAutocomplete from '~/search_autocomplete';
...@@ -215,7 +214,7 @@ describe('Search autocomplete dropdown', () => { ...@@ -215,7 +214,7 @@ describe('Search autocomplete dropdown', () => {
function triggerAutocomplete() { function triggerAutocomplete() {
return new Promise(resolve => { return new Promise(resolve => {
const dropdown = widget.searchInput.data('glDropdown'); const dropdown = widget.searchInput.data('deprecatedJQueryDropdown');
const filterCallback = dropdown.filter.options.callback; const filterCallback = dropdown.filter.options.callback;
dropdown.filter.options.callback = jest.fn(data => { dropdown.filter.options.callback = jest.fn(data => {
filterCallback(data); filterCallback(data);
......
...@@ -68,12 +68,10 @@ describe('SidebarMoveIssue', () => { ...@@ -68,12 +68,10 @@ describe('SidebarMoveIssue', () => {
}); });
describe('initDropdown', () => { describe('initDropdown', () => {
it('should initialize the gl_dropdown', () => { it('should initialize the deprecatedJQueryDropdown', () => {
jest.spyOn($.fn, 'glDropdown').mockImplementation(() => {});
test.sidebarMoveIssue.initDropdown(); test.sidebarMoveIssue.initDropdown();
expect($.fn.glDropdown).toHaveBeenCalled(); expect(test.sidebarMoveIssue.$dropdownToggle.data('deprecatedJQueryDropdown')).toBeTruthy();
}); });
it('escapes html from project name', done => { it('escapes html from project name', done => {
......
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