From 2faf4a043740b9cd168a65027abf721aeeed29ed Mon Sep 17 00:00:00 2001
From: Dan Jensen <djensen@gitlab.com>
Date: Wed, 13 Jan 2021 08:31:57 +0000
Subject: [PATCH] Consider DevOps Adoption Report a Beta feature

This restores the recently-removed feature flag for the DevOps Adoption
Report feature, except now defaulting to false, and adds a "Beta
feature" note to the documentation. This is intended to prepare us to
pivot the feature in the near future, which is likely to involve
breaking changes.
---
 app/views/admin/dev_ops_report/show.html.haml |  2 +-
 .../development/devops_adoption_feature.yml   |  8 ++++++++
 .../admin_area/analytics/dev_ops_report.md    | 20 ++++++++++++++++++-
 ...er-devops-adoption-report-beta-feature.yml |  5 +++++
 .../admin/admin_dev_ops_report_spec.rb        | 16 +++++++++++++--
 5 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100644 config/feature_flags/development/devops_adoption_feature.yml
 create mode 100644 ee/changelogs/unreleased/297434-consider-devops-adoption-report-beta-feature.yml

diff --git a/app/views/admin/dev_ops_report/show.html.haml b/app/views/admin/dev_ops_report/show.html.haml
index 19ce285162f5..733c0de9fe97 100644
--- a/app/views/admin/dev_ops_report/show.html.haml
+++ b/app/views/admin/dev_ops_report/show.html.haml
@@ -3,7 +3,7 @@
 
 .container
   .gl-mt-3
-    - if Gitlab.ee? && License.feature_available?(:devops_adoption)
+    - if Gitlab.ee? && Feature.enabled?(:devops_adoption_feature, default_enabled: false) && License.feature_available?(:devops_adoption)
       = render_if_exists 'admin/dev_ops_report/devops_tabs'
     - else
       = render 'report'
diff --git a/config/feature_flags/development/devops_adoption_feature.yml b/config/feature_flags/development/devops_adoption_feature.yml
new file mode 100644
index 000000000000..0b643b4e60ea
--- /dev/null
+++ b/config/feature_flags/development/devops_adoption_feature.yml
@@ -0,0 +1,8 @@
+---
+name: devops_adoption_feature
+introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/46005
+rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/271568
+milestone: '13.6'
+type: development
+group: group::optimize
+default_enabled: false
diff --git a/doc/user/admin_area/analytics/dev_ops_report.md b/doc/user/admin_area/analytics/dev_ops_report.md
index 75b99afa5265..80108fba0609 100644
--- a/doc/user/admin_area/analytics/dev_ops_report.md
+++ b/doc/user/admin_area/analytics/dev_ops_report.md
@@ -38,7 +38,7 @@ collected before this feature is available.
 
 ## DevOps Adoption **(ULTIMATE)**
 
-[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/247112) in GitLab 13.7.
+[Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/247112) in GitLab 13.7 as a [Beta feature](https://about.gitlab.com/handbook/product/gitlab-the-product/#beta).
 
 The DevOps Adoption tab shows you which segments of your organization are using the most essential features of GitLab:
 
@@ -61,3 +61,21 @@ DevOps Adoption allows you to:
 - Find the groups that have adopted certain features and can provide guidance to other groups on how to use those features.
 
 ![DevOps Report](img/dev_ops_adoption_v13_7.png)
+
+### Disable or enable DevOps Adoption
+
+DevOps Adoption is deployed behind a feature flag that is **disabled by default**.
+[GitLab administrators with access to the GitLab Rails console](../../../administration/feature_flags.md)
+can opt to enable it.
+
+To enable it:
+
+```ruby
+Feature.enable(:devops_adoption_feature)
+```
+
+To disable it:
+
+```ruby
+Feature.disable(:devops_adoption_feature)
+```
diff --git a/ee/changelogs/unreleased/297434-consider-devops-adoption-report-beta-feature.yml b/ee/changelogs/unreleased/297434-consider-devops-adoption-report-beta-feature.yml
new file mode 100644
index 000000000000..1bf2d748cff7
--- /dev/null
+++ b/ee/changelogs/unreleased/297434-consider-devops-adoption-report-beta-feature.yml
@@ -0,0 +1,5 @@
+---
+title: Add Beta feature warning to DevOps Adoption report, and restore feature flag
+merge_request: 51518
+author:
+type: changed
diff --git a/ee/spec/features/admin/admin_dev_ops_report_spec.rb b/ee/spec/features/admin/admin_dev_ops_report_spec.rb
index 32656cf180ed..8c75fba318ef 100644
--- a/ee/spec/features/admin/admin_dev_ops_report_spec.rb
+++ b/ee/spec/features/admin/admin_dev_ops_report_spec.rb
@@ -13,7 +13,19 @@
     gitlab_enable_admin_mode_sign_in(admin)
   end
 
-  context 'with ultimate license' do
+  context 'with devops_adoption_feature feature flag disabled' do
+    before do
+      stub_feature_flags(devops_adoption_feature: false)
+    end
+
+    it 'does not show the tabbed layout' do
+      visit admin_dev_ops_report_path
+
+      expect(page).not_to have_selector tabs_selector
+    end
+  end
+
+  context 'with ultimate license and devops_adoption_feature feature flag enabled' do
     before do
       stub_licensed_features(devops_adoption: true)
     end
@@ -129,7 +141,7 @@
     end
   end
 
-  context 'without ultimate license' do
+  context 'without ultimate license and devops_adoption_feature feature flag enabled' do
     before do
       stub_licensed_features(devops_adoption: false)
     end
-- 
GitLab