diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2017-11-04 14:51:26 -0400 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2017-11-06 06:12:35 +0100 |
commit | 70b8f421ae6587d2a57db40e7487bf2dd788cbde (patch) | |
tree | 5fbee71dc43e9f637c717a2852bd6310ce286acf | |
parent | 4585f358b923bb9b4ab36a0c3e4682b060e088a7 (diff) | |
download | gitlab-ce-70b8f421ae6587d2a57db40e7487bf2dd788cbde.tar.gz |
Modifies commit branches section
- Display the default branch (if the limit is not exceeded)
- Requires '...' to be clicked before showing the rest of the branches and/or tags
- Fixes haml lints
4 files changed, 85 insertions, 12 deletions
diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index cd93886bb24..b1beb2ff368 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -61,7 +61,7 @@ %span.cgray= n_('parent', 'parents', @commit.parents.count) - @commit.parents.each do |parent| = link_to parent.short_id, project_commit_path(@project, parent), class: "commit-sha" - %div.commit-info.branches + .commit-info.branches %i.fa.fa-spinner.fa-spin - if @commit.last_pipeline diff --git a/app/views/projects/commit/_limit_exceeded_message.html.haml b/app/views/projects/commit/_limit_exceeded_message.html.haml index b3372108321..430ac6df2e4 100644 --- a/app/views/projects/commit/_limit_exceeded_message.html.haml +++ b/app/views/projects/commit/_limit_exceeded_message.html.haml @@ -1,8 +1,8 @@ -.has-tooltip{class: "limit-box limit-box-#{objects.singularize}", data: { title: "Project has too many #{objects} to search"} } +.has-tooltip{ class: "limit-box limit-box-#{objects.singularize}", data: { title: "Project has too many #{objects} to search"} } .limit-icon - if objects == "branches" = icon('code-fork') - else = icon('tag') .limit-message - %span= "#{objects.capitalize} unavailable" + %span #{objects.capitalize} unavailable diff --git a/app/views/projects/commit/branches.html.haml b/app/views/projects/commit/branches.html.haml index d282eb47914..1c4f16b5afa 100644 --- a/app/views/projects/commit/branches.html.haml +++ b/app/views/projects/commit/branches.html.haml @@ -1,9 +1,15 @@ - if @branches_limit_exceeded = render 'limit_exceeded_message', objects: 'branches' -- elsif @branches.any? - = commit_branches_links(@project, @branches) +- else + - branch = commit_default_branch(@project, @branches) + = commit_branch_link(project_ref_path(@project, branch), branch) -- if @tags_limit_exceeded - = render 'limit_exceeded_message', objects: 'tags' -- elsif @tags.any? - = commit_tags_links(@project, @tags) +- if @branches.any? || @tags.any? || @tags_limit_exceeded + %span + = link_to "…", "#", class: "js-details-expand label label-gray" + %span.js-details-content.hide + = commit_branches_links(@project, @branches) + - if @tags_limit_exceeded + = render 'limit_exceeded_message', objects: 'tags' + - else + = commit_tags_links(@project, @tags) diff --git a/spec/views/projects/commit/branches.html.haml_spec.rb b/spec/views/projects/commit/branches.html.haml_spec.rb index c9112ede334..044b73ce419 100644 --- a/spec/views/projects/commit/branches.html.haml_spec.rb +++ b/spec/views/projects/commit/branches.html.haml_spec.rb @@ -7,7 +7,7 @@ describe 'projects/commit/branches.html.haml' do assign(:project, project) end - context 'branches and tags' do + context 'when branches and tags are available' do before do assign(:branches, ['master', 'test-branch']) assign(:branches_limit_exceeded, false) @@ -17,16 +17,75 @@ describe 'projects/commit/branches.html.haml' do render end + it 'shows default branch' do + expect(rendered).to have_link('master') + end + + it 'shows js expand link' do + expect(rendered).to have_selector('.js-details-expand') + end + it 'shows branch and tag links' do + expect(rendered).to have_link('test-branch') + expect(rendered).to have_link('tag1') + end + end + + context 'when branches are available but no tags' do + before do + assign(:branches, ['master', 'test-branch']) + assign(:branches_limit_exceeded, false) + assign(:tags, []) + assign(:tags_limit_exceeded, true) + + render + end + + it 'shows branches' do expect(rendered).to have_link('master') expect(rendered).to have_link('test-branch') + end + + it 'shows js expand link' do + expect(rendered).to have_selector('.js-details-expand') + end + + it 'shows limit exceeded message for tags' do + expect(rendered).to have_text('Tags unavailable') + end + end + + context 'when tags are available but no branches (just default)' do + before do + assign(:branches, ['master']) + assign(:branches_limit_exceeded, true) + assign(:tags, ['tag1', 'tag2']) + assign(:tags_limit_exceeded, false) + + render + end + + it 'shows default branch' do + expect(rendered).to have_text('master') + end + + it 'shows js expand link' do + expect(rendered).to have_selector('.js-details-expand') + end + + it 'shows tags' do expect(rendered).to have_link('tag1') + expect(rendered).to have_link('tag2') + end + + it 'shows limit exceeded for branches' do + expect(rendered).to have_text('Branches unavailable') end end - context 'throttled branches and tags' do + context 'when branches and tags are not available' do before do - assign(:branches, []) + assign(:branches, ['master']) assign(:branches_limit_exceeded, true) assign(:tags, []) assign(:tags_limit_exceeded, true) @@ -34,6 +93,14 @@ describe 'projects/commit/branches.html.haml' do render end + it 'shows default branch' do + expect(rendered).to have_text('master') + end + + it 'shows js expand link' do + expect(rendered).to have_selector('.js-details-expand') + end + it 'shows too many to search' do expect(rendered).to have_text('Branches unavailable') expect(rendered).to have_text('Tags unavailable') |