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