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

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

121 lines
2.7 KiB
JavaScript
Raw Normal View History

2022-01-26 12:08:38 +05:30
import { GlToast } from '@gitlab/ui';
import Vue from 'vue';
import IssuableContext from '~/issuable/issuable_context';
import { parseBoolean } from '~/lib/utils/common_utils';
import Sidebar from '~/right_sidebar';
import { getSidebarOptions } from '~/sidebar/mount_sidebar';
import CsvImportExportButtons from './components/csv_import_export_buttons.vue';
import IssuableByEmail from './components/issuable_by_email.vue';
import IssuableHeaderWarnings from './components/issuable_header_warnings.vue';
export function initCsvImportExportButtons() {
const el = document.querySelector('.js-csv-import-export-buttons');
2022-03-02 08:16:31 +05:30
if (!el) {
return null;
}
2022-01-26 12:08:38 +05:30
const {
showExportButton,
showImportButton,
issuableType,
issuableCount,
email,
exportCsvPath,
importCsvIssuesPath,
containerClass,
canEdit,
projectImportJiraPath,
maxAttachmentSize,
showLabel,
} = el.dataset;
return new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'CsvImportExportButtonsRoot',
2022-01-26 12:08:38 +05:30
provide: {
showExportButton: parseBoolean(showExportButton),
showImportButton: parseBoolean(showImportButton),
issuableType,
email,
importCsvIssuesPath,
containerClass,
canEdit: parseBoolean(canEdit),
projectImportJiraPath,
maxAttachmentSize,
showLabel,
},
2022-03-02 08:16:31 +05:30
render: (createElement) =>
createElement(CsvImportExportButtons, {
2022-01-26 12:08:38 +05:30
props: {
exportCsvPath,
issuableCount: parseInt(issuableCount, 10),
},
2022-03-02 08:16:31 +05:30
}),
2022-01-26 12:08:38 +05:30
});
}
export function initIssuableByEmail() {
const el = document.querySelector('.js-issuable-by-email');
2022-03-02 08:16:31 +05:30
if (!el) {
return null;
}
Vue.use(GlToast);
2022-01-26 12:08:38 +05:30
const {
initialEmail,
issuableType,
emailsHelpPagePath,
quickActionsHelpPath,
markdownHelpPath,
resetPath,
} = el.dataset;
return new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'IssuableByEmailRoot',
2022-01-26 12:08:38 +05:30
provide: {
initialEmail,
issuableType,
emailsHelpPagePath,
quickActionsHelpPath,
markdownHelpPath,
resetPath,
},
2022-03-02 08:16:31 +05:30
render: (createElement) => createElement(IssuableByEmail),
2022-01-26 12:08:38 +05:30
});
}
export function initIssuableHeaderWarnings(store) {
const el = document.getElementById('js-issuable-header-warnings');
if (!el) {
2022-03-02 08:16:31 +05:30
return null;
2022-01-26 12:08:38 +05:30
}
const { hidden } = el.dataset;
return new Vue({
el,
2022-04-04 11:22:00 +05:30
name: 'IssuableHeaderWarningsRoot',
2022-01-26 12:08:38 +05:30
store,
provide: { hidden: parseBoolean(hidden) },
2022-03-02 08:16:31 +05:30
render: (createElement) => createElement(IssuableHeaderWarnings),
2022-01-26 12:08:38 +05:30
});
}
export function initIssuableSidebar() {
2022-03-02 08:16:31 +05:30
const el = document.querySelector('.js-sidebar-options');
2022-01-26 12:08:38 +05:30
2022-03-02 08:16:31 +05:30
if (!el) {
return;
}
2022-01-26 12:08:38 +05:30
2022-03-02 08:16:31 +05:30
const sidebarOptions = getSidebarOptions(el);
2022-01-26 12:08:38 +05:30
new IssuableContext(sidebarOptions.currentUser); // eslint-disable-line no-new
Sidebar.initialize();
}