All files / app/assets/javascripts/pages/projects/pipeline_schedules/index index.js

0% Statements 0/22
0% Branches 0/4
0% Functions 0/8
0% Lines 0/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                                                                       
import Vue from 'vue';
import { BV_SHOW_MODAL } from '~/lib/utils/constants';
import PipelineSchedulesTakeOwnershipModal from '~/pipeline_schedules/components/take_ownership_modal.vue';
import PipelineSchedulesCallout from '../shared/components/pipeline_schedules_callout.vue';
 
function initPipelineSchedules() {
  const el = document.getElementById('pipeline-schedules-callout');
 
  if (!el) {
    return;
  }
 
  const { docsUrl, illustrationUrl } = el.dataset;
 
  // eslint-disable-next-line no-new
  new Vue({
    el,
    provide: {
      docsUrl,
      illustrationUrl,
    },
    render(createElement) {
      return createElement(PipelineSchedulesCallout);
    },
  });
}
 
function initTakeownershipModal() {
  const modalId = 'pipeline-take-ownership-modal';
  const buttonSelector = 'js-take-ownership-button';
  const el = document.getElementById(modalId);
  const takeOwnershipButtons = document.querySelectorAll(`.${buttonSelector}`);
 
  if (!el) {
    return;
  }
 
  // eslint-disable-next-line no-new
  new Vue({
    el,
    data() {
      return {
        url: '',
      };
    },
    mounted() {
      takeOwnershipButtons.forEach((button) => {
        button.addEventListener('click', () => {
          const { url } = button.dataset;
 
          this.url = url;
          this.$root.$emit(BV_SHOW_MODAL, modalId, `.${buttonSelector}`);
        });
      });
    },
    render(createElement) {
      return createElement(PipelineSchedulesTakeOwnershipModal, {
        props: {
          ownershipUrl: this.url,
        },
      });
    },
  });
}
 
initPipelineSchedules();
initTakeownershipModal();