Commit 0c766b96 authored by Jannik Lehmann's avatar Jannik Lehmann Committed by Enrique Alcántara

Remove DOMContentLoaded Eventlisteners

Removing DOMContentLoaded Eventlisteners from
index files since the scripts
are embedded using the defer tag.
parent 9546e89c
import initInsights from 'ee/insights'; import initInsights from 'ee/insights';
document.addEventListener('DOMContentLoaded', () => { initInsights();
initInsights();
});
import initTestCaseList from 'ee/test_case_list/test_case_list_bundle'; import initTestCaseList from 'ee/test_case_list/test_case_list_bundle';
document.addEventListener('DOMContentLoaded', () => { initTestCaseList({
initTestCaseList({ mountPointSelector: '#js-test-cases-list',
mountPointSelector: '#js-test-cases-list',
});
}); });
import { initTestCaseCreate } from 'ee/test_case_create/test_case_create_bundle'; import { initTestCaseCreate } from 'ee/test_case_create/test_case_create_bundle';
document.addEventListener('DOMContentLoaded', () => { initTestCaseCreate({
initTestCaseCreate({ mountPointSelector: '#js-create-test-case',
mountPointSelector: '#js-create-test-case',
});
}); });
...@@ -6,33 +6,31 @@ import ProtectedEnvironmentEditList from 'ee/protected_environments/protected_en ...@@ -6,33 +6,31 @@ import ProtectedEnvironmentEditList from 'ee/protected_environments/protected_en
import showToast from '~/vue_shared/plugins/global_toast'; import showToast from '~/vue_shared/plugins/global_toast';
import '~/pages/projects/settings/ci_cd/show/index'; import '~/pages/projects/settings/ci_cd/show/index';
document.addEventListener('DOMContentLoaded', () => { const el = document.getElementById('js-managed-licenses');
const el = document.getElementById('js-managed-licenses'); const toasts = document.querySelectorAll('.js-toast-message');
const toasts = document.querySelectorAll('.js-toast-message');
if (el && el.dataset && el.dataset.apiUrl) { if (el?.dataset?.apiUrl) {
const store = createStore(); const store = createStore();
store.dispatch('licenseManagement/setIsAdmin', Boolean(el.dataset.apiUrl)); store.dispatch('licenseManagement/setIsAdmin', Boolean(el.dataset.apiUrl));
store.dispatch('licenseManagement/setAPISettings', { apiUrlManageLicenses: el.dataset.apiUrl }); store.dispatch('licenseManagement/setAPISettings', { apiUrlManageLicenses: el.dataset.apiUrl });
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el, el,
store, store,
render(createElement) { render(createElement) {
return createElement(LicenseManagement, { return createElement(LicenseManagement, {
props: { props: {
...el.dataset, ...el.dataset,
}, },
}); });
}, },
}); });
} }
toasts.forEach(toast => showToast(toast.dataset.message)); toasts.forEach(toast => showToast(toast.dataset.message));
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new ProtectedEnvironmentCreate(); new ProtectedEnvironmentCreate();
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new ProtectedEnvironmentEditList(); new ProtectedEnvironmentEditList();
});
...@@ -3,24 +3,22 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -3,24 +3,22 @@ import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { deprecatedCreateFlash as Flash } from '~/flash'; import { deprecatedCreateFlash as Flash } from '~/flash';
document.addEventListener('DOMContentLoaded', () => { const selectElement = document.getElementById('country_select');
const selectElement = document.getElementById('country_select'); const { countriesEndPoint, selectedOption } = selectElement.dataset;
const { countriesEndPoint, selectedOption } = selectElement.dataset;
axios axios
.get(countriesEndPoint) .get(countriesEndPoint)
.then(({ data }) => { .then(({ data }) => {
// fill #country_select element with array of <option>s // fill #country_select element with array of <option>s
data.forEach(([name, code]) => { data.forEach(([name, code]) => {
const option = document.createElement('option'); const option = document.createElement('option');
option.value = code; option.value = code;
option.text = name; option.text = name;
selectElement.appendChild(option); selectElement.appendChild(option);
}); });
$(selectElement) $(selectElement)
.val(selectedOption) .val(selectedOption)
.trigger('change.select2'); .trigger('change.select2');
}) })
.catch(() => new Flash(__('Error loading countries data.'))); .catch(() => new Flash(__('Error loading countries data.')));
});
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