summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/pages/projects/pipelines/index/index.js
blob: bbad3238ec47385fd6fcd796cfb78406a6b39068 (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
import Vue from 'vue';
import { GlToast } from '@gitlab/ui';
import { doesHashExistInUrl } from '~/lib/utils/url_utility';
import {
  parseBoolean,
  historyReplaceState,
  buildUrlWithCurrentLocation,
} from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import PipelinesStore from '../../../../pipelines/stores/pipelines_store';
import pipelinesComponent from '../../../../pipelines/components/pipelines.vue';
import Translate from '../../../../vue_shared/translate';

Vue.use(Translate);
Vue.use(GlToast);

document.addEventListener(
  'DOMContentLoaded',
  () =>
    new Vue({
      el: '#pipelines-list-vue',
      components: {
        pipelinesComponent,
      },
      data() {
        return {
          store: new PipelinesStore(),
        };
      },
      created() {
        this.dataset = document.querySelector(this.$options.el).dataset;

        if (doesHashExistInUrl('delete_success')) {
          this.$toast.show(__('The pipeline has been deleted'));
          historyReplaceState(buildUrlWithCurrentLocation());
        }
      },
      render(createElement) {
        return createElement('pipelines-component', {
          props: {
            store: this.store,
            endpoint: this.dataset.endpoint,
            helpPagePath: this.dataset.helpPagePath,
            emptyStateSvgPath: this.dataset.emptyStateSvgPath,
            errorStateSvgPath: this.dataset.errorStateSvgPath,
            noPipelinesSvgPath: this.dataset.noPipelinesSvgPath,
            autoDevopsPath: this.dataset.helpAutoDevopsPath,
            newPipelinePath: this.dataset.newPipelinePath,
            canCreatePipeline: parseBoolean(this.dataset.canCreatePipeline),
            hasGitlabCi: parseBoolean(this.dataset.hasGitlabCi),
            ciLintPath: this.dataset.ciLintPath,
            resetCachePath: this.dataset.resetCachePath,
            projectId: this.dataset.projectId,
          },
        });
      },
    }),
);