2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
2021-01-29 00:20:46 +05:30
|
|
|
import { mapGetters } from 'vuex';
|
|
|
|
import { parseBoolean } from '~/lib/utils/common_utils';
|
|
|
|
import IssuableApp from './components/app.vue';
|
|
|
|
import HeaderActions from './components/header_actions.vue';
|
2021-09-04 01:27:46 +05:30
|
|
|
import { issueState } from './constants';
|
|
|
|
import apolloProvider from './graphql';
|
|
|
|
import getIssueStateQuery from './queries/get_issue_state.query.graphql';
|
|
|
|
|
|
|
|
const bootstrapApollo = (state = {}) => {
|
|
|
|
return apolloProvider.clients.defaultClient.cache.writeQuery({
|
|
|
|
query: getIssueStateQuery,
|
|
|
|
data: {
|
|
|
|
issueState: state,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
export function initIssuableApp(issuableData, store) {
|
2021-09-04 01:27:46 +05:30
|
|
|
const el = document.getElementById('js-issuable-app');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
bootstrapApollo({ ...issueState, issueType: el.dataset.issueType });
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
return new Vue({
|
2021-09-04 01:27:46 +05:30
|
|
|
el,
|
|
|
|
apolloProvider,
|
2021-01-29 00:20:46 +05:30
|
|
|
store,
|
|
|
|
computed: {
|
|
|
|
...mapGetters(['getNoteableData']),
|
2017-09-10 17:25:29 +05:30
|
|
|
},
|
|
|
|
render(createElement) {
|
2021-01-29 00:20:46 +05:30
|
|
|
return createElement(IssuableApp, {
|
|
|
|
props: {
|
|
|
|
...issuableData,
|
|
|
|
isConfidential: this.getNoteableData?.confidential,
|
|
|
|
isLocked: this.getNoteableData?.discussion_locked,
|
|
|
|
issuableStatus: this.getNoteableData?.state,
|
|
|
|
},
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2018-11-08 19:23:39 +05:30
|
|
|
}
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
export function initIssueHeaderActions(store) {
|
|
|
|
const el = document.querySelector('.js-issue-header-actions');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
bootstrapApollo({ ...issueState, issueType: el.dataset.issueType });
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
store,
|
|
|
|
provide: {
|
|
|
|
canCreateIssue: parseBoolean(el.dataset.canCreateIssue),
|
|
|
|
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),
|
|
|
|
issueType: el.dataset.issueType,
|
|
|
|
newIssuePath: el.dataset.newIssuePath,
|
|
|
|
projectPath: el.dataset.projectPath,
|
2021-03-11 19:13:27 +05:30
|
|
|
projectId: el.dataset.projectId,
|
2021-01-29 00:20:46 +05:30
|
|
|
reportAbusePath: el.dataset.reportAbusePath,
|
|
|
|
submitAsSpamPath: el.dataset.submitAsSpamPath,
|
|
|
|
},
|
2021-03-08 18:12:59 +05:30
|
|
|
render: (createElement) => createElement(HeaderActions),
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
}
|