Commit b45c06fe authored by Coung Ngo's avatar Coung Ngo Committed by Jacques Erasmus

Organise ~/milestones code

parent e242de4a
import { sortMilestonesByDueDate } from '~/milestones/milestone_utils'; import { sortMilestonesByDueDate } from '~/milestones/utils';
import { mergeUrlParams } from '../lib/utils/url_utility'; import { mergeUrlParams } from '../lib/utils/url_utility';
import DropdownAjaxFilter from './dropdown_ajax_filter'; import DropdownAjaxFilter from './dropdown_ajax_filter';
import DropdownEmoji from './dropdown_emoji'; import DropdownEmoji from './dropdown_emoji';
......
import $ from 'jquery';
import initDatePicker from '~/behaviors/date_picker';
import GLForm from '~/gl_form';
import ZenMode from '~/zen_mode';
export default (initGFM = true) => {
new ZenMode(); // eslint-disable-line no-new
initDatePicker();
// eslint-disable-next-line no-new
new GLForm($('.milestone-form'), {
emojis: true,
members: initGFM,
issues: initGFM,
mergeRequests: initGFM,
epics: initGFM,
milestones: initGFM,
labels: initGFM,
snippets: initGFM,
vulnerabilities: initGFM,
});
};
import $ from 'jquery';
import Vue from 'vue'; import Vue from 'vue';
import initDatePicker from '~/behaviors/date_picker';
import GLForm from '~/gl_form';
import { BV_SHOW_MODAL } from '~/lib/utils/constants'; import { BV_SHOW_MODAL } from '~/lib/utils/constants';
import Milestone from '~/milestones/milestone';
import Sidebar from '~/right_sidebar';
import MountMilestoneSidebar from '~/sidebar/mount_milestone_sidebar';
import Translate from '~/vue_shared/translate'; import Translate from '~/vue_shared/translate';
import ZenMode from '~/zen_mode';
import DeleteMilestoneModal from './components/delete_milestone_modal.vue'; import DeleteMilestoneModal from './components/delete_milestone_modal.vue';
import PromoteMilestoneModal from './components/promote_milestone_modal.vue';
import eventHub from './event_hub'; import eventHub from './event_hub';
export default () => { export function initForm(initGFM = true) {
new ZenMode(); // eslint-disable-line no-new
initDatePicker();
// eslint-disable-next-line no-new
new GLForm($('.milestone-form'), {
emojis: true,
members: initGFM,
issues: initGFM,
mergeRequests: initGFM,
epics: initGFM,
milestones: initGFM,
labels: initGFM,
snippets: initGFM,
vulnerabilities: initGFM,
});
}
export function initShow() {
new Milestone(); // eslint-disable-line no-new
new Sidebar(); // eslint-disable-line no-new
new MountMilestoneSidebar(); // eslint-disable-line no-new
}
export function initPromoteMilestoneModal() {
Vue.use(Translate);
const promoteMilestoneModal = document.getElementById('promote-milestone-modal');
if (!promoteMilestoneModal) {
return null;
}
return new Vue({
el: promoteMilestoneModal,
render(createElement) {
return createElement(PromoteMilestoneModal);
},
});
}
export function initDeleteMilestoneModal() {
Vue.use(Translate); Vue.use(Translate);
const onRequestFinished = ({ milestoneUrl, successful }) => { const onRequestFinished = ({ milestoneUrl, successful }) => {
...@@ -72,4 +120,4 @@ export default () => { ...@@ -72,4 +120,4 @@ export default () => {
}); });
}, },
}); });
}; }
/* eslint-disable no-new */
import Milestone from '~/milestones/milestone';
import Sidebar from '~/right_sidebar';
import MountMilestoneSidebar from '~/sidebar/mount_milestone_sidebar';
export default () => {
new Milestone();
new Sidebar();
new MountMilestoneSidebar();
};
...@@ -6,7 +6,7 @@ import { template, escape } from 'lodash'; ...@@ -6,7 +6,7 @@ import { template, escape } from 'lodash';
import Api from '~/api'; import Api from '~/api';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { sortMilestonesByDueDate } from '~/milestones/milestone_utils'; import { sortMilestonesByDueDate } from '~/milestones/utils';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { timeFor, parsePikadayDate, dateInWords } from '~/lib/utils/datetime_utility'; import { timeFor, parsePikadayDate, dateInWords } from '~/lib/utils/datetime_utility';
......
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import PromoteMilestoneModal from './components/promote_milestone_modal.vue';
Vue.use(Translate);
export default () => {
const promoteMilestoneModal = document.getElementById('promote-milestone-modal');
if (!promoteMilestoneModal) {
return null;
}
return new Vue({
el: promoteMilestoneModal,
render(createElement) {
return createElement(PromoteMilestoneModal);
},
});
};
import initForm from '~/milestones/form'; import { initForm } from '~/milestones';
initForm(); initForm();
import initForm from '~/milestones/form'; import { initForm } from '~/milestones';
initForm(); initForm();
import initDeleteMilestoneModal from '~/milestones/delete_milestone_modal_init'; import { initDeleteMilestoneModal, initShow } from '~/milestones';
import initMilestonesShow from '~/milestones/init_milestones_show';
initMilestonesShow(); initShow();
initDeleteMilestoneModal(); initDeleteMilestoneModal();
import initForm from '~/milestones/form'; import { initForm } from '~/milestones';
initForm(); initForm();
import initDeleteMilestoneModal from '~/milestones/delete_milestone_modal_init'; import { initDeleteMilestoneModal, initPromoteMilestoneModal } from '~/milestones';
import initPromoteMilestoneModal from '~/milestones/promote_milestone_modal_init';
initDeleteMilestoneModal(); initDeleteMilestoneModal();
initPromoteMilestoneModal(); initPromoteMilestoneModal();
import initForm from '~/milestones/form'; import { initForm } from '~/milestones';
initForm(); initForm();
import initMilestonesShow from '~/milestones/init_milestones_show'; import { initDeleteMilestoneModal, initPromoteMilestoneModal, initShow } from '~/milestones';
import initDeleteMilestoneModal from '~/milestones/delete_milestone_modal_init';
import initPromoteMilestoneModal from '~/milestones/promote_milestone_modal_init';
initMilestonesShow(); initShow();
initDeleteMilestoneModal(); initDeleteMilestoneModal();
initPromoteMilestoneModal(); initPromoteMilestoneModal();
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlFilteredSearchSuggestion } from '@gitlab/ui'; import { GlFilteredSearchSuggestion } from '@gitlab/ui';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { sortMilestonesByDueDate } from '~/milestones/milestone_utils'; import { sortMilestonesByDueDate } from '~/milestones/utils';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue'; import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
import { DEFAULT_MILESTONES } from '../constants'; import { DEFAULT_MILESTONES } from '../constants';
import { stripQuotes } from '../filtered_search_utils'; import { stripQuotes } from '../filtered_search_utils';
......
...@@ -2,7 +2,7 @@ import AvailableDropdownMappingsCE from '~/filtered_search/available_dropdown_ma ...@@ -2,7 +2,7 @@ import AvailableDropdownMappingsCE from '~/filtered_search/available_dropdown_ma
import DropdownAjaxFilter from '~/filtered_search/dropdown_ajax_filter'; import DropdownAjaxFilter from '~/filtered_search/dropdown_ajax_filter';
import DropdownNonUser from '~/filtered_search/dropdown_non_user'; import DropdownNonUser from '~/filtered_search/dropdown_non_user';
import DropdownUser from '~/filtered_search/dropdown_user'; import DropdownUser from '~/filtered_search/dropdown_user';
import { sortMilestonesByDueDate } from '~/milestones/milestone_utils'; import { sortMilestonesByDueDate } from '~/milestones/utils';
import DropdownWeight from './dropdown_weight'; import DropdownWeight from './dropdown_weight';
export default class AvailableDropdownMappings { export default class AvailableDropdownMappings {
......
...@@ -7,7 +7,7 @@ import Vuex from 'vuex'; ...@@ -7,7 +7,7 @@ import Vuex from 'vuex';
import { ENTER_KEY } from '~/lib/utils/keys'; import { ENTER_KEY } from '~/lib/utils/keys';
import MilestoneCombobox from '~/milestones/components/milestone_combobox.vue'; import MilestoneCombobox from '~/milestones/components/milestone_combobox.vue';
import createStore from '~/milestones/stores/'; import createStore from '~/milestones/stores/';
import { projectMilestones, groupMilestones } from './mock_data'; import { projectMilestones, groupMilestones } from '../mock_data';
const extraLinks = [ const extraLinks = [
{ text: 'Create new', url: 'http://127.0.0.1:3000/h5bp/html5-boilerplate/-/milestones/new' }, { text: 'Create new', url: 'http://127.0.0.1:3000/h5bp/html5-boilerplate/-/milestones/new' },
......
import { useFakeDate } from 'helpers/fake_date'; import { useFakeDate } from 'helpers/fake_date';
import { sortMilestonesByDueDate } from '~/milestones/milestone_utils'; import { sortMilestonesByDueDate } from '~/milestones/utils';
describe('sortMilestonesByDueDate', () => { describe('sortMilestonesByDueDate', () => {
useFakeDate(2021, 6, 22); useFakeDate(2021, 6, 22);
......
...@@ -9,7 +9,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -9,7 +9,7 @@ import MockAdapter from 'axios-mock-adapter';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { sortMilestonesByDueDate } from '~/milestones/milestone_utils'; import { sortMilestonesByDueDate } from '~/milestones/utils';
import { DEFAULT_MILESTONES } from '~/vue_shared/components/filtered_search_bar/constants'; import { DEFAULT_MILESTONES } from '~/vue_shared/components/filtered_search_bar/constants';
import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue'; import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue';
...@@ -17,7 +17,7 @@ import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/m ...@@ -17,7 +17,7 @@ import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/m
import { mockMilestoneToken, mockMilestones, mockRegularMilestone } from '../mock_data'; import { mockMilestoneToken, mockMilestones, mockRegularMilestone } from '../mock_data';
jest.mock('~/flash'); jest.mock('~/flash');
jest.mock('~/milestones/milestone_utils'); jest.mock('~/milestones/utils');
const defaultStubs = { const defaultStubs = {
Portal: true, Portal: true,
......
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