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
a10c3bcb
Commit
a10c3bcb
authored
Dec 24, 2019
by
Kerri Miller
Committed by
Kushal Pandya
Dec 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decorate rich_text with word-diff highlights
parent
2e3c2345
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
12 deletions
+53
-12
app/assets/javascripts/vue_shared/components/lib/utils/diff_utils.js
...javascripts/vue_shared/components/lib/utils/diff_utils.js
+1
-0
app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_row.vue
...ts/vue_shared/components/markdown/suggestion_diff_row.vue
+2
-1
app/serializers/suggestion_entity.rb
app/serializers/suggestion_entity.rb
+3
-1
changelogs/unreleased/26543-add-word-diff-highlight-to-rich-text.yml
...unreleased/26543-add-word-diff-highlight-to-rich-text.yml
+5
-0
spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js
...ue_shared/components/markdown/suggestion_diff_row_spec.js
+42
-10
No files found.
app/assets/javascripts/vue_shared/components/lib/utils/diff_utils.js
View file @
a10c3bcb
...
...
@@ -12,6 +12,7 @@ function cleanSuggestionLine(line = {}) {
return
{
...
line
,
text
:
trimFirstCharOfLineContent
(
line
.
text
),
rich_text
:
trimFirstCharOfLineContent
(
line
.
rich_text
),
};
}
...
...
app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_row.vue
View file @
a10c3bcb
...
...
@@ -24,7 +24,8 @@ export default {
{{
line
.
new_line
}}
</td>
<td
class=
"line_content"
:class=
"lineType"
>
<span
v-if=
"line.text"
>
{{
line
.
text
}}
</span>
<span
v-if=
"line.rich_text"
v-html=
"line.rich_text"
></span>
<span
v-else-if=
"line.text"
>
{{
line
.
text
}}
</span>
<!-- TODO: replace this hack with zero-width whitespace when we have rich_text from BE -->
<span
v-else
>
​
</span>
</td>
...
...
app/serializers/suggestion_entity.rb
View file @
a10c3bcb
...
...
@@ -4,7 +4,9 @@ class SuggestionEntity < API::Entities::Suggestion
include
RequestAwareEntity
unexpose
:from_line
,
:to_line
,
:from_content
,
:to_content
expose
:diff_lines
,
using:
DiffLineEntity
expose
:diff_lines
,
using:
DiffLineEntity
do
|
suggestion
|
Gitlab
::
Diff
::
Highlight
.
new
(
suggestion
.
diff_lines
).
highlight
end
expose
:current_user
do
expose
:can_apply
do
|
suggestion
|
Ability
.
allowed?
(
current_user
,
:apply_suggestion
,
suggestion
)
...
...
changelogs/unreleased/26543-add-word-diff-highlight-to-rich-text.yml
0 → 100644
View file @
a10c3bcb
---
title
:
Apply word-diff highlighting to Suggestions
merge_request
:
22182
author
:
type
:
changed
spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js
View file @
a10c3bcb
...
...
@@ -7,8 +7,8 @@ const oldLine = {
meta_data
:
null
,
new_line
:
null
,
old_line
:
5
,
rich_text
:
'
-old
text
'
,
text
:
'
-old
text
'
,
rich_text
:
'
oldrich
text
'
,
text
:
'
oldplain
text
'
,
type
:
'
old
'
,
};
...
...
@@ -18,8 +18,8 @@ const newLine = {
meta_data
:
null
,
new_line
:
6
,
old_line
:
null
,
rich_text
:
'
-new
text
'
,
text
:
'
-new
text
'
,
rich_text
:
'
newrich
text
'
,
text
:
'
newplain
text
'
,
type
:
'
new
'
,
};
...
...
@@ -42,14 +42,46 @@ describe('SuggestionDiffRow', () => {
wrapper
.
destroy
();
});
it
(
'
renders correctly
'
,
()
=>
{
factory
({
propsData
:
{
line
:
oldLine
,
},
describe
(
'
renders correctly
'
,
()
=>
{
it
(
'
has the right classes on the wrapper
'
,
()
=>
{
factory
({
propsData
:
{
line
:
oldLine
,
},
});
expect
(
wrapper
.
is
(
'
.line_holder
'
)).
toBe
(
true
);
});
it
(
'
renders the rich text when it is available
'
,
()
=>
{
factory
({
propsData
:
{
line
:
newLine
,
},
});
expect
(
wrapper
.
find
(
'
td.line_content
'
).
text
()).
toEqual
(
'
newrichtext
'
);
});
expect
(
wrapper
.
is
(
'
.line_holder
'
)).
toBe
(
true
);
it
(
'
renders the plain text when it is available but rich text is not
'
,
()
=>
{
factory
({
propsData
:
{
line
:
Object
.
assign
({},
newLine
,
{
rich_text
:
undefined
}),
},
});
expect
(
wrapper
.
find
(
'
td.line_content
'
).
text
()).
toEqual
(
'
newplaintext
'
);
});
it
(
'
renders a zero-width space when it has no plain or rich texts
'
,
()
=>
{
factory
({
propsData
:
{
line
:
Object
.
assign
({},
newLine
,
{
rich_text
:
undefined
,
text
:
undefined
}),
},
});
expect
(
wrapper
.
find
(
'
td.line_content
'
).
text
()).
toEqual
(
'
\
u200B
'
);
});
});
describe
(
'
when passed line has type old
'
,
()
=>
{
...
...
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