From 401c155e16e4966be538fd14f23e268cd3383aa7 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski <ayufan@ayufan.eu> Date: Mon, 5 Dec 2016 18:16:34 +0100 Subject: [PATCH] Update stage rendering views --- app/views/projects/builds/_sidebar.html.haml | 4 ++-- app/views/projects/commit/_pipeline.html.haml | 16 +++----------- .../projects/commit/_pipeline_stage.html.haml | 14 ------------ app/views/projects/pipelines/_graph.html.haml | 4 ++++ .../projects/pipelines/_with_tabs.html.haml | 15 +++---------- app/views/projects/stage/_graph.html.haml | 22 +++++++++++++++++++ .../_in_stage_group.html.haml} | 0 app/views/projects/stage/_stage.html.haml | 2 +- 8 files changed, 35 insertions(+), 42 deletions(-) delete mode 100644 app/views/projects/commit/_pipeline_stage.html.haml create mode 100644 app/views/projects/pipelines/_graph.html.haml create mode 100644 app/views/projects/stage/_graph.html.haml rename app/views/projects/{commit/_pipeline_status_group.html.haml => stage/_in_stage_group.html.haml} (100%) diff --git a/app/views/projects/builds/_sidebar.html.haml b/app/views/projects/builds/_sidebar.html.haml index a45612fb28b..ce8b66b1945 100644 --- a/app/views/projects/builds/_sidebar.html.haml +++ b/app/views/projects/builds/_sidebar.html.haml @@ -111,7 +111,7 @@ %span.label.label-primary = tag - - if @build.pipeline.stages_count.many? + - if @build.pipeline.stages_count > 1 .dropdown.build-dropdown .title Stage %button.dropdown-menu-toggle{type: 'button', 'data-toggle' => 'dropdown'} @@ -120,7 +120,7 @@ %ul.dropdown-menu - @build.pipeline.stages.each do |stage| %li - %a.stage-item= stage + %a.stage-item= stage.name .builds-container - HasStatus::ORDERED_STATUSES.each do |build_status| diff --git a/app/views/projects/commit/_pipeline.html.haml b/app/views/projects/commit/_pipeline.html.haml index 2cd40bb1106..4fc5e15592a 100644 --- a/app/views/projects/commit/_pipeline.html.haml +++ b/app/views/projects/commit/_pipeline.html.haml @@ -25,18 +25,7 @@ = time_interval_in_words pipeline.duration .row-content-block.build-content.middle-block.pipeline-graph.hidden - .pipeline-visualization - %ul.stage-column-list - - pipeline.stages.each do |stage| - %li.stage-column - .stage-name - %a{name: stage.name} - - if stage.name - = stage.name.titleize - .builds-container - %ul - = render "projects/commit/pipeline_stage", statuses: stage.statuses - + = render "projects/pipelines/graph", subject: pipeline - if pipeline.yaml_errors.present? .bs-callout.bs-callout-danger @@ -61,4 +50,5 @@ - if pipeline.project.build_coverage_enabled? %th Coverage %th - = render pipeline.stages + - pipeline.stages.each do |stage| + = render "projects/stage/stage", subject: stage diff --git a/app/views/projects/commit/_pipeline_stage.html.haml b/app/views/projects/commit/_pipeline_stage.html.haml deleted file mode 100644 index f9a9c8707f5..00000000000 --- a/app/views/projects/commit/_pipeline_stage.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -- status_groups = statuses.sort_by(&:name).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 - .dropdown.inline.build-content - = render "projects/commit/pipeline_status_group", name: group_name, subject: grouped_statuses diff --git a/app/views/projects/pipelines/_graph.html.haml b/app/views/projects/pipelines/_graph.html.haml new file mode 100644 index 00000000000..3bb6426c156 --- /dev/null +++ b/app/views/projects/pipelines/_graph.html.haml @@ -0,0 +1,4 @@ +.pipeline-visualization + %ul.stage-column-list + - subject.stages.each do |stage| + = render "projects/stage/graph", subject: stage diff --git a/app/views/projects/pipelines/_with_tabs.html.haml b/app/views/projects/pipelines/_with_tabs.html.haml index 57e793d2e59..2ace9339af3 100644 --- a/app/views/projects/pipelines/_with_tabs.html.haml +++ b/app/views/projects/pipelines/_with_tabs.html.haml @@ -13,17 +13,7 @@ .tab-content #js-tab-pipeline.tab-pane .build-content.middle-block.pipeline-graph - .pipeline-visualization - %ul.stage-column-list - - pipeline.stages.each do |stage| - %li.stage-column - .stage-name - %a{name: stage.name} - - if stage.name - = stage.name.titleize - .builds-container - %ul - = render "projects/commit/pipeline_stage", statuses: statuses + = render "projects/pipelines/graph", subject: pipeline #js-tab-builds.tab-pane - if pipeline.yaml_errors.present? @@ -49,4 +39,5 @@ - if pipeline.project.build_coverage_enabled? %th Coverage %th - = render pipeline.stages + - pipeline.stages.each do |stage| + = render "projects/stage/stage", subject: stage diff --git a/app/views/projects/stage/_graph.html.haml b/app/views/projects/stage/_graph.html.haml new file mode 100644 index 00000000000..f1d11db58ab --- /dev/null +++ b/app/views/projects/stage/_graph.html.haml @@ -0,0 +1,22 @@ +%li.stage-column + .stage-name + %a{ name: subject.name } + - if subject.name + = subject.name.titleize + .builds-container + %ul + - statuses = subject.statuses.latest + - status_groups = statuses.sort_by(&:name).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 + .dropdown.inline.build-content + = render "projects/stage/in_stage_group", name: group_name, subject: grouped_statuses diff --git a/app/views/projects/commit/_pipeline_status_group.html.haml b/app/views/projects/stage/_in_stage_group.html.haml similarity index 100% rename from app/views/projects/commit/_pipeline_status_group.html.haml rename to app/views/projects/stage/_in_stage_group.html.haml diff --git a/app/views/projects/stage/_stage.html.haml b/app/views/projects/stage/_stage.html.haml index 717075620d9..055d8fca38b 100644 --- a/app/views/projects/stage/_stage.html.haml +++ b/app/views/projects/stage/_stage.html.haml @@ -1,7 +1,7 @@ %tr %th{colspan: 10} %strong - %a{name: subject.name} + %a{ name: subject.name } %span{class: "ci-status-link ci-status-icon-#{subject.status}"} = ci_icon_for_status(subject.status) - if subject.name -- GitLab