Commit 88bc2340 authored by Adam Hegyi's avatar Adam Hegyi

Eliminate group_level_cycle_analytics FF

This commit removes the `group_level_cycle_analytics` feature flag.
parent d4083f52
...@@ -2,9 +2,7 @@ ...@@ -2,9 +2,7 @@
class Analytics::AnalyticsController < Analytics::ApplicationController class Analytics::AnalyticsController < Analytics::ApplicationController
def index def index
if Feature.disabled?(:group_level_cycle_analytics, default_enabled: true) && Gitlab::Analytics.cycle_analytics_enabled? if can?(current_user, :read_instance_statistics)
redirect_to analytics_cycle_analytics_path
elsif can?(current_user, :read_instance_statistics)
redirect_to instance_statistics_dev_ops_score_index_path redirect_to instance_statistics_dev_ops_score_index_path
else else
render_404 render_404
......
...@@ -38,7 +38,6 @@ module EE ...@@ -38,7 +38,6 @@ module EE
end end
def group_cycle_analytics_navbar_link(group, current_user) def group_cycle_analytics_navbar_link(group, current_user)
return unless ::Feature.enabled?(:group_level_cycle_analytics, default_enabled: true)
return unless group_sidebar_link?(:cycle_analytics) return unless group_sidebar_link?(:cycle_analytics)
navbar_sub_item( navbar_sub_item(
......
...@@ -32,15 +32,11 @@ module EE ...@@ -32,15 +32,11 @@ module EE
end end
def analytics_nav_url def analytics_nav_url
if ::Feature.disabled?(:group_level_cycle_analytics, default_enabled: true) && ::Gitlab::Analytics.any_features_enabled?
return analytics_root_path
end
if can?(current_user, :read_instance_statistics) if can?(current_user, :read_instance_statistics)
return instance_statistics_root_path instance_statistics_root_path
else
'errors/not_found'
end end
'errors/not_found'
end end
private private
...@@ -48,8 +44,6 @@ module EE ...@@ -48,8 +44,6 @@ module EE
override :get_dashboard_nav_links override :get_dashboard_nav_links
def get_dashboard_nav_links def get_dashboard_nav_links
super.tap do |links| super.tap do |links|
links << :analytics if ::Feature.disabled?(:group_level_cycle_analytics, default_enabled: true) && ::Gitlab::Analytics.any_features_enabled?
if can?(current_user, :read_operations_dashboard) if can?(current_user, :read_operations_dashboard)
links << :environments if ::Feature.enabled?(:environments_dashboard, current_user, default_enabled: true) links << :environments if ::Feature.enabled?(:environments_dashboard, current_user, default_enabled: true)
links << :operations links << :operations
......
...@@ -6,19 +6,6 @@ ...@@ -6,19 +6,6 @@
= sprite_icon('chart', size: 24) = sprite_icon('chart', size: 24)
.sidebar-context-title= _('Analytics') .sidebar-context-title= _('Analytics')
%ul.sidebar-top-level-items %ul.sidebar-top-level-items
- if Feature.disabled?(:group_level_cycle_analytics, default_enabled: true) && Gitlab::Analytics.cycle_analytics_enabled?
= nav_link(controller: :cycle_analytics) do
= link_to analytics_cycle_analytics_path, class: 'qa-sidebar-cycle-analytics' do
.nav-icon-container
= sprite_icon('repeat')
%span.nav-item-name
= _('Value Stream Analytics')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: :cycle_analytics, html_options: { class: "fly-out-top-item qa-sidebar-cycle-analytics-fly-out" } ) do
= link_to analytics_cycle_analytics_path do
%strong.fly-out-top-item-name
= _('Value Stream Analytics')
= render_ce 'layouts/nav/sidebar/instance_statistics_links' = render_ce 'layouts/nav/sidebar/instance_statistics_links'
= render 'shared/sidebar_toggle_button' = render 'shared/sidebar_toggle_button'
...@@ -33,7 +33,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do ...@@ -33,7 +33,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
end end
namespace :analytics do namespace :analytics do
resource :productivity_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.productivity_analytics_enabled? } resource :productivity_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.productivity_analytics_enabled? }
resource :cycle_analytics, path: 'value_stream_analytics', only: :show, constraints: -> (req) { Feature.enabled?(:group_level_cycle_analytics, default_enabled: true) && Gitlab::Analytics.cycle_analytics_enabled? } resource :cycle_analytics, path: 'value_stream_analytics', only: :show, constraints: -> (req) { Gitlab::Analytics.cycle_analytics_enabled? }
end end
resource :ldap, only: [] do resource :ldap, only: [] do
......
...@@ -3,28 +3,13 @@ ...@@ -3,28 +3,13 @@
require 'spec_helper' require 'spec_helper'
describe Analytics::AnalyticsController do describe Analytics::AnalyticsController do
include AnalyticsHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
stub_feature_flags(group_level_cycle_analytics: false)
sign_in(user) sign_in(user)
disable_all_analytics_feature_flags
end end
describe 'GET index' do describe 'GET index' do
describe 'redirects to the first enabled analytics page' do
it 'redirects to value stream analytics' do
stub_feature_flags(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG => true)
get :index
expect(response).to redirect_to(analytics_cycle_analytics_path)
end
end
it 'renders devops score page when all the analytics feature flags are disabled' do it 'renders devops score page when all the analytics feature flags are disabled' do
get :index get :index
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe 'accessing the analytics workspace' do describe 'accessing the analytics workspace' do
include AnalyticsHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe 'Showing analytics' do describe 'Showing analytics' do
include AnalyticsHelpers
before do before do
sign_in user if user sign_in user if user
end end
...@@ -25,7 +23,6 @@ describe 'Showing analytics' do ...@@ -25,7 +23,6 @@ describe 'Showing analytics' do
context 'without access to instance statistics and analytics features' do context 'without access to instance statistics and analytics features' do
before do before do
disable_all_analytics_feature_flags
stub_application_setting(instance_statistics_visibility_private: true) stub_application_setting(instance_statistics_visibility_private: true)
end end
......
...@@ -3,53 +3,31 @@ ...@@ -3,53 +3,31 @@
require 'spec_helper' require 'spec_helper'
describe DashboardHelper, type: :helper do describe DashboardHelper, type: :helper do
include AnalyticsHelpers
let(:user) { build(:user) } let(:user) { build(:user) }
describe '#dashboard_nav_links' do describe '#dashboard_nav_links' do
before do before do
allow(helper).to receive(:current_user).and_return(user) allow(helper).to receive(:current_user).and_return(user)
stub_feature_flags(group_level_cycle_analytics: false)
end end
describe 'analytics' do describe 'analytics' do
context 'when at least one analytics feature is enabled' do context 'and the user has no access to instance statistics features' do
before do before do
enable_only_one_analytics_feature_flag
stub_user_permissions_for(:analytics, false) stub_user_permissions_for(:analytics, false)
end end
it 'includes analytics' do it 'does not include analytics' do
expect(helper.dashboard_nav_links).to include(:analytics) expect(helper.dashboard_nav_links).not_to include(:analytics)
end end
end end
context 'when all analytics features are disabled' do context 'and the user has access to instance statistics features' do
before do before do
disable_all_analytics_feature_flags stub_user_permissions_for(:analytics, true)
end end
context 'and the user has no access to instance statistics features' do it 'does include analytics' do
before do expect(helper.dashboard_nav_links).to include(:analytics)
stub_user_permissions_for(:analytics, false)
end
it 'does not include analytics' do
expect(helper.dashboard_nav_links).not_to include(:analytics)
end
end
context 'and the user has access to instance statistics features' do
before do
stub_user_permissions_for(:analytics, true)
end
it 'does include analytics' do
expect(helper.dashboard_nav_links).to include(:analytics)
end
end end
end end
end end
...@@ -239,22 +217,10 @@ describe DashboardHelper, type: :helper do ...@@ -239,22 +217,10 @@ describe DashboardHelper, type: :helper do
describe 'analytics_nav_url' do describe 'analytics_nav_url' do
before do before do
stub_feature_flags(group_level_cycle_analytics: false)
allow(helper).to receive(:current_user).and_return(user) allow(helper).to receive(:current_user).and_return(user)
end end
context 'when any analytics features are enabled' do
it 'returns the analytics root path' do
expect(helper.analytics_nav_url).to match(analytics_root_path)
end
end
context 'when analytics features are disabled' do context 'when analytics features are disabled' do
before do
disable_all_analytics_feature_flags
end
context 'and user has access to instance statistics features' do context 'and user has access to instance statistics features' do
before do before do
allow(helper).to receive(:can?) { true } allow(helper).to receive(:can?) { true }
......
# frozen_string_literal: true
# Helper for analytics related features
module AnalyticsHelpers
def disable_all_analytics_feature_flags
Gitlab::Analytics::FEATURE_FLAGS.each do |flag|
stub_feature_flags(flag => false)
end
end
def enable_only_one_analytics_feature_flag
Gitlab::Analytics::FEATURE_FLAGS.each_with_index do |flag, i|
stub_feature_flags(flag => i == 0)
end
end
end
...@@ -3,14 +3,8 @@ ...@@ -3,14 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe 'layouts/nav/sidebar/_analytics' do describe 'layouts/nav/sidebar/_analytics' do
include AnalyticsHelpers
it_behaves_like 'has nav sidebar' it_behaves_like 'has nav sidebar'
before do
stub_feature_flags(group_level_cycle_analytics: false)
end
context 'top-level items' do context 'top-level items' do
context 'when feature flags are enabled' do context 'when feature flags are enabled' do
it 'has `Analytics` link' do it 'has `Analytics` link' do
...@@ -21,14 +15,6 @@ describe 'layouts/nav/sidebar/_analytics' do ...@@ -21,14 +15,6 @@ describe 'layouts/nav/sidebar/_analytics' do
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#chart">/) expect(rendered).to match(/<use xlink:href=".+?icons-.+?#chart">/)
end end
it 'has `Value Stream` link' do
render
expect(rendered).to have_content('Value Stream')
expect(rendered).to include(analytics_cycle_analytics_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#repeat">/)
end
context 'and user has access to instance statistics features' do context 'and user has access to instance statistics features' do
before do before do
allow(view).to receive(:can?) { true } allow(view).to receive(:can?) { true }
...@@ -65,46 +51,38 @@ describe 'layouts/nav/sidebar/_analytics' do ...@@ -65,46 +51,38 @@ describe 'layouts/nav/sidebar/_analytics' do
end end
end end
context 'when feature flags are disabled' do context 'when user has access to instance statistics features' do
it 'no analytics links are rendered' do before do
disable_all_analytics_feature_flags allow(view).to receive(:can?) { true }
expect(rendered).not_to have_content('Value Stream')
end end
context 'and user has access to instance statistics features' do it 'has `DevOps Score` link' do
before do render
allow(view).to receive(:can?) { true }
end
it 'has `DevOps Score` link' do
render
expect(rendered).to have_content('DevOps Score') expect(rendered).to have_content('DevOps Score')
expect(rendered).to include(instance_statistics_dev_ops_score_index_path) expect(rendered).to include(instance_statistics_dev_ops_score_index_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#comment">/) expect(rendered).to match(/<use xlink:href=".+?icons-.+?#comment">/)
end end
it 'has `Cohorts` link' do it 'has `Cohorts` link' do
render render
expect(rendered).to have_content('Cohorts') expect(rendered).to have_content('Cohorts')
expect(rendered).to include(instance_statistics_cohorts_path) expect(rendered).to include(instance_statistics_cohorts_path)
expect(rendered).to match(/<use xlink:href=".+?icons-.+?#users">/) expect(rendered).to match(/<use xlink:href=".+?icons-.+?#users">/)
end
end end
end
context 'and user does not have access to instance statistics features' do context 'and user does not have access to instance statistics features' do
before do before do
allow(view).to receive(:can?) { false } allow(view).to receive(:can?) { false }
end end
it 'no instance statistics links are rendered' do it 'no instance statistics links are rendered' do
render render
expect(rendered).not_to have_content('DevOps Score') expect(rendered).not_to have_content('DevOps Score')
expect(rendered).not_to have_content('Cohorts') expect(rendered).not_to have_content('Cohorts')
end
end end
end 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