Render cached pipeline status on project dashboard
This commit is contained in:
parent
4b249d522c
commit
a33fbb3c83
|
@ -59,6 +59,20 @@ module CiStatusHelper
|
|||
custom_icon(icon_name)
|
||||
end
|
||||
|
||||
def render_project_pipeline_status(pipeline_status, tooltip_placement: 'auto left')
|
||||
project = pipeline_status.project
|
||||
path = pipelines_namespace_project_commit_path(
|
||||
project.namespace,
|
||||
project,
|
||||
pipeline_status.sha)
|
||||
|
||||
render_status_with_link(
|
||||
'commit',
|
||||
pipeline_status.status,
|
||||
path,
|
||||
tooltip_placement: tooltip_placement)
|
||||
end
|
||||
|
||||
def render_commit_status(commit, ref: nil, tooltip_placement: 'auto left')
|
||||
project = commit.project
|
||||
path = pipelines_namespace_project_commit_path(
|
||||
|
|
|
@ -1209,6 +1209,10 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def pipeline_status
|
||||
@pipeline_status ||= Ci::PipelineStatus.load_for_project(self)
|
||||
end
|
||||
|
||||
def mark_import_as_failed(error_message)
|
||||
original_errors = errors.dup
|
||||
sanitized_message = Gitlab::UrlSanitizer.sanitize(error_message)
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
- show_last_commit_as_description = false unless local_assigns[:show_last_commit_as_description] == true && project.commit
|
||||
- css_class += " no-description" if project.description.blank? && !show_last_commit_as_description
|
||||
- cache_key = [project.namespace, project, controller.controller_name, controller.action_name, current_application_settings, 'v2.3']
|
||||
- cache_key.push(project.commit&.sha, project.commit&.status)
|
||||
- cache_key.push(project.pipeline_status) if project.pipeline_status.has_status?
|
||||
|
||||
%li.project-row{ class: css_class }
|
||||
= cache(cache_key) do
|
||||
.controls
|
||||
- if project.archived
|
||||
%span.label.label-warning archived
|
||||
- if project.commit.try(:status)
|
||||
- if project.pipeline_status.has_status?
|
||||
%span
|
||||
= render_commit_status(project.commit)
|
||||
= render_project_pipeline_status(project.pipeline_status)
|
||||
- if forks
|
||||
%span
|
||||
= icon('code-fork')
|
||||
|
|
|
@ -1916,4 +1916,15 @@ describe Project, models: true do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#pipeline_status' do
|
||||
let(:project) { create(:project) }
|
||||
it 'builds a pipeline status' do
|
||||
expect(project.pipeline_status).to be_a(Ci::PipelineStatus)
|
||||
end
|
||||
|
||||
it 'hase a loaded pipeline status' do
|
||||
expect(project.pipeline_status).to be_loaded
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue