diff options
Diffstat (limited to 'app/assets/javascripts/pages/projects/merge_requests')
10 files changed, 63 insertions, 36 deletions
diff --git a/app/assets/javascripts/pages/projects/merge_requests/conflicts/index.js b/app/assets/javascripts/pages/projects/merge_requests/conflicts/index.js index 28641104c58..05019915fc9 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/conflicts/index.js +++ b/app/assets/javascripts/pages/projects/merge_requests/conflicts/index.js @@ -1,5 +1,5 @@ -import initSidebarBundle from '~/sidebar/sidebar_bundle'; import initMergeConflicts from '~/merge_conflicts/merge_conflicts_bundle'; +import initSidebarBundle from '~/sidebar/sidebar_bundle'; document.addEventListener('DOMContentLoaded', () => { initSidebarBundle(); diff --git a/app/assets/javascripts/pages/projects/merge_requests/creations/index.js b/app/assets/javascripts/pages/projects/merge_requests/creations/index.js index febfecebbd2..34d9fa03d24 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/creations/index.js +++ b/app/assets/javascripts/pages/projects/merge_requests/creations/index.js @@ -1,3 +1,3 @@ import initMergeRequest from '~/pages/projects/merge_requests/init_merge_request'; -document.addEventListener('DOMContentLoaded', initMergeRequest); +initMergeRequest(); diff --git a/app/assets/javascripts/pages/projects/merge_requests/creations/new/compare.js b/app/assets/javascripts/pages/projects/merge_requests/creations/new/compare.js index eb2692c7cb4..1a0fa6e544e 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/creations/new/compare.js +++ b/app/assets/javascripts/pages/projects/merge_requests/creations/new/compare.js @@ -1,7 +1,7 @@ import $ from 'jquery'; -import { localTimeAgo } from '~/lib/utils/datetime_utility'; -import axios from '~/lib/utils/axios_utils'; import initCompareAutocomplete from '~/compare_autocomplete'; +import axios from '~/lib/utils/axios_utils'; +import { localTimeAgo } from '~/lib/utils/datetime_utility'; import initTargetProjectDropdown from './target_project_dropdown'; const updateCommitList = (url, $loadingIndicator, $commitList, params) => { diff --git a/app/assets/javascripts/pages/projects/merge_requests/creations/new/index.js b/app/assets/javascripts/pages/projects/merge_requests/creations/new/index.js index 01a0b4870c1..9aecd154483 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/creations/new/index.js +++ b/app/assets/javascripts/pages/projects/merge_requests/creations/new/index.js @@ -1,17 +1,15 @@ -import MergeRequest from '~/merge_request'; import initPipelines from '~/commit/pipelines/pipelines_bundle'; +import MergeRequest from '~/merge_request'; import initCompare from './compare'; -document.addEventListener('DOMContentLoaded', () => { - const mrNewCompareNode = document.querySelector('.js-merge-request-new-compare'); - if (mrNewCompareNode) { - initCompare(mrNewCompareNode); - } else { - const mrNewSubmitNode = document.querySelector('.js-merge-request-new-submit'); - // eslint-disable-next-line no-new - new MergeRequest({ - action: mrNewSubmitNode.dataset.mrSubmitAction, - }); - initPipelines(); - } -}); +const mrNewCompareNode = document.querySelector('.js-merge-request-new-compare'); +if (mrNewCompareNode) { + initCompare(mrNewCompareNode); +} else { + const mrNewSubmitNode = document.querySelector('.js-merge-request-new-submit'); + // eslint-disable-next-line no-new + new MergeRequest({ + action: mrNewSubmitNode.dataset.mrSubmitAction, + }); + initPipelines(); +} diff --git a/app/assets/javascripts/pages/projects/merge_requests/edit/check_form_state.js b/app/assets/javascripts/pages/projects/merge_requests/edit/check_form_state.js new file mode 100644 index 00000000000..74178ab96e3 --- /dev/null +++ b/app/assets/javascripts/pages/projects/merge_requests/edit/check_form_state.js @@ -0,0 +1,24 @@ +import { serializeForm } from '~/lib/utils/forms'; + +const findForm = () => document.querySelector('.merge-request-form'); +const serializeFormData = () => JSON.stringify(serializeForm(findForm())); + +export default () => { + const oldFormData = serializeFormData(); + + const compareFormData = (e) => { + const newFormData = serializeFormData(); + + if (oldFormData !== newFormData) { + e.preventDefault(); + // eslint-disable-next-line no-param-reassign + e.returnValue = ''; // Chrome requires returnValue to be set + } + }; + + window.addEventListener('beforeunload', compareFormData); + + findForm().addEventListener('submit', () => + window.removeEventListener('beforeunload', compareFormData), + ); +}; diff --git a/app/assets/javascripts/pages/projects/merge_requests/edit/index.js b/app/assets/javascripts/pages/projects/merge_requests/edit/index.js index febfecebbd2..399aebb0c83 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/edit/index.js +++ b/app/assets/javascripts/pages/projects/merge_requests/edit/index.js @@ -1,3 +1,7 @@ import initMergeRequest from '~/pages/projects/merge_requests/init_merge_request'; +import initCheckFormState from './check_form_state'; -document.addEventListener('DOMContentLoaded', initMergeRequest); +document.addEventListener('DOMContentLoaded', () => { + initMergeRequest(); + initCheckFormState(); +}); diff --git a/app/assets/javascripts/pages/projects/merge_requests/index/index.js b/app/assets/javascripts/pages/projects/merge_requests/index/index.js index 94a12cc2706..76705256fe2 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/index/index.js +++ b/app/assets/javascripts/pages/projects/merge_requests/index/index.js @@ -1,11 +1,12 @@ import addExtraTokensForMergeRequests from 'ee_else_ce/filtered_search/add_extra_tokens_for_merge_requests'; -import IssuableIndex from '~/issuable_index'; import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation'; -import UsersSelect from '~/users_select'; -import initFilteredSearch from '~/pages/search/init_filtered_search'; import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys'; +import initIssuableByEmail from '~/issuable/init_issuable_by_email'; +import IssuableIndex from '~/issuable_index'; import { FILTERED_SEARCH } from '~/pages/constants'; import { ISSUABLE_INDEX } from '~/pages/projects/constants'; +import initFilteredSearch from '~/pages/search/init_filtered_search'; +import UsersSelect from '~/users_select'; new IssuableIndex(ISSUABLE_INDEX.MERGE_REQUEST); // eslint-disable-line no-new @@ -19,3 +20,5 @@ initFilteredSearch({ new UsersSelect(); // eslint-disable-line no-new new ShortcutsNavigation(); // eslint-disable-line no-new + +initIssuableByEmail(); diff --git a/app/assets/javascripts/pages/projects/merge_requests/init_merge_request.js b/app/assets/javascripts/pages/projects/merge_requests/init_merge_request.js index 76d72efb11b..7d5719cf8a8 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/init_merge_request.js +++ b/app/assets/javascripts/pages/projects/merge_requests/init_merge_request.js @@ -2,8 +2,8 @@ import $ from 'jquery'; import IssuableForm from 'ee_else_ce/issuable_form'; -import Diff from '~/diff'; import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation'; +import Diff from '~/diff'; import GLForm from '~/gl_form'; import LabelsSelect from '~/labels_select'; import MilestoneSelect from '~/milestone_select'; diff --git a/app/assets/javascripts/pages/projects/merge_requests/init_merge_request_show.js b/app/assets/javascripts/pages/projects/merge_requests/init_merge_request_show.js index 1a0c5860991..d4d5e9f2711 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/init_merge_request_show.js +++ b/app/assets/javascripts/pages/projects/merge_requests/init_merge_request_show.js @@ -1,16 +1,16 @@ import Vue from 'vue'; -import ZenMode from '~/zen_mode'; -import initIssuableSidebar from '~/init_issuable_sidebar'; +import loadAwardsHandler from '~/awards_handler'; import ShortcutsIssuable from '~/behaviors/shortcuts/shortcuts_issuable'; -import { handleLocationHash } from '~/lib/utils/common_utils'; import initPipelines from '~/commit/pipelines/pipelines_bundle'; -import initSourcegraph from '~/sourcegraph'; -import loadAwardsHandler from '~/awards_handler'; -import initInviteMemberTrigger from '~/invite_member/init_invite_member_trigger'; +import initIssuableSidebar from '~/init_issuable_sidebar'; import initInviteMemberModal from '~/invite_member/init_invite_member_modal'; +import initInviteMemberTrigger from '~/invite_member/init_invite_member_trigger'; +import { handleLocationHash } from '~/lib/utils/common_utils'; import StatusBox from '~/merge_request/components/status_box.vue'; +import initSourcegraph from '~/sourcegraph'; +import ZenMode from '~/zen_mode'; -export default function () { +export default function initMergeRequestShow() { new ZenMode(); // eslint-disable-line no-new initIssuableSidebar(); initPipelines(); diff --git a/app/assets/javascripts/pages/projects/merge_requests/show/index.js b/app/assets/javascripts/pages/projects/merge_requests/show/index.js index 602d749ee07..546fa66eda6 100644 --- a/app/assets/javascripts/pages/projects/merge_requests/show/index.js +++ b/app/assets/javascripts/pages/projects/merge_requests/show/index.js @@ -1,14 +1,12 @@ -import initMrNotes from '~/mr_notes'; import { initReviewBar } from '~/batch_comments'; +import initMrNotes from '~/mr_notes'; +import store from '~/mr_notes/stores'; import initSidebarBundle from '~/sidebar/sidebar_bundle'; -import initShow from '../init_merge_request_show'; import initIssuableHeaderWarning from '~/vue_shared/components/issuable/init_issuable_header_warning'; -import store from '~/mr_notes/stores'; +import initShow from '../init_merge_request_show'; initShow(); -if (gon.features && !gon.features.vueIssuableSidebar) { - initSidebarBundle(); -} +initSidebarBundle(); initMrNotes(); initReviewBar(); initIssuableHeaderWarning(store); |