debian-mirror-gitlab/app/assets/javascripts/issues/list/index.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

176 lines
5 KiB
JavaScript
Raw Normal View History

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';
2022-07-16 23:28:13 +05:30
import VueRouter from 'vue-router';
2022-03-02 08:16:31 +05:30
import getIssuesQuery from 'ee_else_ce/issues/list/queries/get_issues.query.graphql';
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';
2022-03-02 08:16:31 +05:30
import { parseBoolean } from '~/lib/utils/common_utils';
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,
2022-04-04 11:22:00 +05:30
name: 'JiraIssuesImportStatusRoot',
2020-05-24 23:13:21 +05:30
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 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);
2022-07-16 23:28:13 +05:30
Vue.use(VueRouter);
2021-09-04 01:27:46 +05:30
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-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-04-04 11:22:00 +05:30
initialSort,
2022-01-26 12:08:38 +05:30
isAnonymousSearchDisabled,
isIssueRepositioningDisabled,
2021-11-11 11:23:49 +05:30
isProject,
2022-07-16 23:28:13 +05:30
isPublicVisibilityRestricted,
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,
2022-04-04 11:22:00 +05:30
name: 'IssuesListRoot',
2022-07-16 23:28:13 +05:30
apolloProvider: new VueApollo({
defaultClient: createDefaultClient(resolvers),
}),
router: new VueRouter({
base: window.location.pathname,
mode: 'history',
routes: [{ path: '/' }],
}),
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-04-04 11:22:00 +05:30
initialSort,
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),
2022-07-16 23:28:13 +05:30
isPublicVisibilityRestricted: parseBoolean(isPublicVisibilityRestricted),
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),
});
}