Commit 6bbdba44 authored by Phil Hughes's avatar Phil Hughes

Merge branch '344122-glmodal-in-deprecated-notes' into 'master'

Replace window.confirm in deprecated_modal

See merge request gitlab-org/gitlab!81051
parents f05e078f 89f273b0
/* eslint-disable no-restricted-properties, babel/camelcase, /* eslint-disable no-restricted-properties, babel/camelcase,
no-unused-expressions, default-case, no-unused-expressions, default-case,
consistent-return, no-alert, no-param-reassign, consistent-return, no-param-reassign,
no-shadow, no-useless-escape, no-shadow, no-useless-escape,
class-methods-use-this */ class-methods-use-this */
...@@ -20,6 +20,7 @@ import AjaxCache from '~/lib/utils/ajax_cache'; ...@@ -20,6 +20,7 @@ import AjaxCache from '~/lib/utils/ajax_cache';
import syntaxHighlight from '~/syntax_highlight'; import syntaxHighlight from '~/syntax_highlight';
import CommentTypeDropdown from '~/notes/components/comment_type_dropdown.vue'; import CommentTypeDropdown from '~/notes/components/comment_type_dropdown.vue';
import * as constants from '~/notes/constants'; import * as constants from '~/notes/constants';
import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal';
import Autosave from './autosave'; import Autosave from './autosave';
import loadAwardsHandler from './awards_handler'; import loadAwardsHandler from './awards_handler';
import createFlash from './flash'; import createFlash from './flash';
...@@ -243,7 +244,7 @@ export default class Notes { ...@@ -243,7 +244,7 @@ export default class Notes {
}); });
} }
keydownNoteText(e) { async keydownNoteText(e) {
let discussionNoteForm; let discussionNoteForm;
let editNote; let editNote;
let myLastNote; let myLastNote;
...@@ -276,9 +277,11 @@ export default class Notes { ...@@ -276,9 +277,11 @@ export default class Notes {
discussionNoteForm = $textarea.closest('.js-discussion-note-form'); discussionNoteForm = $textarea.closest('.js-discussion-note-form');
if (discussionNoteForm.length) { if (discussionNoteForm.length) {
if ($textarea.val() !== '') { if ($textarea.val() !== '') {
if (!window.confirm(__('Your comment will be discarded.'))) { const confirmed = await confirmAction(__('Your comment will be discarded.'), {
return; primaryBtnVariant: 'danger',
} primaryBtnText: __('Discard'),
});
if (!confirmed) return;
} }
this.removeDiscussionNoteForm(discussionNoteForm); this.removeDiscussionNoteForm(discussionNoteForm);
return; return;
...@@ -288,9 +291,14 @@ export default class Notes { ...@@ -288,9 +291,14 @@ export default class Notes {
originalText = $textarea.closest('form').data('originalNote'); originalText = $textarea.closest('form').data('originalNote');
newText = $textarea.val(); newText = $textarea.val();
if (originalText !== newText) { if (originalText !== newText) {
if (!window.confirm(__('Are you sure you want to discard this comment?'))) { const confirmed = await confirmAction(
return; __('Are you sure you want to discard this comment?'),
} {
primaryBtnVariant: 'danger',
primaryBtnText: __('Discard'),
},
);
if (!confirmed) return;
} }
return this.removeNoteEditForm(editNote); return this.removeNoteEditForm(editNote);
} }
......
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