summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/sidebar/sidebar_bundle.js
blob: 3d8972050a9a9de1ccc27b47b828d3703dce4878 (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
import Vue from 'vue';
import sidebarTimeTracking from './components/time_tracking/sidebar_time_tracking';
import sidebarAssignees from './components/assignees/sidebar_assignees';
import confidential from './components/confidential/confidential_issue_sidebar.vue';
import SidebarMoveIssue from './lib/sidebar_move_issue';

import Mediator from './sidebar_mediator';

function domContentLoaded() {
  const sidebarOptions = JSON.parse(document.querySelector('.js-sidebar-options').innerHTML);
  const mediator = new Mediator(sidebarOptions);
  mediator.fetch();

  const sidebarAssigneesEl = document.querySelector('#js-vue-sidebar-assignees');
  const confidentialEl = document.querySelector('#js-confidential-entry-point');
  // Only create the sidebarAssignees vue app if it is found in the DOM
  // We currently do not use sidebarAssignees for the MR page
  if (sidebarAssigneesEl) {
    new Vue(sidebarAssignees).$mount(sidebarAssigneesEl);
  }

  if (confidentialEl) {
    const dataNode = document.getElementById('js-confidential-issue-data');
    const initialData = JSON.parse(dataNode.innerHTML);

    const ConfidentialComp = Vue.extend(confidential);

    new ConfidentialComp({
      propsData: {
        isConfidential: initialData.is_confidential,
        isEditable: initialData.is_editable,
        service: mediator.service,
      },
    }).$mount(confidentialEl);

    new SidebarMoveIssue(
      mediator,
      $('.js-move-issue'),
      $('.js-move-issue-confirmation-button'),
    ).init();
  }

  new Vue(sidebarTimeTracking).$mount('#issuable-time-tracker');
}

document.addEventListener('DOMContentLoaded', domContentLoaded);

export default domContentLoaded;