Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
35faecb0
Commit
35faecb0
authored
Nov 06, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restored width & height properties
parent
f7df9ddb
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
9 deletions
+74
-9
app/assets/javascripts/diffs/components/diff_content.vue
app/assets/javascripts/diffs/components/diff_content.vue
+2
-0
app/assets/javascripts/diffs/components/image_diff_overlay.vue
...ssets/javascripts/diffs/components/image_diff_overlay.vue
+26
-2
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+2
-0
lib/gitlab/diff/formatters/image_formatter.rb
lib/gitlab/diff/formatters/image_formatter.rb
+1
-1
spec/javascripts/diffs/components/diff_content_spec.js
spec/javascripts/diffs/components/diff_content_spec.js
+9
-1
spec/javascripts/diffs/components/image_diff_overlay_spec.js
spec/javascripts/diffs/components/image_diff_overlay_spec.js
+30
-5
spec/javascripts/diffs/mock_data/diff_discussions.js
spec/javascripts/diffs/mock_data/diff_discussions.js
+4
-0
No files found.
app/assets/javascripts/diffs/components/diff_content.vue
View file @
35faecb0
...
@@ -57,6 +57,8 @@ export default {
...
@@ -57,6 +57,8 @@ export default {
positionType
:
IMAGE_DIFF_POSITION_TYPE
,
positionType
:
IMAGE_DIFF_POSITION_TYPE
,
x
:
this
.
diffFileCommentForm
.
x
,
x
:
this
.
diffFileCommentForm
.
x
,
y
:
this
.
diffFileCommentForm
.
y
,
y
:
this
.
diffFileCommentForm
.
y
,
width
:
this
.
diffFileCommentForm
.
width
,
height
:
this
.
diffFileCommentForm
.
height
,
},
},
});
});
},
},
...
...
app/assets/javascripts/diffs/components/image_diff_overlay.vue
View file @
35faecb0
...
@@ -50,15 +50,39 @@ export default {
...
@@ -50,15 +50,39 @@ export default {
methods
:
{
methods
:
{
...
mapActions
([
'
toggleDiscussion
'
]),
...
mapActions
([
'
toggleDiscussion
'
]),
...
mapActions
(
'
diffs
'
,
[
'
openDiffFileCommentForm
'
]),
...
mapActions
(
'
diffs
'
,
[
'
openDiffFileCommentForm
'
]),
getImageDimensions
()
{
return
{
width
:
this
.
$parent
.
width
,
height
:
this
.
$parent
.
height
,
};
},
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
),
};
},
getPosition
(
discussion
)
{
getPosition
(
discussion
)
{
const
{
x
,
y
}
=
this
.
getPositionForObject
(
discussion
.
position
);
return
{
return
{
left
:
`
${
discussion
.
position
.
x
}
px`
,
left
:
`
${
x
}
px`
,
top
:
`
${
discussion
.
position
.
y
}
px`
,
top
:
`
${
y
}
px`
,
};
};
},
},
clickedImage
(
x
,
y
)
{
clickedImage
(
x
,
y
)
{
const
{
width
,
height
}
=
this
.
getImageDimensions
();
this
.
openDiffFileCommentForm
({
this
.
openDiffFileCommentForm
({
fileHash
:
this
.
fileHash
,
fileHash
:
this
.
fileHash
,
width
,
height
,
x
,
x
,
y
,
y
,
});
});
...
...
app/assets/javascripts/diffs/store/utils.js
View file @
35faecb0
...
@@ -49,6 +49,8 @@ export function getFormData(params) {
...
@@ -49,6 +49,8 @@ export function getFormData(params) {
new_line
:
noteTargetLine
?
noteTargetLine
.
newLine
:
null
,
new_line
:
noteTargetLine
?
noteTargetLine
.
newLine
:
null
,
x
:
params
.
x
,
x
:
params
.
x
,
y
:
params
.
y
,
y
:
params
.
y
,
width
:
params
.
width
,
height
:
params
.
height
,
});
});
const
postData
=
{
const
postData
=
{
...
...
lib/gitlab/diff/formatters/image_formatter.rb
View file @
35faecb0
...
@@ -21,7 +21,7 @@ module Gitlab
...
@@ -21,7 +21,7 @@ module Gitlab
end
end
def
complete?
def
complete?
x
&&
y
x
&&
y
&&
width
&&
height
end
end
def
to_h
def
to_h
...
...
spec/javascripts/diffs/components/diff_content_spec.js
View file @
35faecb0
...
@@ -62,7 +62,13 @@ describe('DiffContent', () => {
...
@@ -62,7 +62,13 @@ describe('DiffContent', () => {
vm
.
diffFile
.
oldSha
=
'
ABC
'
;
vm
.
diffFile
.
oldSha
=
'
ABC
'
;
vm
.
diffFile
.
viewPath
=
''
;
vm
.
diffFile
.
viewPath
=
''
;
vm
.
diffFile
.
discussions
=
[{
...
discussionsMockData
}];
vm
.
diffFile
.
discussions
=
[{
...
discussionsMockData
}];
vm
.
$store
.
state
.
diffs
.
commentForms
.
push
({
fileHash
:
vm
.
diffFile
.
fileHash
,
x
:
10
,
y
:
20
});
vm
.
$store
.
state
.
diffs
.
commentForms
.
push
({
fileHash
:
vm
.
diffFile
.
fileHash
,
x
:
10
,
y
:
20
,
width
:
100
,
height
:
200
,
});
vm
.
$nextTick
(
done
);
vm
.
$nextTick
(
done
);
});
});
...
@@ -96,6 +102,8 @@ describe('DiffContent', () => {
...
@@ -96,6 +102,8 @@ describe('DiffContent', () => {
positionType
:
'
image
'
,
positionType
:
'
image
'
,
x
:
10
,
x
:
10
,
y
:
20
,
y
:
20
,
width
:
100
,
height
:
200
,
},
},
});
});
});
});
...
...
spec/javascripts/diffs/components/image_diff_overlay_spec.js
View file @
35faecb0
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
ImageDiffOverlay
from
'
~/diffs/components/image_diff_overlay.vue
'
;
import
ImageDiffOverlay
from
'
~/diffs/components/image_diff_overlay.vue
'
;
import
{
createStore
}
from
'
~/mr_notes/stores
'
;
import
{
createStore
}
from
'
~/mr_notes/stores
'
;
import
{
mount
ComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
create
ComponentWithStore
}
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
imageDiffDiscussions
}
from
'
../mock_data/diff_discussions
'
;
import
{
imageDiffDiscussions
}
from
'
../mock_data/diff_discussions
'
;
describe
(
'
Diffs image diff overlay component
'
,
()
=>
{
describe
(
'
Diffs image diff overlay component
'
,
()
=>
{
const
dimensions
=
{
width
:
100
,
height
:
200
,
};
let
Component
;
let
Component
;
let
vm
;
let
vm
;
...
@@ -13,9 +17,10 @@ describe('Diffs image diff overlay component', () => {
...
@@ -13,9 +17,10 @@ describe('Diffs image diff overlay component', () => {
extendStore
(
store
);
extendStore
(
store
);
vm
=
mountComponentWithStore
(
Component
,
{
vm
=
createComponentWithStore
(
Component
,
store
,
{
store
,
discussions
:
[...
imageDiffDiscussions
],
props
:
{
discussions
:
[...
imageDiffDiscussions
],
fileHash
:
'
ABC
'
,
...
props
},
fileHash
:
'
ABC
'
,
...
props
,
});
});
}
}
...
@@ -29,12 +34,16 @@ describe('Diffs image diff overlay component', () => {
...
@@ -29,12 +34,16 @@ describe('Diffs image diff overlay component', () => {
it
(
'
renders comment badges
'
,
()
=>
{
it
(
'
renders comment badges
'
,
()
=>
{
createComponent
();
createComponent
();
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
).
length
).
toBe
(
2
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
).
length
).
toBe
(
2
);
});
});
it
(
'
renders index of discussion in badge
'
,
()
=>
{
it
(
'
renders index of discussion in badge
'
,
()
=>
{
createComponent
();
createComponent
();
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
)[
0
].
textContent
.
trim
()).
toBe
(
'
1
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
)[
0
].
textContent
.
trim
()).
toBe
(
'
1
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
)[
1
].
textContent
.
trim
()).
toBe
(
'
2
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
)[
1
].
textContent
.
trim
()).
toBe
(
'
2
'
);
...
@@ -42,12 +51,16 @@ describe('Diffs image diff overlay component', () => {
...
@@ -42,12 +51,16 @@ describe('Diffs image diff overlay component', () => {
it
(
'
renders icon when showCommentIcon is true
'
,
()
=>
{
it
(
'
renders icon when showCommentIcon is true
'
,
()
=>
{
createComponent
({
showCommentIcon
:
true
});
createComponent
({
showCommentIcon
:
true
});
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-image-badge svg
'
)).
not
.
toBe
(
null
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-image-badge svg
'
)).
not
.
toBe
(
null
);
});
});
it
(
'
sets badge comment positions
'
,
()
=>
{
it
(
'
sets badge comment positions
'
,
()
=>
{
createComponent
();
createComponent
();
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
)[
0
].
style
.
left
).
toBe
(
'
10px
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
)[
0
].
style
.
left
).
toBe
(
'
10px
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
)[
0
].
style
.
top
).
toBe
(
'
10px
'
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
)[
0
].
style
.
top
).
toBe
(
'
10px
'
);
...
@@ -62,12 +75,16 @@ describe('Diffs image diff overlay component', () => {
...
@@ -62,12 +75,16 @@ describe('Diffs image diff overlay component', () => {
...
imageDiffDiscussions
[
0
],
...
imageDiffDiscussions
[
0
],
},
},
});
});
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
).
length
).
toBe
(
1
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-image-badge
'
).
length
).
toBe
(
1
);
});
});
it
(
'
dispatches openDiffFileCommentForm when clcking overlay
'
,
()
=>
{
it
(
'
dispatches openDiffFileCommentForm when cl
i
cking overlay
'
,
()
=>
{
createComponent
({
canComment
:
true
});
createComponent
({
canComment
:
true
});
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
spyOn
(
vm
.
$store
,
'
dispatch
'
).
and
.
stub
();
spyOn
(
vm
.
$store
,
'
dispatch
'
).
and
.
stub
();
...
@@ -77,18 +94,24 @@ describe('Diffs image diff overlay component', () => {
...
@@ -77,18 +94,24 @@ describe('Diffs image diff overlay component', () => {
fileHash
:
'
ABC
'
,
fileHash
:
'
ABC
'
,
x
:
0
,
x
:
0
,
y
:
0
,
y
:
0
,
width
:
100
,
height
:
200
,
});
});
});
});
describe
(
'
toggle discussion
'
,
()
=>
{
describe
(
'
toggle discussion
'
,
()
=>
{
it
(
'
disables buttons when shouldToggleDiscussion is false
'
,
()
=>
{
it
(
'
disables buttons when shouldToggleDiscussion is false
'
,
()
=>
{
createComponent
({
shouldToggleDiscussion
:
false
});
createComponent
({
shouldToggleDiscussion
:
false
});
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
expect
(
vm
.
$el
.
querySelector
(
'
.js-image-badge
'
).
hasAttribute
(
'
disabled
'
)).
toBe
(
true
);
expect
(
vm
.
$el
.
querySelector
(
'
.js-image-badge
'
).
hasAttribute
(
'
disabled
'
)).
toBe
(
true
);
});
});
it
(
'
dispatches toggleDiscussion when clicking image badge
'
,
()
=>
{
it
(
'
dispatches toggleDiscussion when clicking image badge
'
,
()
=>
{
createComponent
();
createComponent
();
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
spyOn
(
vm
.
$store
,
'
dispatch
'
).
and
.
stub
();
spyOn
(
vm
.
$store
,
'
dispatch
'
).
and
.
stub
();
...
@@ -107,6 +130,8 @@ describe('Diffs image diff overlay component', () => {
...
@@ -107,6 +130,8 @@ describe('Diffs image diff overlay component', () => {
y
:
10
,
y
:
10
,
});
});
});
});
spyOn
(
vm
,
'
getImageDimensions
'
).
and
.
returnValue
(
dimensions
);
vm
.
$mount
();
});
});
it
(
'
renders comment form badge
'
,
()
=>
{
it
(
'
renders comment form badge
'
,
()
=>
{
...
...
spec/javascripts/diffs/mock_data/diff_discussions.js
View file @
35faecb0
...
@@ -499,6 +499,8 @@ export const imageDiffDiscussions = [
...
@@ -499,6 +499,8 @@ export const imageDiffDiscussions = [
position
:
{
position
:
{
x
:
10
,
x
:
10
,
y
:
10
,
y
:
10
,
width
:
100
,
height
:
200
,
},
},
},
},
{
{
...
@@ -506,6 +508,8 @@ export const imageDiffDiscussions = [
...
@@ -506,6 +508,8 @@ export const imageDiffDiscussions = [
position
:
{
position
:
{
x
:
5
,
x
:
5
,
y
:
5
,
y
:
5
,
width
:
100
,
height
:
200
,
},
},
},
},
];
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment