Commit bcca77eb authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents d8b5438a 3a6c2a41
......@@ -123,7 +123,7 @@ export const handleLocationHash = () => {
}
if (isInIssuePage()) {
adjustment -= fixedIssuableTitle.offsetHeight;
adjustment -= fixedIssuableTitle?.offsetHeight;
}
if (isInMRPage()) {
......
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),
);
};
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();
});
import ZenMode from '~/zen_mode';
import initNewRelease from '~/releases/mount_new';
document.addEventListener('DOMContentLoaded', () => {
new ZenMode(); // eslint-disable-line no-new
initNewRelease();
});
new ZenMode(); // eslint-disable-line no-new
initNewRelease();
---
title: Display unload warning if MR edit changed
merge_request: 53438
author:
type: added
......@@ -23,6 +23,9 @@ export default {
fallbackApprovalsRequired: (state) => state.approvals.fallbackApprovalsRequired,
}),
},
mounted() {
this.$root.$emit('hidden-inputs-mounted');
},
INPUT_ID,
INPUT_SOURCE_ID,
INPUT_NAME,
......
import mountApprovals from 'ee/approvals/mount_mr_edit';
import mountBlockingMergeRequestsInput from 'ee/projects/merge_requests/blocking_mr_input';
import initCheckFormState from '~/pages/projects/merge_requests/edit/check_form_state';
export default () => {
mountApprovals(document.getElementById('js-mr-approvals-input'));
const editMrApp = mountApprovals(document.getElementById('js-mr-approvals-input'));
mountBlockingMergeRequestsInput(document.getElementById('js-blocking-merge-requests-input'));
editMrApp.$on('hidden-inputs-mounted', initCheckFormState);
};
......@@ -4,7 +4,7 @@ export * from '~/vue_shared/security_reports/components/constants';
export const SEVERITY_TOOLTIP_TITLE_MAP = {
unknown: s__(
`SecurityReports|The rating "unknown" indicates that the underlying scanner doesn’t contain or provide a severity rating.`,
`SecurityReports|Sometimes a scanner can't determine a finding's severity. Those findings may still be a potential source of risk though. Please review these manually.`,
),
};
......
......@@ -26124,13 +26124,13 @@ msgstr ""
msgid "SecurityReports|Severity"
msgstr ""
msgid "SecurityReports|Sorry, your filter produced no results"
msgid "SecurityReports|Sometimes a scanner can't determine a finding's severity. Those findings may still be a potential source of risk though. Please review these manually."
msgstr ""
msgid "SecurityReports|Status"
msgid "SecurityReports|Sorry, your filter produced no results"
msgstr ""
msgid "SecurityReports|The rating \"unknown\" indicates that the underlying scanner doesn’t contain or provide a severity rating."
msgid "SecurityReports|Status"
msgstr ""
msgid "SecurityReports|The security dashboard displays the latest security findings for projects you wish to monitor. Add projects to your group to view their vulnerabilities here."
......
import initCheckFormState from '~/pages/projects/merge_requests/edit/check_form_state';
describe('Check form state', () => {
const findInput = () => document.querySelector('#form-input');
let beforeUnloadEvent;
let setDialogContent;
beforeEach(() => {
setFixtures(`
<form class="merge-request-form">
<input type="text" name="test" id="form-input"/>
</form>`);
beforeUnloadEvent = new Event('beforeunload');
jest.spyOn(beforeUnloadEvent, 'preventDefault');
setDialogContent = jest.spyOn(beforeUnloadEvent, 'returnValue', 'set');
initCheckFormState();
});
afterEach(() => {
beforeUnloadEvent.preventDefault.mockRestore();
setDialogContent.mockRestore();
});
it('shows confirmation dialog when there are unsaved changes', () => {
findInput().value = 'value changed';
window.dispatchEvent(beforeUnloadEvent);
expect(beforeUnloadEvent.preventDefault).toHaveBeenCalled();
expect(setDialogContent).toHaveBeenCalledWith('');
});
it('does not show confirmation dialog when there are no unsaved changes', () => {
window.dispatchEvent(beforeUnloadEvent);
expect(beforeUnloadEvent.preventDefault).not.toHaveBeenCalled();
expect(setDialogContent).not.toHaveBeenCalled();
});
});
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