debian-mirror-gitlab/app/assets/javascripts/issues_list/index.js

142 lines
3.8 KiB
JavaScript
Raw Normal View History

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';
2021-04-17 20:07:23 +05:30
import IssuesListApp from '~/issues_list/components/issues_list_app.vue';
2020-05-24 23:13:21 +05:30
import createDefaultClient from '~/lib/graphql';
2021-04-17 20:07:23 +05:30
import { convertObjectPropsToCamelCase, parseBoolean } from '~/lib/utils/common_utils';
2019-12-26 22:10:19 +05:30
import IssuablesListApp from './components/issuables_list_app.vue';
2021-04-17 20:07:23 +05:30
import JiraIssuesImportStatusRoot from './components/jira_issues_import_status_app.vue';
2019-12-26 22:10:19 +05:30
2020-11-24 15:15:51 +05:30
function mountJiraIssuesListApp() {
2021-04-17 20:07:23 +05:30
const el = document.querySelector('.js-jira-issues-import-status');
2020-05-24 23:13:21 +05:30
if (!el) {
return false;
}
Vue.use(VueApollo);
const defaultClient = createDefaultClient();
const apolloProvider = new VueApollo({
defaultClient,
});
return new Vue({
el,
apolloProvider,
render(createComponent) {
2021-04-17 20:07:23 +05:30
return createComponent(JiraIssuesImportStatusRoot, {
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() {
2021-04-17 20:07:23 +05:30
if (!gon.features?.vueIssuablesList) {
2019-12-26 22:10:19 +05:30
return;
}
2021-03-08 18:12:59 +05:30
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
2021-04-17 20:07:23 +05:30
export function initIssuesListApp() {
const el = document.querySelector('.js-issues-list');
if (!el) {
return false;
}
const {
2021-04-29 21:17:54 +05:30
calendarPath,
canBulkUpdate,
canEdit,
canImportIssues,
email,
emptyStateSvgPath,
2021-04-17 20:07:23 +05:30
endpoint,
2021-04-29 21:17:54 +05:30
exportCsvPath,
2021-04-17 20:07:23 +05:30
fullPath,
hasBlockedIssuesFeature,
hasIssuableHealthStatusFeature,
2021-04-29 21:17:54 +05:30
hasIssues,
2021-04-17 20:07:23 +05:30
hasIssueWeightsFeature,
2021-04-29 21:17:54 +05:30
importCsvIssuesPath,
isSignedIn,
issuesPath,
jiraIntegrationPath,
maxAttachmentSize,
newIssuePath,
projectImportJiraPath,
rssPath,
showNewIssueLink,
signInPath,
2021-04-17 20:07:23 +05:30
} = el.dataset;
return new Vue({
el,
// Currently does not use Vue Apollo, but need to provide {} for now until the
// issue is fixed upstream in https://github.com/vuejs/vue-apollo/pull/1153
apolloProvider: {},
provide: {
2021-04-29 21:17:54 +05:30
calendarPath,
canBulkUpdate: parseBoolean(canBulkUpdate),
emptyStateSvgPath,
2021-04-17 20:07:23 +05:30
endpoint,
fullPath,
hasBlockedIssuesFeature: parseBoolean(hasBlockedIssuesFeature),
hasIssuableHealthStatusFeature: parseBoolean(hasIssuableHealthStatusFeature),
2021-04-29 21:17:54 +05:30
hasIssues: parseBoolean(hasIssues),
2021-04-17 20:07:23 +05:30
hasIssueWeightsFeature: parseBoolean(hasIssueWeightsFeature),
2021-04-29 21:17:54 +05:30
isSignedIn: parseBoolean(isSignedIn),
issuesPath,
jiraIntegrationPath,
newIssuePath,
rssPath,
showNewIssueLink: parseBoolean(showNewIssueLink),
signInPath,
// For CsvImportExportButtons component
canEdit: parseBoolean(canEdit),
email,
exportCsvPath,
importCsvIssuesPath,
maxAttachmentSize,
projectImportJiraPath,
showExportButton: parseBoolean(hasIssues),
showImportButton: parseBoolean(canImportIssues),
showLabel: !parseBoolean(hasIssues),
2021-04-17 20:07:23 +05:30
},
render: (createComponent) => createComponent(IssuesListApp),
});
}
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();
}