openSUSE/open-build-service

View on GitHub
src/api/app/components/staging_project_link_component.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
class StagingProjectLinkComponent < ApplicationComponent
  def initialize(staging_project:, staging_workflow:, link_options: {})
    super

    @staging_project = staging_project
    @staging_workflow = staging_workflow
    @link_options = link_options
  end

  def title
    return @staging_project.title if @staging_project.title.present?

    # If the staging project has no title and is a subproject of the workflow
    # project we remove the workflow project name from the string.
    # And if the staging project has no title and is not a subproject then we
    # show the name.
    workflow_project = @staging_project.staging_workflow.project
    @staging_project.name.delete_prefix("#{workflow_project}:")
  end
end