2020-11-24 15:15:51 +05:30
|
|
|
import Vue from 'vue';
|
2022-03-02 08:16:31 +05:30
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import errorTrackingStore from '~/error_tracking/store';
|
2023-04-23 21:23:45 +05:30
|
|
|
import { apolloProvider } from '~/graphql_shared/issuable_client';
|
2023-05-27 22:25:52 +05:30
|
|
|
import { TYPE_INCIDENT } from '~/issues/constants';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
2022-03-02 08:16:31 +05:30
|
|
|
import { scrollToTargetOnResize } from '~/lib/utils/resize_observer';
|
|
|
|
import IssueApp from './components/app.vue';
|
|
|
|
import HeaderActions from './components/header_actions.vue';
|
|
|
|
import IncidentTabs from './components/incidents/incident_tabs.vue';
|
|
|
|
import SentryErrorStackTrace from './components/sentry_error_stack_trace.vue';
|
2023-05-27 22:25:52 +05:30
|
|
|
import { issueState } from './constants';
|
2021-09-04 01:27:46 +05:30
|
|
|
import getIssueStateQuery from './queries/get_issue_state.query.graphql';
|
2023-05-27 22:25:52 +05:30
|
|
|
import createRouter from './components/incidents/router';
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
const bootstrapApollo = (state = {}) => {
|
|
|
|
return apolloProvider.clients.defaultClient.cache.writeQuery({
|
|
|
|
query: getIssueStateQuery,
|
|
|
|
data: {
|
|
|
|
issueState: state,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
export function initIncidentApp(issueData = {}, store) {
|
2021-09-04 01:27:46 +05:30
|
|
|
const el = document.getElementById('js-issuable-app');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
bootstrapApollo({ ...issueState, issueType: el.dataset.issueType });
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const {
|
2021-12-11 22:18:48 +05:30
|
|
|
canCreateIncident,
|
2021-03-08 18:12:59 +05:30
|
|
|
canUpdate,
|
2022-10-11 01:57:18 +05:30
|
|
|
canUpdateTimelineEvent,
|
2021-03-08 18:12:59 +05:30
|
|
|
iid,
|
2022-07-23 23:45:48 +05:30
|
|
|
issuableId,
|
2023-05-27 22:25:52 +05:30
|
|
|
currentPath,
|
|
|
|
currentTab,
|
2021-03-08 18:12:59 +05:30
|
|
|
projectNamespace,
|
|
|
|
projectPath,
|
|
|
|
projectId,
|
2023-05-27 22:25:52 +05:30
|
|
|
hasLinkedAlerts,
|
2021-03-08 18:12:59 +05:30
|
|
|
slaFeatureAvailable,
|
|
|
|
uploadMetricsFeatureAvailable,
|
2022-07-16 23:28:13 +05:30
|
|
|
state,
|
2022-03-02 08:16:31 +05:30
|
|
|
} = issueData;
|
2021-03-08 18:12:59 +05:30
|
|
|
|
|
|
|
const fullPath = `${projectNamespace}/${projectPath}`;
|
2023-05-27 22:25:52 +05:30
|
|
|
const router = createRouter(currentPath, currentTab);
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
return new Vue({
|
2021-09-04 01:27:46 +05:30
|
|
|
el,
|
2022-04-04 11:22:00 +05:30
|
|
|
name: 'DescriptionRoot',
|
2020-11-24 15:15:51 +05:30
|
|
|
apolloProvider,
|
2023-04-23 21:23:45 +05:30
|
|
|
store,
|
2023-05-27 22:25:52 +05:30
|
|
|
router,
|
2020-11-24 15:15:51 +05:30
|
|
|
provide: {
|
2023-05-27 22:25:52 +05:30
|
|
|
issueType: TYPE_INCIDENT,
|
2021-12-11 22:18:48 +05:30
|
|
|
canCreateIncident,
|
2022-10-11 01:57:18 +05:30
|
|
|
canUpdateTimelineEvent,
|
2021-03-08 18:12:59 +05:30
|
|
|
canUpdate,
|
|
|
|
fullPath,
|
2020-11-24 15:15:51 +05:30
|
|
|
iid,
|
2022-07-23 23:45:48 +05:30
|
|
|
issuableId,
|
2021-03-08 18:12:59 +05:30
|
|
|
projectId,
|
2023-05-27 22:25:52 +05:30
|
|
|
hasLinkedAlerts: parseBoolean(hasLinkedAlerts),
|
2021-01-03 14:25:43 +05:30
|
|
|
slaFeatureAvailable: parseBoolean(slaFeatureAvailable),
|
2021-03-08 18:12:59 +05:30
|
|
|
uploadMetricsFeatureAvailable: parseBoolean(uploadMetricsFeatureAvailable),
|
2022-11-25 23:54:43 +05:30
|
|
|
contentEditorOnIssues: gon.features.contentEditorOnIssues,
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
2023-04-23 21:23:45 +05:30
|
|
|
computed: {
|
|
|
|
...mapGetters(['getNoteableData']),
|
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
render(createElement) {
|
2022-03-02 08:16:31 +05:30
|
|
|
return createElement(IssueApp, {
|
2020-11-24 15:15:51 +05:30
|
|
|
props: {
|
2022-03-02 08:16:31 +05:30
|
|
|
...issueData,
|
2022-08-13 15:12:31 +05:30
|
|
|
issueId: Number(issuableId),
|
2022-07-16 23:28:13 +05:30
|
|
|
issuableStatus: state,
|
2022-03-02 08:16:31 +05:30
|
|
|
descriptionComponent: IncidentTabs,
|
2020-11-24 15:15:51 +05:30
|
|
|
showTitleBorder: false,
|
2023-04-23 21:23:45 +05:30
|
|
|
isConfidential: this.getNoteableData?.confidential,
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
export function initIssueApp(issueData, store) {
|
|
|
|
const el = document.getElementById('js-issuable-app');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
const { fullPath, registerPath, signInPath } = el.dataset;
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
scrollToTargetOnResize();
|
2022-03-02 08:16:31 +05:30
|
|
|
|
|
|
|
bootstrapApollo({ ...issueState, issueType: el.dataset.issueType });
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
const {
|
|
|
|
canCreateIncident,
|
|
|
|
hasIssueWeightsFeature,
|
|
|
|
hasIterationsFeature,
|
|
|
|
...issueProps
|
|
|
|
} = issueData;
|
2022-03-02 08:16:31 +05:30
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2022-04-04 11:22:00 +05:30
|
|
|
name: 'DescriptionRoot',
|
2022-03-02 08:16:31 +05:30
|
|
|
apolloProvider,
|
|
|
|
store,
|
|
|
|
provide: {
|
|
|
|
canCreateIncident,
|
2022-04-04 11:22:00 +05:30
|
|
|
fullPath,
|
2023-03-17 16:20:25 +05:30
|
|
|
registerPath,
|
|
|
|
signInPath,
|
2022-07-23 23:45:48 +05:30
|
|
|
hasIssueWeightsFeature,
|
2023-04-23 21:23:45 +05:30
|
|
|
hasIterationsFeature,
|
2022-03-02 08:16:31 +05:30
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters(['getNoteableData']),
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement(IssueApp, {
|
|
|
|
props: {
|
|
|
|
...issueProps,
|
|
|
|
isConfidential: this.getNoteableData?.confidential,
|
|
|
|
isLocked: this.getNoteableData?.discussion_locked,
|
|
|
|
issuableStatus: this.getNoteableData?.state,
|
2022-06-21 17:19:12 +05:30
|
|
|
issueId: this.getNoteableData?.id,
|
2022-03-02 08:16:31 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
export function initHeaderActions(store, type = '') {
|
2021-12-11 22:18:48 +05:30
|
|
|
const el = document.querySelector('.js-issue-header-actions');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
bootstrapApollo({ ...issueState, issueType: el.dataset.issueType });
|
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
const canCreate =
|
2023-05-27 22:25:52 +05:30
|
|
|
type === TYPE_INCIDENT ? el.dataset.canCreateIncident : el.dataset.canCreateIssue;
|
2022-03-02 08:16:31 +05:30
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
return new Vue({
|
|
|
|
el,
|
2022-04-04 11:22:00 +05:30
|
|
|
name: 'HeaderActionsRoot',
|
2021-12-11 22:18:48 +05:30
|
|
|
apolloProvider,
|
|
|
|
store,
|
|
|
|
provide: {
|
2022-03-02 08:16:31 +05:30
|
|
|
canCreateIssue: parseBoolean(canCreate),
|
2022-01-26 12:08:38 +05:30
|
|
|
canDestroyIssue: parseBoolean(el.dataset.canDestroyIssue),
|
2021-12-11 22:18:48 +05:30
|
|
|
canPromoteToEpic: parseBoolean(el.dataset.canPromoteToEpic),
|
|
|
|
canReopenIssue: parseBoolean(el.dataset.canReopenIssue),
|
|
|
|
canReportSpam: parseBoolean(el.dataset.canReportSpam),
|
|
|
|
canUpdateIssue: parseBoolean(el.dataset.canUpdateIssue),
|
|
|
|
iid: el.dataset.iid,
|
|
|
|
isIssueAuthor: parseBoolean(el.dataset.isIssueAuthor),
|
2022-01-26 12:08:38 +05:30
|
|
|
issuePath: el.dataset.issuePath,
|
2021-12-11 22:18:48 +05:30
|
|
|
issueType: el.dataset.issueType,
|
|
|
|
newIssuePath: el.dataset.newIssuePath,
|
|
|
|
projectPath: el.dataset.projectPath,
|
|
|
|
projectId: el.dataset.projectId,
|
|
|
|
reportAbusePath: el.dataset.reportAbusePath,
|
2023-04-23 21:23:45 +05:30
|
|
|
reportedUserId: parseInt(el.dataset.reportedUserId, 10),
|
2023-03-17 16:20:25 +05:30
|
|
|
reportedFromUrl: el.dataset.reportedFromUrl,
|
2021-12-11 22:18:48 +05:30
|
|
|
submitAsSpamPath: el.dataset.submitAsSpamPath,
|
|
|
|
},
|
|
|
|
render: (createElement) => createElement(HeaderActions),
|
|
|
|
});
|
|
|
|
}
|
2022-03-02 08:16:31 +05:30
|
|
|
|
|
|
|
export function initSentryErrorStackTrace() {
|
|
|
|
const el = document.querySelector('#js-sentry-error-stack-trace');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { issueStackTracePath } = el.dataset;
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2022-04-04 11:22:00 +05:30
|
|
|
name: 'SentryErrorStackTraceRoot',
|
2022-03-02 08:16:31 +05:30
|
|
|
store: errorTrackingStore,
|
|
|
|
render: (createElement) =>
|
|
|
|
createElement(SentryErrorStackTrace, { props: { issueStackTracePath } }),
|
|
|
|
});
|
|
|
|
}
|