Commit 9f496541 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/mrPageReduceJSLoad' into 'master'

Reduces the bundle size of the merge request page

See merge request gitlab-org/gitlab!65759
parents d612507b a92ac6a7
import Vue from 'vue'; import Vue from 'vue';
import CommitPipelinesTable from './pipelines_table.vue';
/** /**
* Used in: * Used in:
...@@ -23,12 +22,15 @@ export default () => { ...@@ -23,12 +22,15 @@ export default () => {
if (pipelineTableViewEl.dataset.disableInitialization === undefined) { if (pipelineTableViewEl.dataset.disableInitialization === undefined) {
const table = new Vue({ const table = new Vue({
components: {
CommitPipelinesTable: () => import('~/commit/pipelines/pipelines_table.vue'),
},
provide: { provide: {
artifactsEndpoint: pipelineTableViewEl.dataset.artifactsEndpoint, artifactsEndpoint: pipelineTableViewEl.dataset.artifactsEndpoint,
artifactsEndpointPlaceholder: pipelineTableViewEl.dataset.artifactsEndpointPlaceholder, artifactsEndpointPlaceholder: pipelineTableViewEl.dataset.artifactsEndpointPlaceholder,
}, },
render(createElement) { render(createElement) {
return createElement(CommitPipelinesTable, { return createElement('commit-pipelines-table', {
props: { props: {
endpoint: pipelineTableViewEl.dataset.endpoint, endpoint: pipelineTableViewEl.dataset.endpoint,
emptyStateSvgPath: pipelineTableViewEl.dataset.emptyStateSvgPath, emptyStateSvgPath: pipelineTableViewEl.dataset.emptyStateSvgPath,
......
...@@ -9,19 +9,23 @@ export default class IssuableContext { ...@@ -9,19 +9,23 @@ export default class IssuableContext {
this.userSelect = new UsersSelect(currentUser); this.userSelect = new UsersSelect(currentUser);
this.reviewersSelect = new UsersSelect(currentUser, '.js-reviewer-search'); this.reviewersSelect = new UsersSelect(currentUser, '.js-reviewer-search');
import(/* webpackChunkName: 'select2' */ 'select2/select2') const $select2 = $('select.select2');
.then(() => {
// eslint-disable-next-line promise/no-nesting if ($select2.length) {
loadCSSFile(gon.select2_css_path) import(/* webpackChunkName: 'select2' */ 'select2/select2')
.then(() => { .then(() => {
$('select.select2').select2({ // eslint-disable-next-line promise/no-nesting
width: 'resolve', loadCSSFile(gon.select2_css_path)
dropdownAutoWidth: true, .then(() => {
}); $select2.select2({
}) width: 'resolve',
.catch(() => {}); dropdownAutoWidth: true,
}) });
.catch(() => {}); })
.catch(() => {});
})
.catch(() => {});
}
$('.issuable-sidebar .inline-update').on('change', 'select', function onClickSelect() { $('.issuable-sidebar .inline-update').on('change', 'select', function onClickSelect() {
return $(this).submit(); return $(this).submit();
......
...@@ -148,14 +148,6 @@ MergeRequest.prototype.initCommitMessageListeners = function () { ...@@ -148,14 +148,6 @@ MergeRequest.prototype.initCommitMessageListeners = function () {
}); });
}; };
MergeRequest.setStatusBoxToMerged = function () {
$('.detail-page-header .status-box')
.removeClass('status-box-open')
.addClass('status-box-mr-merged')
.find('span')
.text(__('Merged'));
};
MergeRequest.decreaseCounter = function (by = 1) { MergeRequest.decreaseCounter = function (by = 1) {
const $el = $('.js-merge-counter'); const $el = $('.js-merge-counter');
const count = Math.max(parseInt($el.text().replace(/[^\d]/, ''), 10) - by, 0); const count = Math.max(parseInt($el.text().replace(/[^\d]/, ''), 10) - by, 0);
......
...@@ -3,9 +3,7 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; ...@@ -3,9 +3,7 @@ import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils';
import $ from 'jquery'; import $ from 'jquery';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import Vue from 'vue'; import Vue from 'vue';
import CommitPipelinesTable from '~/commit/pipelines/pipelines_table.vue';
import createEventHub from '~/helpers/event_hub_factory'; import createEventHub from '~/helpers/event_hub_factory';
import initAddContextCommitsTriggers from './add_context_commits_modal';
import BlobForkSuggestion from './blob/blob_fork_suggestion'; import BlobForkSuggestion from './blob/blob_fork_suggestion';
import Diff from './diff'; import Diff from './diff';
import createFlash from './flash'; import createFlash from './flash';
...@@ -341,8 +339,10 @@ export default class MergeRequestTabs { ...@@ -341,8 +339,10 @@ export default class MergeRequestTabs {
this.scrollToContainerElement('#commits'); this.scrollToContainerElement('#commits');
this.toggleLoading(false); this.toggleLoading(false);
initAddContextCommitsTriggers();
return import('./add_context_commits_modal');
}) })
.then((m) => m.default())
.catch(() => { .catch(() => {
this.toggleLoading(false); this.toggleLoading(false);
createFlash({ createFlash({
...@@ -356,13 +356,16 @@ export default class MergeRequestTabs { ...@@ -356,13 +356,16 @@ export default class MergeRequestTabs {
const { mrWidgetData } = gl; const { mrWidgetData } = gl;
this.commitPipelinesTable = new Vue({ this.commitPipelinesTable = new Vue({
components: {
CommitPipelinesTable: () => import('~/commit/pipelines/pipelines_table.vue'),
},
provide: { provide: {
artifactsEndpoint: pipelineTableViewEl.dataset.artifactsEndpoint, artifactsEndpoint: pipelineTableViewEl.dataset.artifactsEndpoint,
artifactsEndpointPlaceholder: pipelineTableViewEl.dataset.artifactsEndpointPlaceholder, artifactsEndpointPlaceholder: pipelineTableViewEl.dataset.artifactsEndpointPlaceholder,
targetProjectFullPath: mrWidgetData?.target_project_full_path || '', targetProjectFullPath: mrWidgetData?.target_project_full_path || '',
}, },
render(createElement) { render(createElement) {
return createElement(CommitPipelinesTable, { return createElement('commit-pipelines-table', {
props: { props: {
endpoint: pipelineTableViewEl.dataset.endpoint, endpoint: pipelineTableViewEl.dataset.endpoint,
emptyStateSvgPath: pipelineTableViewEl.dataset.emptyStateSvgPath, emptyStateSvgPath: pipelineTableViewEl.dataset.emptyStateSvgPath,
......
...@@ -412,7 +412,6 @@ export default { ...@@ -412,7 +412,6 @@ export default {
// If state is merged we should update the widget and stop the polling // If state is merged we should update the widget and stop the polling
eventHub.$emit('MRWidgetUpdateRequested'); eventHub.$emit('MRWidgetUpdateRequested');
eventHub.$emit('FetchActionsContent'); eventHub.$emit('FetchActionsContent');
MergeRequest.setStatusBoxToMerged();
MergeRequest.hideCloseButton(); MergeRequest.hideCloseButton();
MergeRequest.decreaseCounter(); MergeRequest.decreaseCounter();
stopPolling(); stopPolling();
......
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