Commit 26f86603 authored by mfluharty's avatar mfluharty

Add license check for sidebar link

Add feature to license.rb
Check feature availability and grant access in group policy
Use availability/access to determine whether sidebar link is shown
parent 7c812336
......@@ -118,12 +118,10 @@ module EE
def get_group_sidebar_links
links = super
if can?(current_user, :read_group_cycle_analytics, @group)
links << :cycle_analytics
end
resources = [:cycle_analytics, :merge_request_analytics]
if can?(current_user, :read_group_merge_request_analytics, @group)
links << :merge_request_analytics
links += resources.select do |resource|
can?(current_user, "read_group_#{resource}".to_sym, @group)
end
if can?(current_user, :read_group_contribution_analytics, @group) || show_promotions?
......@@ -150,7 +148,7 @@ module EE
links << :iterations
end
if true
if @group.feature_available?(:group_repositories_analytics) && can?(current_user, :read_group_repositories_analytics, @group)
links << :repositories_analytics
end
......
......@@ -83,6 +83,7 @@ class License < ApplicationRecord
group_ip_restriction
group_merge_request_analytics
group_project_templates
group_repositories_analytics
group_saml
issues_analytics
jira_issues_integration
......
......@@ -25,6 +25,10 @@ module EE
@subject.feature_available?(:group_merge_request_analytics)
end
condition(:group_repositories_analytics_available) do
@subject.feature_available?(:group_repositories_analytics)
end
condition(:group_activity_analytics_available) do
@subject.feature_available?(:group_activity_analytics) && ::Feature.enabled?(:group_activity_analytics, @subject, default_enabled: true)
end
......@@ -131,6 +135,9 @@ module EE
rule { has_access & group_activity_analytics_available }
.enable :read_group_activity_analytics
rule { has_access & group_repositories_analytics_available }
.enable :read_group_repositories_analytics
rule { reporter & group_merge_request_analytics_available }
.enable :read_group_merge_request_analytics
......
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