2018-03-09 15:18:59 -05:00
|
|
|
import $ from 'jquery';
|
2017-12-03 21:43:10 -05:00
|
|
|
import Vue from 'vue';
|
2020-05-04 08:09:46 -04:00
|
|
|
import VueApollo from 'vue-apollo';
|
2020-09-17 11:09:24 -04:00
|
|
|
import Vuex from 'vuex';
|
2018-05-01 18:44:48 -04:00
|
|
|
import SidebarTimeTracking from './components/time_tracking/sidebar_time_tracking.vue';
|
2018-02-27 13:06:55 -05:00
|
|
|
import SidebarAssignees from './components/assignees/sidebar_assignees.vue';
|
2020-09-17 11:09:24 -04:00
|
|
|
import SidebarLabels from './components/labels/sidebar_labels.vue';
|
2017-12-03 21:43:10 -05:00
|
|
|
import ConfidentialIssueSidebar from './components/confidential/confidential_issue_sidebar.vue';
|
|
|
|
import SidebarMoveIssue from './lib/sidebar_move_issue';
|
2020-07-30 02:09:55 -04:00
|
|
|
import IssuableLockForm from './components/lock/issuable_lock_form.vue';
|
2017-12-03 21:43:10 -05:00
|
|
|
import sidebarParticipants from './components/participants/sidebar_participants.vue';
|
|
|
|
import sidebarSubscriptions from './components/subscriptions/sidebar_subscriptions.vue';
|
2020-09-10 14:08:54 -04:00
|
|
|
import SidebarSeverity from './components/severity/sidebar_severity.vue';
|
2017-12-03 21:43:10 -05:00
|
|
|
import Translate from '../vue_shared/translate';
|
2020-05-04 08:09:46 -04:00
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2020-09-17 11:09:24 -04:00
|
|
|
import { isInIssuePage, parseBoolean } from '~/lib/utils/common_utils';
|
2020-09-21 08:09:34 -04:00
|
|
|
import createFlash from '~/flash';
|
|
|
|
import { __ } from '~/locale';
|
2020-09-17 11:09:24 -04:00
|
|
|
import labelsSelectModule from '~/vue_shared/components/sidebar/labels_select_vue/store';
|
2017-12-03 21:43:10 -05:00
|
|
|
|
|
|
|
Vue.use(Translate);
|
2020-05-04 08:09:46 -04:00
|
|
|
Vue.use(VueApollo);
|
2020-09-17 11:09:24 -04:00
|
|
|
Vue.use(Vuex);
|
2020-05-04 08:09:46 -04:00
|
|
|
|
2020-09-22 11:09:37 -04:00
|
|
|
function getSidebarOptions(sidebarOptEl = document.querySelector('.js-sidebar-options')) {
|
|
|
|
return JSON.parse(sidebarOptEl.innerHTML);
|
2020-05-04 08:09:46 -04:00
|
|
|
}
|
2017-12-03 21:43:10 -05:00
|
|
|
|
2017-12-07 12:37:33 -05:00
|
|
|
function mountAssigneesComponent(mediator) {
|
|
|
|
const el = document.getElementById('js-vue-sidebar-assignees');
|
2020-05-04 08:09:46 -04:00
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
});
|
2017-12-07 12:37:33 -05:00
|
|
|
|
|
|
|
if (!el) return;
|
|
|
|
|
2020-05-04 08:09:46 -04:00
|
|
|
const { iid, fullPath } = getSidebarOptions();
|
2017-12-07 12:37:33 -05:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
2020-05-04 08:09:46 -04:00
|
|
|
apolloProvider,
|
2017-12-07 12:37:33 -05:00
|
|
|
components: {
|
|
|
|
SidebarAssignees,
|
|
|
|
},
|
2018-10-10 02:53:35 -04:00
|
|
|
render: createElement =>
|
|
|
|
createElement('sidebar-assignees', {
|
|
|
|
props: {
|
|
|
|
mediator,
|
2020-05-04 08:09:46 -04:00
|
|
|
issuableIid: String(iid),
|
|
|
|
projectPath: fullPath,
|
2018-10-10 02:53:35 -04:00
|
|
|
field: el.dataset.field,
|
|
|
|
signedIn: el.hasAttribute('data-signed-in'),
|
2020-07-15 23:09:12 -04:00
|
|
|
issuableType: isInIssuePage() ? 'issue' : 'merge_request',
|
2018-10-10 02:53:35 -04:00
|
|
|
},
|
|
|
|
}),
|
2017-12-07 12:37:33 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-17 11:09:24 -04:00
|
|
|
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),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-12-03 21:43:10 -05:00
|
|
|
function mountConfidentialComponent(mediator) {
|
|
|
|
const el = document.getElementById('js-confidential-entry-point');
|
|
|
|
|
2020-06-25 11:08:37 -04:00
|
|
|
const { fullPath, iid } = getSidebarOptions();
|
|
|
|
|
2017-12-03 21:43:10 -05:00
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
const dataNode = document.getElementById('js-confidential-issue-data');
|
|
|
|
const initialData = JSON.parse(dataNode.innerHTML);
|
|
|
|
|
2020-09-21 08:09:34 -04:00
|
|
|
import(/* webpackChunkName: 'notesStore' */ '~/notes/stores')
|
|
|
|
.then(
|
|
|
|
({ store }) =>
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
store,
|
|
|
|
components: {
|
|
|
|
ConfidentialIssueSidebar,
|
|
|
|
},
|
|
|
|
render: createElement =>
|
|
|
|
createElement('confidential-issue-sidebar', {
|
|
|
|
props: {
|
|
|
|
iid: String(iid),
|
|
|
|
fullPath,
|
|
|
|
isEditable: initialData.is_editable,
|
|
|
|
service: mediator.service,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
.catch(() => {
|
|
|
|
createFlash({ message: __('Failed to load sidebar confidential toggle') });
|
|
|
|
});
|
2017-12-03 21:43:10 -05:00
|
|
|
}
|
|
|
|
|
2020-07-29 11:09:39 -04:00
|
|
|
function mountLockComponent() {
|
2017-12-03 21:43:10 -05:00
|
|
|
const el = document.getElementById('js-lock-entry-point');
|
2020-09-21 08:09:34 -04:00
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-07-29 11:09:39 -04:00
|
|
|
const { fullPath } = getSidebarOptions();
|
2017-12-03 21:43:10 -05:00
|
|
|
|
|
|
|
const dataNode = document.getElementById('js-lock-issue-data');
|
|
|
|
const initialData = JSON.parse(dataNode.innerHTML);
|
|
|
|
|
2020-09-21 08:09:34 -04:00
|
|
|
let importStore;
|
|
|
|
if (isInIssuePage()) {
|
|
|
|
importStore = import(/* webpackChunkName: 'notesStore' */ '~/notes/stores').then(
|
|
|
|
({ store }) => store,
|
|
|
|
);
|
|
|
|
} else {
|
2020-09-25 08:10:00 -04:00
|
|
|
importStore = import(/* webpackChunkName: 'mrNotesStore' */ '~/mr_notes/stores').then(
|
|
|
|
store => store.default,
|
|
|
|
);
|
2020-09-21 08:09:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
importStore
|
|
|
|
.then(
|
|
|
|
store =>
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
store,
|
|
|
|
provide: {
|
|
|
|
fullPath,
|
|
|
|
},
|
|
|
|
render: createElement =>
|
|
|
|
createElement(IssuableLockForm, {
|
|
|
|
props: {
|
|
|
|
isEditable: initialData.is_editable,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
)
|
|
|
|
.catch(() => {
|
|
|
|
createFlash({ message: __('Failed to load sidebar lock status') });
|
|
|
|
});
|
2017-12-03 21:43:10 -05:00
|
|
|
}
|
|
|
|
|
2017-12-07 12:37:33 -05:00
|
|
|
function mountParticipantsComponent(mediator) {
|
2017-12-03 21:43:10 -05:00
|
|
|
const el = document.querySelector('.js-sidebar-participants-entry-point');
|
|
|
|
|
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
components: {
|
|
|
|
sidebarParticipants,
|
|
|
|
},
|
2018-10-10 02:53:35 -04:00
|
|
|
render: createElement =>
|
|
|
|
createElement('sidebar-participants', {
|
|
|
|
props: {
|
|
|
|
mediator,
|
|
|
|
},
|
|
|
|
}),
|
2017-12-03 21:43:10 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-12-07 12:37:33 -05:00
|
|
|
function mountSubscriptionsComponent(mediator) {
|
2017-12-03 21:43:10 -05:00
|
|
|
const el = document.querySelector('.js-sidebar-subscriptions-entry-point');
|
|
|
|
|
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
components: {
|
|
|
|
sidebarSubscriptions,
|
|
|
|
},
|
2018-10-10 02:53:35 -04:00
|
|
|
render: createElement =>
|
|
|
|
createElement('sidebar-subscriptions', {
|
|
|
|
props: {
|
|
|
|
mediator,
|
|
|
|
},
|
|
|
|
}),
|
2017-12-03 21:43:10 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-12-07 12:37:33 -05:00
|
|
|
function mountTimeTrackingComponent() {
|
|
|
|
const el = document.getElementById('issuable-time-tracker');
|
2017-12-03 21:43:10 -05:00
|
|
|
|
2017-12-07 12:37:33 -05:00
|
|
|
if (!el) return;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el,
|
|
|
|
components: {
|
|
|
|
SidebarTimeTracking,
|
|
|
|
},
|
|
|
|
render: createElement => createElement('sidebar-time-tracking', {}),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-10 14:08:54 -04:00
|
|
|
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(),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-12-07 12:37:33 -05:00
|
|
|
export function mountSidebar(mediator) {
|
|
|
|
mountAssigneesComponent(mediator);
|
2017-12-03 21:43:10 -05:00
|
|
|
mountConfidentialComponent(mediator);
|
2020-09-21 08:09:34 -04:00
|
|
|
mountLockComponent();
|
2017-12-07 12:37:33 -05:00
|
|
|
mountParticipantsComponent(mediator);
|
|
|
|
mountSubscriptionsComponent(mediator);
|
2017-12-03 21:43:10 -05:00
|
|
|
|
|
|
|
new SidebarMoveIssue(
|
|
|
|
mediator,
|
|
|
|
$('.js-move-issue'),
|
|
|
|
$('.js-move-issue-confirmation-button'),
|
|
|
|
).init();
|
|
|
|
|
2017-12-07 12:37:33 -05:00
|
|
|
mountTimeTrackingComponent();
|
2020-09-10 14:08:54 -04:00
|
|
|
|
|
|
|
mountSeverityComponent();
|
2017-12-03 21:43:10 -05:00
|
|
|
}
|
|
|
|
|
2020-05-04 08:09:46 -04:00
|
|
|
export { getSidebarOptions };
|