Commit 4a76cbe2 authored by Stan Hu's avatar Stan Hu

Merge branch 'fix-reload-with-full-diff-url' into 'master'

Fix the "Reload with full diff" URL button

On the first load, the merge request tabs would be requested in JSON format to render
the HTML. This would cause the "Reload with full diff" button to create a link to `diff.json`. Instead, generate the path in HTML mode.

Closes #2041

See merge request !1019
parents fffbc369 ae3f869f
...@@ -4,6 +4,7 @@ v 7.14.0 (unreleased) ...@@ -4,6 +4,7 @@ v 7.14.0 (unreleased)
- Fix Error 500 when browsing projects with no HEAD (Stan Hu) - Fix Error 500 when browsing projects with no HEAD (Stan Hu)
- Fix full screen mode for snippet comments (Daniel Gerhardt) - Fix full screen mode for snippet comments (Daniel Gerhardt)
- Fix 404 error in files view after deleting the last file in a repository (Stan Hu) - Fix 404 error in files view after deleting the last file in a repository (Stan Hu)
- Fix the "Reload with full diff" URL button (Stan Hu)
- Fix label read access for unauthenticated users (Daniel Gerhardt) - Fix label read access for unauthenticated users (Daniel Gerhardt)
- Fix access to disabled features for unauthenticated users (Daniel Gerhardt) - Fix access to disabled features for unauthenticated users (Daniel Gerhardt)
- Fix OAuth provider bug where GitLab would not go return to the redirect_uri after sign-in (Stan Hu) - Fix OAuth provider bug where GitLab would not go return to the redirect_uri after sign-in (Stan Hu)
......
...@@ -49,12 +49,6 @@ class @MergeRequestTabs ...@@ -49,12 +49,6 @@ class @MergeRequestTabs
# Store the `location` object, allowing for easier stubbing in tests # Store the `location` object, allowing for easier stubbing in tests
@_location = location @_location = location
switch @opts.action
when 'commits'
@commitsLoaded = true
when 'diffs'
@diffsLoaded = true
@bindEvents() @bindEvents()
@activateTab(@opts.action) @activateTab(@opts.action)
...@@ -102,7 +96,7 @@ class @MergeRequestTabs ...@@ -102,7 +96,7 @@ class @MergeRequestTabs
action = 'notes' if action == 'show' action = 'notes' if action == 'show'
# Remove a trailing '/commits' or '/diffs' # Remove a trailing '/commits' or '/diffs'
new_state = @_location.pathname.replace(/\/(commits|diffs)\/?$/, '') new_state = @_location.pathname.replace(/\/(commits|diffs)(\.html)?\/?$/, '')
# Append the new action if we're on a tab other than 'notes' # Append the new action if we're on a tab other than 'notes'
unless action == 'notes' unless action == 'notes'
...@@ -133,7 +127,7 @@ class @MergeRequestTabs ...@@ -133,7 +127,7 @@ class @MergeRequestTabs
return if @diffsLoaded return if @diffsLoaded
@_get @_get
url: "#{source}.json" url: "#{source}.json" + @_location.search
success: (data) => success: (data) =>
document.getElementById('diffs').innerHTML = data.html document.getElementById('diffs').innerHTML = data.html
@diffsLoaded = true @diffsLoaded = true
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Too many changes to show. Too many changes to show.
.pull-right .pull-right
- unless diff_hard_limit_enabled? - unless diff_hard_limit_enabled?
= link_to "Reload with full diff", url_for(params.merge(force_show_diff: true)), class: "btn btn-sm btn-warning" = link_to "Reload with full diff", url_for(params.merge(force_show_diff: true, format: :html)), class: "btn btn-sm btn-warning"
- if current_controller?(:commit) or current_controller?(:merge_requests) - if current_controller?(:commit) or current_controller?(:merge_requests)
- if current_controller?(:commit) - if current_controller?(:commit)
......
...@@ -66,11 +66,9 @@ ...@@ -66,11 +66,9 @@
#notes.notes.tab-pane.voting_notes #notes.notes.tab-pane.voting_notes
= render "projects/merge_requests/discussion" = render "projects/merge_requests/discussion"
#commits.commits.tab-pane #commits.commits.tab-pane
- if current_page?(action: 'commits') - # This tab is always loaded via AJAX
= render "projects/merge_requests/show/commits"
#diffs.diffs.tab-pane #diffs.diffs.tab-pane
- if current_page?(action: 'diffs') - # This tab is always loaded via AJAX
= render "projects/merge_requests/show/diffs"
.mr-loading-status .mr-loading-status
= spinner = spinner
......
...@@ -51,6 +51,12 @@ describe 'MergeRequestTabs', -> ...@@ -51,6 +51,12 @@ describe 'MergeRequestTabs', ->
expect(@subject('notes')).toBe('/foo/bar/merge_requests/1') expect(@subject('notes')).toBe('/foo/bar/merge_requests/1')
expect(@subject('commits')).toBe('/foo/bar/merge_requests/1/commits') expect(@subject('commits')).toBe('/foo/bar/merge_requests/1/commits')
it 'changes from diffs.html', ->
@class._location = stubLocation(pathname: '/foo/bar/merge_requests/1/diffs.html')
expect(@subject('notes')).toBe('/foo/bar/merge_requests/1')
expect(@subject('commits')).toBe('/foo/bar/merge_requests/1/commits')
it 'changes from notes', -> it 'changes from notes', ->
@class._location = stubLocation(pathname: '/foo/bar/merge_requests/1') @class._location = stubLocation(pathname: '/foo/bar/merge_requests/1')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment