diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-14 16:03:45 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-09-14 16:03:59 +0300 |
commit | 8759770c962f7b6fe509a2d650dd420f75864de6 (patch) | |
tree | 9c092b6b251606c8d5ba9ac70138af14e948c5a8 | |
parent | 1ef8be768df68b42d238ca9368aea65982ad0659 (diff) |
Re-use as much of views as possible
6 files changed, 46 insertions, 58 deletions
diff --git a/app/views/projects/ci/builds/_build_pipeline.html.haml b/app/views/projects/ci/builds/_build_pipeline.html.haml index 5289cd672f5..d19e193c432 100644 --- a/app/views/projects/ci/builds/_build_pipeline.html.haml +++ b/app/views/projects/ci/builds/_build_pipeline.html.haml @@ -1,15 +1,14 @@ - is_playable = subject.playable? && can?(current_user, :update_build, @project) -%li.build{class: ("playable" if is_playable)} - .curve - .build-content - - if is_playable - = link_to play_namespace_project_build_path(subject.project.namespace, subject.project, subject, return_to: request.original_url), method: :post, title: 'Play' do - = render_status_with_link('build', 'play') - .ci-status-text= subject.name - - elsif can?(current_user, :read_build, @project) - = link_to namespace_project_build_path(subject.project.namespace, subject.project, subject) do - = render_status_with_link('build', subject.status) - .ci-status-text= subject.name - - else - = render_status_with_link('build', subject.status) - = ci_icon_for_status(subject.status) +- if is_playable + = link_to play_namespace_project_build_path(subject.project.namespace, subject.project, subject, return_to: request.original_url), method: :post, title: 'Play' do + = render_status_with_link('build', 'play') + .ci-status-text= subject.name +- elsif can?(current_user, :read_build, @project) + = link_to namespace_project_build_path(subject.project.namespace, subject.project, subject) do + = render_status_with_link('build', subject.status) + .ci-status-text= subject.name +- else + = render_status_with_link('build', subject.status) + = ci_icon_for_status(subject.status) + + diff --git a/app/views/projects/commit/_pipeline.html.haml b/app/views/projects/commit/_pipeline.html.haml index a330c14061f..9258f4b3c25 100644 --- a/app/views/projects/commit/_pipeline.html.haml +++ b/app/views/projects/commit/_pipeline.html.haml @@ -39,13 +39,7 @@ = stage.titleize .builds-container %ul - - status_groups = statuses.group_by(&:group_name) - - status_groups.each do |group_name, grouped_statuses| - - if grouped_statuses.one? - - status = grouped_statuses.first - = render "projects/#{status.to_partial_path}_pipeline", subject: status - - else - = render "projects/commit/pipeline_grouped_status", name: group_name, subject: grouped_statuses + = render "projects/commit/pipeline_stage", statuses: statuses - if pipeline.yaml_errors.present? diff --git a/app/views/projects/commit/_pipeline_grouped_status.html.haml b/app/views/projects/commit/_pipeline_grouped_status.html.haml deleted file mode 100644 index dc8efc83d48..00000000000 --- a/app/views/projects/commit/_pipeline_grouped_status.html.haml +++ /dev/null @@ -1,27 +0,0 @@ -%li.build - .curve - .build-content - - group_status = CommitStatus.where(id: subject).status - = render_status_with_link('build', group_status) - .dropdown.inline - %button.dropdown-menu-toggle{type: 'button', data: {toggle: 'dropdown'}} - %span.ci-status-text - = name - %span.badge= subject.length - %ul.dropdown-menu.grouped-pipeline-dropdown - .arrow - - subject.each do |status| - -# = render "projects/#{status.to_partial_path}_pipeline", subject: status - - is_playable = status.playable? && can?(current_user, :update_build, @project) - %li - - if is_playable - = link_to play_namespace_project_build_path(status.project.namespace, status.project, status, return_to: request.original_url), method: :post, title: 'Play' do - = render_status_with_link('build', 'play') - .ci-status-text= status.name - - elsif can?(current_user, :read_build, @project) - = link_to namespace_project_build_path(status.project.namespace, status.project, status) do - = render_status_with_link('build', status.status) - .ci-status-text= status.name - - else - = render_status_with_link('build', status.status) - = ci_icon_for_status(status.status) diff --git a/app/views/projects/commit/_pipeline_stage.html.haml b/app/views/projects/commit/_pipeline_stage.html.haml new file mode 100644 index 00000000000..368564481c4 --- /dev/null +++ b/app/views/projects/commit/_pipeline_stage.html.haml @@ -0,0 +1,14 @@ +- status_groups = statuses.group_by(&:group_name) +- status_groups.each do |group_name, grouped_statuses| + - if grouped_statuses.one? + - status = grouped_statuses.first + - is_playable = status.playable? && can?(current_user, :update_build, @project) + %li.build{class: ("playable" if is_playable)} + .curve + .build-content + = render "projects/#{status.to_partial_path}_pipeline", subject: status + - else + %li.build + .curve + .build-content + = render "projects/commit/pipeline_status_group", name: group_name, subject: grouped_statuses diff --git a/app/views/projects/commit/_pipeline_status_group.html.haml b/app/views/projects/commit/_pipeline_status_group.html.haml new file mode 100644 index 00000000000..03b6249963b --- /dev/null +++ b/app/views/projects/commit/_pipeline_status_group.html.haml @@ -0,0 +1,11 @@ +- group_status = CommitStatus.where(id: subject).status += render_status_with_link('build', group_status) +.dropdown.inline + %button.dropdown-menu-toggle{type: 'button', data: {toggle: 'dropdown'}} + %span.ci-status-text + = name + %span.badge= subject.length + %ul.dropdown-menu.grouped-pipeline-dropdown + .arrow + - subject.each do |status| + = render "projects/#{status.to_partial_path}_pipeline", subject: status diff --git a/app/views/projects/generic_commit_statuses/_generic_commit_status_pipeline.html.haml b/app/views/projects/generic_commit_statuses/_generic_commit_status_pipeline.html.haml index 576d0bec51b..9b54c2bc3af 100644 --- a/app/views/projects/generic_commit_statuses/_generic_commit_status_pipeline.html.haml +++ b/app/views/projects/generic_commit_statuses/_generic_commit_status_pipeline.html.haml @@ -1,10 +1,7 @@ -%li.build - .curve - .build-content - - if subject.target_url - - link_to subject.target_url do - = render_status_with_link('commit status', subject.status) - %span.ci-status-text= subject.name - - else - = render_status_with_link('commit status', subject.status) - %span.ci-status-text= subject.name +- if subject.target_url + - link_to subject.target_url do + = render_status_with_link('commit status', subject.status) + %span.ci-status-text= subject.name +- else + = render_status_with_link('commit status', subject.status) + %span.ci-status-text= subject.name |