2019-12-26 22:10:19 +05:30
|
|
|
import Vue from 'vue';
|
2020-05-24 23:13:21 +05:30
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { parseBoolean, convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
|
2020-11-24 15:15:51 +05:30
|
|
|
import JiraIssuesListRoot from './components/jira_issues_list_root.vue';
|
2019-12-26 22:10:19 +05:30
|
|
|
import IssuablesListApp from './components/issuables_list_app.vue';
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
function mountJiraIssuesListApp() {
|
2020-05-24 23:13:21 +05:30
|
|
|
const el = document.querySelector('.js-projects-issues-root');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
|
|
|
const defaultClient = createDefaultClient();
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient,
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
render(createComponent) {
|
2020-11-24 15:15:51 +05:30
|
|
|
return createComponent(JiraIssuesListRoot, {
|
2020-05-24 23:13:21 +05:30
|
|
|
props: {
|
|
|
|
canEdit: parseBoolean(el.dataset.canEdit),
|
|
|
|
isJiraConfigured: parseBoolean(el.dataset.isJiraConfigured),
|
|
|
|
issuesPath: el.dataset.issuesPath,
|
|
|
|
projectPath: el.dataset.projectPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function mountIssuablesListApp() {
|
2020-07-28 23:09:34 +05:30
|
|
|
if (!gon.features?.vueIssuablesList && !gon.features?.jiraIssuesIntegration) {
|
2019-12-26 22:10:19 +05:30
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
document.querySelectorAll('.js-issuables-list').forEach(el => {
|
2021-01-29 00:20:46 +05:30
|
|
|
const { canBulkEdit, emptyStateMeta = {}, scopedLabelsAvailable, ...data } = el.dataset;
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2021-01-29 00:20:46 +05:30
|
|
|
provide: {
|
|
|
|
scopedLabelsAvailable: parseBoolean(scopedLabelsAvailable),
|
|
|
|
},
|
2019-12-26 22:10:19 +05:30
|
|
|
render(createElement) {
|
2020-05-24 23:13:21 +05:30
|
|
|
return createElement(IssuablesListApp, {
|
|
|
|
props: {
|
|
|
|
...data,
|
2020-10-24 23:57:45 +05:30
|
|
|
emptyStateMeta:
|
|
|
|
Object.keys(emptyStateMeta).length !== 0
|
|
|
|
? convertObjectPropsToCamelCase(JSON.parse(emptyStateMeta))
|
|
|
|
: {},
|
2020-05-24 23:13:21 +05:30
|
|
|
canBulkEdit: Boolean(canBulkEdit),
|
|
|
|
},
|
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
export default function initIssuablesList() {
|
2020-11-24 15:15:51 +05:30
|
|
|
mountJiraIssuesListApp();
|
2020-05-24 23:13:21 +05:30
|
|
|
mountIssuablesListApp();
|
|
|
|
}
|