Commit b1d5186d authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Allow all AutoDevOps banners to be disabled

Given the default in the development and production environment is
false, the negation of enabling is used in the flag to signal you'd turn
it off. It reads a bit awkward, but makes us have a migration less.

Fixes gitlab-org/gitlab-ce#37653
parent 7e992b0b
module AutoDevopsHelper module AutoDevopsHelper
def show_auto_devops_callout?(project) def show_auto_devops_callout?(project)
Feature.get(:auto_devops_banner_disabled).off? &&
show_callout?('auto_devops_settings_dismissed') && show_callout?('auto_devops_settings_dismissed') &&
can?(current_user, :admin_pipeline, project) && can?(current_user, :admin_pipeline, project) &&
project.has_auto_devops_implicitly_disabled? project.has_auto_devops_implicitly_disabled?
......
---
title: Allow all AutoDevOps banners to be turned off
merge_request:
author:
type: changed
...@@ -323,6 +323,23 @@ container registry. **Restarting a pod, scaling a service, or other actions whic ...@@ -323,6 +323,23 @@ container registry. **Restarting a pod, scaling a service, or other actions whic
require on-going access to the registry will fail**. On-going secure access is require on-going access to the registry will fail**. On-going secure access is
planned for a subsequent release. planned for a subsequent release.
## Disable the banner instance wide
If an administrater would like to disable the banners on an instance level, this
feature can be disabled either through the console:
```basb
$ gitlab-rails console
[1] pry(main)> Feature.get(:auto_devops_banner_disabled).disable
=> true
```
Or through the HTTP API with the admin access token:
```
curl --data "value=true" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/features/auto_devops_banner_disabled
```
## Troubleshooting ## Troubleshooting
- Auto Build and Auto Test may fail in detecting your language/framework. There - Auto Build and Auto Test may fail in detecting your language/framework. There
......
...@@ -10,6 +10,8 @@ describe AutoDevopsHelper do ...@@ -10,6 +10,8 @@ describe AutoDevopsHelper do
before do before do
allow(helper).to receive(:can?).with(user, :admin_pipeline, project) { allowed } allow(helper).to receive(:can?).with(user, :admin_pipeline, project) { allowed }
allow(helper).to receive(:current_user) { user } allow(helper).to receive(:current_user) { user }
Feature.get(:auto_devops_banner_disabled).disable
end end
subject { helper.show_auto_devops_callout?(project) } subject { helper.show_auto_devops_callout?(project) }
...@@ -18,6 +20,14 @@ describe AutoDevopsHelper do ...@@ -18,6 +20,14 @@ describe AutoDevopsHelper do
it { is_expected.to eq(true) } it { is_expected.to eq(true) }
end end
context 'when the banner is disabled by feature flag' do
it 'allows the feature flag to disable' do
Feature.get(:auto_devops_banner_disabled).enable
expect(subject).to be(false)
end
end
context 'when dismissed' do context 'when dismissed' do
before do before do
helper.request.cookies[:auto_devops_settings_dismissed] = 'true' helper.request.cookies[:auto_devops_settings_dismissed] = 'true'
......
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