Commit 9c4f6ecb authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch 'remove-eventlisteners-setting-pages' into 'master'

Remove DOMContentLoaded Eventlistener

See merge request gitlab-org/gitlab!47621
parents 695735e3 0c766b96
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,11 +6,10 @@ import ProtectedEnvironmentEditList from 'ee/protected_environments/protected_en ...@@ -6,11 +6,10 @@ 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 });
...@@ -26,13 +25,12 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -26,13 +25,12 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
}, },
}); });
} }
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,11 +3,10 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -3,11 +3,10 @@ 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
...@@ -23,4 +22,3 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -23,4 +22,3 @@ document.addEventListener('DOMContentLoaded', () => {
.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