diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-20 13:37:47 +0000 |
commit | aee0a117a889461ce8ced6fcf73207fe017f1d99 (patch) | |
tree | 891d9ef189227a8445d83f35c1b0fc99573f4380 /app/assets/javascripts/diffs | |
parent | 8d46af3258650d305f53b819eabf7ab18d22f59e (diff) | |
download | gitlab-ce-aee0a117a889461ce8ced6fcf73207fe017f1d99.tar.gz |
Add latest changes from gitlab-org/gitlab@14-6-stable-eev14.6.0-rc42
Diffstat (limited to 'app/assets/javascripts/diffs')
7 files changed, 13 insertions, 85 deletions
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index f405b82b05b..66d06a3a1b6 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -44,7 +44,6 @@ import { TRACKING_MULTIPLE_FILES_MODE, } from '../constants'; -import { discussionIntersectionObserverHandlerFactory } from '../utils/discussions'; import diffsEventHub from '../event_hub'; import { reviewStatuses } from '../utils/file_reviews'; import { diffsApp } from '../utils/performance'; @@ -87,9 +86,6 @@ export default { ALERT_MERGE_CONFLICT, ALERT_COLLAPSED_FILES, }, - provide: { - discussionObserverHandler: discussionIntersectionObserverHandlerFactory(), - }, props: { endpoint: { type: String, diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue index d09cc064b2c..4e77bf81c1e 100644 --- a/app/assets/javascripts/diffs/components/diff_file.vue +++ b/app/assets/javascripts/diffs/components/diff_file.vue @@ -10,6 +10,7 @@ import { import { escape } from 'lodash'; import { mapActions, mapGetters, mapState } from 'vuex'; import { IdState } from 'vendor/vue-virtual-scroller'; +import DiffContent from 'jh_else_ce/diffs/components/diff_content.vue'; import createFlash from '~/flash'; import { hasDiff } from '~/helpers/diffs_helper'; import { diffViewerErrors } from '~/ide/constants'; @@ -28,7 +29,6 @@ import { import eventHub from '../event_hub'; import { DIFF_FILE, GENERIC_ERROR, CONFLICT_TEXT } from '../i18n'; import { collapsedType, getShortShaFromFile } from '../utils/diff_file'; -import DiffContent from './diff_content.vue'; import DiffFileHeader from './diff_file_header.vue'; export default { diff --git a/app/assets/javascripts/diffs/components/diff_row.vue b/app/assets/javascripts/diffs/components/diff_row.vue index 4e33a02ca0e..4893803a3b6 100644 --- a/app/assets/javascripts/diffs/components/diff_row.vue +++ b/app/assets/javascripts/diffs/components/diff_row.vue @@ -42,6 +42,11 @@ export default { required: false, default: false, }, + coverageLoaded: { + type: Boolean, + required: false, + default: false, + }, inline: { type: Boolean, required: false, @@ -83,14 +88,15 @@ export default { if (!props.inline || !props.line.left) return {}; return props.fileLineCoverage(props.filePath, props.line.left.new_line); }, - (props) => [props.inline, props.filePath, props.line.left?.new_line].join(':'), + (props) => + [props.inline, props.filePath, props.line.left?.new_line, props.coverageLoaded].join(':'), ), coverageStateRight: memoize( (props) => { if (!props.line.right) return {}; return props.fileLineCoverage(props.filePath, props.line.right.new_line); }, - (props) => [props.line.right?.new_line, props.filePath].join(':'), + (props) => [props.line.right?.new_line, props.filePath, props.coverageLoaded].join(':'), ), showCodequalityLeft: memoize( (props) => { diff --git a/app/assets/javascripts/diffs/components/diff_view.vue b/app/assets/javascripts/diffs/components/diff_view.vue index 55c796182ee..8562a1d44e7 100644 --- a/app/assets/javascripts/diffs/components/diff_view.vue +++ b/app/assets/javascripts/diffs/components/diff_view.vue @@ -52,7 +52,7 @@ export default { }, computed: { ...mapGetters('diffs', ['commitId', 'fileLineCoverage']), - ...mapState('diffs', ['codequalityDiff', 'highlightedRow']), + ...mapState('diffs', ['codequalityDiff', 'highlightedRow', 'coverageLoaded']), ...mapState({ selectedCommentPosition: ({ notes }) => notes.selectedCommentPosition, selectedCommentPositionHover: ({ notes }) => notes.selectedCommentPositionHover, @@ -180,6 +180,7 @@ export default { :index="index" :is-highlighted="isHighlighted(line)" :file-line-coverage="fileLineCoverage" + :coverage-loaded="coverageLoaded" @showCommentForm="(code) => singleLineComment(code, line)" @setHighlightedRow="setHighlightedRow" @toggleLineDiscussions=" diff --git a/app/assets/javascripts/diffs/store/modules/diff_state.js b/app/assets/javascripts/diffs/store/modules/diff_state.js index a5b1a577a78..5f66360a040 100644 --- a/app/assets/javascripts/diffs/store/modules/diff_state.js +++ b/app/assets/javascripts/diffs/store/modules/diff_state.js @@ -21,6 +21,7 @@ export default () => ({ startVersion: null, // Null unless a target diff is selected for comparison that is not the "base" diff diffFiles: [], coverageFiles: {}, + coverageLoaded: false, mergeRequestDiffs: [], mergeRequestDiff: null, diffViewType: getViewTypeFromQueryString() || viewTypeFromCookie || defaultViewType, diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index 4a9df0eafcc..fb35114c0a9 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -86,7 +86,7 @@ export default { }, [types.SET_COVERAGE_DATA](state, coverageFiles) { - Object.assign(state, { coverageFiles }); + Object.assign(state, { coverageFiles, coverageLoaded: true }); }, [types.RENDER_FILE](state, file) { diff --git a/app/assets/javascripts/diffs/utils/discussions.js b/app/assets/javascripts/diffs/utils/discussions.js deleted file mode 100644 index c404705d209..00000000000 --- a/app/assets/javascripts/diffs/utils/discussions.js +++ /dev/null @@ -1,76 +0,0 @@ -function normalize(processable) { - const { entry } = processable; - const offset = entry.rootBounds.bottom - entry.boundingClientRect.top; - const direction = - offset < 0 ? 'Up' : 'Down'; /* eslint-disable-line @gitlab/require-i18n-strings */ - - return { - ...processable, - entry: { - time: entry.time, - type: entry.isIntersecting ? 'intersection' : `scroll${direction}`, - }, - }; -} - -function sort({ entry: alpha }, { entry: beta }) { - const diff = alpha.time - beta.time; - let order = 0; - - if (diff < 0) { - order = -1; - } else if (diff > 0) { - order = 1; - } else if (alpha.type === 'intersection' && beta.type === 'scrollUp') { - order = 2; - } else if (alpha.type === 'scrollUp' && beta.type === 'intersection') { - order = -2; - } - - return order; -} - -function filter(entry) { - return entry.type !== 'scrollDown'; -} - -export function discussionIntersectionObserverHandlerFactory() { - let unprocessed = []; - let timer = null; - - return (processable) => { - unprocessed.push(processable); - - if (timer) { - clearTimeout(timer); - } - - timer = setTimeout(() => { - unprocessed - .map(normalize) - .filter(filter) - .sort(sort) - .forEach((discussionObservationContainer) => { - const { - entry: { type }, - currentDiscussion, - isFirstUnresolved, - isDiffsPage, - functions: { setCurrentDiscussionId, getPreviousUnresolvedDiscussionId }, - } = discussionObservationContainer; - - if (type === 'intersection') { - setCurrentDiscussionId(currentDiscussion.id); - } else if (type === 'scrollUp') { - setCurrentDiscussionId( - isFirstUnresolved - ? null - : getPreviousUnresolvedDiscussionId(currentDiscussion.id, isDiffsPage), - ); - } - }); - - unprocessed = []; - }, 0); - }; -} |