Commit cfb9fa65 authored by David O'Regan's avatar David O'Regan

Merge branch 'mrincon-instanciate-pipelines-table-correctly' into 'master'

Instantiate the Pipelines table in the commit page using a Vue render function

See merge request gitlab-org/gitlab!54239
parents 0a877848 6d210510
import Vue from 'vue'; import Vue from 'vue';
import commitPipelinesTable from './pipelines_table.vue'; import CommitPipelinesTable from './pipelines_table.vue';
/** /**
* Used in: * Used in:
...@@ -8,14 +8,6 @@ import commitPipelinesTable from './pipelines_table.vue'; ...@@ -8,14 +8,6 @@ import commitPipelinesTable from './pipelines_table.vue';
* - Merge Request details View > Pipelines Tab > Pipelines Table (projects:merge_requests:show) * - Merge Request details View > Pipelines Tab > Pipelines Table (projects:merge_requests:show)
* - New Merge Request View > Pipelines Tab > Pipelines Table (projects:merge_requests:creations:new) * - New Merge Request View > Pipelines Tab > Pipelines Table (projects:merge_requests:creations:new)
*/ */
const CommitPipelinesTable = Vue.extend(commitPipelinesTable);
// export for use in merge_request_tabs.js (TODO: remove this hack when we understand how to load
// vue.js in merge_request_tabs.js)
window.gl = window.gl || {};
window.gl.CommitPipelinesTable = CommitPipelinesTable;
export default () => { export default () => {
const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view'); const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view');
...@@ -34,13 +26,17 @@ export default () => { ...@@ -34,13 +26,17 @@ export default () => {
}); });
if (pipelineTableViewEl.dataset.disableInitialization === undefined) { if (pipelineTableViewEl.dataset.disableInitialization === undefined) {
const table = new CommitPipelinesTable({ const table = new Vue({
propsData: { render(createElement) {
endpoint: pipelineTableViewEl.dataset.endpoint, return createElement(CommitPipelinesTable, {
helpPagePath: pipelineTableViewEl.dataset.helpPagePath, props: {
emptyStateSvgPath: pipelineTableViewEl.dataset.emptyStateSvgPath, endpoint: pipelineTableViewEl.dataset.endpoint,
errorStateSvgPath: pipelineTableViewEl.dataset.errorStateSvgPath, helpPagePath: pipelineTableViewEl.dataset.helpPagePath,
autoDevopsHelpPath: pipelineTableViewEl.dataset.helpAutoDevopsPath, emptyStateSvgPath: pipelineTableViewEl.dataset.emptyStateSvgPath,
errorStateSvgPath: pipelineTableViewEl.dataset.errorStateSvgPath,
autoDevopsHelpPath: pipelineTableViewEl.dataset.helpAutoDevopsPath,
},
});
}, },
}).$mount(); }).$mount();
pipelineTableViewEl.appendChild(table.$el); pipelineTableViewEl.appendChild(table.$el);
......
/* eslint-disable no-new, class-methods-use-this */ /* eslint-disable no-new, class-methods-use-this */
import { GlBreakpointInstance as bp } from '@gitlab/ui/dist/utils'; 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 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 initAddContextCommitsTriggers from './add_context_commits_modal';
import BlobForkSuggestion from './blob/blob_fork_suggestion'; import BlobForkSuggestion from './blob/blob_fork_suggestion';
...@@ -350,26 +351,30 @@ export default class MergeRequestTabs { ...@@ -350,26 +351,30 @@ export default class MergeRequestTabs {
mountPipelinesView() { mountPipelinesView() {
const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view'); const pipelineTableViewEl = document.querySelector('#commit-pipeline-table-view');
const { CommitPipelinesTable, mrWidgetData } = gl; const { mrWidgetData } = gl;
this.commitPipelinesTable = new CommitPipelinesTable({ this.commitPipelinesTable = new Vue({
propsData: {
endpoint: pipelineTableViewEl.dataset.endpoint,
helpPagePath: pipelineTableViewEl.dataset.helpPagePath,
emptyStateSvgPath: pipelineTableViewEl.dataset.emptyStateSvgPath,
errorStateSvgPath: pipelineTableViewEl.dataset.errorStateSvgPath,
autoDevopsHelpPath: pipelineTableViewEl.dataset.helpAutoDevopsPath,
canCreatePipelineInTargetProject: Boolean(
mrWidgetData?.can_create_pipeline_in_target_project,
),
sourceProjectFullPath: mrWidgetData?.source_project_full_path || '',
targetProjectFullPath: mrWidgetData?.target_project_full_path || '',
projectId: pipelineTableViewEl.dataset.projectId,
mergeRequestId: mrWidgetData ? mrWidgetData.iid : null,
},
provide: { provide: {
targetProjectFullPath: mrWidgetData?.target_project_full_path || '', targetProjectFullPath: mrWidgetData?.target_project_full_path || '',
}, },
render(createElement) {
return createElement(CommitPipelinesTable, {
props: {
endpoint: pipelineTableViewEl.dataset.endpoint,
helpPagePath: pipelineTableViewEl.dataset.helpPagePath,
emptyStateSvgPath: pipelineTableViewEl.dataset.emptyStateSvgPath,
errorStateSvgPath: pipelineTableViewEl.dataset.errorStateSvgPath,
autoDevopsHelpPath: pipelineTableViewEl.dataset.helpAutoDevopsPath,
canCreatePipelineInTargetProject: Boolean(
mrWidgetData?.can_create_pipeline_in_target_project,
),
sourceProjectFullPath: mrWidgetData?.source_project_full_path || '',
targetProjectFullPath: mrWidgetData?.target_project_full_path || '',
projectId: pipelineTableViewEl.dataset.projectId,
mergeRequestId: mrWidgetData ? mrWidgetData.iid : null,
},
});
},
}).$mount(); }).$mount();
// $mount(el) replaces the el with the new rendered component. We need it in order to mount // $mount(el) replaces the el with the new rendered component. We need it in order to mount
......
...@@ -3,7 +3,6 @@ import $ from 'jquery'; ...@@ -3,7 +3,6 @@ import $ from 'jquery';
import initMrPage from 'helpers/init_vue_mr_page_helper'; import initMrPage from 'helpers/init_vue_mr_page_helper';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import MergeRequestTabs from '~/merge_request_tabs'; import MergeRequestTabs from '~/merge_request_tabs';
import '~/commit/pipelines/pipelines_bundle';
import '~/lib/utils/common_utils'; import '~/lib/utils/common_utils';
jest.mock('~/lib/utils/webpack', () => ({ jest.mock('~/lib/utils/webpack', () => ({
......
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