2018-05-09 12:01:36 +05:30
|
|
|
import $ from 'jquery';
|
2018-03-17 18:26:18 +05:30
|
|
|
import Vue from 'vue';
|
2020-05-24 23:13:21 +05:30
|
|
|
import VueApollo from 'vue-apollo';
|
2020-11-24 15:15:51 +05:30
|
|
|
import Vuex from 'vuex';
|
2018-10-15 14:42:47 +05:30
|
|
|
import SidebarTimeTracking from './components/time_tracking/sidebar_time_tracking.vue';
|
2018-03-27 19:54:05 +05:30
|
|
|
import SidebarAssignees from './components/assignees/sidebar_assignees.vue';
|
2020-11-24 15:15:51 +05:30
|
|
|
import SidebarLabels from './components/labels/sidebar_labels.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
import ConfidentialIssueSidebar from './components/confidential/confidential_issue_sidebar.vue';
|
|
|
|
import SidebarMoveIssue from './lib/sidebar_move_issue';
|
2020-10-24 23:57:45 +05:30
|
|
|
import IssuableLockForm from './components/lock/issuable_lock_form.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
import sidebarParticipants from './components/participants/sidebar_participants.vue';
|
|
|
|
import sidebarSubscriptions from './components/subscriptions/sidebar_subscriptions.vue';
|
2020-11-24 15:15:51 +05:30
|
|
|
import SidebarSeverity from './components/severity/sidebar_severity.vue';
|
2018-03-17 18:26:18 +05:30
|
|
|
import Translate from '../vue_shared/translate';
|
2020-05-24 23:13:21 +05:30
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
import { store } from '~/notes/stores';
|
2020-11-24 15:15:51 +05:30
|
|
|
import { isInIssuePage, parseBoolean } from '~/lib/utils/common_utils';
|
2020-10-24 23:57:45 +05:30
|
|
|
import mergeRequestStore from '~/mr_notes/stores';
|
2020-11-24 15:15:51 +05:30
|
|
|
import labelsSelectModule from '~/vue_shared/components/sidebar/labels_select_vue/store';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
Vue.use(Translate);
|
2020-05-24 23:13:21 +05:30
|
|
|
Vue.use(VueApollo);
|
2020-11-24 15:15:51 +05:30
|
|
|
Vue.use(Vuex);
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
function getSidebarOptions() {
|
|
|
|
return JSON.parse(document.querySelector('.js-sidebar-options').innerHTML);
|
|
|
|
}
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
function mountAssigneesComponent(mediator) {
|
|
|
|
const el = document.getElementById('js-vue-sidebar-assignees');
|
2020-05-24 23:13:21 +05:30
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
if (!el) return;
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
const { iid, fullPath } = getSidebarOptions();
|
2018-03-17 18:26:18 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
2020-05-24 23:13:21 +05:30
|
|
|
apolloProvider,
|
2018-03-17 18:26:18 +05:30
|
|
|
components: {
|
|
|
|
SidebarAssignees,
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
render: createElement =>
|
|
|
|
createElement('sidebar-assignees', {
|
|
|
|
props: {
|
|
|
|
mediator,
|
2020-05-24 23:13:21 +05:30
|
|
|
issuableIid: String(iid),
|
|
|
|
projectPath: fullPath,
|
2018-12-13 13:39:08 +05:30
|
|
|
field: el.dataset.field,
|
|
|
|
signedIn: el.hasAttribute('data-signed-in'),
|
2020-07-28 23:09:34 +05:30
|
|
|
issuableType: isInIssuePage() ? 'issue' : 'merge_request',
|
2018-12-13 13:39:08 +05:30
|
|
|
},
|
|
|
|
}),
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
export function mountSidebarLabels() {
|
|
|
|
const el = document.querySelector('.js-sidebar-labels');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const labelsStore = new Vuex.Store(labelsSelectModule());
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
provide: {
|
|
|
|
...el.dataset,
|
|
|
|
allowLabelCreate: parseBoolean(el.dataset.allowLabelCreate),
|
|
|
|
allowLabelEdit: parseBoolean(el.dataset.canEdit),
|
|
|
|
allowScopedLabels: parseBoolean(el.dataset.allowScopedLabels),
|
|
|
|
initiallySelectedLabels: JSON.parse(el.dataset.selectedLabels),
|
|
|
|
},
|
|
|
|
store: labelsStore,
|
|
|
|
render: createElement => createElement(SidebarLabels),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
function mountConfidentialComponent(mediator) {
|
|
|
|
const el = document.getElementById('js-confidential-entry-point');
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
const { fullPath, iid } = getSidebarOptions();
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
const dataNode = document.getElementById('js-confidential-issue-data');
|
|
|
|
const initialData = JSON.parse(dataNode.innerHTML);
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
2020-05-24 23:13:21 +05:30
|
|
|
store,
|
2020-07-28 23:09:34 +05:30
|
|
|
components: {
|
|
|
|
ConfidentialIssueSidebar,
|
2018-03-17 18:26:18 +05:30
|
|
|
},
|
2020-07-28 23:09:34 +05:30
|
|
|
render: createElement =>
|
|
|
|
createElement('confidential-issue-sidebar', {
|
|
|
|
props: {
|
|
|
|
iid: String(iid),
|
|
|
|
fullPath,
|
|
|
|
isEditable: initialData.is_editable,
|
|
|
|
service: mediator.service,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
function mountLockComponent() {
|
2018-03-17 18:26:18 +05:30
|
|
|
const el = document.getElementById('js-lock-entry-point');
|
2020-10-24 23:57:45 +05:30
|
|
|
const { fullPath } = getSidebarOptions();
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
const dataNode = document.getElementById('js-lock-issue-data');
|
|
|
|
const initialData = JSON.parse(dataNode.innerHTML);
|
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
return el
|
|
|
|
? new Vue({
|
|
|
|
el,
|
|
|
|
store: isInIssuePage() ? store : mergeRequestStore,
|
|
|
|
provide: {
|
|
|
|
fullPath,
|
|
|
|
},
|
|
|
|
render: createElement =>
|
|
|
|
createElement(IssuableLockForm, {
|
|
|
|
props: {
|
|
|
|
isEditable: initialData.is_editable,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
: undefined;
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
function mountParticipantsComponent(mediator) {
|
|
|
|
const el = document.querySelector('.js-sidebar-participants-entry-point');
|
|
|
|
|
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
components: {
|
|
|
|
sidebarParticipants,
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
render: createElement =>
|
|
|
|
createElement('sidebar-participants', {
|
|
|
|
props: {
|
|
|
|
mediator,
|
|
|
|
},
|
|
|
|
}),
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function mountSubscriptionsComponent(mediator) {
|
|
|
|
const el = document.querySelector('.js-sidebar-subscriptions-entry-point');
|
|
|
|
|
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
components: {
|
|
|
|
sidebarSubscriptions,
|
|
|
|
},
|
2018-12-13 13:39:08 +05:30
|
|
|
render: createElement =>
|
|
|
|
createElement('sidebar-subscriptions', {
|
|
|
|
props: {
|
|
|
|
mediator,
|
|
|
|
},
|
|
|
|
}),
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function mountTimeTrackingComponent() {
|
|
|
|
const el = document.getElementById('issuable-time-tracker');
|
|
|
|
|
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
components: {
|
|
|
|
SidebarTimeTracking,
|
|
|
|
},
|
|
|
|
render: createElement => createElement('sidebar-time-tracking', {}),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
function mountSeverityComponent() {
|
|
|
|
const severityContainerEl = document.querySelector('#js-severity');
|
|
|
|
|
|
|
|
if (!severityContainerEl) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
});
|
|
|
|
|
|
|
|
const { fullPath, iid, severity } = getSidebarOptions();
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el: severityContainerEl,
|
|
|
|
apolloProvider,
|
|
|
|
components: {
|
|
|
|
SidebarSeverity,
|
|
|
|
},
|
|
|
|
render: createElement =>
|
|
|
|
createElement('sidebar-severity', {
|
|
|
|
props: {
|
|
|
|
projectPath: fullPath,
|
|
|
|
iid: String(iid),
|
|
|
|
initialSeverity: severity.toUpperCase(),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
export function mountSidebar(mediator) {
|
|
|
|
mountAssigneesComponent(mediator);
|
|
|
|
mountConfidentialComponent(mediator);
|
|
|
|
mountLockComponent(mediator);
|
|
|
|
mountParticipantsComponent(mediator);
|
|
|
|
mountSubscriptionsComponent(mediator);
|
|
|
|
|
|
|
|
new SidebarMoveIssue(
|
|
|
|
mediator,
|
|
|
|
$('.js-move-issue'),
|
|
|
|
$('.js-move-issue-confirmation-button'),
|
|
|
|
).init();
|
|
|
|
|
|
|
|
mountTimeTrackingComponent();
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
mountSeverityComponent();
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
export { getSidebarOptions };
|