2017-09-05 13:39:19 +00:00
|
|
|
module AutoDevopsHelper
|
2017-09-05 11:35:31 +00:00
|
|
|
def show_auto_devops_callout?(project)
|
2017-09-12 12:00:50 +00:00
|
|
|
Feature.get(:auto_devops_banner_disabled).off? &&
|
|
|
|
show_callout?('auto_devops_settings_dismissed') &&
|
2017-09-07 11:23:05 +00:00
|
|
|
can?(current_user, :admin_pipeline, project) &&
|
2017-09-12 07:21:47 +00:00
|
|
|
project.has_auto_devops_implicitly_disabled? &&
|
|
|
|
!project.repository.gitlab_ci_yml &&
|
2017-09-16 13:02:37 +00:00
|
|
|
!project.ci_service
|
|
|
|
end
|
|
|
|
|
|
|
|
def auto_devops_warning_message(project)
|
2018-02-02 18:54:00 +00:00
|
|
|
if missing_auto_devops_service?(project)
|
2017-09-16 13:02:37 +00:00
|
|
|
params = {
|
2018-01-25 09:27:10 +00:00
|
|
|
kubernetes: link_to('Kubernetes cluster', project_clusters_path(project))
|
2017-09-16 13:02:37 +00:00
|
|
|
}
|
|
|
|
|
2018-02-02 18:54:00 +00:00
|
|
|
if missing_auto_devops_domain?(project)
|
2018-01-25 09:27:10 +00:00
|
|
|
_('Auto Review Apps and Auto Deploy need a domain name and a %{kubernetes} to work correctly.') % params
|
2017-09-16 13:02:37 +00:00
|
|
|
else
|
2018-01-25 09:27:10 +00:00
|
|
|
_('Auto Review Apps and Auto Deploy need a %{kubernetes} to work correctly.') % params
|
2017-09-16 13:02:37 +00:00
|
|
|
end
|
2018-02-02 18:54:00 +00:00
|
|
|
elsif missing_auto_devops_domain?(project)
|
2017-09-16 13:02:37 +00:00
|
|
|
_('Auto Review Apps and Auto Deploy need a domain name to work correctly.')
|
|
|
|
end
|
2017-09-05 11:35:31 +00:00
|
|
|
end
|
2018-02-01 22:29:11 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-02-02 18:54:00 +00:00
|
|
|
def missing_auto_devops_domain?(project)
|
2018-02-01 22:29:11 +00:00
|
|
|
!(project.auto_devops&.has_domain? || current_application_settings.auto_devops_domain.present?)
|
|
|
|
end
|
|
|
|
|
2018-02-02 18:54:00 +00:00
|
|
|
def missing_auto_devops_service?(project)
|
2018-02-01 22:29:11 +00:00
|
|
|
!project.deployment_platform&.active?
|
|
|
|
end
|
2017-09-05 11:35:31 +00:00
|
|
|
end
|