- has_base_domain = @project.all_clusters.any? { |cluster| cluster.base_domain && !cluster.base_domain.empty? }

- link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe
- link_end = '</a>'.html_safe

- kubernetes_cluster_path = help_page_path('user/project/clusters/index')
- kubernetes_cluster_link_start = link_start % { url: kubernetes_cluster_path }

- base_domain_path = help_page_path('user/project/clusters/index', anchor: 'base-domain')
- base_domain_link_start = link_start % { url: base_domain_path }

.row
  .col-lg-12
    = form_for @project, url: project_settings_ci_cd_path(@project, anchor: 'autodevops-settings') do |f|
      = form_errors(@project)
      %fieldset.builds-feature.js-auto-devops-settings
        .form-group
          = f.fields_for :auto_devops_attributes, @auto_devops do |form|
            .card.auto-devops-card
              .card-body
                .form-check
                  = form.check_box :enabled, class: 'form-check-input js-toggle-extra-settings', checked: auto_devops_enabled, data: { qa_selector: 'enable_autodevops_checkbox' }
                  = form.label :enabled, class: 'form-check-label' do
                    %strong= s_('CICD|Default to Auto DevOps pipeline')
                    - if auto_devops_enabled
                      %span.badge.badge-info.js-instance-default-badge= badge_for_auto_devops_scope(@project)
                  .form-text.text-muted
                    = s_('CICD|The Auto DevOps pipeline will run if no alternative CI configuration file is found.')
                    = link_to _('More information'), help_page_path('topics/autodevops/index.md'), target: '_blank'
              .card-footer.js-extra-settings{ class: auto_devops_enabled || 'hidden' }
                - if @project.all_clusters.empty?
                  %p.settings-message.text-center
                    = s_('CICD|Add a %{kubernetes_cluster_link_start}Kubernetes cluster integration%{link_end} with a domain or create an AUTO_DEVOPS_PLATFORM_TARGET CI variable.').html_safe % { kubernetes_cluster_link_start: kubernetes_cluster_link_start, link_end: link_end }
                - elsif !has_base_domain
                  %p.settings-message.text-center
                    = s_('CICD|You must add a %{base_domain_link_start}base domain%{link_end} to your %{kubernetes_cluster_link_start}Kubernetes cluster%{link_end} in order for your deployment strategy to work.').html_safe % { base_domain_link_start: base_domain_link_start, kubernetes_cluster_link_start: kubernetes_cluster_link_start, link_end: link_end }
                %label.gl-mt-3
                  %strong= s_('CICD|Deployment strategy')
                .form-check
                  = form.radio_button :deploy_strategy, 'continuous', class: 'form-check-input'
                  = form.label :deploy_strategy_continuous, class: 'form-check-label' do
                    = s_('CICD|Continuous deployment to production')
                    = link_to sprite_icon('question-o'), help_page_path('topics/autodevops/stages.md', anchor: 'auto-deploy'), target: '_blank'

                .form-check
                  = form.radio_button :deploy_strategy, 'timed_incremental', class: 'form-check-input'
                  = form.label :deploy_strategy_timed_incremental, class: 'form-check-label' do
                    = s_('CICD|Continuous deployment to production using timed incremental rollout')
                    = link_to sprite_icon('question-o'), help_page_path('topics/autodevops/customize.md', anchor: 'timed-incremental-rollout-to-production'), target: '_blank'

                .form-check
                  = form.radio_button :deploy_strategy, 'manual', class: 'form-check-input'
                  = form.label :deploy_strategy_manual, class: 'form-check-label' do
                    = s_('CICD|Automatic deployment to staging, manual deployment to production')
                    = link_to sprite_icon('question-o'), help_page_path('topics/autodevops/customize.md', anchor: 'incremental-rollout-to-production'), target: '_blank'

          = f.submit _('Save changes'), class: "btn btn-success gl-mt-5", data: { qa_selector: 'save_changes_button' }
