diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-20 13:43:29 +0300 |
commit | 3b1af5cc7ed2666ff18b718ce5d30fa5a2756674 (patch) | |
tree | 3bc4a40e0ee51ec27eabf917c537033c0c5b14d4 /app/assets/javascripts/batch_comments/stores | |
parent | 9bba14be3f2c211bf79e15769cd9b77bc73a13bc (diff) |
Add latest changes from gitlab-org/gitlab@16-1-stable-eev16.1.0-rc42
Diffstat (limited to 'app/assets/javascripts/batch_comments/stores')
5 files changed, 17 insertions, 3 deletions
diff --git a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js index f6eae7c0c83..45e7256a734 100644 --- a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js +++ b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/actions.js @@ -2,6 +2,7 @@ import { isEmpty } from 'lodash'; import { createAlert } from '~/alert'; import { scrollToElement } from '~/lib/utils/common_utils'; import { __ } from '~/locale'; +import { FILE_DIFF_POSITION_TYPE } from '~/diffs/constants'; import { CHANGES_TAB, DISCUSSION_TAB, SHOW_TAB } from '../../../constants'; import service from '../../../services/drafts_service'; import * as types from './mutation_types'; @@ -23,12 +24,17 @@ export const addDraftToDiscussion = ({ commit }, { endpoint, data }) => }); }); -export const createNewDraft = ({ commit }, { endpoint, data }) => +export const createNewDraft = ({ commit, dispatch }, { endpoint, data }) => service .createNewDraft(endpoint, data) .then((res) => res.data) .then((res) => { commit(types.ADD_NEW_DRAFT, res); + + if (res.position?.position_type === FILE_DIFF_POSITION_TYPE) { + dispatch('diffs/addDraftToFile', { filePath: res.file_path, draft: res }, { root: true }); + } + return res; }) .catch(() => { @@ -56,7 +62,9 @@ export const fetchDrafts = ({ commit, getters, state, dispatch }) => .then((data) => commit(types.SET_BATCH_COMMENTS_DRAFTS, data)) .then(() => { state.drafts.forEach((draft) => { - if (!draft.line_code) { + if (draft.position?.position_type === FILE_DIFF_POSITION_TYPE) { + dispatch('diffs/addDraftToFile', { filePath: draft.file_path, draft }, { root: true }); + } else if (!draft.line_code) { dispatch('convertToDiscussion', draft.discussion_id, { root: true }); } }); diff --git a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/getters.js b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/getters.js index 75e4ae63c18..28b9100c5f3 100644 --- a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/getters.js +++ b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/getters.js @@ -71,7 +71,7 @@ export const draftsForLine = (state, getters) => (diffFileSha, line, side = null const showDraftsForThisSide = showDraftOnSide(line, side); if (showDraftsForThisSide && draftsForFile?.[key]) { - return draftsForFile[key]; + return draftsForFile[key].filter((d) => d.position.position_type === 'text'); } return []; }; diff --git a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutation_types.js b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutation_types.js index 67bcc53ac7d..2000ee69bad 100644 --- a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutation_types.js +++ b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutation_types.js @@ -16,3 +16,5 @@ export const RECEIVE_DRAFT_UPDATE_SUCCESS = 'RECEIVE_DRAFT_UPDATE_SUCCESS'; export const TOGGLE_RESOLVE_DISCUSSION = 'TOGGLE_RESOLVE_DISCUSSION'; export const CLEAR_DRAFTS = 'CLEAR_DRAFTS'; + +export const SET_REVIEW_BAR_RENDERED = 'SET_REVIEW_BAR_RENDERED'; diff --git a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutations.js b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutations.js index 7961cf134be..453dc861702 100644 --- a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutations.js +++ b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/mutations.js @@ -68,4 +68,7 @@ export default { [types.CLEAR_DRAFTS](state) { state.drafts = []; }, + [types.SET_REVIEW_BAR_RENDERED](state) { + state.reviewBarRendered = true; + }, }; diff --git a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/state.js b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/state.js index 10033ba17f9..1efc00059d0 100644 --- a/app/assets/javascripts/batch_comments/stores/modules/batch_comments/state.js +++ b/app/assets/javascripts/batch_comments/stores/modules/batch_comments/state.js @@ -5,4 +5,5 @@ export default () => ({ isPublishing: false, currentlyPublishingDrafts: [], shouldAnimateReviewButton: false, + reviewBarRendered: false, }); |