Commit eb370124 authored by Doug Stull's avatar Doug Stull

Merge branch '343840-resolve-ee-ce-difference-of-group-navbar-analytics-menu-item-2' into 'master'

Remove Group Analytics menu item from unlicensed EE

See merge request gitlab-org/gitlab!76212
parents e84a78bd fd295686
......@@ -4,7 +4,6 @@ class Groups::ContributionAnalyticsController < Groups::ApplicationController
include RedisTracking
before_action :group
before_action :check_contribution_analytics_available!
before_action :authorize_read_contribution_analytics!
layout 'group'
......@@ -33,18 +32,8 @@ class Groups::ContributionAnalyticsController < Groups::ApplicationController
.new(group: @group, from: params[:start_date] || 1.week.ago.to_date)
end
def check_contribution_analytics_available!
return if group_has_access_to_feature?
show_promotions? ? render_promotion : render_404
end
def authorize_read_contribution_analytics!
render_promotion unless user_has_access_to_feature?
end
def render_promotion
render 'shared/promotions/_promote_contribution_analytics'
render_404 unless group_has_access_to_feature? && user_has_access_to_feature?
end
def show_promotions?
......
- page_title _('Contribution Analytics')
- if @group.licensed_feature_available?(:contribution_analytics)
.mb-3
%h3
= _('Contribution Analytics')
.sub-header-block.gl-display-flex.gl-justify-content-space-between.gl-align-items-center
= s_('ContributionAnalytics|Contribution analytics for issues, merge requests and push events since %{start_date}') % { start_date: @start_date }
.js-contribution-analytics-date-selector{ data: { path: group_contribution_analytics_path } }
%div{ data: { qa_selector: 'push_content' } }
%h3= _('Pushes')
- code_push_count = @data_collector.total_push_count
- commits_count = @data_collector.total_commit_count
- person_count = @data_collector.total_push_author_count
- person_count_string = pluralize person_count, 'person'
- pushes_string = html_escape(s_('ContributionAnalytics|%{pushes} pushes, more than %{commits} commits by %{people} contributors.')) % { pushes: tag.strong(code_push_count), commits: tag.strong(commits_count), people: tag.strong(person_count_string) }
- if code_push_count > 0 || commits_count > 0 || person_count > 0
= pushes_string
- else
= s_('ContributionAnalytics|No pushes for the selected time period.')
.row
.col-md-12
#js_pushes_chart_vue
%div{ data: { qa_selector: 'merge_request_content' } }
%h3= s_('ContributionAnalytics|Merge requests')
- mr_closed_count = @data_collector.total_merge_requests_closed_count
- mr_created_count = @data_collector.total_merge_requests_created_count
- mr_merged_count = @data_collector.total_merge_requests_merged_count
- if mr_closed_count > 0 || mr_created_count > 0 || mr_merged_count > 0
= html_escape(s_('ContributionAnalytics|%{created_count} created, %{merged_count} merged, %{closed_count} closed.')) % { closed_count: tag.strong(mr_closed_count), created_count: tag.strong(mr_created_count), merged_count: tag.strong(mr_merged_count) }
- else
= s_('ContributionAnalytics|No merge requests for the selected time period.')
.row
.col-md-12
#js_merge_requests_chart_vue
%div{ data: { qa_selector: 'issue_content' } }
%h3= s_('ContributionAnalytics|Issues')
- issues_created_count = @data_collector.total_issues_created_count
- issues_closed_count = @data_collector.total_issues_closed_count
- if issues_created_count > 0 && issues_closed_count > 0
= html_escape(s_('ContributionAnalytics|%{created_count} created, %{closed_count} closed.')) % { created_count: tag.strong(issues_created_count), closed_count: tag.strong(issues_closed_count) }
- else
= s_('ContributionAnalytics|No issues for the selected time period.')
.row
.col-md-12
#js_issues_chart_vue
#js-group-member-contributions{ data: { member_contributions_path: group_contribution_analytics_path(@group, { start_date: @start_date, format: :json }) } }
-# haml-lint:disable InlineJavaScript
%script#js-analytics-data{ type: "application/json" }
= @data_collector.group_member_contributions_table_data.to_json.html_safe
- elsif show_promotions?
= render 'shared/promotions/promote_contribution_analytics'
.mb-3
%h3
= _('Contribution Analytics')
.sub-header-block.gl-display-flex.gl-justify-content-space-between.gl-align-items-center
= s_('ContributionAnalytics|Contribution analytics for issues, merge requests and push events since %{start_date}') % { start_date: @start_date }
.js-contribution-analytics-date-selector{ data: { path: group_contribution_analytics_path } }
%div{ data: { qa_selector: 'push_content' } }
%h3= _('Pushes')
- code_push_count = @data_collector.total_push_count
- commits_count = @data_collector.total_commit_count
- person_count = @data_collector.total_push_author_count
- person_count_string = pluralize person_count, 'person'
- pushes_string = html_escape(s_('ContributionAnalytics|%{pushes} pushes, more than %{commits} commits by %{people} contributors.')) % { pushes: tag.strong(code_push_count), commits: tag.strong(commits_count), people: tag.strong(person_count_string) }
- if code_push_count > 0 || commits_count > 0 || person_count > 0
= pushes_string
- else
= s_('ContributionAnalytics|No pushes for the selected time period.')
.row
.col-md-12
#js_pushes_chart_vue
%div{ data: { qa_selector: 'merge_request_content' } }
%h3= s_('ContributionAnalytics|Merge requests')
- mr_closed_count = @data_collector.total_merge_requests_closed_count
- mr_created_count = @data_collector.total_merge_requests_created_count
- mr_merged_count = @data_collector.total_merge_requests_merged_count
- if mr_closed_count > 0 || mr_created_count > 0 || mr_merged_count > 0
= html_escape(s_('ContributionAnalytics|%{created_count} created, %{merged_count} merged, %{closed_count} closed.')) % { closed_count: tag.strong(mr_closed_count), created_count: tag.strong(mr_created_count), merged_count: tag.strong(mr_merged_count) }
- else
= s_('ContributionAnalytics|No merge requests for the selected time period.')
.row
.col-md-12
#js_merge_requests_chart_vue
%div{ data: { qa_selector: 'issue_content' } }
%h3= s_('ContributionAnalytics|Issues')
- issues_created_count = @data_collector.total_issues_created_count
- issues_closed_count = @data_collector.total_issues_closed_count
- if issues_created_count > 0 && issues_closed_count > 0
= html_escape(s_('ContributionAnalytics|%{created_count} created, %{closed_count} closed.')) % { created_count: tag.strong(issues_created_count), closed_count: tag.strong(issues_closed_count) }
- else
= s_('ContributionAnalytics|No issues for the selected time period.')
.row
.col-md-12
#js_issues_chart_vue
#js-group-member-contributions{ data: { member_contributions_path: group_contribution_analytics_path(@group, { start_date: @start_date, format: :json }) } }
-# haml-lint:disable InlineJavaScript
%script#js-analytics-data{ type: "application/json" }
= @data_collector.group_member_contributions_table_data.to_json.html_safe
.center.user-callout.promotion-callout
.svg-container
= custom_icon('icon_contribution_analytics')
.user-callout-copy
%h4
- if Gitlab::CurrentSettings.should_check_namespace_plan?
= s_('Promotions|Upgrade your plan to activate Contribution Analytics.')
- else
= s_('Promotions|Track activity with Contribution Analytics.')
%p
= s_('Promotions|With Contribution Analytics you can have an overview for the activity of issues, merge requests, and push events of your organization and its members.')
= link_to _('Read more'), help_page_path('user/group/contribution_analytics/index.md'), target: '_blank'
= render 'shared/promotions/promotion_link_project', location: :contribution_analytics
......@@ -81,8 +81,7 @@ module Sidebars
end
def show_contribution_analytics?
can?(context.current_user, :read_group_contribution_analytics, context.group) ||
LicenseHelper.show_promotions?(context.current_user)
can?(context.current_user, :read_group_contribution_analytics, context.group)
end
def devops_adoption_menu_item
......
......@@ -69,11 +69,10 @@ RSpec.describe Groups::ContributionAnalyticsController do
context 'when user does not have access to the feature' do
let(:user_has_access_to_feature) { false }
it 'renders 403' do
it 'renders 404' do
request
expect(response).to render_template(
'shared/promotions/_promote_contribution_analytics')
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -93,30 +92,12 @@ RSpec.describe Groups::ContributionAnalyticsController do
allow(License).to receive(:feature_available?)
.with(:contribution_analytics)
.and_return(false)
allow(LicenseHelper).to receive(:show_promotions?)
.and_return(show_promotions)
end
context 'when promotions are on' do
let(:show_promotions) { true }
it 'renders promotions page' do
request
expect(response).to render_template(
'shared/promotions/_promote_contribution_analytics')
end
end
context 'when promotions are not on' do
let(:show_promotions) { false }
it 'renders 404' do
request
it 'renders 404' do
request
expect(response).to have_gitlab_http_status(:not_found)
end
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -275,22 +275,6 @@ RSpec.describe 'Promotions', :js do
end
end
describe 'for group contribution analytics', :js do
before do
allow(License).to receive(:current).and_return(nil)
stub_application_setting(check_namespace_plan: false)
group.add_owner(user)
sign_in(user)
end
it 'appears on the page' do
visit group_contribution_analytics_path(group)
expect(find('.user-callout-copy')).to have_content 'Track activity with Contribution Analytics.'
end
end
describe 'for group webhooks' do
before do
allow(License).to receive(:current).and_return(nil)
......
......@@ -140,14 +140,8 @@ RSpec.describe Sidebars::Groups::Menus::AnalyticsMenu do
describe 'when the user does not have access' do
let(:user) { nil }
specify { is_expected.to be_nil }
describe 'when show_promotions? is true' do
specify do
allow(LicenseHelper).to receive(:show_promotions?).and_return(true)
is_expected.not_to be_nil
end
it 'is not available' do
is_expected.to be_nil
end
end
end
......
......@@ -348,11 +348,7 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
stub_licensed_features(contribution_analytics: false)
end
context 'we do not show promotions' do
before do
allow(LicenseHelper).to receive(:show_promotions?).and_return(false)
end
context 'we do not show Contribution' do
it 'is not visible' do
render
......@@ -369,12 +365,10 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
allow(view).to receive(:can?) { |*args| Ability.allowed?(*args) }
end
it 'is visible when there is no valid license but we show promotions' do
stub_licensed_features(contribution_analytics: false)
it 'is not visible' do
render
expect(rendered).to have_text 'Contribution'
expect(rendered).not_to have_text 'Contribution'
end
end
......
......@@ -28336,9 +28336,6 @@ msgstr ""
msgid "Promotions|This feature is locked."
msgstr ""
msgid "Promotions|Track activity with Contribution Analytics."
msgstr ""
msgid "Promotions|Try it for free"
msgstr ""
......@@ -28351,9 +28348,6 @@ msgstr ""
msgid "Promotions|Upgrade your plan to activate Audit Events."
msgstr ""
msgid "Promotions|Upgrade your plan to activate Contribution Analytics."
msgstr ""
msgid "Promotions|Upgrade your plan to activate Group Webhooks."
msgstr ""
......@@ -28378,9 +28372,6 @@ msgstr ""
msgid "Promotions|When you have a lot of issues, it can be hard to get an overview. By adding a weight to your issues, you can get a better idea of the effort, cost, required time, or value of each, and so better manage them."
msgstr ""
msgid "Promotions|With Contribution Analytics you can have an overview for the activity of issues, merge requests, and push events of your organization and its members."
msgstr ""
msgid "Promotions|You can restrict access to protected branches by choosing a role (Maintainers, Developers) as well as certain users."
msgstr ""
......
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