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>2020-11-26 15:09:48 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-26 15:09:48 +0300
commit142890d5bbefa7b1e1b30f263f9ad67d9d496d29 (patch)
tree2c4de4059aba586f3204f983f17757dbf1643b6c /app/assets/javascripts/diffs
parentbbede1e22c4dd615042a3e9c0d7e24afc83ca377 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/diffs')
-rw-r--r--app/assets/javascripts/diffs/components/diff_content.vue16
-rw-r--r--app/assets/javascripts/diffs/components/image_diff_overlay.vue45
2 files changed, 37 insertions, 24 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_content.vue b/app/assets/javascripts/diffs/components/diff_content.vue
index 1454728288e..f938ea368d8 100644
--- a/app/assets/javascripts/diffs/components/diff_content.vue
+++ b/app/assets/javascripts/diffs/components/diff_content.vue
@@ -169,12 +169,16 @@ export default {
:a-mode="diffFile.a_mode"
:b-mode="diffFile.b_mode"
>
- <image-diff-overlay
- slot="image-overlay"
- :discussions="imageDiscussions"
- :file-hash="diffFileHash"
- :can-comment="getNoteableData.current_user.can_create_note && !diffFile.brokenSymlink"
- />
+ <template #image-overlay="{ renderedWidth, renderedHeight }">
+ <image-diff-overlay
+ v-if="renderedWidth"
+ :rendered-width="renderedWidth"
+ :rendered-height="renderedHeight"
+ :discussions="imageDiscussions"
+ :file-hash="diffFileHash"
+ :can-comment="getNoteableData.current_user.can_create_note && !diffFile.brokenSymlink"
+ />
+ </template>
<div v-if="showNotesContainer" class="note-container">
<user-avatar-link
v-if="diffFileCommentForm && author"
diff --git a/app/assets/javascripts/diffs/components/image_diff_overlay.vue b/app/assets/javascripts/diffs/components/image_diff_overlay.vue
index 3956c2fab49..6a1e0d8cbd6 100644
--- a/app/assets/javascripts/diffs/components/image_diff_overlay.vue
+++ b/app/assets/javascripts/diffs/components/image_diff_overlay.vue
@@ -4,6 +4,10 @@ import { isArray } from 'lodash';
import imageDiffMixin from 'ee_else_ce/diffs/mixins/image_diff';
import { GlIcon } from '@gitlab/ui';
+function calcPercent(pos, size, renderedSize) {
+ return (((pos / size) * 100) / ((renderedSize / size) * 100)) * 100;
+}
+
export default {
name: 'ImageDiffOverlay',
components: {
@@ -39,6 +43,14 @@ export default {
required: false,
default: true,
},
+ renderedWidth: {
+ type: Number,
+ required: true,
+ },
+ renderedHeight: {
+ type: Number,
+ required: true,
+ },
},
computed: {
...mapGetters('diffs', ['getDiffFileByHash', 'getCommentFormForDiffFile']),
@@ -59,33 +71,33 @@ export default {
},
getPositionForObject(meta) {
const { x, y, width, height } = meta;
- const imageWidth = this.getImageDimensions().width;
- const imageHeight = this.getImageDimensions().height;
- const widthRatio = imageWidth / width;
- const heightRatio = imageHeight / height;
return {
- x: Math.round(x * widthRatio),
- y: Math.round(y * heightRatio),
+ x: (x / width) * 100,
+ y: (y / height) * 100,
};
},
getPosition(discussion) {
const { x, y } = this.getPositionForObject(discussion.position);
return {
- left: `${x}px`,
- top: `${y}px`,
+ left: `${x}%`,
+ top: `${y}%`,
};
},
clickedImage(x, y) {
const { width, height } = this.getImageDimensions();
+ const xPercent = calcPercent(x, width, this.renderedWidth);
+ const yPercent = calcPercent(y, height, this.renderedHeight);
this.openDiffFileCommentForm({
fileHash: this.fileHash,
width,
height,
- x,
- y,
+ x: width * (xPercent / 100),
+ y: height * (yPercent / 100),
+ xPercent,
+ yPercent,
});
},
},
@@ -112,22 +124,19 @@ export default {
type="button"
@click="clickedToggle(discussion)"
>
- <gl-icon v-if="showCommentIcon" name="image-comment-dark" />
+ <gl-icon v-if="showCommentIcon" name="image-comment-dark" :size="24" />
<template v-else>
{{ toggleText(discussion, index) }}
</template>
</button>
<button
- v-if="currentCommentForm"
- :style="{
- left: `${currentCommentForm.x}px`,
- top: `${currentCommentForm.y}px`,
- }"
+ v-if="canComment && currentCommentForm"
+ :style="{ left: `${currentCommentForm.xPercent}%`, top: `${currentCommentForm.yPercent}%` }"
:aria-label="__('Comment form position')"
- class="btn-transparent comment-indicator"
+ class="btn-transparent comment-indicator position-absolute"
type="button"
>
- <gl-icon name="image-comment-dark" />
+ <gl-icon name="image-comment-dark" :size="24" />
</button>
</div>
</template>