debian-mirror-gitlab/app/assets/javascripts/issue_show/issue.js

64 lines
1.9 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2021-01-29 00:20:46 +05:30
import VueApollo from 'vue-apollo';
import { mapGetters } from 'vuex';
import createDefaultClient from '~/lib/graphql';
import { parseBoolean } from '~/lib/utils/common_utils';
import IssuableApp from './components/app.vue';
import HeaderActions from './components/header_actions.vue';
2017-08-17 22:00:37 +05:30
2021-01-29 00:20:46 +05:30
export function initIssuableApp(issuableData, store) {
2017-09-10 17:25:29 +05:30
return new Vue({
el: document.getElementById('js-issuable-app'),
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;
}
Vue.use(VueApollo);
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
});
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
});
}