Commit ac73de50 authored by Rubén Dávila Santos's avatar Rubén Dávila Santos

Merge branch 'tab-persistance' into 'master'

Make new tabs persistent when changing view.

## What does this MR do?

## Are there points in the code the reviewer needs to double check?

## Why was this MR needed?

## What are the relevant issue numbers?

## Screenshots (if relevant)

## Does this MR meet the acceptance criteria?

- [ ] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- Tests
  - [ ] Added for this feature/bug
  - [ ] All builds are passing
- [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [ ] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

cc @stanhu @DouweM @rdavila 

See merge request !5859
parents 2c1062f8 22ce76d4
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
function MergeRequestTabs(opts) { function MergeRequestTabs(opts) {
this.opts = opts != null ? opts : {}; this.opts = opts != null ? opts : {};
this.opts.setUrl = this.opts.setUrl !== undefined ? this.opts.setUrl : true;
this.setCurrentAction = bind(this.setCurrentAction, this); this.setCurrentAction = bind(this.setCurrentAction, this);
this.tabShown = bind(this.tabShown, this); this.tabShown = bind(this.tabShown, this);
this.showTab = bind(this.showTab, this); this.showTab = bind(this.showTab, this);
...@@ -58,7 +59,9 @@ ...@@ -58,7 +59,9 @@
} else { } else {
this.expandView(); this.expandView();
} }
return this.setCurrentAction(action); if (this.opts.setUrl) {
this.setCurrentAction(action);
}
}; };
MergeRequestTabs.prototype.scrollToElement = function(container) { MergeRequestTabs.prototype.scrollToElement = function(container) {
......
...@@ -83,6 +83,7 @@ class Projects::ApplicationController < ApplicationController ...@@ -83,6 +83,7 @@ class Projects::ApplicationController < ApplicationController
end end
def apply_diff_view_cookie! def apply_diff_view_cookie!
@show_changes_tab = params[:view].present?
cookies.permanent[:diff_view] = params.delete(:view) if params[:view].present? cookies.permanent[:diff_view] = params.delete(:view) if params[:view].present?
end end
......
...@@ -216,7 +216,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -216,7 +216,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@base_commit = @merge_request.diff_base_commit @base_commit = @merge_request.diff_base_commit
@diffs = @merge_request.diffs(diff_options) if @merge_request.compare @diffs = @merge_request.diffs(diff_options) if @merge_request.compare
@diff_notes_disabled = true @diff_notes_disabled = true
@pipeline = @merge_request.pipeline @pipeline = @merge_request.pipeline
@statuses = @pipeline.statuses.relevant if @pipeline @statuses = @pipeline.statuses.relevant if @pipeline
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
.mr-compare.merge-request .mr-compare.merge-request
%ul.merge-request-tabs.nav-links.no-top.no-bottom %ul.merge-request-tabs.nav-links.no-top.no-bottom
%li.commits-tab %li.commits-tab
= link_to url_for(params), data: {target: 'div#commits', action: 'commits', toggle: 'tab'} do = link_to url_for(params), data: {target: 'div#commits', action: 'new', toggle: 'tab'} do
Commits Commits
%span.badge= @commits.size %span.badge= @commits.size
- if @pipeline - if @pipeline
...@@ -52,11 +52,8 @@ ...@@ -52,11 +52,8 @@
$('#merge_request_assignee_id').val("#{current_user.id}").trigger("change"); $('#merge_request_assignee_id').val("#{current_user.id}").trigger("change");
e.preventDefault(); e.preventDefault();
}); });
:javascript :javascript
var merge_request var merge_request = new MergeRequest({
merge_request = new MergeRequest({ action: "#{(@show_changes_tab ? 'diffs' : 'new')}",
action: 'new', setUrl: false
diffs_loaded: true,
commits_loaded: true
}); });
...@@ -49,14 +49,14 @@ feature 'Create New Merge Request', feature: true, js: true do ...@@ -49,14 +49,14 @@ feature 'Create New Merge Request', feature: true, js: true do
click_link 'Changes' click_link 'Changes'
expect(page.find_link('Inline')[:class]).to match(/\bactive\b/) expect(page).to have_css('a.btn.active', text: 'Inline')
expect(page.find_link('Side-by-side')[:class]).not_to match(/\bactive\b/) expect(page).not_to have_css('a.btn.active', text: 'Side-by-side')
click_link 'Side-by-side' click_link 'Side-by-side'
click_link 'Changes' within '.merge-request' do
expect(page).not_to have_css('a.btn.active', text: 'Inline')
expect(page.find_link('Inline')[:class]).not_to match(/\bactive\b/) expect(page).to have_css('a.btn.active', text: 'Side-by-side')
expect(page.find_link('Side-by-side')[:class]).to match(/\bactive\b/) end
end end
end end
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