Commit 40d15136 authored by Scott Hampton's avatar Scott Hampton

Adding ability to pass in path to status icon

Project passed a very specific details path. Also reverted a change.
parent 2b517453
......@@ -100,6 +100,32 @@ module CiStatusHelper
"pipeline-status/#{pipeline_status.sha}-#{pipeline_status.status}"
end
def render_commit_status(commit, ref: nil, tooltip_placement: 'left')
project = commit.project
path = pipelines_project_commit_path(project, commit, ref: ref)
render_status_with_link(
'commit',
commit.status(ref),
path,
tooltip_placement: tooltip_placement,
icon_size: 24)
end
def render_status_with_link(type, status, path = nil, tooltip_placement: 'left', cssclass: '', container: 'body', icon_size: 16)
klass = "ci-status-link ci-status-icon-#{status.dasherize} #{cssclass}"
title = "#{type.titleize}: #{ci_label_for_status(status)}"
data = { toggle: 'tooltip', placement: tooltip_placement, container: container }
if path
link_to ci_icon_for_status(status, size: icon_size), path,
class: klass, title: title, data: data
else
content_tag :span, ci_icon_for_status(status, size: icon_size),
class: klass, title: title, data: data
end
end
def detailed_status?(status)
status.respond_to?(:text) &&
status.respond_to?(:label) &&
......
......@@ -3,8 +3,12 @@
- type = local_assigns.fetch(:type, 'pipeline')
- title = local_assigns.fetch(:title, "#{type.titleize}: #{status.label}")
- tooltip_placement = local_assigns.fetch(:tooltip_placement, "left")
- path = local_assigns.fetch(:path, status.has_details? ? status.details_path : nil)
- css_classes = "ci-status-link ci-status-icon ci-status-icon-#{status.group} has-tooltip"
- if status.has_details?
= link_to status.details_path, class: css_classes, title: title, data: { html: true, placement: tooltip_placement } do
= link_to path, class: css_classes, title: title, data: { html: true, placement: tooltip_placement } do
= sprite_icon(status.icon, size: size)
- else
%span{ class: css_classes, title: title, data: { html: true, placement: tooltip_placement } }
= sprite_icon(status.icon, size: size)
......@@ -25,7 +25,7 @@
= commit.short_id
- if commit_status
.d-block.d-sm-none
= render 'ci/status/icon', status: commit.last_pipeline.detailed_status(current_user), type: 'commit', size: 24
= render_commit_status(commit, ref: ref)
- if commit.description?
%button.text-expander.js-toggle-button
= sprite_icon('ellipsis_h', size: 12)
......@@ -47,7 +47,7 @@
= render partial: 'projects/commit/ajax_signature', locals: { commit: commit }
- if commit_status
= render 'ci/status/icon', status: commit.last_pipeline.detailed_status(current_user), type: 'commit', size: 24
= render_commit_status(commit, ref: ref)
.js-commit-pipeline-status{ data: { endpoint: pipelines_project_commit_path(project, commit.id, ref: ref) } }
......
......@@ -84,7 +84,8 @@
= sprite_icon('issues', size: 14, css_class: 'append-right-4')
= number_with_delimiter(project.open_issues_count)
- if pipeline_status && can?(current_user, :read_cross_project) && project.pipeline_status.has_status? && can?(current_user, :read_build, project)
- pipeline_path = pipelines_project_commit_path(project.pipeline_status.project, project.pipeline_status.sha, ref: project.pipeline_status.ref)
%span.icon-wrapper.pipeline-status
= render 'ci/status/icon', status: project.commit.last_pipeline.detailed_status(current_user), type: 'commit', tooltip_placement: 'top'
= render 'ci/status/icon', status: project.commit.last_pipeline.detailed_status(current_user), type: 'commit', tooltip_placement: 'top', path: pipeline_path
.updated-note
%span Updated #{updated_tooltip}
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