Commit b3dd294f authored by Coung Ngo's avatar Coung Ngo Committed by Ezekiel Kigbo

Tidy ~/issuable init functions

parent 67d9dbee
import Vue from 'vue';
import StatusSelect from './components/status_select.vue';
import issuableBulkUpdateActions from './issuable_bulk_update_actions';
import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar';
export function initBulkUpdateSidebar(prefixId) {
const el = document.querySelector('.issues-bulk-update');
if (!el) {
return;
}
issuableBulkUpdateActions.init({ prefixId });
new IssuableBulkUpdateSidebar(); // eslint-disable-line no-new
}
export function initIssueStatusSelect() {
const el = document.querySelector('.js-issue-status');
if (!el) {
return null;
}
return new Vue({
el,
render: (createElement) => createElement(StatusSelect),
});
}
import Vue from 'vue';
import StatusSelect from './components/status_select.vue';
export default function initIssueStatusSelect() {
const el = document.querySelector('.js-issue-status');
if (!el) {
return null;
}
return new Vue({
el,
render(h) {
return h(StatusSelect);
},
});
}
...@@ -6,7 +6,6 @@ import { property } from 'lodash'; ...@@ -6,7 +6,6 @@ import { property } from 'lodash';
import issuableEventHub from '~/issues_list/eventhub'; import issuableEventHub from '~/issues_list/eventhub';
import LabelsSelect from '~/labels/labels_select'; import LabelsSelect from '~/labels/labels_select';
import MilestoneSelect from '~/milestones/milestone_select'; import MilestoneSelect from '~/milestones/milestone_select';
import initIssueStatusSelect from './init_issue_status_select';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions'; import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
import subscriptionSelect from './subscription_select'; import subscriptionSelect from './subscription_select';
...@@ -57,7 +56,6 @@ export default class IssuableBulkUpdateSidebar { ...@@ -57,7 +56,6 @@ export default class IssuableBulkUpdateSidebar {
initDropdowns() { initDropdowns() {
new LabelsSelect(); new LabelsSelect();
new MilestoneSelect(); new MilestoneSelect();
initIssueStatusSelect();
subscriptionSelect(); subscriptionSelect();
if (IS_EE) { if (IS_EE) {
......
import issuableBulkUpdateActions from './issuable_bulk_update_actions';
import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar';
export default {
bulkUpdateSidebar: null,
init(prefixId) {
const bulkUpdateEl = document.querySelector('.issues-bulk-update');
const alreadyInitialized = Boolean(this.bulkUpdateSidebar);
if (bulkUpdateEl && !alreadyInitialized) {
issuableBulkUpdateActions.init({ prefixId });
this.bulkUpdateSidebar = new IssuableBulkUpdateSidebar();
}
return this.bulkUpdateSidebar;
},
};
...@@ -11,7 +11,9 @@ import IssuableHeaderWarnings from './components/issuable_header_warnings.vue'; ...@@ -11,7 +11,9 @@ import IssuableHeaderWarnings from './components/issuable_header_warnings.vue';
export function initCsvImportExportButtons() { export function initCsvImportExportButtons() {
const el = document.querySelector('.js-csv-import-export-buttons'); const el = document.querySelector('.js-csv-import-export-buttons');
if (!el) return null; if (!el) {
return null;
}
const { const {
showExportButton, showExportButton,
...@@ -42,23 +44,24 @@ export function initCsvImportExportButtons() { ...@@ -42,23 +44,24 @@ export function initCsvImportExportButtons() {
maxAttachmentSize, maxAttachmentSize,
showLabel, showLabel,
}, },
render(h) { render: (createElement) =>
return h(CsvImportExportButtons, { createElement(CsvImportExportButtons, {
props: { props: {
exportCsvPath, exportCsvPath,
issuableCount: parseInt(issuableCount, 10), issuableCount: parseInt(issuableCount, 10),
}, },
}); }),
},
}); });
} }
export function initIssuableByEmail() { export function initIssuableByEmail() {
Vue.use(GlToast);
const el = document.querySelector('.js-issuable-by-email'); const el = document.querySelector('.js-issuable-by-email');
if (!el) return null; if (!el) {
return null;
}
Vue.use(GlToast);
const { const {
initialEmail, initialEmail,
...@@ -79,9 +82,7 @@ export function initIssuableByEmail() { ...@@ -79,9 +82,7 @@ export function initIssuableByEmail() {
markdownHelpPath, markdownHelpPath,
resetPath, resetPath,
}, },
render(h) { render: (createElement) => createElement(IssuableByEmail),
return h(IssuableByEmail);
},
}); });
} }
...@@ -89,7 +90,7 @@ export function initIssuableHeaderWarnings(store) { ...@@ -89,7 +90,7 @@ export function initIssuableHeaderWarnings(store) {
const el = document.getElementById('js-issuable-header-warnings'); const el = document.getElementById('js-issuable-header-warnings');
if (!el) { if (!el) {
return false; return null;
} }
const { hidden } = el.dataset; const { hidden } = el.dataset;
...@@ -98,18 +99,18 @@ export function initIssuableHeaderWarnings(store) { ...@@ -98,18 +99,18 @@ export function initIssuableHeaderWarnings(store) {
el, el,
store, store,
provide: { hidden: parseBoolean(hidden) }, provide: { hidden: parseBoolean(hidden) },
render(createElement) { render: (createElement) => createElement(IssuableHeaderWarnings),
return createElement(IssuableHeaderWarnings);
},
}); });
} }
export function initIssuableSidebar() { export function initIssuableSidebar() {
const sidebarOptEl = document.querySelector('.js-sidebar-options'); const el = document.querySelector('.js-sidebar-options');
if (!sidebarOptEl) return; if (!el) {
return;
}
const sidebarOptions = getSidebarOptions(sidebarOptEl); const sidebarOptions = getSidebarOptions(el);
new IssuableContext(sidebarOptions.currentUser); // eslint-disable-line no-new new IssuableContext(sidebarOptions.currentUser); // eslint-disable-line no-new
Sidebar.initialize(); Sidebar.initialize();
......
...@@ -516,10 +516,9 @@ export default { ...@@ -516,10 +516,9 @@ export default {
}, },
async handleBulkUpdateClick() { async handleBulkUpdateClick() {
if (!this.hasInitBulkEdit) { if (!this.hasInitBulkEdit) {
const initBulkUpdateSidebar = await import( const bulkUpdateSidebar = await import('~/issuable/bulk_update_sidebar');
'~/issuable/bulk_update_sidebar/issuable_init_bulk_update_sidebar' bulkUpdateSidebar.initBulkUpdateSidebar('issuable_');
); bulkUpdateSidebar.initIssueStatusSelect();
initBulkUpdateSidebar.default.init('issuable_');
const usersSelect = await import('~/users_select'); const usersSelect = await import('~/users_select');
const UsersSelect = usersSelect.default; const UsersSelect = usersSelect.default;
......
import IssuableFilteredSearchTokenKeys from 'ee_else_ce/filtered_search/issuable_filtered_search_token_keys'; import IssuableFilteredSearchTokenKeys from 'ee_else_ce/filtered_search/issuable_filtered_search_token_keys';
import issuableInitBulkUpdateSidebar from '~/issuable/bulk_update_sidebar/issuable_init_bulk_update_sidebar'; import { initBulkUpdateSidebar } from '~/issuable/bulk_update_sidebar';
import { mountIssuablesListApp, mountIssuesListApp } from '~/issues_list'; import { mountIssuablesListApp, mountIssuesListApp } from '~/issues_list';
import initManualOrdering from '~/issues/manual_ordering'; import initManualOrdering from '~/issues/manual_ordering';
import { FILTERED_SEARCH } from '~/filtered_search/constants'; import { FILTERED_SEARCH } from '~/filtered_search/constants';
...@@ -13,7 +13,7 @@ if (gon.features?.vueIssuesList) { ...@@ -13,7 +13,7 @@ if (gon.features?.vueIssuesList) {
IssuableFilteredSearchTokenKeys.addExtraTokensForIssues(); IssuableFilteredSearchTokenKeys.addExtraTokensForIssues();
IssuableFilteredSearchTokenKeys.removeTokensForKeys('release'); IssuableFilteredSearchTokenKeys.removeTokensForKeys('release');
issuableInitBulkUpdateSidebar.init(ISSUE_BULK_UPDATE_PREFIX); initBulkUpdateSidebar(ISSUE_BULK_UPDATE_PREFIX);
initFilteredSearch({ initFilteredSearch({
page: FILTERED_SEARCH.ISSUES, page: FILTERED_SEARCH.ISSUES,
......
import addExtraTokensForMergeRequests from 'ee_else_ce/filtered_search/add_extra_tokens_for_merge_requests'; import addExtraTokensForMergeRequests from 'ee_else_ce/filtered_search/add_extra_tokens_for_merge_requests';
import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys'; import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys';
import issuableInitBulkUpdateSidebar from '~/issuable/bulk_update_sidebar/issuable_init_bulk_update_sidebar'; import { initBulkUpdateSidebar } from '~/issuable/bulk_update_sidebar';
import { FILTERED_SEARCH } from '~/filtered_search/constants'; import { FILTERED_SEARCH } from '~/filtered_search/constants';
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
import projectSelect from '~/project_select'; import projectSelect from '~/project_select';
...@@ -8,7 +8,7 @@ import projectSelect from '~/project_select'; ...@@ -8,7 +8,7 @@ import projectSelect from '~/project_select';
const ISSUABLE_BULK_UPDATE_PREFIX = 'merge_request_'; const ISSUABLE_BULK_UPDATE_PREFIX = 'merge_request_';
addExtraTokensForMergeRequests(IssuableFilteredSearchTokenKeys); addExtraTokensForMergeRequests(IssuableFilteredSearchTokenKeys);
issuableInitBulkUpdateSidebar.init(ISSUABLE_BULK_UPDATE_PREFIX); initBulkUpdateSidebar(ISSUABLE_BULK_UPDATE_PREFIX);
initFilteredSearch({ initFilteredSearch({
page: FILTERED_SEARCH.MERGE_REQUESTS, page: FILTERED_SEARCH.MERGE_REQUESTS,
......
import IssuableFilteredSearchTokenKeys from 'ee_else_ce/filtered_search/issuable_filtered_search_token_keys'; import IssuableFilteredSearchTokenKeys from 'ee_else_ce/filtered_search/issuable_filtered_search_token_keys';
import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation'; import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation';
import { initCsvImportExportButtons, initIssuableByEmail } from '~/issuable'; import { initCsvImportExportButtons, initIssuableByEmail } from '~/issuable';
import issuableInitBulkUpdateSidebar from '~/issuable/bulk_update_sidebar/issuable_init_bulk_update_sidebar'; import { initBulkUpdateSidebar, initIssueStatusSelect } from '~/issuable/bulk_update_sidebar';
import { mountIssuablesListApp, mountIssuesListApp, mountJiraIssuesListApp } from '~/issues_list'; import { mountIssuablesListApp, mountIssuesListApp, mountJiraIssuesListApp } from '~/issues_list';
import initManualOrdering from '~/issues/manual_ordering'; import initManualOrdering from '~/issues/manual_ordering';
import { FILTERED_SEARCH } from '~/filtered_search/constants'; import { FILTERED_SEARCH } from '~/filtered_search/constants';
...@@ -20,7 +20,8 @@ if (gon.features?.vueIssuesList) { ...@@ -20,7 +20,8 @@ if (gon.features?.vueIssuesList) {
useDefaultState: true, useDefaultState: true,
}); });
issuableInitBulkUpdateSidebar.init(ISSUABLE_INDEX.ISSUE); initBulkUpdateSidebar(ISSUABLE_INDEX.ISSUE);
initIssueStatusSelect();
new UsersSelect(); // eslint-disable-line no-new new UsersSelect(); // eslint-disable-line no-new
initCsvImportExportButtons(); initCsvImportExportButtons();
......
...@@ -2,13 +2,14 @@ import addExtraTokensForMergeRequests from 'ee_else_ce/filtered_search/add_extra ...@@ -2,13 +2,14 @@ import addExtraTokensForMergeRequests from 'ee_else_ce/filtered_search/add_extra
import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation'; import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation';
import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys'; import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys';
import { initCsvImportExportButtons, initIssuableByEmail } from '~/issuable'; import { initCsvImportExportButtons, initIssuableByEmail } from '~/issuable';
import issuableInitBulkUpdateSidebar from '~/issuable/bulk_update_sidebar/issuable_init_bulk_update_sidebar'; import { initBulkUpdateSidebar, initIssueStatusSelect } from '~/issuable/bulk_update_sidebar';
import { FILTERED_SEARCH } from '~/filtered_search/constants'; import { FILTERED_SEARCH } from '~/filtered_search/constants';
import { ISSUABLE_INDEX } from '~/issuable/constants'; import { ISSUABLE_INDEX } from '~/issuable/constants';
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
import UsersSelect from '~/users_select'; import UsersSelect from '~/users_select';
issuableInitBulkUpdateSidebar.init(ISSUABLE_INDEX.MERGE_REQUEST); initBulkUpdateSidebar(ISSUABLE_INDEX.MERGE_REQUEST);
initIssueStatusSelect();
addExtraTokensForMergeRequests(IssuableFilteredSearchTokenKeys); addExtraTokensForMergeRequests(IssuableFilteredSearchTokenKeys);
IssuableFilteredSearchTokenKeys.removeTokensForKeys('iteration'); IssuableFilteredSearchTokenKeys.removeTokensForKeys('iteration');
......
import initEpicCreateApp from 'ee/epic/epic_bundle'; import initEpicCreateApp from 'ee/epic/epic_bundle';
import initEpicsList from 'ee/epics_list/epics_list_bundle'; import initEpicsList from 'ee/epics_list/epics_list_bundle';
import FilteredSearchTokenKeysEpics from 'ee/filtered_search/filtered_search_token_keys_epics'; import FilteredSearchTokenKeysEpics from 'ee/filtered_search/filtered_search_token_keys_epics';
import issuableInitBulkUpdateSidebar from '~/issuable/bulk_update_sidebar/issuable_init_bulk_update_sidebar'; import { initBulkUpdateSidebar } from '~/issuable/bulk_update_sidebar';
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
const EPIC_BULK_UPDATE_PREFIX = 'epic_'; const EPIC_BULK_UPDATE_PREFIX = 'epic_';
...@@ -21,6 +21,5 @@ if (gon.features.vueEpicsList) { ...@@ -21,6 +21,5 @@ if (gon.features.vueEpicsList) {
}); });
initEpicCreateApp(true); initEpicCreateApp(true);
initBulkUpdateSidebar(EPIC_BULK_UPDATE_PREFIX);
issuableInitBulkUpdateSidebar.init(EPIC_BULK_UPDATE_PREFIX);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment