From 3f2578bce5afbb1f92acab2481ec6de2f38a6296 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 21 Apr 2017 15:09:37 +0100 Subject: [PATCH 1/4] Commit view correctly spans the full width when parallel view Closes #30881 --- app/assets/stylesheets/pages/issuable.scss | 11 ++++++--- app/views/projects/commit/show.html.haml | 4 +++- .../commit-limited-container-width.yml | 4 ++++ .../projects/commit/container_spec.rb | 23 +++++++++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/commit-limited-container-width.yml create mode 100644 spec/features/projects/commit/container_spec.rb diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index 8d3d1a72b9b..cf8735e6fad 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -6,7 +6,13 @@ } .limit-container-width { - .detail-page-header { + .detail-page-header, + .page-content-header, + .commit-box, + .info-well, + .notes, + .commit-ci-menu, + .files-changed { @extend .fixed-width-container; } @@ -36,8 +42,7 @@ } .diffs { - .mr-version-controls, - .files-changed { + .mr-version-controls { @extend .fixed-width-container; } } diff --git a/app/views/projects/commit/show.html.haml b/app/views/projects/commit/show.html.haml index 0d11da2451a..cdf0f11dc5f 100644 --- a/app/views/projects/commit/show.html.haml +++ b/app/views/projects/commit/show.html.haml @@ -1,9 +1,11 @@ - @no_container = true +- container_class = !fluid_layout && diff_view == :inline ? 'container-limited' : '' +- limited_container_width = fluid_layout || diff_view == :inline ? '' : 'limit-container-width' - page_title "#{@commit.title} (#{@commit.short_id})", "Commits" - page_description @commit.description = render "projects/commits/head" -%div{ class: container_class } +%div.container-fluid{ class: [limited_container_width, container_class] } = render "commit_box" - if @commit.status = render "ci_menu" diff --git a/changelogs/unreleased/commit-limited-container-width.yml b/changelogs/unreleased/commit-limited-container-width.yml new file mode 100644 index 00000000000..253646b13da --- /dev/null +++ b/changelogs/unreleased/commit-limited-container-width.yml @@ -0,0 +1,4 @@ +--- +title: Side-by-side view in commits correcly expands full window width +merge_request: +author: diff --git a/spec/features/projects/commit/container_spec.rb b/spec/features/projects/commit/container_spec.rb new file mode 100644 index 00000000000..80b758ec14f --- /dev/null +++ b/spec/features/projects/commit/container_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe 'Commit container', :js, :feature do + let(:user) { create(:user) } + let(:project) { create(:project) } + + before do + project.team << [user, :master] + login_as(user) + end + + it 'keeps container-limited when view type is inline' do + visit namespace_project_commit_path(project.namespace, project, project.commit.id, view: :inline) + + expect(page).not_to have_selector('.limit-container-width') + end + + it 'diff spans full width when view type is parallel' do + visit namespace_project_commit_path(project.namespace, project, project.commit.id, view: :parallel) + + expect(page).to have_selector('.limit-container-width') + end +end From 064739431a837ea644851f3f3d01f5da6ee05951 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 24 Apr 2017 16:20:23 +0100 Subject: [PATCH 2/4] Fixed HAML lint --- app/views/projects/commit/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/commit/show.html.haml b/app/views/projects/commit/show.html.haml index cdf0f11dc5f..16d2646cb4e 100644 --- a/app/views/projects/commit/show.html.haml +++ b/app/views/projects/commit/show.html.haml @@ -5,7 +5,7 @@ - page_description @commit.description = render "projects/commits/head" -%div.container-fluid{ class: [limited_container_width, container_class] } +.container-fluid{ class: [limited_container_width, container_class] } = render "commit_box" - if @commit.status = render "ci_menu" From 7fd3a5883e5a6135873f2e6def9dabf2ab82f361 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 28 Apr 2017 12:11:30 +0100 Subject: [PATCH 3/4] Changed spec to a view spec --- .../projects/commit/container_spec.rb | 23 ---------- .../projects/commit/show.html.haml_spec.rb | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 23 deletions(-) delete mode 100644 spec/features/projects/commit/container_spec.rb create mode 100644 spec/views/projects/commit/show.html.haml_spec.rb diff --git a/spec/features/projects/commit/container_spec.rb b/spec/features/projects/commit/container_spec.rb deleted file mode 100644 index 80b758ec14f..00000000000 --- a/spec/features/projects/commit/container_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'spec_helper' - -describe 'Commit container', :js, :feature do - let(:user) { create(:user) } - let(:project) { create(:project) } - - before do - project.team << [user, :master] - login_as(user) - end - - it 'keeps container-limited when view type is inline' do - visit namespace_project_commit_path(project.namespace, project, project.commit.id, view: :inline) - - expect(page).not_to have_selector('.limit-container-width') - end - - it 'diff spans full width when view type is parallel' do - visit namespace_project_commit_path(project.namespace, project, project.commit.id, view: :parallel) - - expect(page).to have_selector('.limit-container-width') - end -end diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb new file mode 100644 index 00000000000..abbdc65ea71 --- /dev/null +++ b/spec/views/projects/commit/show.html.haml_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe 'projects/commit/show.html.haml', :view do + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + + before do + assign(:project, project) + assign(:repository, project.repository) + assign(:commit, project.commit) + assign(:noteable, project.commit) + assign(:notes, []) + assign(:diffs, project.commit.diffs) + + allow(view).to receive(:current_user).and_return(user) + allow(view).to receive(:can?).and_return(false) + allow(view).to receive(:can_collaborate_with_project?).and_return(false) + allow(view).to receive(:current_ref).and_return(project.repository.root_ref) + allow(view).to receive(:diff_btn).and_return('') + end + + context 'inline diff view' do + before do + allow(view).to receive(:diff_view).and_return(:inline) + + render + end + + it 'keeps container-limited' do + expect(rendered).not_to have_selector('.limit-container-width') + end + end + + context 'parallel diff view' do + before do + allow(view).to receive(:diff_view).and_return(:parallel) + + render + end + + it 'spans full width' do + expect(rendered).to have_selector('.limit-container-width') + end + end +end From ce5f7008fbd697e1af4a0bcf91b8a0d7c26cb643 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 2 May 2017 16:02:58 +0100 Subject: [PATCH 4/4] Fixed view specs --- spec/views/projects/commit/show.html.haml_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb index abbdc65ea71..122075cc10e 100644 --- a/spec/views/projects/commit/show.html.haml_spec.rb +++ b/spec/views/projects/commit/show.html.haml_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' describe 'projects/commit/show.html.haml', :view do - let(:user) { create(:user) } let(:project) { create(:project, :repository) } before do @@ -12,7 +11,7 @@ describe 'projects/commit/show.html.haml', :view do assign(:notes, []) assign(:diffs, project.commit.diffs) - allow(view).to receive(:current_user).and_return(user) + allow(view).to receive(:current_user).and_return(nil) allow(view).to receive(:can?).and_return(false) allow(view).to receive(:can_collaborate_with_project?).and_return(false) allow(view).to receive(:current_ref).and_return(project.repository.root_ref)