Commit 5f081b28 authored by Adam Hegyi's avatar Adam Hegyi

Empty Merge Request analytics page

parent 1e4701d6
# frozen_string_literal: true
class Groups::Analytics::MergeRequestAnalyticsController < Groups::Analytics::ApplicationController
check_feature_flag Gitlab::Analytics::GROUP_MERGE_REQUEST_ANALYTICS_FEATURE_FLAG
layout 'group'
before_action :load_group
before_action -> {
check_feature_availability!(:group_merge_request_analytics)
}
before_action -> {
authorize_view_by_action!(:read_group_merge_request_analytics)
}
def show
end
end
......@@ -21,7 +21,8 @@ module EE
group_insights_navbar_link(group, current_user),
issues_analytics_navbar_link(group, current_user),
productivity_analytics_navbar_link(group, current_user),
group_cycle_analytics_navbar_link(group, current_user)
group_cycle_analytics_navbar_link(group, current_user),
group_merge_request_analytics_navbar_link(group, current_user)
].compact
end
......@@ -38,6 +39,16 @@ module EE
)
end
def group_merge_request_analytics_navbar_link(group, current_user)
return unless group_sidebar_link?(:merge_request_analytics)
navbar_sub_item(
title: _('Merge Requests'),
path: 'groups/analytics/merge_requests_analytics#show',
link: group_analytics_merge_request_analytics_path(group)
)
end
def group_cycle_analytics_navbar_link(group, current_user)
return unless group_sidebar_link?(:cycle_analytics)
......
......@@ -125,6 +125,10 @@ module EE
links << :cycle_analytics
end
if can?(current_user, :read_group_merge_request_analytics, @group)
links << :merge_request_analytics
end
if can?(current_user, :read_group_contribution_analytics, @group) || show_promotions?
links << :contribution_analytics
end
......
......@@ -74,11 +74,12 @@ class License < ApplicationRecord
feature_flags
file_locks
geo
github_project_service_integration
generic_alert_fingerprinting
github_project_service_integration
group_allowed_email_domains
group_coverage_reports
group_ip_restriction
group_merge_request_analytics
group_project_templates
group_saml
issues_analytics
......
......@@ -21,6 +21,10 @@ module EE
@subject.feature_available?(:cycle_analytics_for_groups)
end
condition(:group_merge_request_analytics_available) do
@subject.feature_available?(:group_merge_request_analytics)
end
condition(:group_activity_analytics_available) do
@subject.beta_feature_available?(:group_activity_analytics)
end
......@@ -124,6 +128,9 @@ module EE
rule { has_access & group_activity_analytics_available }
.enable :read_group_activity_analytics
rule { reporter & group_merge_request_analytics_available }
.enable :read_group_merge_request_analytics
rule { reporter & cycle_analytics_available }.policy do
enable :read_group_cycle_analytics, :create_group_stage, :read_group_stage, :update_group_stage, :delete_group_stage
end
......
......@@ -24,8 +24,8 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
namespace :analytics do
resource :productivity_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.productivity_analytics_enabled? }
resources :coverage_reports, only: :index, constraints: -> (req) { Gitlab::Analytics.group_coverage_reports_enabled? }
resource :merge_request_analytics, only: :show, constraints: -> (req) { Gitlab::Analytics.group_merge_request_analytics_enabled? }
feature_default_enabled = Gitlab::Analytics.feature_enabled_by_default?(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG)
constrainer = ::Constraints::FeatureConstrainer.new(Gitlab::Analytics::CYCLE_ANALYTICS_FEATURE_FLAG, default_enabled: feature_default_enabled)
......
......@@ -6,6 +6,7 @@ module Gitlab
CYCLE_ANALYTICS_FEATURE_FLAG = :cycle_analytics
PRODUCTIVITY_ANALYTICS_FEATURE_FLAG = :productivity_analytics
GROUP_COVERAGE_REPORTS_FEATURE_FLAG = :group_coverage_reports
GROUP_MERGE_REQUEST_ANALYTICS_FEATURE_FLAG = :group_merge_request_analytics
FEATURE_FLAGS = [
CYCLE_ANALYTICS_FEATURE_FLAG,
......@@ -35,6 +36,10 @@ module Gitlab
feature_enabled?(GROUP_COVERAGE_REPORTS_FEATURE_FLAG)
end
def self.group_merge_request_analytics_enabled?
feature_enabled?(GROUP_MERGE_REQUEST_ANALYTICS_FEATURE_FLAG)
end
def self.feature_enabled_by_default?(flag)
!!FEATURE_FLAG_DEFAULTS[flag]
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Groups::Analytics::MergeRequestAnalyticsController do
let_it_be(:current_user) { create(:user) }
let_it_be(:group) { create :group }
let_it_be(:feature_flag_name) { Gitlab::Analytics::GROUP_MERGE_REQUEST_ANALYTICS_FEATURE_FLAG }
let_it_be(:feature_name) { :group_merge_request_analytics }
before do
sign_in(current_user)
stub_feature_flags(feature_flag_name => true)
stub_licensed_features(feature_name => true)
end
describe 'GET show' do
subject { get :show, params: { group_id: group } }
before do
group.add_maintainer(current_user)
end
it { is_expected.to be_successful }
context 'when license is missing' do
before do
stub_licensed_features(feature_name => false)
end
it { is_expected.to have_gitlab_http_status(:forbidden) }
end
context 'when feature flag is off' do
before do
stub_feature_flags(feature_flag_name => false)
end
it { is_expected.to have_gitlab_http_status(:not_found) }
end
context 'when the user has no access to the group' do
before do
current_user.group_members.delete_all
end
it { is_expected.to have_gitlab_http_status(:forbidden) }
end
end
end
......@@ -37,6 +37,22 @@ RSpec.describe 'Group navbar' do
it_behaves_like 'verified navigation bar'
end
context 'when merge request analytics is available' do
before do
stub_licensed_features(group_merge_request_analytics: true)
insert_after_sub_nav_item(
_('Contribution'),
within: _('Analytics'),
new_sub_nav_item_name: _('Merge Requests')
)
visit group_path(group)
end
it_behaves_like 'verified navigation bar'
end
context 'when value stream analytics is available' do
before do
stub_licensed_features(cycle_analytics_for_groups: 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