2021-10-27 15:23:28 +05:30
|
|
|
import produce from 'immer';
|
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-10-27 15:23:28 +05:30
|
|
|
import getIssuesQuery from 'ee_else_ce/issues_list/queries/get_issues.query.graphql';
|
2022-01-26 12:08:38 +05:30
|
|
|
import IssuesListApp from 'ee_else_ce/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
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
export 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;
|
|
|
|
}
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
const { issuesPath, projectPath } = el.dataset;
|
|
|
|
const canEdit = parseBoolean(el.dataset.canEdit);
|
|
|
|
const isJiraConfigured = parseBoolean(el.dataset.isJiraConfigured);
|
|
|
|
|
|
|
|
if (!isJiraConfigured || !canEdit) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
Vue.use(VueApollo);
|
2021-12-11 22:18:48 +05:30
|
|
|
const defaultClient = createDefaultClient();
|
2020-05-24 23:13:21 +05:30
|
|
|
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: {
|
2021-10-27 15:23:28 +05:30
|
|
|
canEdit,
|
|
|
|
isJiraConfigured,
|
|
|
|
issuesPath,
|
|
|
|
projectPath,
|
2020-05-24 23:13:21 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
export 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-06-08 01:23:25 +05:30
|
|
|
export function mountIssuesListApp() {
|
2021-04-17 20:07:23 +05:30
|
|
|
const el = document.querySelector('.js-issues-list');
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
const resolvers = {
|
|
|
|
Mutation: {
|
2021-11-11 11:23:49 +05:30
|
|
|
reorderIssues: (_, { oldIndex, newIndex, namespace, serializedVariables }, { cache }) => {
|
2021-10-27 15:23:28 +05:30
|
|
|
const variables = JSON.parse(serializedVariables);
|
|
|
|
const sourceData = cache.readQuery({ query: getIssuesQuery, variables });
|
|
|
|
|
|
|
|
const data = produce(sourceData, (draftData) => {
|
2021-11-11 11:23:49 +05:30
|
|
|
const issues = draftData[namespace].issues.nodes.slice();
|
2021-10-27 15:23:28 +05:30
|
|
|
const issueToMove = issues[oldIndex];
|
|
|
|
issues.splice(oldIndex, 1);
|
|
|
|
issues.splice(newIndex, 0, issueToMove);
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
draftData[namespace].issues.nodes = issues;
|
2021-10-27 15:23:28 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
cache.writeQuery({ query: getIssuesQuery, variables, data });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
const defaultClient = createDefaultClient(resolvers);
|
2021-09-04 01:27:46 +05:30
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient,
|
|
|
|
});
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
const {
|
2021-06-08 01:23:25 +05:30
|
|
|
autocompleteAwardEmojisPath,
|
2021-04-29 21:17:54 +05:30
|
|
|
calendarPath,
|
|
|
|
canBulkUpdate,
|
|
|
|
canEdit,
|
|
|
|
canImportIssues,
|
|
|
|
email,
|
2021-06-08 01:23:25 +05:30
|
|
|
emailsHelpPagePath,
|
2021-04-29 21:17:54 +05:30
|
|
|
emptyStateSvgPath,
|
|
|
|
exportCsvPath,
|
2021-11-11 11:23:49 +05:30
|
|
|
fullPath,
|
2021-11-18 22:05:49 +05:30
|
|
|
groupPath,
|
2021-11-11 11:23:49 +05:30
|
|
|
hasAnyIssues,
|
2021-11-18 22:05:49 +05:30
|
|
|
hasAnyProjects,
|
2021-04-17 20:07:23 +05:30
|
|
|
hasBlockedIssuesFeature,
|
|
|
|
hasIssuableHealthStatusFeature,
|
|
|
|
hasIssueWeightsFeature,
|
2021-09-30 23:02:18 +05:30
|
|
|
hasIterationsFeature,
|
2021-06-08 01:23:25 +05:30
|
|
|
hasMultipleIssueAssigneesFeature,
|
2021-04-29 21:17:54 +05:30
|
|
|
importCsvIssuesPath,
|
2021-06-08 01:23:25 +05:30
|
|
|
initialEmail,
|
2022-01-26 12:08:38 +05:30
|
|
|
isAnonymousSearchDisabled,
|
|
|
|
isIssueRepositioningDisabled,
|
2021-11-11 11:23:49 +05:30
|
|
|
isProject,
|
2021-04-29 21:17:54 +05:30
|
|
|
isSignedIn,
|
|
|
|
jiraIntegrationPath,
|
2021-06-08 01:23:25 +05:30
|
|
|
markdownHelpPath,
|
2021-04-29 21:17:54 +05:30
|
|
|
maxAttachmentSize,
|
|
|
|
newIssuePath,
|
|
|
|
projectImportJiraPath,
|
2021-06-08 01:23:25 +05:30
|
|
|
quickActionsHelpPath,
|
2021-12-11 22:18:48 +05:30
|
|
|
releasesPath,
|
2021-06-08 01:23:25 +05:30
|
|
|
resetPath,
|
2021-04-29 21:17:54 +05:30
|
|
|
rssPath,
|
|
|
|
showNewIssueLink,
|
|
|
|
signInPath,
|
2021-04-17 20:07:23 +05:30
|
|
|
} = el.dataset;
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2021-09-04 01:27:46 +05:30
|
|
|
apolloProvider,
|
2021-04-17 20:07:23 +05:30
|
|
|
provide: {
|
2021-06-08 01:23:25 +05:30
|
|
|
autocompleteAwardEmojisPath,
|
2021-04-29 21:17:54 +05:30
|
|
|
calendarPath,
|
|
|
|
canBulkUpdate: parseBoolean(canBulkUpdate),
|
|
|
|
emptyStateSvgPath,
|
2021-11-11 11:23:49 +05:30
|
|
|
fullPath,
|
2021-11-18 22:05:49 +05:30
|
|
|
groupPath,
|
2021-11-11 11:23:49 +05:30
|
|
|
hasAnyIssues: parseBoolean(hasAnyIssues),
|
2021-11-18 22:05:49 +05:30
|
|
|
hasAnyProjects: parseBoolean(hasAnyProjects),
|
2021-04-17 20:07:23 +05:30
|
|
|
hasBlockedIssuesFeature: parseBoolean(hasBlockedIssuesFeature),
|
|
|
|
hasIssuableHealthStatusFeature: parseBoolean(hasIssuableHealthStatusFeature),
|
|
|
|
hasIssueWeightsFeature: parseBoolean(hasIssueWeightsFeature),
|
2021-09-30 23:02:18 +05:30
|
|
|
hasIterationsFeature: parseBoolean(hasIterationsFeature),
|
2021-06-08 01:23:25 +05:30
|
|
|
hasMultipleIssueAssigneesFeature: parseBoolean(hasMultipleIssueAssigneesFeature),
|
2022-01-26 12:08:38 +05:30
|
|
|
isAnonymousSearchDisabled: parseBoolean(isAnonymousSearchDisabled),
|
|
|
|
isIssueRepositioningDisabled: parseBoolean(isIssueRepositioningDisabled),
|
2021-11-11 11:23:49 +05:30
|
|
|
isProject: parseBoolean(isProject),
|
2021-04-29 21:17:54 +05:30
|
|
|
isSignedIn: parseBoolean(isSignedIn),
|
|
|
|
jiraIntegrationPath,
|
|
|
|
newIssuePath,
|
2021-12-11 22:18:48 +05:30
|
|
|
releasesPath,
|
2021-04-29 21:17:54 +05:30
|
|
|
rssPath,
|
|
|
|
showNewIssueLink: parseBoolean(showNewIssueLink),
|
|
|
|
signInPath,
|
|
|
|
// For CsvImportExportButtons component
|
|
|
|
canEdit: parseBoolean(canEdit),
|
|
|
|
email,
|
|
|
|
exportCsvPath,
|
|
|
|
importCsvIssuesPath,
|
|
|
|
maxAttachmentSize,
|
|
|
|
projectImportJiraPath,
|
2021-11-11 11:23:49 +05:30
|
|
|
showExportButton: parseBoolean(hasAnyIssues),
|
2021-04-29 21:17:54 +05:30
|
|
|
showImportButton: parseBoolean(canImportIssues),
|
2021-11-11 11:23:49 +05:30
|
|
|
showLabel: !parseBoolean(hasAnyIssues),
|
2021-06-08 01:23:25 +05:30
|
|
|
// For IssuableByEmail component
|
|
|
|
emailsHelpPagePath,
|
|
|
|
initialEmail,
|
|
|
|
markdownHelpPath,
|
|
|
|
quickActionsHelpPath,
|
|
|
|
resetPath,
|
2021-04-17 20:07:23 +05:30
|
|
|
},
|
|
|
|
render: (createComponent) => createComponent(IssuesListApp),
|
|
|
|
});
|
|
|
|
}
|