diff options
Diffstat (limited to 'app/assets/javascripts/notes')
5 files changed, 49 insertions, 9 deletions
diff --git a/app/assets/javascripts/notes/components/comment_form.vue b/app/assets/javascripts/notes/components/comment_form.vue index 90be5b3e470..7213658bdf2 100644 --- a/app/assets/javascripts/notes/components/comment_form.vue +++ b/app/assets/javascripts/notes/components/comment_form.vue @@ -273,6 +273,13 @@ export default { this.toggleIssueState(); } }, + handleEnter() { + if (this.hasDrafts) { + this.handleSaveDraft(); + } else { + this.handleSave(); + } + }, toggleIssueState() { if (this.isIssue) { // We want to invoke the close/reopen logic in the issue header @@ -395,8 +402,8 @@ export default { :aria-label="$options.i18n.comment" :placeholder="$options.i18n.bodyPlaceholder" @keydown.up="editCurrentUserLastNote()" - @keydown.meta.enter="handleSave()" - @keydown.ctrl.enter="handleSave()" + @keydown.meta.enter="handleEnter()" + @keydown.ctrl.enter="handleEnter()" ></textarea> </template> </markdown-field> diff --git a/app/assets/javascripts/notes/components/note_actions.vue b/app/assets/javascripts/notes/components/note_actions.vue index 0cc818c6d0e..0f72b4f2dba 100644 --- a/app/assets/javascripts/notes/components/note_actions.vue +++ b/app/assets/javascripts/notes/components/note_actions.vue @@ -304,7 +304,7 @@ export default { v-else v-gl-tooltip :class="{ 'js-user-authored': isAuthoredByCurrentUser }" - class="note-action-button note-emoji-button add-reaction-button btn-icon js-add-award js-note-emoji" + class="note-action-button note-emoji-button add-reaction-button js-add-award js-note-emoji" category="tertiary" variant="default" :title="$options.i18n.addReactionLabel" diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue index 34dd21dcbac..1af9e4be373 100644 --- a/app/assets/javascripts/notes/components/noteable_discussion.vue +++ b/app/assets/javascripts/notes/components/noteable_discussion.vue @@ -135,6 +135,13 @@ export default { resolveWithIssuePath() { return !this.discussionResolved ? this.discussion.resolve_with_issue_path : ''; }, + canShowReplyActions() { + if (this.shouldRenderDiffs && !this.discussion.diff_file.diff_refs) { + return false; + } + + return true; + }, }, created() { eventHub.$on('startReplying', this.onStartReplying); @@ -263,7 +270,7 @@ export default { :draft="draftForDiscussion(discussion.reply_id)" /> <div - v-else-if="showReplies" + v-else-if="canShowReplyActions && showReplies" :class="{ 'is-replying': isReplying }" class="discussion-reply-holder gl-border-t-0! clearfix" > diff --git a/app/assets/javascripts/notes/mixins/diff_line_note_form.js b/app/assets/javascripts/notes/mixins/diff_line_note_form.js index 76342e07c04..7b9c0959464 100644 --- a/app/assets/javascripts/notes/mixins/diff_line_note_form.js +++ b/app/assets/javascripts/notes/mixins/diff_line_note_form.js @@ -1,7 +1,7 @@ import { mapActions, mapGetters, mapState } from 'vuex'; import { getDraftReplyFormData, getDraftFormData } from '~/batch_comments/utils'; import { TEXT_DIFF_POSITION_TYPE, IMAGE_DIFF_POSITION_TYPE } from '~/diffs/constants'; -import { deprecatedCreateFlash as createFlash } from '~/flash'; +import createFlash from '~/flash'; import { clearDraft } from '~/lib/utils/autosave'; import { s__ } from '~/locale'; import { formatLineRange } from '~/notes/components/multiline_comment_utils'; @@ -42,7 +42,9 @@ export default { this.handleClearForm(this.discussion.line_code); }) .catch(() => { - createFlash(s__('MergeRequests|An error occurred while saving the draft comment.')); + createFlash({ + message: s__('MergeRequests|An error occurred while saving the draft comment.'), + }); }); }, addToReview(note) { @@ -80,7 +82,9 @@ export default { } }) .catch(() => { - createFlash(s__('MergeRequests|An error occurred while saving the draft comment.')); + createFlash({ + message: s__('MergeRequests|An error occurred while saving the draft comment.'), + }); }); }, handleClearForm(lineCode) { diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index bdb85360be8..086e9122c60 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -12,6 +12,7 @@ import loadAwardsHandler from '../../awards_handler'; import { deprecatedCreateFlash as Flash } from '../../flash'; import { isInViewport, scrollToElement, isInMRPage } from '../../lib/utils/common_utils'; import Poll from '../../lib/utils/poll'; +import { create } from '../../lib/utils/recurrence'; import { mergeUrlParams } from '../../lib/utils/url_utility'; import sidebarTimeTrackingEventHub from '../../sidebar/event_hub'; import TaskList from '../../task_list'; @@ -21,6 +22,7 @@ import eventHub from '../event_hub'; import * as types from './mutation_types'; import * as utils from './utils'; +const NOTES_POLLING_INTERVAL = 6000; let eTagPoll; export const updateLockedAttribute = ({ commit, getters }, { locked, fullPath }) => { @@ -469,6 +471,19 @@ const getFetchDataParams = (state) => { }; export const poll = ({ commit, state, getters, dispatch }) => { + const notePollOccurrenceTracking = create(); + let flashContainer; + + notePollOccurrenceTracking.handle(1, () => { + // Since polling halts internally after 1 failure, we manually try one more time + setTimeout(() => eTagPoll.restart(), NOTES_POLLING_INTERVAL); + }); + notePollOccurrenceTracking.handle(2, () => { + // On the second failure in a row, show the alert and try one more time (hoping to succeed and clear the error) + flashContainer = Flash(__('Something went wrong while fetching latest comments.')); + setTimeout(() => eTagPoll.restart(), NOTES_POLLING_INTERVAL); + }); + eTagPoll = new Poll({ resource: { poll: () => { @@ -477,8 +492,15 @@ export const poll = ({ commit, state, getters, dispatch }) => { }, }, method: 'poll', - successCallback: ({ data }) => pollSuccessCallBack(data, commit, state, getters, dispatch), - errorCallback: () => Flash(__('Something went wrong while fetching latest comments.')), + successCallback: ({ data }) => { + pollSuccessCallBack(data, commit, state, getters, dispatch); + + if (notePollOccurrenceTracking.count) { + notePollOccurrenceTracking.reset(); + } + flashContainer?.close(); + }, + errorCallback: () => notePollOccurrenceTracking.occur(), }); if (!Visibility.hidden()) { |