Commit 3def569d authored by Jannik Lehmann's avatar Jannik Lehmann

Remove obsolete DOMContentLoadedEventListener

parent b424f289
import UsersSelect from '~/users_select'; import UsersSelect from '~/users_select';
document.addEventListener('DOMContentLoaded', () => new UsersSelect()); new UsersSelect(); // eslint-disable-line no-new
import mountImportProjectsTable from '~/import_entities/import_projects'; import mountImportProjectsTable from '~/import_entities/import_projects';
document.addEventListener('DOMContentLoaded', () => { const mountElement = document.getElementById('import-projects-mount-element');
const mountElement = document.getElementById('import-projects-mount-element');
mountImportProjectsTable(mountElement); mountImportProjectsTable(mountElement);
});
import { initClose2faSuccessMessage } from '~/authentication/two_factor_auth'; import { initClose2faSuccessMessage } from '~/authentication/two_factor_auth';
import initProfileAccount from '~/profile/account'; import initProfileAccount from '~/profile/account';
document.addEventListener('DOMContentLoaded', initProfileAccount); initProfileAccount();
initClose2faSuccessMessage(); initClose2faSuccessMessage();
import initConfirmModal from '~/confirm_modal'; import initConfirmModal from '~/confirm_modal';
import AddSshKeyValidation from '~/profile/add_ssh_key_validation'; import AddSshKeyValidation from '~/profile/add_ssh_key_validation';
document.addEventListener('DOMContentLoaded', () => { initConfirmModal();
initConfirmModal();
function initSshKeyValidation() {
const input = document.querySelector('.js-add-ssh-key-validation-input'); const input = document.querySelector('.js-add-ssh-key-validation-input');
if (!input) return; if (!input) return;
...@@ -18,4 +18,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -18,4 +18,6 @@ document.addEventListener('DOMContentLoaded', () => {
confirmSubmit, confirmSubmit,
); );
addSshKeyValidation.register(); addSshKeyValidation.register();
}); }
initSshKeyValidation();
...@@ -2,17 +2,15 @@ import { mount2faRegistration } from '~/authentication/mount_2fa'; ...@@ -2,17 +2,15 @@ import { mount2faRegistration } from '~/authentication/mount_2fa';
import { initRecoveryCodes } from '~/authentication/two_factor_auth'; import { initRecoveryCodes } from '~/authentication/two_factor_auth';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
document.addEventListener('DOMContentLoaded', () => { const twoFactorNode = document.querySelector('.js-two-factor-auth');
const twoFactorNode = document.querySelector('.js-two-factor-auth'); const skippable = twoFactorNode ? parseBoolean(twoFactorNode.dataset.twoFactorSkippable) : false;
const skippable = twoFactorNode ? parseBoolean(twoFactorNode.dataset.twoFactorSkippable) : false;
if (skippable) { if (skippable) {
const button = `<a class="btn btn-sm btn-warning float-right" data-qa-selector="configure_it_later_button" data-method="patch" href="${twoFactorNode.dataset.two_factor_skip_url}">Configure it later</a>`; const button = `<a class="btn btn-sm btn-warning float-right" data-qa-selector="configure_it_later_button" data-method="patch" href="${twoFactorNode.dataset.two_factor_skip_url}">Configure it later</a>`;
const flashAlert = document.querySelector('.flash-alert'); const flashAlert = document.querySelector('.flash-alert');
if (flashAlert) flashAlert.insertAdjacentHTML('beforeend', button); if (flashAlert) flashAlert.insertAdjacentHTML('beforeend', button);
} }
mount2faRegistration(); mount2faRegistration();
});
initRecoveryCodes(); initRecoveryCodes();
...@@ -7,151 +7,149 @@ import SeriesDataMixin from './series_data_mixin'; ...@@ -7,151 +7,149 @@ import SeriesDataMixin from './series_data_mixin';
const seriesDataToBarData = (raw) => Object.entries(raw).map(([name, data]) => ({ name, data })); const seriesDataToBarData = (raw) => Object.entries(raw).map(([name, data]) => ({ name, data }));
document.addEventListener('DOMContentLoaded', () => { waitForCSSLoaded(() => {
waitForCSSLoaded(() => { const languagesContainer = document.getElementById('js-languages-chart');
const languagesContainer = document.getElementById('js-languages-chart'); const codeCoverageContainer = document.getElementById('js-code-coverage-chart');
const codeCoverageContainer = document.getElementById('js-code-coverage-chart'); const monthContainer = document.getElementById('js-month-chart');
const monthContainer = document.getElementById('js-month-chart'); const weekdayContainer = document.getElementById('js-weekday-chart');
const weekdayContainer = document.getElementById('js-weekday-chart'); const hourContainer = document.getElementById('js-hour-chart');
const hourContainer = document.getElementById('js-hour-chart'); const LANGUAGE_CHART_HEIGHT = 300;
const LANGUAGE_CHART_HEIGHT = 300; const reorderWeekDays = (weekDays, firstDayOfWeek = 0) => {
const reorderWeekDays = (weekDays, firstDayOfWeek = 0) => { if (firstDayOfWeek === 0) {
if (firstDayOfWeek === 0) { return weekDays;
return weekDays; }
}
return Object.keys(weekDays).reduce((acc, dayName, idx, arr) => { return Object.keys(weekDays).reduce((acc, dayName, idx, arr) => {
const reorderedDayName = arr[(idx + firstDayOfWeek) % arr.length]; const reorderedDayName = arr[(idx + firstDayOfWeek) % arr.length];
return { return {
...acc, ...acc,
[reorderedDayName]: weekDays[reorderedDayName], [reorderedDayName]: weekDays[reorderedDayName],
}; };
}, {}); }, {});
}; };
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: languagesContainer, el: languagesContainer,
components: { components: {
GlColumnChart, GlColumnChart,
},
data() {
return {
chartData: JSON.parse(languagesContainer.dataset.chartData),
};
},
computed: {
seriesData() {
return [{ name: 'full', data: this.chartData.map((d) => [d.label, d.value]) }];
}, },
data() { },
return { render(h) {
chartData: JSON.parse(languagesContainer.dataset.chartData), return h(GlColumnChart, {
}; props: {
}, bars: this.seriesData,
computed: { xAxisTitle: __('Used programming language'),
seriesData() { yAxisTitle: __('Percentage'),
return [{ name: 'full', data: this.chartData.map((d) => [d.label, d.value]) }]; xAxisType: 'category',
}, },
}, attrs: {
render(h) { height: LANGUAGE_CHART_HEIGHT,
return h(GlColumnChart, { },
props: { });
bars: this.seriesData, },
xAxisTitle: __('Used programming language'), });
yAxisTitle: __('Percentage'),
xAxisType: 'category',
},
attrs: {
height: LANGUAGE_CHART_HEIGHT,
},
});
},
});
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: codeCoverageContainer, el: codeCoverageContainer,
render(h) { render(h) {
return h(CodeCoverage, { return h(CodeCoverage, {
props: { props: {
graphEndpoint: codeCoverageContainer.dataset?.graphEndpoint, graphEndpoint: codeCoverageContainer.dataset?.graphEndpoint,
}, },
}); });
}, },
}); });
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: monthContainer, el: monthContainer,
components: { components: {
GlColumnChart, GlColumnChart,
}, },
mixins: [SeriesDataMixin], mixins: [SeriesDataMixin],
data() { data() {
return { return {
chartData: JSON.parse(monthContainer.dataset.chartData), chartData: JSON.parse(monthContainer.dataset.chartData),
}; };
}, },
render(h) { render(h) {
return h(GlColumnChart, { return h(GlColumnChart, {
props: { props: {
bars: seriesDataToBarData(this.seriesData), bars: seriesDataToBarData(this.seriesData),
xAxisTitle: __('Day of month'), xAxisTitle: __('Day of month'),
yAxisTitle: __('No. of commits'), yAxisTitle: __('No. of commits'),
xAxisType: 'category', xAxisType: 'category',
}, },
}); });
}, },
}); });
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: weekdayContainer, el: weekdayContainer,
components: { components: {
GlColumnChart, GlColumnChart,
}, },
data() { data() {
return { return {
chartData: JSON.parse(weekdayContainer.dataset.chartData), chartData: JSON.parse(weekdayContainer.dataset.chartData),
}; };
},
computed: {
seriesData() {
const weekDays = reorderWeekDays(this.chartData, gon.first_day_of_week);
const data = Object.keys(weekDays).reduce((acc, key) => {
acc.push([key, weekDays[key]]);
return acc;
}, []);
return [{ name: 'full', data }];
}, },
computed: { },
seriesData() { render(h) {
const weekDays = reorderWeekDays(this.chartData, gon.first_day_of_week); return h(GlColumnChart, {
const data = Object.keys(weekDays).reduce((acc, key) => { props: {
acc.push([key, weekDays[key]]); bars: this.seriesData,
return acc; xAxisTitle: __('Weekday'),
}, []); yAxisTitle: __('No. of commits'),
return [{ name: 'full', data }]; xAxisType: 'category',
}, },
}, });
render(h) { },
return h(GlColumnChart, { });
props: {
bars: this.seriesData,
xAxisTitle: __('Weekday'),
yAxisTitle: __('No. of commits'),
xAxisType: 'category',
},
});
},
});
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new Vue({ new Vue({
el: hourContainer, el: hourContainer,
components: { components: {
GlColumnChart, GlColumnChart,
}, },
mixins: [SeriesDataMixin], mixins: [SeriesDataMixin],
data() { data() {
return { return {
chartData: JSON.parse(hourContainer.dataset.chartData), chartData: JSON.parse(hourContainer.dataset.chartData),
}; };
}, },
render(h) { render(h) {
return h(GlColumnChart, { return h(GlColumnChart, {
props: { props: {
bars: seriesDataToBarData(this.seriesData), bars: seriesDataToBarData(this.seriesData),
xAxisTitle: __('Hour (UTC)'), xAxisTitle: __('Hour (UTC)'),
yAxisTitle: __('No. of commits'), yAxisTitle: __('No. of commits'),
xAxisType: 'category', xAxisType: 'category',
}, },
}); });
}, },
});
}); });
}); });
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