summaryrefslogtreecommitdiff
path: root/app/helpers/auto_devops_helper.rb
blob: ec6194d204f47ad0fe07d5c4ea20072fdf7be85f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module AutoDevopsHelper
  def show_auto_devops_callout?(project)
    Feature.get(:auto_devops_banner_disabled).off? &&
      show_callout?('auto_devops_settings_dismissed') &&
      can?(current_user, :admin_pipeline, project) &&
      project.has_auto_devops_implicitly_disabled? &&
      !project.repository.gitlab_ci_yml &&
      !project.ci_service
  end

  def show_run_auto_devops_pipeline_checkbox_for_instance_setting?(project)
    return false if project.repository.gitlab_ci_yml

    if project&.auto_devops&.enabled.present?
      !project.auto_devops.enabled && current_application_settings.auto_devops_enabled?
    else
      current_application_settings.auto_devops_enabled?
    end
  end

  def show_run_auto_devops_pipeline_checkbox_for_explicit_setting?(project)
    return false if project.repository.gitlab_ci_yml

    !project.auto_devops_enabled?
  end

  def auto_devops_warning_message(project)
    missing_domain = !project.auto_devops&.has_domain?
    missing_service = !project.deployment_platform&.active?

    if missing_service
      params = {
        kubernetes: link_to('Kubernetes service', edit_project_service_path(project, 'kubernetes'))
      }

      if missing_domain
        _('Auto Review Apps and Auto Deploy need a domain name and the %{kubernetes} to work correctly.') % params
      else
        _('Auto Review Apps and Auto Deploy need the %{kubernetes} to work correctly.') % params
      end
    elsif missing_domain
      _('Auto Review Apps and Auto Deploy need a domain name to work correctly.')
    end
  end
end