Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 13:43:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-20 13:43:29 +0300
commit3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch)
tree3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /app/assets/javascripts/deprecated_notes.js
parent9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff)
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'app/assets/javascripts/deprecated_notes.js')
-rw-r--r--app/assets/javascripts/deprecated_notes.js43
1 files changed, 28 insertions, 15 deletions
diff --git a/app/assets/javascripts/deprecated_notes.js b/app/assets/javascripts/deprecated_notes.js
index a46a8d4affa..08177cd0eac 100644
--- a/app/assets/javascripts/deprecated_notes.js
+++ b/app/assets/javascripts/deprecated_notes.js
@@ -25,6 +25,7 @@ import syntaxHighlight from '~/syntax_highlight';
import CommentTypeDropdown from '~/notes/components/comment_type_dropdown.vue';
import * as constants from '~/notes/constants';
import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal';
+import { COMMENT_FORM, UPDATE_COMMENT_FORM } from '~/notes/i18n';
import Autosave from './autosave';
import loadAwardsHandler from './awards_handler';
import { defaultAutocompleteConfig } from './gfm_auto_complete';
@@ -687,26 +688,36 @@ export default class Notes {
return this.renderNote(note);
}
- addNoteError($form) {
+ addNoteError(error, $form) {
let formParentTimeline;
if ($form.hasClass('js-main-target-form')) {
formParentTimeline = $form.parents('.timeline');
} else if ($form.hasClass('js-discussion-note-form')) {
formParentTimeline = $form.closest('.discussion-notes').find('.notes');
}
+
+ const serverErrorMessage = error?.response?.data?.errors;
+
+ const alertMessage = serverErrorMessage
+ ? sprintf(COMMENT_FORM.error, { reason: serverErrorMessage.toLowerCase() }, false)
+ : COMMENT_FORM.GENERIC_UNSUBMITTABLE_NETWORK;
+
return this.addAlert({
- message: __(
- 'Your comment could not be submitted! Please check your network connection and try again.',
- ),
+ message: alertMessage,
parent: formParentTimeline.get(0),
});
}
- updateNoteError() {
- createAlert({
- message: __(
- 'Your comment could not be updated! Please check your network connection and try again.',
- ),
+ updateNoteError(error, $editingNote) {
+ const serverErrorMessage = error?.response?.data?.errors;
+
+ const alertMessage = serverErrorMessage
+ ? sprintf(UPDATE_COMMENT_FORM.error, { reason: serverErrorMessage }, false)
+ : UPDATE_COMMENT_FORM.defaultError;
+
+ return this.addAlert({
+ message: alertMessage,
+ parent: $editingNote.get(0),
});
}
@@ -788,6 +799,8 @@ export default class Notes {
const $note = $target.closest('.note');
const $currentlyEditing = $('.note.is-editing:visible');
+ this.clearAlertWrapper();
+
if ($currentlyEditing.length) {
const isEditAllowed = this.checkContentToAllowEditing($currentlyEditing);
@@ -1777,7 +1790,7 @@ export default class Notes {
$form.trigger('ajax:success', [note]);
})
- .catch(() => {
+ .catch((error) => {
// Submission failed, remove placeholder note and show Flash error message
$notesContainer.find(`#${noteUniqueId}`).remove();
$submitBtn.prop('disabled', false);
@@ -1806,7 +1819,7 @@ export default class Notes {
$form.find('.js-note-text').val(formContentOriginal);
this.reenableTargetFormSubmitButton(e);
- this.addNoteError($form);
+ this.addNoteError(error, $form);
});
}
@@ -1854,14 +1867,14 @@ export default class Notes {
// Submission successful! render final note element
this.updateNote(data, $editingNote);
})
- .catch(() => {
+ .catch((error) => {
+ $editingNote.addClass('is-editing fade-in-full').removeClass('being-posted fade-in-half');
// Submission failed, revert back to original note
- $noteBodyText.html(escape(cachedNoteBodyText));
- $editingNote.removeClass('being-posted fade-in');
+ $noteBodyText.html(cachedNoteBodyText);
$editingNote.find('.gl-spinner').remove();
// Show Flash message about failure
- this.updateNoteError();
+ this.updateNoteError(error, $editingNote);
});
return $closeBtn.text($closeBtn.data('originalText'));