diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/assets/javascripts/diffs/store | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/assets/javascripts/diffs/store')
6 files changed, 52 insertions, 37 deletions
diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js index e95e9ac3ee4..4b2dc2d45df 100644 --- a/app/assets/javascripts/diffs/store/actions.js +++ b/app/assets/javascripts/diffs/store/actions.js @@ -1,25 +1,14 @@ -import Vue from 'vue'; import Cookies from 'js-cookie'; -import Poll from '~/lib/utils/poll'; -import axios from '~/lib/utils/axios_utils'; -import httpStatusCodes from '~/lib/utils/http_status'; +import Vue from 'vue'; import { deprecatedCreateFlash as createFlash } from '~/flash'; -import { __, s__ } from '~/locale'; +import { diffViewerModes } from '~/ide/constants'; +import axios from '~/lib/utils/axios_utils'; import { handleLocationHash, historyPushState, scrollToElement } from '~/lib/utils/common_utils'; +import httpStatusCodes from '~/lib/utils/http_status'; +import Poll from '~/lib/utils/poll'; import { mergeUrlParams, getLocationHash } from '~/lib/utils/url_utility'; -import TreeWorker from '../workers/tree_worker'; +import { __, s__ } from '~/locale'; import notesEventHub from '../../notes/event_hub'; -import eventHub from '../event_hub'; -import { - getDiffPositionByLineCode, - getNoteFormData, - convertExpandLines, - idleCallback, - allDiscussionWrappersExpanded, - prepareDiffData, - prepareLineForRenamedFile, -} from './utils'; -import * as types from './mutation_types'; import { PARALLEL_DIFF_VIEW_TYPE, INLINE_DIFF_VIEW_TYPE, @@ -48,10 +37,21 @@ import { DIFF_VIEW_ALL_FILES, DIFF_FILE_BY_FILE_COOKIE_NAME, } from '../constants'; -import { diffViewerModes } from '~/ide/constants'; +import eventHub from '../event_hub'; import { isCollapsed } from '../utils/diff_file'; -import { getDerivedMergeRequestInformation } from '../utils/merge_request'; import { markFileReview, setReviewsForMergeRequest } from '../utils/file_reviews'; +import { getDerivedMergeRequestInformation } from '../utils/merge_request'; +import TreeWorker from '../workers/tree_worker'; +import * as types from './mutation_types'; +import { + getDiffPositionByLineCode, + getNoteFormData, + convertExpandLines, + idleCallback, + allDiscussionWrappersExpanded, + prepareDiffData, + prepareLineForRenamedFile, +} from './utils'; export const setBaseConfig = ({ commit }, options) => { const { @@ -749,12 +749,10 @@ export const setFileByFile = ({ commit }, { fileByFile }) => { ); }; -export function reviewFile({ commit, state, getters }, { file, reviewed = true }) { +export function reviewFile({ commit, state }, { file, reviewed = true }) { const { mrPath } = getDerivedMergeRequestInformation({ endpoint: file.load_collapsed_diff_url }); - const reviews = setReviewsForMergeRequest( - mrPath, - markFileReview(getters.fileReviews(state), file, reviewed), - ); + const reviews = markFileReview(state.mrReviews, file, reviewed); + setReviewsForMergeRequest(mrPath, reviews); commit(types.SET_MR_FILE_REVIEWS, reviews); } diff --git a/app/assets/javascripts/diffs/store/getters.js b/app/assets/javascripts/diffs/store/getters.js index a167b6d4694..1fc2a684e95 100644 --- a/app/assets/javascripts/diffs/store/getters.js +++ b/app/assets/javascripts/diffs/store/getters.js @@ -1,11 +1,11 @@ import { __, n__ } from '~/locale'; -import { parallelizeDiffLines } from './utils'; -import { isFileReviewed } from '../utils/file_reviews'; import { PARALLEL_DIFF_VIEW_TYPE, INLINE_DIFF_VIEW_TYPE, INLINE_DIFF_LINES_KEY, } from '../constants'; +import { computeSuggestionCommitMessage } from '../utils/suggestions'; +import { parallelizeDiffLines } from './utils'; export * from './getters_versions_dropdowns'; @@ -156,6 +156,17 @@ export const diffLines = (state) => (file, unifiedDiffComponents) => { ); }; -export function fileReviews(state) { - return state.diffFiles.map((file) => isFileReviewed(state.mrReviews, file)); +export function suggestionCommitMessage(state) { + return (values = {}) => + computeSuggestionCommitMessage({ + message: state.defaultSuggestionCommitMessage, + values: { + branch_name: state.branchName, + project_path: state.projectPath, + project_name: state.projectName, + username: state.username, + user_full_name: state.userFullName, + ...values, + }, + }); } diff --git a/app/assets/javascripts/diffs/store/getters_versions_dropdowns.js b/app/assets/javascripts/diffs/store/getters_versions_dropdowns.js index 3f33b0c900e..01811e60caa 100644 --- a/app/assets/javascripts/diffs/store/getters_versions_dropdowns.js +++ b/app/assets/javascripts/diffs/store/getters_versions_dropdowns.js @@ -1,5 +1,5 @@ -import { __, n__, sprintf } from '~/locale'; import { getParameterByName, parseBoolean } from '~/lib/utils/common_utils'; +import { __, n__, sprintf } from '~/locale'; import { DIFF_COMPARE_BASE_VERSION_INDEX, DIFF_COMPARE_HEAD_VERSION_INDEX } from '../constants'; export const selectedTargetIndex = (state) => diff --git a/app/assets/javascripts/diffs/store/modules/diff_state.js b/app/assets/javascripts/diffs/store/modules/diff_state.js index aa89c74cef0..f93435363ec 100644 --- a/app/assets/javascripts/diffs/store/modules/diff_state.js +++ b/app/assets/javascripts/diffs/store/modules/diff_state.js @@ -47,4 +47,5 @@ export default () => ({ showSuggestPopover: true, defaultSuggestionCommitMessage: '', mrReviews: {}, + latestDiff: true, }); diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index 06f0f2c3dfb..d06793c05af 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -1,6 +1,12 @@ import Vue from 'vue'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { + DIFF_FILE_MANUAL_COLLAPSE, + DIFF_FILE_AUTOMATIC_COLLAPSE, + INLINE_DIFF_LINES_KEY, +} from '../constants'; +import * as types from './mutation_types'; +import { findDiffFile, addLineReferences, removeMatchLine, @@ -9,12 +15,6 @@ import { isDiscussionApplicableToLine, updateLineInFile, } from './utils'; -import { - DIFF_FILE_MANUAL_COLLAPSE, - DIFF_FILE_AUTOMATIC_COLLAPSE, - INLINE_DIFF_LINES_KEY, -} from '../constants'; -import * as types from './mutation_types'; function updateDiffFilesInState(state, files) { return Object.assign(state, { diffFiles: files }); @@ -159,7 +159,12 @@ export default { [types.SET_LINE_DISCUSSIONS_FOR_FILE](state, { discussion, diffPositionByLineCode, hash }) { const { latestDiff } = state; - const discussionLineCodes = [discussion.line_code, ...(discussion.line_codes || [])]; + const originalStartLineCode = discussion.original_position?.line_range?.start?.line_code; + const discussionLineCodes = [ + discussion.line_code, + originalStartLineCode, + ...(discussion.line_codes || []), + ]; const fileHash = discussion.diff_file.file_hash; const lineCheck = (line) => discussionLineCodes.some( diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js index c52da558be2..87b4f33c216 100644 --- a/app/assets/javascripts/diffs/store/utils.js +++ b/app/assets/javascripts/diffs/store/utils.js @@ -1,6 +1,6 @@ import { property, isEqual } from 'lodash'; -import { truncatePathMiddleToLength } from '~/lib/utils/text_utility'; import { diffModes, diffViewerModes } from '~/ide/constants'; +import { truncatePathMiddleToLength } from '~/lib/utils/text_utility'; import { LINE_POSITION_LEFT, LINE_POSITION_RIGHT, |