Commit b8cd0f6a authored by Toon Claes's avatar Toon Claes Committed by Stan Hu

Make Geo helpers registry-neutral

Any type of registry can go through these helper functions.
parent 80fe87a4
......@@ -92,36 +92,36 @@ module EE
data: data
end
def project_registry_status(project_registry)
status_type = case project_registry.synchronization_state
def geo_registry_status(registry)
status_type = case registry.synchronization_state
when :failed then
'status-type-failure'
when :synced then
'status-type-success'
end
content_tag(:div, class: "project-status-content #{status_type}") do
icon = project_registry_status_icon(project_registry)
text = project_registry_status_text(project_registry)
content_tag(:div, class: "geo-status-content #{status_type}") do
icon = geo_registry_status_icon(registry)
text = geo_registry_status_text(registry)
[icon, text].join(' ').html_safe
end
end
def project_registry_status_icon(project_registry)
icon(STATUS_ICON_NAMES_BY_STATE.fetch(project_registry.synchronization_state, 'exclamation-triangle'))
def geo_registry_status_icon(registry)
icon STATUS_ICON_NAMES_BY_STATE.fetch(registry.synchronization_state, 'exclamation-triangle')
end
def project_registry_status_text(project_registry)
case project_registry.synchronization_state
def geo_registry_status_text(registry)
case registry.synchronization_state
when :never
s_('Geo|Not synced yet')
when :failed
s_('Geo|Failed')
when :pending
if project_registry.pending_synchronization?
if registry.pending_synchronization?
s_('Geo|Pending synchronization')
elsif project_registry.pending_verification?
elsif registry.pending_verification?
s_('Geo|Pending verification')
else
# should never reach this state, unless we introduce new behavior
......
......@@ -4,7 +4,7 @@
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
= project_registry_status(project_registry)
= geo_registry_status(project_registry)
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
......
......@@ -4,7 +4,7 @@
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
= project_registry_status(project_registry)
= geo_registry_status(project_registry)
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
......
......@@ -4,7 +4,7 @@
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
= project_registry_status(project_registry)
= geo_registry_status(project_registry)
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Next sync scheduled at')
......
......@@ -4,7 +4,7 @@
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Status')
= project_registry_status(project_registry)
= geo_registry_status(project_registry)
.col-sm.project-status-container
.project-status-title.text-muted
= s_('Geo|Last successful sync')
......
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