diff --git a/doc/user/analytics/analytics_dashboards.md b/doc/user/analytics/analytics_dashboards.md index 9d2c91b6bc87f741429eeec2ea9ee763b367b044..7fcae5019823f13d31d502f8ef201f8cc2320c09 100644 --- a/doc/user/analytics/analytics_dashboards.md +++ b/doc/user/analytics/analytics_dashboards.md @@ -69,6 +69,10 @@ You can use the dashboard designer to: ## View project dashboards +Prerequisite: + +- You must have at least the Developer role for the project. + To view a list of dashboards (both built-in and custom) for a project: 1. On the left sidebar, at the top, select **Search GitLab** (**{search}**) to find your project. diff --git a/ee/app/controllers/projects/analytics/dashboards_controller.rb b/ee/app/controllers/projects/analytics/dashboards_controller.rb index 93502243ba8f38de447e61bbaf36a051bb955493..6d479a134dc4c4365d49d3f8c72d55488f3e5d56 100644 --- a/ee/app/controllers/projects/analytics/dashboards_controller.rb +++ b/ee/app/controllers/projects/analytics/dashboards_controller.rb @@ -8,6 +8,7 @@ class DashboardsController < Projects::ApplicationController feature_category :product_analytics before_action :dashboards_enabled!, only: [:index] + before_action :authorize_read_product_analytics! before_action :authorize_read_combined_project_analytics_dashboards! before_action do push_frontend_feature_flag(:product_analytics_snowplow_support) diff --git a/ee/lib/ee/sidebars/projects/menus/analytics_menu.rb b/ee/lib/ee/sidebars/projects/menus/analytics_menu.rb index 99979dc2e091b7a1e72db3b05c6d0e6f7d19bc90..b4503eb2c860a56edd802cebf10d9da76654ed24 100644 --- a/ee/lib/ee/sidebars/projects/menus/analytics_menu.rb +++ b/ee/lib/ee/sidebars/projects/menus/analytics_menu.rb @@ -92,7 +92,8 @@ def merge_request_analytics_menu_item def dashboards_analytics_menu_item unless ::Feature.enabled?(:combined_analytics_dashboards, context.project) && context.project.licensed_feature_available?(:combined_project_analytics_dashboards) && - can?(context.current_user, :read_combined_project_analytics_dashboards, context.project) + can?(context.current_user, :read_combined_project_analytics_dashboards, context.project) && + can?(context.current_user, :read_product_analytics, context.project) return ::Sidebars::NilMenuItem.new(item_id: :dashboards_analytics) end diff --git a/ee/spec/features/projects/product_analytics/dashboards_shared_examples.rb b/ee/spec/features/projects/product_analytics/dashboards_shared_examples.rb index 9d90afec18507522675fbed2626d72a3900975d6..1bbb0b968b322b0d12046124ec073d85dae8b51c 100644 --- a/ee/spec/features/projects/product_analytics/dashboards_shared_examples.rb +++ b/ee/spec/features/projects/product_analytics/dashboards_shared_examples.rb @@ -117,6 +117,10 @@ end context 'without the correct user permissions' do + before do + project.add_reporter(user) + end + it_behaves_like 'does not render the product analytics list item' end diff --git a/ee/spec/lib/ee/sidebars/projects/menus/analytics_menu_spec.rb b/ee/spec/lib/ee/sidebars/projects/menus/analytics_menu_spec.rb index 1014e86f6cff732bf992eff99013a78de3965c35..8f1c612fdcaf7c0d556bbcba2e5179f8e4dfe08d 100644 --- a/ee/spec/lib/ee/sidebars/projects/menus/analytics_menu_spec.rb +++ b/ee/spec/lib/ee/sidebars/projects/menus/analytics_menu_spec.rb @@ -116,7 +116,7 @@ context 'with different user access levels' do where(:access_level, :has_menu_item) do nil | false - :reporter | true + :reporter | false :developer | true :maintainer | true end diff --git a/ee/spec/requests/projects/analytics/dashboards_controller_spec.rb b/ee/spec/requests/projects/analytics/dashboards_controller_spec.rb index d358a2f2cc4afa455e546f94dffc0e984dca3481..742b861461180a94f8fa32ee35566625b7b55091 100644 --- a/ee/spec/requests/projects/analytics/dashboards_controller_spec.rb +++ b/ee/spec/requests/projects/analytics/dashboards_controller_spec.rb @@ -79,7 +79,7 @@ context 'with the licensed feature' do where(:access_level, :example_to_run) do nil | 'returns not found' - :reporter | 'returns success' + :reporter | 'returns not found' :developer | 'returns success' :maintainer | 'returns success' end