Commit 8256666e authored by Mike Greiling's avatar Mike Greiling

Port of '38542-application-control-panel-in-settings-page' to EE

parent 1d2993a7
......@@ -22,4 +22,18 @@ document.addEventListener('DOMContentLoaded', () => {
errorBox: variableListEl.querySelector('.js-ci-variable-error-box'),
saveEndpoint: variableListEl.dataset.saveEndpoint,
});
// hide extra auto devops settings based on data-attributes
const autoDevOpsSettings = document.querySelector('.js-auto-devops-settings');
const autoDevOpsExtraSettings = document.querySelector('.js-extra-settings');
autoDevOpsSettings.addEventListener('click', event => {
const target = event.target;
if (target.classList.contains('js-toggle-extra-settings')) {
autoDevOpsExtraSettings.classList.toggle(
'hidden',
!!(target.dataset && target.dataset.hideExtraSettings),
);
}
});
});
......@@ -16,3 +16,12 @@
.registry-placeholder {
min-height: 60px;
}
.auto-devops-card {
margin-bottom: $gl-vert-padding;
> .card-body {
border-radius: $card-border-radius;
padding: $gl-padding $gl-padding-24;
}
}
......@@ -41,7 +41,7 @@ module Projects
:runners_token, :builds_enabled, :build_allow_git_fetch,
:build_timeout_human_readable, :build_coverage_regex, :public_builds,
:auto_cancel_pending_pipelines, :ci_config_path,
auto_devops_attributes: [:id, :domain, :enabled]
auto_devops_attributes: [:id, :domain, :enabled, :deploy_strategy]
)
end
......
class ProjectAutoDevops < ActiveRecord::Base
belongs_to :project
enum deploy_strategy: {
continuous: 0,
manual: 1
}
scope :enabled, -> { where(enabled: true) }
scope :disabled, -> { where(enabled: false) }
......@@ -20,6 +25,11 @@ class ProjectAutoDevops < ActiveRecord::Base
variables.append(key: 'AUTO_DEVOPS_DOMAIN',
value: domain.presence || instance_domain)
end
if manual?
variables.append(key: 'STAGING_ENABLED', value: 1)
variables.append(key: 'INCREMENTAL_ROLLOUT_ENABLED', value: 1)
end
end
end
end
.row.prepend-top-default
.row
.col-lg-12
= form_for @project, url: project_settings_ci_cd_path(@project) do |f|
= form_errors(@project)
%fieldset.builds-feature
%fieldset.builds-feature.js-auto-devops-settings
.form-group
- message = auto_devops_warning_message(@project)
- ci_file_formatted = '<code>.gitlab-ci.yml</code>'.html_safe
- if message
%p.settings-message.text-center
%p.auto-devops-warning-message.settings-message.text-center
= message.html_safe
= f.fields_for :auto_devops_attributes, @auto_devops do |form|
.form-check
= form.radio_button :enabled, 'true', class: 'form-check-input'
= form.label :enabled_true, class: 'form-check-label' do
%strong= s_('CICD|Enable Auto DevOps')
%br
= s_('CICD|The Auto DevOps pipeline configuration will be used when there is no %{ci_file} in the project.').html_safe % { ci_file: ci_file_formatted }
.card.auto-devops-card
.card-body
.form-check
= form.radio_button :enabled, 'true', class: 'form-check-input js-toggle-extra-settings'
= form.label :enabled_true, class: 'form-check-label' do
%strong= s_('CICD|Enable Auto DevOps')
.form-text.text-muted
= s_('CICD|The Auto DevOps pipeline configuration will be used when there is no %{ci_file} in the project.').html_safe % { ci_file: ci_file_formatted }
.form-check
= form.radio_button :enabled, 'false', class: 'form-check-input'
= form.label :enabled_false, class: 'form-check-label' do
%strong= s_('CICD|Disable Auto DevOps')
%br
= s_('CICD|An explicit %{ci_file} needs to be specified before you can begin using Continuous Integration and Delivery.').html_safe % { ci_file: ci_file_formatted }
.card.auto-devops-card
.card-body
.form-check
= form.radio_button :enabled, '', class: 'form-check-input js-toggle-extra-settings'
= form.label :enabled_, class: 'form-check-label' do
%strong= s_('CICD|Instance default (%{state})') % { state: "#{Gitlab::CurrentSettings.auto_devops_enabled? ? _('enabled') : _('disabled')}" }
.form-text.text-muted
= s_('CICD|Follow the instance default to either have Auto DevOps enabled or disabled when there is no project specific %{ci_file}.').html_safe % { ci_file: ci_file_formatted }
.form-check
= form.radio_button :enabled, '', class: 'form-check-input'
= form.label :enabled_, class: 'form-check-label' do
%strong= s_('CICD|Instance default (%{state})') % { state: "#{Gitlab::CurrentSettings.auto_devops_enabled? ? _('enabled') : _('disabled')}" }
%br
= s_('CICD|Follow the instance default to either have Auto DevOps enabled or disabled when there is no project specific %{ci_file}.').html_safe % { ci_file: ci_file_formatted }
.card.auto-devops-card.js-extra-settings{ class: form.object&.enabled == false ? 'hidden' : nil }
.card-body.bg-light
= form.label :domain do
%strong= _('Domain')
= form.text_field :domain, class: 'form-control', placeholder: 'domain.com'
.form-text.text-muted
= s_('CICD|You need to specify a domain if you want to use Auto Review Apps and Auto Deploy stages.')
- if cluster_ingress_ip = cluster_ingress_ip(@project)
= s_('%{nip_domain} can be used as an alternative to a custom domain.').html_safe % { nip_domain: "<code>#{cluster_ingress_ip}.nip.io</code>".html_safe }
= link_to icon('question-circle'), help_page_path('topics/autodevops/index.md', anchor: 'auto-devops-base-domain'), target: '_blank'
= form.label :domain, class:"prepend-top-10" do
= _('Domain')
= form.text_field :domain, class: 'form-control', placeholder: 'domain.com'
.form-text.text-muted
= s_('CICD|A domain is required to use Auto Review Apps and Auto Deploy Stages.')
- if cluster_ingress_ip = cluster_ingress_ip(@project)
= s_('%{nip_domain} can be used as an alternative to a custom domain.').html_safe % { nip_domain: "<code>#{cluster_ingress_ip}.nip.io</code>".html_safe }
= link_to icon('question-circle'), help_page_path('topics/autodevops/index.md', anchor: 'auto-devops-base-domain'), target: '_blank'
.form-text.text-muted
= s_('CICD|Do not set up a domain here if you are setting up multiple Kubernetes clusters with Auto DevOps.')
= link_to icon('question-circle'), help_page_path('topics/autodevops/index.md', anchor: 'using-multiple-kubernetes-clusters'), target: '_blank'
-# EE-specific start
.form-text.text-muted
= s_('CICD|Do not set up a domain here if you are setting up multiple Kubernetes clusters with Auto DevOps.')
= link_to icon('question-circle'), help_page_path('topics/autodevops/index.md', anchor: 'using-multiple-kubernetes-clusters'), target: '_blank'
-# EE-specific end
%label.prepend-top-10
%strong= s_('CICD|Deployment strategy')
%p.settings-message.text-center
= s_('CICD|Deployment strategy needs a domain name to work correctly.')
.form-check
= form.radio_button :deploy_strategy, 'continuous', class: 'form-check-input'
= form.label :deploy_strategy_continuous, class: 'form-check-label' do
%strong= s_('CICD|Continuous deployment to production')
= link_to icon('question-circle'), help_page_path('topics/autodevops/index.md', anchor: 'auto-deploy'), target: '_blank'
.form-check
= form.radio_button :deploy_strategy, 'manual', class: 'form-check-input'
= form.label :deploy_strategy_manual, class: 'form-check-label' do
%strong= s_('CICD|Automatic deployment to staging, manual deployment to production')
= link_to icon('question-circle'), help_page_path('ci/environments.md', anchor: 'manually-deploying-to-environments'), target: '_blank'
.card.auto-devops-card
.card-body
.form-check
= form.radio_button :enabled, 'false', class: 'form-check-input js-toggle-extra-settings', data: { hide_extra_settings: true }
= form.label :enabled_false, class: 'form-check-label' do
%strong= s_('CICD|Disable Auto DevOps')
.form-text.text-muted
= s_('CICD|An explicit %{ci_file} needs to be specified before you can begin using Continuous Integration and Delivery.').html_safe % { ci_file: ci_file_formatted }
= f.submit 'Save changes', class: "btn btn-success prepend-top-15"
---
title: Add deploy strategies to the Auto DevOps settings
merge_request: 19172
author:
type: added
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class AddDeployStrategyToProjectAutoDevops < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default :project_auto_devops, :deploy_strategy, :integer, default: 0, allow_null: false
end
def down
remove_column :project_auto_devops, :deploy_strategy
end
end
......@@ -1946,6 +1946,7 @@ ActiveRecord::Schema.define(version: 20180605213516) do
t.datetime "updated_at", null: false
t.boolean "enabled"
t.string "domain"
t.integer "deploy_strategy", default: 0, null: false
end
add_index "project_auto_devops", ["project_id"], name: "index_project_auto_devops_on_project_id", unique: true, using: :btree
......
......@@ -3,5 +3,14 @@ FactoryBot.define do
project
enabled true
domain "example.com"
deploy_strategy :continuous
trait :manual do
deploy_strategy :manual
end
trait :disabled do
enabled false
end
end
end
......@@ -567,6 +567,7 @@ ProjectAutoDevops:
- id
- enabled
- domain
- deploy_strategy
- project_id
- created_at
- updated_at
......
......@@ -5,6 +5,8 @@ describe ProjectAutoDevops do
it { is_expected.to belong_to(:project) }
it { is_expected.to define_enum_for(:deploy_strategy) }
it { is_expected.to respond_to(:created_at) }
it { is_expected.to respond_to(:updated_at) }
......@@ -67,6 +69,32 @@ describe ProjectAutoDevops do
end
end
context 'when deploy_strategy is manual' do
let(:domain) { 'example.com' }
before do
auto_devops.deploy_strategy = 'manual'
end
it do
expect(auto_devops.predefined_variables.map { |var| var[:key] })
.to include("STAGING_ENABLED", "INCREMENTAL_ROLLOUT_ENABLED")
end
end
context 'when deploy_strategy is continuous' do
let(:domain) { 'example.com' }
before do
auto_devops.deploy_strategy = 'continuous'
end
it do
expect(auto_devops.predefined_variables.map { |var| var[:key] })
.not_to include("STAGING_ENABLED", "INCREMENTAL_ROLLOUT_ENABLED")
end
end
def domain_variable
{ key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true }
end
......
......@@ -12,7 +12,7 @@ describe 'projects/settings/ci_cd/_autodevops_form' do
it 'shows warning message' do
render
expect(rendered).to have_css('.settings-message')
expect(rendered).to have_css('.auto-devops-warning-message')
expect(rendered).to have_text('Auto Review Apps and Auto Deploy need a domain name and a')
expect(rendered).to have_link('Kubernetes cluster')
end
......@@ -26,7 +26,7 @@ describe 'projects/settings/ci_cd/_autodevops_form' do
it 'shows warning message' do
render
expect(rendered).to have_css('.settings-message')
expect(rendered).to have_css('.auto-devops-warning-message')
expect(rendered).to have_text('Auto Review Apps and Auto Deploy need a')
expect(rendered).to have_link('Kubernetes cluster')
end
......@@ -42,7 +42,7 @@ describe 'projects/settings/ci_cd/_autodevops_form' do
it 'shows warning message' do
render
expect(rendered).to have_css('.settings-message')
expect(rendered).to have_css('.auto-devops-warning-message')
expect(rendered).to have_text('Auto Review Apps and Auto Deploy need a domain name to work correctly.')
end
end
......@@ -55,7 +55,7 @@ describe 'projects/settings/ci_cd/_autodevops_form' do
it 'does not show warning message' do
render
expect(rendered).not_to have_css('.settings-message')
expect(rendered).not_to have_css('.auto-devops-warning-message')
end
end
end
......
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