gitlab-org--gitlab-foss/app/assets/javascripts/sidebar/sidebar_bundle.js

79 lines
2.4 KiB
JavaScript
Raw Normal View History

import Vue from 'vue';
2017-10-01 15:45:48 +00:00
import SidebarTimeTracking from './components/time_tracking/sidebar_time_tracking';
import SidebarAssignees from './components/assignees/sidebar_assignees';
import ConfidentialIssueSidebar from './components/confidential/confidential_issue_sidebar.vue';
import SidebarMoveIssue from './lib/sidebar_move_issue';
2017-10-01 15:45:48 +00:00
import LockIssueSidebar from './components/lock/lock_issue_sidebar.vue';
2017-09-14 11:01:07 +00:00
import Translate from '../vue_shared/translate';
import Mediator from './sidebar_mediator';
2017-09-14 11:01:07 +00:00
Vue.use(Translate);
function mountConfidentialComponent(mediator) {
2017-10-01 15:45:48 +00:00
const el = document.getElementById('js-confidential-entry-point');
2017-09-14 11:01:07 +00:00
if (!el) return;
const dataNode = document.getElementById('js-confidential-issue-data');
const initialData = JSON.parse(dataNode.innerHTML);
2017-10-01 15:45:48 +00:00
const ConfidentialComp = Vue.extend(ConfidentialIssueSidebar);
2017-09-14 11:01:07 +00:00
new ConfidentialComp({
propsData: {
isConfidential: initialData.is_confidential,
isEditable: initialData.is_editable,
service: mediator.service,
},
}).$mount(el);
}
function mountLockComponent(mediator) {
2017-10-01 15:45:48 +00:00
const el = document.getElementById('js-lock-entry-point');
2017-09-14 11:01:07 +00:00
if (!el) return;
const dataNode = document.getElementById('js-lock-issue-data');
const initialData = JSON.parse(dataNode.innerHTML);
2017-10-01 15:45:48 +00:00
const LockComp = Vue.extend(LockIssueSidebar);
2017-09-14 11:01:07 +00:00
new LockComp({
propsData: {
isLocked: initialData.is_locked,
isEditable: initialData.is_editable,
mediator,
issuableType: gl.utils.isInIssuePage() ? 'issue' : 'merge_request',
},
}).$mount(el);
}
2017-05-05 18:23:31 +00:00
function domContentLoaded() {
const sidebarOptions = JSON.parse(document.querySelector('.js-sidebar-options').innerHTML);
const mediator = new Mediator(sidebarOptions);
mediator.fetch();
2017-10-01 15:45:48 +00:00
const sidebarAssigneesEl = document.getElementById('js-vue-sidebar-assignees');
// 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) {
2017-10-01 15:45:48 +00:00
new Vue(SidebarAssignees).$mount(sidebarAssigneesEl);
}
2017-09-14 11:01:07 +00:00
mountConfidentialComponent(mediator);
mountLockComponent(mediator);
2017-08-07 23:56:16 +00:00
2017-09-14 11:01:07 +00:00
new SidebarMoveIssue(
mediator,
$('.js-move-issue'),
$('.js-move-issue-confirmation-button'),
).init();
2017-08-07 23:56:16 +00:00
2017-10-01 15:45:48 +00:00
new Vue(SidebarTimeTracking).$mount('#issuable-time-tracker');
2017-05-05 18:23:31 +00:00
}
2017-05-05 18:23:31 +00:00
document.addEventListener('DOMContentLoaded', domContentLoaded);
export default domContentLoaded;