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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
a236b5e6
Commit
a236b5e6
authored
Apr 13, 2018
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render only one error message per diff
Move html to haml file instead of JS
parent
b01fd7ad
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
19 deletions
+17
-19
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+11
-16
app/assets/stylesheets/framework/buttons.scss
app/assets/stylesheets/framework/buttons.scss
+1
-1
app/views/discussions/_diff_with_notes.html.haml
app/views/discussions/_diff_with_notes.html.haml
+4
-1
spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb
...atures/merge_request/user_scrolls_to_note_on_load_spec.rb
+1
-1
No files found.
app/assets/javascripts/notes.js
View file @
a236b5e6
...
@@ -1431,31 +1431,21 @@ export default class Notes {
...
@@ -1431,31 +1431,21 @@ export default class Notes {
syntaxHighlight
(
fileHolder
);
syntaxHighlight
(
fileHolder
);
}
}
static
renderDiffError
(
$container
)
{
$container
.
find
(
'
.line_content
'
).
html
(
$
(
`
<div class="js-error-load-lazy-diff nothing-here-block">
${
sprintf
(
__
(
'
Unable to load the diff.%{buttonStartTag}Try again%{buttonEndTag}?
'
),
{
buttonStartTag
:
'
<button type="button" class="btn-link btn-no-padding js-toggle-lazy-diff">
'
,
buttonEndTag
:
'
</button>
'
},
false
)}
</div>
`
),
);
}
loadLazyDiff
(
e
)
{
loadLazyDiff
(
e
)
{
const
$container
=
$
(
e
.
currentTarget
).
closest
(
'
.js-toggle-container
'
);
const
$container
=
$
(
e
.
currentTarget
).
closest
(
'
.js-toggle-container
'
);
Notes
.
renderPlaceholderComponent
(
$container
);
Notes
.
renderPlaceholderComponent
(
$container
);
$container
.
find
(
'
.js-toggle-lazy-diff
'
).
removeClass
(
'
js-toggle-lazy-diff
'
);
$container
.
find
(
'
.js-toggle-lazy-diff
'
).
removeClass
(
'
js-toggle-lazy-diff
'
);
const
tableEl
=
$container
.
find
(
'
tbody
'
);
const
$
tableEl
=
$container
.
find
(
'
tbody
'
);
if
(
tableEl
.
length
===
0
)
return
;
if
(
$
tableEl
.
length
===
0
)
return
;
const
fileHolder
=
$container
.
find
(
'
.file-holder
'
);
const
fileHolder
=
$container
.
find
(
'
.file-holder
'
);
const
url
=
fileHolder
.
data
(
'
linesPath
'
);
const
url
=
fileHolder
.
data
(
'
linesPath
'
);
const
$errorContainer
=
$container
.
find
(
'
.js-error-lazy-load-diff
'
);
const
$successContainer
=
$container
.
find
(
'
.js-success-lazy-load
'
);
/**
/**
* We only fetch resolved discussions.
* We only fetch resolved discussions.
* Unresolved discussions don't have an endpoint being provided.
* Unresolved discussions don't have an endpoint being provided.
...
@@ -1464,10 +1454,15 @@ export default class Notes {
...
@@ -1464,10 +1454,15 @@ export default class Notes {
axios
axios
.
get
(
url
)
.
get
(
url
)
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
// Reset state in case last request returned error
$successContainer
.
removeClass
(
'
hidden
'
);
$errorContainer
.
addClass
(
'
hidden
'
);
Notes
.
renderDiffContent
(
$container
,
data
);
Notes
.
renderDiffContent
(
$container
,
data
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
Notes
.
renderDiffError
(
$container
);
$successContainer
.
addClass
(
'
hidden
'
);
$errorContainer
.
removeClass
(
'
hidden
'
);
});
});
}
}
}
}
...
...
app/assets/stylesheets/framework/buttons.scss
View file @
a236b5e6
app/views/discussions/_diff_with_notes.html.haml
View file @
a236b5e6
...
@@ -28,8 +28,11 @@
...
@@ -28,8 +28,11 @@
%tr
.line_holder.line-holder-placeholder
%tr
.line_holder.line-holder-placeholder
%td
.old_line.diff-line-num
%td
.old_line.diff-line-num
%td
.new_line.diff-line-num
%td
.new_line.diff-line-num
%td
.line_content
%td
.line_content
.js-success-lazy-load
.js-code-placeholder
.js-code-placeholder
%td
.line_content.js-error-lazy-load-diff.hidden
-
button
=
button_tag
(
_
(
"Try again"
),
class:
"btn-link btn-no-padding js-toggle-lazy-diff"
)
=
_
(
"Unable to load the diff. %{button_try_again}"
).
html_safe
%
{
button_try_again:
button
}
=
render
"discussions/diff_discussion"
,
discussions:
[
discussion
],
expanded:
true
=
render
"discussions/diff_discussion"
,
discussions:
[
discussion
],
expanded:
true
-
else
-
else
-
partial
=
(
diff_file
.
new_file?
||
diff_file
.
deleted_file?
)
?
'single_image_diff'
:
'replaced_image_diff'
-
partial
=
(
diff_file
.
new_file?
||
diff_file
.
deleted_file?
)
?
'single_image_diff'
:
'replaced_image_diff'
...
...
spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb
View file @
a236b5e6
...
@@ -40,7 +40,7 @@ describe 'Merge request > User scrolls to note on load', :js do
...
@@ -40,7 +40,7 @@ describe 'Merge request > User scrolls to note on load', :js do
expect
(
note_element
.
visible?
).
to
eq
true
expect
(
note_element
.
visible?
).
to
eq
true
page
.
within
note_container
do
page
.
within
note_container
do
expect
(
page
).
not_to
have_selector
(
'.js-error-l
oad-lazy
-diff'
)
expect
(
page
).
not_to
have_selector
(
'.js-error-l
azy-load
-diff'
)
end
end
end
end
...
...
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