Skip to content
代码片段 群组 项目
提交 75a10d45 编辑于 作者: Luke Duncalfe's avatar Luke Duncalfe
浏览文件

Merge branch '413980-hide-analytics-dashboards-for-users-without-access' into 'master'

No related branches found
No related tags found
无相关合并请求
......@@ -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.
......
......@@ -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(:combined_analytics_dashboards_editor, project)
......
......@@ -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
......
......@@ -15,82 +15,15 @@
subject(:visit_page) { visit project_analytics_dashboards_path(project) }
shared_examples 'renders not found' do
before do
visit_page
end
it do
expect(page).to have_content(s_('404|Page Not Found'))
end
end
context 'with the combined dashboards feature flag disabled' do
before do
stub_feature_flags(combined_analytics_dashboards: false)
end
it_behaves_like 'renders not found'
end
context 'with the combined dashboards feature flag enabled' do
before do
stub_feature_flags(combined_analytics_dashboards: true)
end
context 'with the licensed feature disabled' do
before do
stub_licensed_features(combined_project_analytics_dashboards: false)
end
it_behaves_like 'renders not found'
end
context 'with the licensed feature enabled' do
before do
stub_licensed_features(combined_project_analytics_dashboards: true)
end
context 'without access to the project' do
it_behaves_like 'renders not found'
end
context 'with access to the project' do
before do
project.add_guest(user)
end
context 'when loading the default page' do
before do
visit_page
end
it 'renders the dashboards list' do
expect(page).to have_content('Analytics dashboards')
end
it 'has the dashboards list breadcrumb' do
page.within(find('[data-testid="breadcrumb-links"]')) do
expect(page).to have_link(
s_('Analytics|Analytics dashboards'),
href: "#{project_analytics_dashboards_path(project)}/"
)
end
end
end
it_behaves_like 'product analytics dashboards' do
let(:project_settings) { { product_analytics_instrumentation_key: 456 } }
let(:application_settings) do
{
product_analytics_configurator_connection_string: 'https://configurator.example.com',
product_analytics_data_collector_host: 'https://collector.example.com',
cube_api_base_url: 'https://cube.example.com',
cube_api_key: '123'
}
end
end
end
it_behaves_like 'product analytics dashboards' do
let(:project_settings) { { product_analytics_instrumentation_key: 456 } }
let(:application_settings) do
{
product_analytics_configurator_connection_string: 'https://configurator.example.com',
product_analytics_data_collector_host: 'https://collector.example.com',
cube_api_base_url: 'https://cube.example.com',
cube_api_key: '123'
}
end
end
end
......@@ -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
......
......@@ -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
......
......@@ -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
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册