Skip to content

Commit

Permalink
Wrap REPO_STATUS constants in a method and add a default
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken committed Dec 19, 2018
1 parent e35661a commit 418bfd9
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/api/app/helpers/webui/webui_helper.rb
Expand Up @@ -111,14 +111,21 @@ def format_projectname(prjname, login)
'scheduling' => 'The repository state is being calculated right now'
}.freeze

def repo_status_description(status)
REPO_STATUS_DESCRIPTIONS[status] || 'Unknown state of repository'
end

def webui2_repo_status_icon(status)
WEBUI2_REPO_STATUS_ICONS[status] || 'eye'
end

def check_first(first)
first.nil? ? true : nil
end

# TODO: bento_only
def repo_status_icon(status, details = nil)
icon = REPO_STATUS_ICONS[status] || 'eye'

outdated = nil
if /^outdated_/.match?(status)
status.gsub!(%r{^outdated_}, '')
Expand All @@ -135,19 +142,14 @@ def repo_status_icon(status, details = nil)
def webui2_repository_status_icon(status:, details: nil, html_class: '')
outdated = status.sub!(/^outdated_/, '')
description = outdated ? 'State needs recalculations, former state was: ' : ''
description << REPO_STATUS_DESCRIPTIONS[status] || 'Unknown state of repository'
description << repo_status_description(status)
description << " (#{details})" if details

repo_state_class = outdated ? 'outdated' : 'default'
content_tag(:i, '', class: "repository-state-#{repo_state_class} #{html_class} #{webui2_repo_status_icon(status)}",
content_tag(:i, '', class: "repository-state-#{repo_state_class} #{html_class} fas fa-#{webui2_repo_status_icon(status)}",
data: { content: description, placement: 'top', toggle: 'popover' })
end

def webui2_repo_status_icon(status)
icon = WEBUI2_REPO_STATUS_ICONS[status] || 'eye'
"fas fa-#{icon}"
end

# TODO: bento_only
def tab(id, text, opts)
opts[:package] = @package.to_s if @package
Expand Down

0 comments on commit 418bfd9

Please sign in to comment.