debian-mirror-gitlab/app/assets/javascripts/sidebar/mount_sidebar.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

739 lines
19 KiB
JavaScript
Raw Normal View History

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';
2021-09-30 23:02:18 +05:30
import { TYPE_ISSUE, TYPE_MERGE_REQUEST } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils';
2021-09-04 01:27:46 +05:30
import initInviteMembersModal from '~/invite_members/init_invite_members_modal';
import initInviteMembersTrigger from '~/invite_members/init_invite_members_trigger';
2022-01-26 12:08:38 +05:30
import { IssuableType } from '~/issues/constants';
2023-03-04 22:38:38 +05:30
import { gqlClient } from '~/issues/list/graphql';
2021-03-11 19:13:27 +05:30
import {
isInIssuePage,
isInDesignPage,
isInIncidentPage,
2022-05-07 20:08:51 +05:30
isInMRPage,
2021-03-11 19:13:27 +05:30
parseBoolean,
} from '~/lib/utils/common_utils';
2022-01-26 12:08:38 +05:30
import { __ } from '~/locale';
2022-10-11 01:57:18 +05:30
import { apolloProvider } from '~/graphql_shared/issuable_client';
2023-03-04 22:38:38 +05:30
import Translate from '~/vue_shared/translate';
import CollapsedAssigneeList from './components/assignees/collapsed_assignee_list.vue';
2018-03-27 19:54:05 +05:30
import SidebarAssignees from './components/assignees/sidebar_assignees.vue';
2023-03-04 22:38:38 +05:30
import SidebarAssigneesWidget from './components/assignees/sidebar_assignees_widget.vue';
import SidebarConfidentialityWidget from './components/confidential/sidebar_confidentiality_widget.vue';
import CopyEmailToClipboard from './components/copy/copy_email_to_clipboard.vue';
import SidebarDueDateWidget from './components/date/sidebar_date_widget.vue';
2022-05-07 20:08:51 +05:30
import SidebarEscalationStatus from './components/incidents/sidebar_escalation_status.vue';
2023-03-04 22:38:38 +05:30
import { DropdownVariant } from './components/labels/labels_select_vue/constants';
import { LabelType } from './components/labels/labels_select_widget/constants';
import LabelsSelectWidget from './components/labels/labels_select_widget/labels_select_root.vue';
2020-10-24 23:57:45 +05:30
import IssuableLockForm from './components/lock/issuable_lock_form.vue';
2023-03-04 22:38:38 +05:30
import MilestoneDropdown from './components/milestone/milestone_dropdown.vue';
import MoveIssuesButton from './components/move/move_issues_button.vue';
import SidebarParticipantsWidget from './components/participants/sidebar_participants_widget.vue';
import SidebarReferenceWidget from './components/copy/sidebar_reference_widget.vue';
2021-03-11 19:13:27 +05:30
import SidebarReviewers from './components/reviewers/sidebar_reviewers.vue';
2023-01-13 00:05:48 +05:30
import SidebarReviewersInputs from './components/reviewers/sidebar_reviewers_inputs.vue';
2020-11-24 15:15:51 +05:30
import SidebarSeverity from './components/severity/sidebar_severity.vue';
2023-03-04 22:38:38 +05:30
import SidebarDropdownWidget from './components/sidebar_dropdown_widget.vue';
import StatusDropdown from './components/status/status_dropdown.vue';
2021-06-08 01:23:25 +05:30
import SidebarSubscriptionsWidget from './components/subscriptions/sidebar_subscriptions_widget.vue';
2023-03-04 22:38:38 +05:30
import SubscriptionsDropdown from './components/subscriptions/subscriptions_dropdown.vue';
2021-03-11 19:13:27 +05:30
import SidebarTimeTracking from './components/time_tracking/sidebar_time_tracking.vue';
2023-03-04 22:38:38 +05:30
import SidebarTodoWidget from './components/todo_toggle/sidebar_todo_widget.vue';
2021-09-30 23:02:18 +05:30
import { IssuableAttributeType } from './constants';
2022-01-26 12:08:38 +05:30
import CrmContacts from './components/crm_contacts/crm_contacts.vue';
2023-03-04 22:38:38 +05:30
import SidebarMoveIssue from './lib/sidebar_move_issue';
import trackShowInviteMemberLink from './track_invite_members';
2018-03-17 18:26:18 +05:30
Vue.use(Translate);
2020-05-24 23:13:21 +05:30
Vue.use(VueApollo);
2021-01-03 14:25:43 +05:30
function getSidebarOptions(sidebarOptEl = document.querySelector('.js-sidebar-options')) {
return JSON.parse(sidebarOptEl.innerHTML);
2020-05-24 23:13:21 +05:30
}
2018-03-17 18:26:18 +05:30
2023-01-13 00:05:48 +05:30
function mountSidebarTodoWidget() {
const el = document.querySelector('.js-sidebar-todo-widget-root');
2021-09-30 23:02:18 +05:30
if (!el) {
2023-01-13 00:05:48 +05:30
return null;
2021-09-30 23:02:18 +05:30
}
const { projectPath, iid, id } = el.dataset;
return new Vue({
el,
2023-01-13 00:05:48 +05:30
name: 'SidebarTodoWidgetRoot',
2021-09-30 23:02:18 +05:30
apolloProvider,
provide: {
isClassicSidebar: true,
},
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarTodoWidget, {
2021-09-30 23:02:18 +05:30
props: {
fullPath: projectPath,
issuableId:
2022-08-13 15:12:31 +05:30
isInIssuePage() || isInIncidentPage() || isInDesignPage()
2021-09-30 23:02:18 +05:30
? convertToGraphQLId(TYPE_ISSUE, id)
: convertToGraphQLId(TYPE_MERGE_REQUEST, id),
issuableIid: iid,
issuableType:
2022-08-13 15:12:31 +05:30
isInIssuePage() || isInIncidentPage() || isInDesignPage()
? IssuableType.Issue
: IssuableType.MergeRequest,
2021-09-30 23:02:18 +05:30
},
}),
});
}
2021-03-11 19:13:27 +05:30
function getSidebarAssigneeAvailabilityData() {
const sidebarAssigneeEl = document.querySelectorAll('.js-sidebar-assignee-data input');
return Array.from(sidebarAssigneeEl)
.map((el) => el.dataset)
.reduce(
(acc, { username, availability = '' }) => ({
...acc,
[username]: availability,
}),
{},
);
}
2023-01-13 00:05:48 +05:30
function mountSidebarAssigneesDeprecated(mediator) {
const el = document.querySelector('.js-sidebar-assignees-root');
2018-03-17 18:26:18 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return null;
}
2018-03-17 18:26:18 +05:30
2021-06-08 01:23:25 +05:30
const { id, iid, fullPath } = getSidebarOptions();
2021-03-11 19:13:27 +05:30
const assigneeAvailabilityStatus = getSidebarAssigneeAvailabilityData();
2023-01-13 00:05:48 +05:30
return new Vue({
2018-03-17 18:26:18 +05:30
el,
2022-04-04 11:22:00 +05:30
name: 'SidebarAssigneesRoot',
2020-05-24 23:13:21 +05:30
apolloProvider,
2021-03-08 18:12:59 +05:30
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarAssignees, {
2021-01-03 14:25:43 +05:30
props: {
mediator,
issuableIid: String(iid),
projectPath: fullPath,
field: el.dataset.field,
2022-07-23 23:45:48 +05:30
signedIn: Object.prototype.hasOwnProperty.call(el.dataset, 'signedIn'),
2021-03-11 19:13:27 +05:30
issuableType:
2021-04-17 20:07:23 +05:30
isInIssuePage() || isInIncidentPage() || isInDesignPage()
? IssuableType.Issue
: IssuableType.MergeRequest,
2021-06-08 01:23:25 +05:30
issuableId: id,
2021-03-11 19:13:27 +05:30
assigneeAvailabilityStatus,
2021-01-03 14:25:43 +05:30
},
}),
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarAssigneesWidget() {
const el = document.querySelector('.js-sidebar-assignees-root');
2021-04-29 21:17:54 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return;
}
2021-04-29 21:17:54 +05:30
2021-06-08 01:23:25 +05:30
const { id, iid, fullPath, editable } = getSidebarOptions();
2022-05-07 20:08:51 +05:30
const isIssuablePage = isInIssuePage() || isInIncidentPage() || isInDesignPage();
const issuableType = isIssuablePage ? IssuableType.Issue : IssuableType.MergeRequest;
2021-04-29 21:17:54 +05:30
// eslint-disable-next-line no-new
new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'SidebarAssigneesRoot',
2021-04-29 21:17:54 +05:30
apolloProvider,
provide: {
canUpdate: editable,
2022-07-23 23:45:48 +05:30
directlyInviteMembers: Object.prototype.hasOwnProperty.call(
el.dataset,
'directlyInviteMembers',
),
2021-04-29 21:17:54 +05:30
},
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarAssigneesWidget, {
2021-04-29 21:17:54 +05:30
props: {
iid: String(iid),
fullPath,
2022-05-07 20:08:51 +05:30
issuableType,
2021-06-08 01:23:25 +05:30
issuableId: id,
2022-11-25 23:54:43 +05:30
allowMultipleAssignees: !el.dataset.maxAssignees || el.dataset.maxAssignees > 1,
2022-10-11 01:57:18 +05:30
editable,
2021-04-29 21:17:54 +05:30
},
scopedSlots: {
2022-05-07 20:08:51 +05:30
collapsed: ({ users }) =>
2021-04-29 21:17:54 +05:30
createElement(CollapsedAssigneeList, {
props: {
users,
2022-05-07 20:08:51 +05:30
issuableType,
2021-04-29 21:17:54 +05:30
},
}),
},
}),
});
2021-09-04 01:27:46 +05:30
const assigneeDropdown = document.querySelector('.js-sidebar-assignee-dropdown');
if (assigneeDropdown) {
trackShowInviteMemberLink(assigneeDropdown);
}
2021-04-29 21:17:54 +05:30
}
2023-01-13 00:05:48 +05:30
function mountSidebarReviewers(mediator) {
const el = document.querySelector('.js-sidebar-reviewers-root');
2021-01-03 14:25:43 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return;
}
2021-01-03 14:25:43 +05:30
const { iid, fullPath } = getSidebarOptions();
// eslint-disable-next-line no-new
new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'SidebarReviewersRoot',
2021-01-03 14:25:43 +05:30
apolloProvider,
2021-03-08 18:12:59 +05:30
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarReviewers, {
2018-12-13 13:39:08 +05:30
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,
2021-09-30 23:02:18 +05:30
issuableType:
isInIssuePage() || isInDesignPage() ? IssuableType.Issue : IssuableType.MergeRequest,
2018-12-13 13:39:08 +05:30
},
}),
2018-03-17 18:26:18 +05:30
});
2021-09-04 01:27:46 +05:30
2023-01-13 00:05:48 +05:30
const reviewersInputEl = document.querySelector('.js-reviewers-inputs');
if (reviewersInputEl) {
// eslint-disable-next-line no-new
new Vue({
el: reviewersInputEl,
render(createElement) {
return createElement(SidebarReviewersInputs);
},
});
}
2021-09-04 01:27:46 +05:30
const reviewerDropdown = document.querySelector('.js-sidebar-reviewer-dropdown');
if (reviewerDropdown) {
trackShowInviteMemberLink(reviewerDropdown);
}
2018-03-17 18:26:18 +05:30
}
2023-01-13 00:05:48 +05:30
function mountSidebarCrmContacts() {
const el = document.querySelector('.js-sidebar-crm-contacts-root');
2022-01-26 12:08:38 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return null;
}
2022-01-26 12:08:38 +05:30
2022-07-16 23:28:13 +05:30
const { issueId, groupIssuesPath } = el.dataset;
2023-01-13 00:05:48 +05:30
return new Vue({
2022-01-26 12:08:38 +05:30
el,
2022-04-04 11:22:00 +05:30
name: 'SidebarCrmContactsRoot',
2022-01-26 12:08:38 +05:30
apolloProvider,
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(CrmContacts, {
2022-01-26 12:08:38 +05:30
props: {
issueId,
2022-07-16 23:28:13 +05:30
groupIssuesPath,
2022-01-26 12:08:38 +05:30
},
}),
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarMilestoneWidget() {
const el = document.querySelector('.js-sidebar-milestone-widget-root');
2021-09-30 23:02:18 +05:30
if (!el) {
2023-01-13 00:05:48 +05:30
return null;
2021-09-30 23:02:18 +05:30
}
const { canEdit, projectPath, issueIid } = el.dataset;
return new Vue({
el,
2023-01-13 00:05:48 +05:30
name: 'SidebarMilestoneWidgetRoot',
2021-09-30 23:02:18 +05:30
apolloProvider,
provide: {
canUpdate: parseBoolean(canEdit),
isClassicSidebar: true,
},
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarDropdownWidget, {
2021-09-30 23:02:18 +05:30
props: {
attrWorkspacePath: projectPath,
workspacePath: projectPath,
iid: issueIid,
issuableType:
isInIssuePage() || isInDesignPage() ? IssuableType.Issue : IssuableType.MergeRequest,
issuableAttribute: IssuableAttributeType.Milestone,
icon: 'clock',
},
}),
});
}
2023-01-13 00:05:48 +05:30
export function mountMilestoneDropdown() {
const el = document.querySelector('.js-milestone-dropdown-root');
2020-11-24 15:15:51 +05:30
if (!el) {
2023-01-13 00:05:48 +05:30
return null;
2020-11-24 15:15:51 +05:30
}
2023-01-13 00:05:48 +05:30
Vue.use(VueApollo);
const {
canAdminMilestone,
fullPath,
inputName,
milestoneId,
milestoneTitle,
projectMilestonesPath,
workspaceType,
} = el.dataset;
2020-11-24 15:15:51 +05:30
return new Vue({
el,
2023-01-13 00:05:48 +05:30
name: 'MilestoneDropdownRoot',
2021-01-29 00:20:46 +05:30
apolloProvider,
2023-01-13 00:05:48 +05:30
render(createElement) {
return createElement(MilestoneDropdown, {
props: {
attrWorkspacePath: fullPath,
canAdminMilestone,
inputName,
issuableType: isInIssuePage() ? IssuableType.Issue : IssuableType.MergeRequest,
milestoneId,
milestoneTitle,
projectMilestonesPath,
workspaceType,
},
});
2022-01-26 12:08:38 +05:30
},
2023-01-13 00:05:48 +05:30
});
}
export function mountSidebarLabelsWidget() {
const el = document.querySelector('.js-sidebar-labels-widget-root');
if (!el) {
return null;
}
return new Vue({
el,
name: 'SidebarLabelsWidgetRoot',
apolloProvider,
2020-11-24 15:15:51 +05:30
provide: {
...el.dataset,
2022-01-26 12:08:38 +05:30
canUpdate: parseBoolean(el.dataset.canEdit),
2020-11-24 15:15:51 +05:30
allowLabelCreate: parseBoolean(el.dataset.allowLabelCreate),
allowLabelEdit: parseBoolean(el.dataset.canEdit),
allowScopedLabels: parseBoolean(el.dataset.allowScopedLabels),
2021-11-11 11:23:49 +05:30
isClassicSidebar: true,
2020-11-24 15:15:51 +05:30
},
2022-01-26 12:08:38 +05:30
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(LabelsSelectWidget, {
2022-01-26 12:08:38 +05:30
props: {
iid: String(el.dataset.iid),
fullPath: el.dataset.projectPath,
allowLabelRemove: parseBoolean(el.dataset.canEdit),
allowMultiselect: true,
footerCreateLabelTitle: __('Create project label'),
footerManageLabelTitle: __('Manage project labels'),
labelsCreateTitle: __('Create project label'),
labelsFilterBasePath: el.dataset.projectIssuesPath,
variant: DropdownVariant.Sidebar,
issuableType:
isInIssuePage() || isInIncidentPage() || isInDesignPage()
? IssuableType.Issue
: IssuableType.MergeRequest,
workspaceType: 'project',
attrWorkspacePath: el.dataset.projectPath,
labelCreateType: LabelType.project,
},
class: ['block labels js-labels-block'],
scopedSlots: {
default: () => __('None'),
},
}),
2020-11-24 15:15:51 +05:30
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarConfidentialityWidget() {
const el = document.querySelector('.js-sidebar-confidential-widget-root');
2021-04-17 20:07:23 +05:30
if (!el) {
2023-01-13 00:05:48 +05:30
return null;
2021-04-17 20:07:23 +05:30
}
2018-03-17 18:26:18 +05:30
2020-07-28 23:09:34 +05:30
const { fullPath, iid } = getSidebarOptions();
2018-03-17 18:26:18 +05:30
const dataNode = document.getElementById('js-confidential-issue-data');
const initialData = JSON.parse(dataNode.innerHTML);
2023-01-13 00:05:48 +05:30
return new Vue({
2021-04-17 20:07:23 +05:30
el,
2023-01-13 00:05:48 +05:30
name: 'SidebarConfidentialityWidgetRoot',
2021-04-17 20:07:23 +05:30
apolloProvider,
provide: {
canUpdate: initialData.is_editable,
2021-09-04 01:27:46 +05:30
isClassicSidebar: true,
2021-04-17 20:07:23 +05:30
},
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarConfidentialityWidget, {
2021-04-17 20:07:23 +05:30
props: {
2021-04-29 21:17:54 +05:30
iid: String(iid),
fullPath,
2021-04-17 20:07:23 +05:30
issuableType:
isInIssuePage() || isInIncidentPage() || isInDesignPage()
? IssuableType.Issue
: IssuableType.MergeRequest,
},
}),
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarDueDateWidget() {
const el = document.querySelector('.js-sidebar-due-date-widget-root');
2021-04-29 21:17:54 +05:30
if (!el) {
2023-01-13 00:05:48 +05:30
return null;
2021-04-29 21:17:54 +05:30
}
const { fullPath, iid, editable } = getSidebarOptions();
2023-01-13 00:05:48 +05:30
return new Vue({
2021-04-29 21:17:54 +05:30
el,
2023-01-13 00:05:48 +05:30
name: 'SidebarDueDateWidgetRoot',
2021-04-29 21:17:54 +05:30
apolloProvider,
provide: {
canUpdate: editable,
},
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarDueDateWidget, {
2021-04-29 21:17:54 +05:30
props: {
2021-06-08 01:23:25 +05:30
iid: String(iid),
fullPath,
2021-04-29 21:17:54 +05:30
issuableType: IssuableType.Issue,
},
}),
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarReferenceWidget() {
const el = document.querySelector('.js-sidebar-reference-widget-root');
2021-04-17 20:07:23 +05:30
if (!el) {
2023-01-13 00:05:48 +05:30
return null;
2021-04-17 20:07:23 +05:30
}
const { fullPath, iid } = getSidebarOptions();
2023-01-13 00:05:48 +05:30
return new Vue({
2021-04-17 20:07:23 +05:30
el,
2023-01-13 00:05:48 +05:30
name: 'SidebarReferenceWidgetRoot',
2021-04-17 20:07:23 +05:30
apolloProvider,
provide: {
iid: String(iid),
fullPath,
},
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarReferenceWidget, {
2021-04-17 20:07:23 +05:30
props: {
issuableType:
isInIssuePage() || isInIncidentPage() || isInDesignPage()
? IssuableType.Issue
: IssuableType.MergeRequest,
},
}),
});
2018-03-17 18:26:18 +05:30
}
2023-01-13 00:05:48 +05:30
function mountIssuableLockForm(store) {
const el = document.querySelector('.js-sidebar-lock-root');
2021-01-03 14:25:43 +05:30
2021-11-11 11:23:49 +05:30
if (!el || !store) {
2023-01-13 00:05:48 +05:30
return null;
2021-01-03 14:25:43 +05:30
}
2022-07-16 23:28:13 +05:30
const { fullPath, editable } = getSidebarOptions();
2018-03-17 18:26:18 +05:30
2023-01-13 00:05:48 +05:30
return new Vue({
2021-11-11 11:23:49 +05:30
el,
2022-04-04 11:22:00 +05:30
name: 'SidebarLockRoot',
2021-11-11 11:23:49 +05:30
store,
provide: {
fullPath,
},
render: (createElement) =>
createElement(IssuableLockForm, {
props: {
2022-07-16 23:28:13 +05:30
isEditable: editable,
2021-11-11 11:23:49 +05:30
},
}),
});
2018-03-17 18:26:18 +05:30
}
2023-01-13 00:05:48 +05:30
function mountSidebarParticipantsWidget() {
const el = document.querySelector('.js-sidebar-participants-widget-root');
2018-03-17 18:26:18 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return null;
}
2018-03-17 18:26:18 +05:30
2021-09-04 01:27:46 +05:30
const { fullPath, iid } = getSidebarOptions();
2023-01-13 00:05:48 +05:30
return new Vue({
2018-03-17 18:26:18 +05:30
el,
2023-01-13 00:05:48 +05:30
name: 'SidebarParticipantsWidgetRoot',
2021-09-04 01:27:46 +05:30
apolloProvider,
2021-03-08 18:12:59 +05:30
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarParticipantsWidget, {
2018-12-13 13:39:08 +05:30
props: {
2021-09-04 01:27:46 +05:30
iid: String(iid),
fullPath,
issuableType:
isInIssuePage() || isInIncidentPage() || isInDesignPage()
? IssuableType.Issue
: IssuableType.MergeRequest,
2018-12-13 13:39:08 +05:30
},
}),
2018-03-17 18:26:18 +05:30
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarSubscriptionsWidget() {
const el = document.querySelector('.js-sidebar-subscriptions-widget-root');
2018-03-17 18:26:18 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return null;
}
2018-03-17 18:26:18 +05:30
2021-06-08 01:23:25 +05:30
const { fullPath, iid, editable } = getSidebarOptions();
2023-01-13 00:05:48 +05:30
return new Vue({
2018-03-17 18:26:18 +05:30
el,
2023-01-13 00:05:48 +05:30
name: 'SidebarSubscriptionsWidgetRoot',
2021-06-08 01:23:25 +05:30
apolloProvider,
provide: {
canUpdate: editable,
2018-03-17 18:26:18 +05:30
},
2021-03-08 18:12:59 +05:30
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarSubscriptionsWidget, {
2018-12-13 13:39:08 +05:30
props: {
2021-06-08 01:23:25 +05:30
iid: String(iid),
fullPath,
issuableType:
isInIssuePage() || isInIncidentPage() || isInDesignPage()
? IssuableType.Issue
: IssuableType.MergeRequest,
2018-12-13 13:39:08 +05:30
},
}),
2018-03-17 18:26:18 +05:30
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarTimeTracking() {
const el = document.querySelector('.js-sidebar-time-tracking-root');
2023-03-04 22:38:38 +05:30
const {
id,
iid,
fullPath,
issuableType,
timeTrackingLimitToHours,
canCreateTimelogs,
} = getSidebarOptions();
2018-03-17 18:26:18 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return null;
}
2018-03-17 18:26:18 +05:30
2023-01-13 00:05:48 +05:30
return new Vue({
2018-03-17 18:26:18 +05:30
el,
2022-04-04 11:22:00 +05:30
name: 'SidebarTimeTrackingRoot',
2021-06-08 01:23:25 +05:30
apolloProvider,
2021-09-04 01:27:46 +05:30
provide: { issuableType },
render: (createElement) =>
createElement(SidebarTimeTracking, {
props: {
fullPath,
issuableId: id.toString(),
issuableIid: iid.toString(),
limitToHours: timeTrackingLimitToHours,
2023-03-04 22:38:38 +05:30
canAddTimeEntries: canCreateTimelogs,
2021-09-04 01:27:46 +05:30
},
}),
2018-03-17 18:26:18 +05:30
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarSeverity() {
const el = document.querySelector('.js-sidebar-severity-root');
2020-11-24 15:15:51 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return null;
2020-11-24 15:15:51 +05:30
}
2021-10-27 15:23:28 +05:30
const { fullPath, iid, severity, editable } = getSidebarOptions();
2020-11-24 15:15:51 +05:30
return new Vue({
2023-01-13 00:05:48 +05:30
el,
2022-04-04 11:22:00 +05:30
name: 'SidebarSeverityRoot',
2020-11-24 15:15:51 +05:30
apolloProvider,
2021-10-27 15:23:28 +05:30
provide: {
canUpdate: editable,
},
2021-03-08 18:12:59 +05:30
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarSeverity, {
2020-11-24 15:15:51 +05:30
props: {
projectPath: fullPath,
iid: String(iid),
initialSeverity: severity.toUpperCase(),
},
}),
});
}
2023-01-13 00:05:48 +05:30
function mountSidebarEscalationStatus() {
const el = document.querySelector('.js-sidebar-escalation-status-root');
2022-05-07 20:08:51 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return null;
2022-05-07 20:08:51 +05:30
}
const { issuableType } = getSidebarOptions();
2023-01-13 00:05:48 +05:30
const { canUpdate, issueIid, projectPath } = el.dataset;
2022-05-07 20:08:51 +05:30
return new Vue({
2023-01-13 00:05:48 +05:30
el,
name: 'SidebarEscalationStatusRoot',
2022-05-07 20:08:51 +05:30
apolloProvider,
provide: {
canUpdate: parseBoolean(canUpdate),
},
render: (createElement) =>
2023-01-13 00:05:48 +05:30
createElement(SidebarEscalationStatus, {
2022-05-07 20:08:51 +05:30
props: {
iid: issueIid,
issuableType,
projectPath,
},
}),
});
}
2023-01-13 00:05:48 +05:30
function mountCopyEmailToClipboard() {
const el = document.querySelector('.js-sidebar-copy-email-root');
2021-03-08 18:12:59 +05:30
2023-01-13 00:05:48 +05:30
if (!el) {
return null;
}
2021-03-08 18:12:59 +05:30
const { createNoteEmail } = getSidebarOptions();
2023-01-13 00:05:48 +05:30
return new Vue({
2021-03-08 18:12:59 +05:30
el,
2022-04-04 11:22:00 +05:30
name: 'SidebarCopyEmailRoot',
2021-03-08 18:12:59 +05:30
render: (createElement) =>
2021-04-29 21:17:54 +05:30
createElement(CopyEmailToClipboard, { props: { issueEmailAddress: createNoteEmail } }),
2021-03-08 18:12:59 +05:30
});
}
2023-03-04 22:38:38 +05:30
export function mountMoveIssuesButton() {
const el = document.querySelector('.js-move-issues');
if (!el) {
return null;
}
Vue.use(VueApollo);
return new Vue({
el,
name: 'MoveIssuesRoot',
apolloProvider: new VueApollo({
defaultClient: gqlClient,
}),
render: (createElement) =>
createElement(MoveIssuesButton, {
props: {
projectFullPath: el.dataset.projectFullPath,
projectsFetchPath: el.dataset.projectsFetchPath,
},
}),
});
}
export function mountStatusDropdown() {
const el = document.querySelector('.js-status-dropdown');
if (!el) {
return null;
}
return new Vue({
el,
name: 'StatusDropdownRoot',
render: (createElement) => createElement(StatusDropdown),
});
}
export function mountSubscriptionsDropdown() {
const el = document.querySelector('.js-subscriptions-dropdown');
if (!el) {
return null;
}
return new Vue({
el,
name: 'SubscriptionsDropdownRoot',
render: (createElement) => createElement(SubscriptionsDropdown),
});
}
2021-04-29 21:17:54 +05:30
const isAssigneesWidgetShown =
2022-05-07 20:08:51 +05:30
(isInIssuePage() || isInDesignPage() || isInMRPage()) && gon.features.issueAssigneesWidget;
2021-04-29 21:17:54 +05:30
2021-11-11 11:23:49 +05:30
export function mountSidebar(mediator, store) {
2021-09-04 01:27:46 +05:30
initInviteMembersModal();
initInviteMembersTrigger();
2023-01-13 00:05:48 +05:30
mountSidebarTodoWidget();
2021-04-29 21:17:54 +05:30
if (isAssigneesWidgetShown) {
2023-01-13 00:05:48 +05:30
mountSidebarAssigneesWidget();
2021-04-29 21:17:54 +05:30
} else {
2023-01-13 00:05:48 +05:30
mountSidebarAssigneesDeprecated(mediator);
2021-04-29 21:17:54 +05:30
}
2023-01-13 00:05:48 +05:30
mountSidebarReviewers(mediator);
mountSidebarCrmContacts();
mountSidebarLabelsWidget();
mountSidebarMilestoneWidget();
mountSidebarConfidentialityWidget();
mountSidebarDueDateWidget();
mountSidebarReferenceWidget();
mountIssuableLockForm(store);
mountSidebarParticipantsWidget();
mountSidebarSubscriptionsWidget();
mountCopyEmailToClipboard();
mountSidebarTimeTracking();
mountSidebarSeverity();
mountSidebarEscalationStatus();
2018-03-17 18:26:18 +05:30
new SidebarMoveIssue(
mediator,
$('.js-move-issue'),
$('.js-move-issue-confirmation-button'),
).init();
}
2020-05-24 23:13:21 +05:30
export { getSidebarOptions };