diff --git a/ee/app/controllers/analytics/reports/pages_controller.rb b/ee/app/controllers/analytics/reports/pages_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..b316c5c6117ca49435089b5291a7b1a3ab9bbe5a --- /dev/null +++ b/ee/app/controllers/analytics/reports/pages_controller.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Analytics + module Reports + class PagesController < ::ApplicationController + layout 'report_pages' + + before_action do + render_404 unless feature_enabled? && feature_available? + end + + def feature_enabled? + Feature.enabled?(Gitlab::Analytics::REPORT_PAGES_FEATURE_FLAG) + end + + def feature_available? + ::License.feature_available?(:group_activity_analytics) + end + end + end +end diff --git a/ee/app/views/analytics/reports/pages/show.html.haml b/ee/app/views/analytics/reports/pages/show.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..1becb885af07505bd1f55c6b5500f931c36f5a5e --- /dev/null +++ b/ee/app/views/analytics/reports/pages/show.html.haml @@ -0,0 +1,2 @@ +- page_title _("Reports") + diff --git a/ee/app/views/layouts/report_pages.html.haml b/ee/app/views/layouts/report_pages.html.haml new file mode 100644 index 0000000000000000000000000000000000000000..e042ea2e501a5c1410ee910af9c31d9eac34dec6 --- /dev/null +++ b/ee/app/views/layouts/report_pages.html.haml @@ -0,0 +1,3 @@ +- page_title _('Reports') + += render template: 'layouts/application' diff --git a/ee/config/routes/analytics.rb b/ee/config/routes/analytics.rb index ff0d1d3cf8aad3f3e54bf0bd3e4891783adc0c1d..2d24dc2882db6410e638a4d08ec2e63e38d73542 100644 --- a/ee/config/routes/analytics.rb +++ b/ee/config/routes/analytics.rb @@ -3,6 +3,10 @@ namespace :analytics do root to: 'analytics#index' + constraints(::Constraints::FeatureConstrainer.new(Gitlab::Analytics::REPORT_PAGES_FEATURE_FLAG)) do + get :report_pages, to: 'reports/pages#show' + end + constraints(-> (req) { Gitlab::Analytics.cycle_analytics_enabled? }) do resource :cycle_analytics, only: :show, path: 'value_stream_analytics' scope module: :cycle_analytics, as: 'cycle_analytics', path: 'value_stream_analytics' do diff --git a/ee/lib/gitlab/analytics.rb b/ee/lib/gitlab/analytics.rb index a1617f0521f9fabac0f5ddaef4de8ab5d343989e..733126340d5a06f4bea8454f3ec1bd5867a1e436 100644 --- a/ee/lib/gitlab/analytics.rb +++ b/ee/lib/gitlab/analytics.rb @@ -5,15 +5,18 @@ module Analytics # Normally each analytics feature should be guarded with a feature flag. CYCLE_ANALYTICS_FEATURE_FLAG = :cycle_analytics PRODUCTIVITY_ANALYTICS_FEATURE_FLAG = :productivity_analytics + REPORT_PAGES_FEATURE_FLAG = :report_pages FEATURE_FLAGS = [ CYCLE_ANALYTICS_FEATURE_FLAG, - PRODUCTIVITY_ANALYTICS_FEATURE_FLAG + PRODUCTIVITY_ANALYTICS_FEATURE_FLAG, + REPORT_PAGES_FEATURE_FLAG ].freeze FEATURE_FLAG_DEFAULTS = { PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true, - CYCLE_ANALYTICS_FEATURE_FLAG => true + CYCLE_ANALYTICS_FEATURE_FLAG => true, + REPORT_PAGES_FEATURE_FLAG => false }.freeze def self.any_features_enabled? @@ -28,6 +31,10 @@ def self.productivity_analytics_enabled? feature_enabled?(PRODUCTIVITY_ANALYTICS_FEATURE_FLAG) end + def self.report_pages_enabled? + feature_enabled?(REPORT_PAGES_FEATURE_FLAG) + end + def self.feature_enabled_by_default?(flag) !!FEATURE_FLAG_DEFAULTS[flag] end diff --git a/ee/spec/controllers/analytics/reports/pages_controller_spec.rb b/ee/spec/controllers/analytics/reports/pages_controller_spec.rb new file mode 100644 index 0000000000000000000000000000000000000000..734d624a940adadd5c0e87defbe4f378fb07e03d --- /dev/null +++ b/ee/spec/controllers/analytics/reports/pages_controller_spec.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Analytics::Reports::PagesController do + let(:user) { create(:user) } + + before do + sign_in(user) + + stub_licensed_features(group_activity_analytics: true) + stub_feature_flags(Gitlab::Analytics::REPORT_PAGES_FEATURE_FLAG => true) + end + + describe 'GET show' do + it 'renders the report page' do + get :show + + expect(response).to render_template :show + end + + context 'when the feature flag is false' do + before do + stub_feature_flags(Gitlab::Analytics::REPORT_PAGES_FEATURE_FLAG => false) + end + + it 'renders 404, not found' do + get :show + + expect(response).to have_gitlab_http_status(:not_found) + end + end + + context 'when the feature is not available' do + before do + stub_licensed_features(group_activity_analytics: false) + end + + it 'renders 404, not found' do + get :show + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end +end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index e791fd771d7ba46586c6e7dd42ca9cd03c52fad9..cc705334d2962706a0faeeb9b312927ad46ead80 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -19049,6 +19049,9 @@ msgstr "" msgid "Reporting" msgstr "" +msgid "Reports" +msgstr "" + msgid "Reports|%{combinedString} and %{resolvedString}" msgstr ""