summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pipelines/pipeline_details_bundle.js
blob: 338de65e795509c1c8c201d32e0d0943b688e370 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import createFlash from '~/flash';
import { __ } from '~/locale';
import createDagApp from './pipeline_details_dag';
import { createPipelinesDetailApp } from './pipeline_details_graph';
import { createPipelineHeaderApp } from './pipeline_details_header';
import { createPipelineNotificationApp } from './pipeline_details_notification';
import { createPipelineJobsApp } from './pipeline_details_jobs';
import { apolloProvider } from './pipeline_shared_client';
import { createTestDetails } from './pipeline_test_details';

const SELECTORS = {
  PIPELINE_DETAILS: '.js-pipeline-details-vue',
  PIPELINE_GRAPH: '#js-pipeline-graph-vue',
  PIPELINE_HEADER: '#js-pipeline-header-vue',
  PIPELINE_NOTIFICATION: '#js-pipeline-notification',
  PIPELINE_TABS: '#js-pipeline-tabs',
  PIPELINE_TESTS: '#js-pipeline-tests-detail',
  PIPELINE_JOBS: '#js-pipeline-jobs-vue',
};

export default async function initPipelineDetailsBundle() {
  const { dataset } = document.querySelector(SELECTORS.PIPELINE_DETAILS);

  try {
    createPipelineHeaderApp(SELECTORS.PIPELINE_HEADER, apolloProvider, dataset.graphqlResourceEtag);
  } catch {
    createFlash({
      message: __('An error occurred while loading a section of this page.'),
    });
  }

  try {
    createPipelineNotificationApp(SELECTORS.PIPELINE_NOTIFICATION, apolloProvider);
  } catch {
    createFlash({
      message: __('An error occurred while loading a section of this page.'),
    });
  }

  if (gon.features?.pipelineTabsVue) {
    const { createPipelineTabs } = await import('./pipeline_tabs');

    try {
      createPipelineTabs(SELECTORS.PIPELINE_TABS, apolloProvider);
    } catch {
      createFlash({
        message: __('An error occurred while loading a section of this page.'),
      });
    }
  } else {
    try {
      createPipelinesDetailApp(SELECTORS.PIPELINE_GRAPH, apolloProvider, dataset);
    } catch {
      createFlash({
        message: __('An error occurred while loading the pipeline.'),
      });
    }

    try {
      createDagApp(apolloProvider);
    } catch {
      createFlash({
        message: __('An error occurred while loading the Needs tab.'),
      });
    }

    try {
      createTestDetails(SELECTORS.PIPELINE_TESTS);
    } catch {
      createFlash({
        message: __('An error occurred while loading the Test Reports tab.'),
      });
    }

    try {
      createPipelineJobsApp(SELECTORS.PIPELINE_JOBS);
    } catch {
      createFlash({
        message: __('An error occurred while loading the Jobs tab.'),
      });
    }
  }
}