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
dfc62605
Commit
dfc62605
authored
Jan 30, 2018
by
Clement Ho
Committed by
Filipa Lacerda
Jan 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace $.get in single file diff with axios
parent
5f1a09e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
18 deletions
+15
-18
app/assets/javascripts/single_file_diff.js
app/assets/javascripts/single_file_diff.js
+15
-11
spec/features/expand_collapse_diffs_spec.rb
spec/features/expand_collapse_diffs_spec.rb
+0
-7
No files found.
app/assets/javascripts/single_file_diff.js
View file @
dfc62605
/* eslint-disable func-names, prefer-arrow-callback, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, one-var, one-var-declaration-per-line, consistent-return, no-param-reassign, max-len */
/* eslint-disable func-names, prefer-arrow-callback, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, one-var, one-var-declaration-per-line, consistent-return, no-param-reassign, max-len */
import
{
__
}
from
'
./locale
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
createFlash
from
'
./flash
'
;
import
FilesCommentButton
from
'
./files_comment_button
'
;
import
FilesCommentButton
from
'
./files_comment_button
'
;
import
imageDiffHelper
from
'
./image_diff/helpers/index
'
;
import
imageDiffHelper
from
'
./image_diff/helpers/index
'
;
import
syntaxHighlight
from
'
./syntax_highlight
'
;
import
syntaxHighlight
from
'
./syntax_highlight
'
;
...
@@ -60,30 +63,31 @@ export default class SingleFileDiff {
...
@@ -60,30 +63,31 @@ export default class SingleFileDiff {
getContentHTML
(
cb
)
{
getContentHTML
(
cb
)
{
this
.
collapsedContent
.
hide
();
this
.
collapsedContent
.
hide
();
this
.
loadingContent
.
show
();
this
.
loadingContent
.
show
();
$
.
get
(
this
.
diffForPath
,
(
function
(
_this
)
{
return
function
(
data
)
{
axios
.
get
(
this
.
diffForPath
)
_this
.
loadingContent
.
hide
();
.
then
(({
data
})
=>
{
this
.
loadingContent
.
hide
();
if
(
data
.
html
)
{
if
(
data
.
html
)
{
_
this
.
content
=
$
(
data
.
html
);
this
.
content
=
$
(
data
.
html
);
syntaxHighlight
(
_
this
.
content
);
syntaxHighlight
(
this
.
content
);
}
else
{
}
else
{
_
this
.
hasError
=
true
;
this
.
hasError
=
true
;
_
this
.
content
=
$
(
ERROR_HTML
);
this
.
content
=
$
(
ERROR_HTML
);
}
}
_this
.
collapsedContent
.
after
(
_
this
.
content
);
this
.
collapsedContent
.
after
(
this
.
content
);
if
(
typeof
gl
.
diffNotesCompileComponents
!==
'
undefined
'
)
{
if
(
typeof
gl
.
diffNotesCompileComponents
!==
'
undefined
'
)
{
gl
.
diffNotesCompileComponents
();
gl
.
diffNotesCompileComponents
();
}
}
const
$file
=
$
(
_
this
.
file
);
const
$file
=
$
(
this
.
file
);
FilesCommentButton
.
init
(
$file
);
FilesCommentButton
.
init
(
$file
);
const
canCreateNote
=
$file
.
closest
(
'
.files
'
).
is
(
'
[data-can-create-note]
'
);
const
canCreateNote
=
$file
.
closest
(
'
.files
'
).
is
(
'
[data-can-create-note]
'
);
imageDiffHelper
.
initImageDiff
(
$file
[
0
],
canCreateNote
);
imageDiffHelper
.
initImageDiff
(
$file
[
0
],
canCreateNote
);
if
(
cb
)
cb
();
if
(
cb
)
cb
();
}
;
}
)
})(
this
));
.
catch
(
createFlash
(
__
(
'
An error occurred while retrieving diff
'
)
));
}
}
}
}
spec/features/expand_collapse_diffs_spec.rb
View file @
dfc62605
...
@@ -112,13 +112,6 @@ feature 'Expand and collapse diffs', :js do
...
@@ -112,13 +112,6 @@ feature 'Expand and collapse diffs', :js do
wait_for_requests
wait_for_requests
end
end
it
'makes a request to get the content'
do
ajax_uris
=
evaluate_script
(
'ajaxUris'
)
expect
(
ajax_uris
).
not_to
be_empty
expect
(
ajax_uris
.
first
).
to
include
(
'large_diff.md'
)
end
it
'shows the diff content'
do
it
'shows the diff content'
do
expect
(
large_diff
).
to
have_selector
(
'.code'
)
expect
(
large_diff
).
to
have_selector
(
'.code'
)
expect
(
large_diff
).
not_to
have_selector
(
'.nothing-here-block'
)
expect
(
large_diff
).
not_to
have_selector
(
'.nothing-here-block'
)
...
...
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