Commit 71214ed1 authored by Coung Ngo's avatar Coung Ngo

Lazy import bulk edit in issues page refactor

Lazy import bulk edit to reduce page bundle size since
it likely isn't used every time a user visits the page.

Also tidy up the issues/index page JS
parent 5ff51c71
...@@ -353,7 +353,18 @@ export default { ...@@ -353,7 +353,18 @@ export default {
eventHub.$emit('issuables:updateBulkEdit'); eventHub.$emit('issuables:updateBulkEdit');
}); });
}, },
handleBulkUpdateClick() { async handleBulkUpdateClick() {
if (!this.hasInitBulkEdit) {
const initBulkUpdateSidebar = await import('~/issuable_init_bulk_update_sidebar');
initBulkUpdateSidebar.default.init('issuable_');
const usersSelect = await import('~/users_select');
const UsersSelect = usersSelect.default;
new UsersSelect(); // eslint-disable-line no-new
this.hasInitBulkEdit = true;
}
eventHub.$emit('issuables:enableBulkEdit'); eventHub.$emit('issuables:enableBulkEdit');
}, },
handleClickTab(state) { handleClickTab(state) {
......
...@@ -7,7 +7,7 @@ import { convertObjectPropsToCamelCase, parseBoolean } from '~/lib/utils/common_ ...@@ -7,7 +7,7 @@ import { convertObjectPropsToCamelCase, parseBoolean } from '~/lib/utils/common_
import IssuablesListApp from './components/issuables_list_app.vue'; import IssuablesListApp from './components/issuables_list_app.vue';
import JiraIssuesImportStatusRoot from './components/jira_issues_import_status_app.vue'; import JiraIssuesImportStatusRoot from './components/jira_issues_import_status_app.vue';
function mountJiraIssuesListApp() { export function mountJiraIssuesListApp() {
const el = document.querySelector('.js-jira-issues-import-status'); const el = document.querySelector('.js-jira-issues-import-status');
if (!el) { if (!el) {
...@@ -37,7 +37,7 @@ function mountJiraIssuesListApp() { ...@@ -37,7 +37,7 @@ function mountJiraIssuesListApp() {
}); });
} }
function mountIssuablesListApp() { export function mountIssuablesListApp() {
if (!gon.features?.vueIssuablesList) { if (!gon.features?.vueIssuablesList) {
return; return;
} }
...@@ -66,7 +66,7 @@ function mountIssuablesListApp() { ...@@ -66,7 +66,7 @@ function mountIssuablesListApp() {
}); });
} }
export function initIssuesListApp() { export function mountIssuesListApp() {
const el = document.querySelector('.js-issues-list'); const el = document.querySelector('.js-issues-list');
if (!el) { if (!el) {
...@@ -157,8 +157,3 @@ export function initIssuesListApp() { ...@@ -157,8 +157,3 @@ export function initIssuesListApp() {
render: (createComponent) => createComponent(IssuesListApp), render: (createComponent) => createComponent(IssuesListApp),
}); });
} }
export default function initIssuablesList() {
mountJiraIssuesListApp();
mountIssuablesListApp();
}
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_init_bulk_update_sidebar'; import issuableInitBulkUpdateSidebar from '~/issuable_init_bulk_update_sidebar';
import initIssuablesList from '~/issues_list'; import { mountIssuablesListApp } from '~/issues_list';
import initManualOrdering from '~/manual_ordering'; import initManualOrdering from '~/manual_ordering';
import { FILTERED_SEARCH } from '~/pages/constants'; import { FILTERED_SEARCH } from '~/pages/constants';
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
...@@ -12,8 +12,6 @@ IssuableFilteredSearchTokenKeys.addExtraTokensForIssues(); ...@@ -12,8 +12,6 @@ IssuableFilteredSearchTokenKeys.addExtraTokensForIssues();
IssuableFilteredSearchTokenKeys.removeTokensForKeys('release'); IssuableFilteredSearchTokenKeys.removeTokensForKeys('release');
issuableInitBulkUpdateSidebar.init(ISSUE_BULK_UPDATE_PREFIX); issuableInitBulkUpdateSidebar.init(ISSUE_BULK_UPDATE_PREFIX);
initIssuablesList();
initFilteredSearch({ initFilteredSearch({
page: FILTERED_SEARCH.ISSUES, page: FILTERED_SEARCH.ISSUES,
isGroupDecendent: true, isGroupDecendent: true,
...@@ -22,3 +20,7 @@ initFilteredSearch({ ...@@ -22,3 +20,7 @@ initFilteredSearch({
}); });
projectSelect(); projectSelect();
initManualOrdering(); initManualOrdering();
if (gon.features?.vueIssuablesList) {
mountIssuablesListApp();
}
/* eslint-disable no-new */
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 from '~/issuable/init_csv_import_export_buttons'; import initCsvImportExportButtons from '~/issuable/init_csv_import_export_buttons';
import initIssuableByEmail from '~/issuable/init_issuable_by_email'; import initIssuableByEmail from '~/issuable/init_issuable_by_email';
import IssuableIndex from '~/issuable_index'; import IssuableIndex from '~/issuable_index';
import initIssuablesList, { initIssuesListApp } from '~/issues_list'; import { mountIssuablesListApp, mountIssuesListApp, mountJiraIssuesListApp } from '~/issues_list';
import initManualOrdering from '~/manual_ordering'; import initManualOrdering from '~/manual_ordering';
import { FILTERED_SEARCH } from '~/pages/constants'; import { FILTERED_SEARCH } from '~/pages/constants';
import { ISSUABLE_INDEX } from '~/pages/projects/constants'; import { ISSUABLE_INDEX } from '~/pages/projects/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';
IssuableFilteredSearchTokenKeys.addExtraTokensForIssues(); if (gon.features?.vueIssuesList) {
mountIssuesListApp();
} else {
IssuableFilteredSearchTokenKeys.addExtraTokensForIssues();
initFilteredSearch({ initFilteredSearch({
page: FILTERED_SEARCH.ISSUES, page: FILTERED_SEARCH.ISSUES,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys, filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys,
useDefaultState: true, useDefaultState: true,
}); });
if (gon.features?.vueIssuesList) { new IssuableIndex(ISSUABLE_INDEX.ISSUE); // eslint-disable-line no-new
new IssuableIndex(); new UsersSelect(); // eslint-disable-line no-new
} else {
new IssuableIndex(ISSUABLE_INDEX.ISSUE); initCsvImportExportButtons();
initIssuableByEmail();
initManualOrdering();
if (gon.features?.vueIssuablesList) {
mountIssuablesListApp();
}
} }
new ShortcutsNavigation(); new ShortcutsNavigation(); // eslint-disable-line no-new
new UsersSelect();
initManualOrdering(); mountJiraIssuesListApp();
initIssuablesList();
initIssuableByEmail();
initCsvImportExportButtons();
initIssuesListApp();
import initIssuablesList from '~/issues_list'; import { mountIssuablesListApp } from '~/issues_list';
import FilteredSearchServiceDesk from './filtered_search'; import FilteredSearchServiceDesk from './filtered_search';
const supportBotData = JSON.parse( const supportBotData = JSON.parse(
...@@ -11,5 +11,5 @@ if (document.querySelector('.filtered-search')) { ...@@ -11,5 +11,5 @@ if (document.querySelector('.filtered-search')) {
} }
if (gon.features?.vueIssuablesList) { if (gon.features?.vueIssuablesList) {
initIssuablesList(); mountIssuablesListApp();
} }
...@@ -170,13 +170,15 @@ describe('IssuesListApp component', () => { ...@@ -170,13 +170,15 @@ describe('IssuesListApp component', () => {
expect(findGlButtons().filter((button) => button.text() === 'Edit issues')).toHaveLength(0); expect(findGlButtons().filter((button) => button.text() === 'Edit issues')).toHaveLength(0);
}); });
it('emits "issuables:enableBulkEdit" event to legacy bulk edit class', () => { it('emits "issuables:enableBulkEdit" event to legacy bulk edit class', async () => {
wrapper = mountComponent({ provide: { canBulkUpdate: true }, mountFn: mount }); wrapper = mountComponent({ provide: { canBulkUpdate: true }, mountFn: mount });
jest.spyOn(eventHub, '$emit'); jest.spyOn(eventHub, '$emit');
findGlButtonAt(2).vm.$emit('click'); findGlButtonAt(2).vm.$emit('click');
await waitForPromises();
expect(eventHub.$emit).toHaveBeenCalledWith('issuables:enableBulkEdit'); expect(eventHub.$emit).toHaveBeenCalledWith('issuables:enableBulkEdit');
}); });
}); });
......
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