Commit 2da3eb70 authored by James Fargher's avatar James Fargher

Merge branch '220494-setup-controller-and-routing-for-group-mr-activity-report-page' into 'master'

Add route, controller and view for generic reports page

See merge request gitlab-org/gitlab!35011
parents 496b8167 c59d5131
# 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
- page_title _('Reports')
= render template: 'layouts/application'
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
namespace :analytics do namespace :analytics do
root to: 'analytics#index' 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 constraints(-> (req) { Gitlab::Analytics.cycle_analytics_enabled? }) do
resource :cycle_analytics, only: :show, path: 'value_stream_analytics' resource :cycle_analytics, only: :show, path: 'value_stream_analytics'
scope module: :cycle_analytics, as: 'cycle_analytics', path: 'value_stream_analytics' do scope module: :cycle_analytics, as: 'cycle_analytics', path: 'value_stream_analytics' do
......
...@@ -5,15 +5,18 @@ module Gitlab ...@@ -5,15 +5,18 @@ module Gitlab
# Normally each analytics feature should be guarded with a feature flag. # Normally each analytics feature should be guarded with a feature flag.
CYCLE_ANALYTICS_FEATURE_FLAG = :cycle_analytics CYCLE_ANALYTICS_FEATURE_FLAG = :cycle_analytics
PRODUCTIVITY_ANALYTICS_FEATURE_FLAG = :productivity_analytics PRODUCTIVITY_ANALYTICS_FEATURE_FLAG = :productivity_analytics
REPORT_PAGES_FEATURE_FLAG = :report_pages
FEATURE_FLAGS = [ FEATURE_FLAGS = [
CYCLE_ANALYTICS_FEATURE_FLAG, CYCLE_ANALYTICS_FEATURE_FLAG,
PRODUCTIVITY_ANALYTICS_FEATURE_FLAG PRODUCTIVITY_ANALYTICS_FEATURE_FLAG,
REPORT_PAGES_FEATURE_FLAG
].freeze ].freeze
FEATURE_FLAG_DEFAULTS = { FEATURE_FLAG_DEFAULTS = {
PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true, PRODUCTIVITY_ANALYTICS_FEATURE_FLAG => true,
CYCLE_ANALYTICS_FEATURE_FLAG => true CYCLE_ANALYTICS_FEATURE_FLAG => true,
REPORT_PAGES_FEATURE_FLAG => false
}.freeze }.freeze
def self.any_features_enabled? def self.any_features_enabled?
...@@ -28,6 +31,10 @@ module Gitlab ...@@ -28,6 +31,10 @@ module Gitlab
feature_enabled?(PRODUCTIVITY_ANALYTICS_FEATURE_FLAG) feature_enabled?(PRODUCTIVITY_ANALYTICS_FEATURE_FLAG)
end end
def self.report_pages_enabled?
feature_enabled?(REPORT_PAGES_FEATURE_FLAG)
end
def self.feature_enabled_by_default?(flag) def self.feature_enabled_by_default?(flag)
!!FEATURE_FLAG_DEFAULTS[flag] !!FEATURE_FLAG_DEFAULTS[flag]
end end
......
# 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
...@@ -19057,6 +19057,9 @@ msgstr "" ...@@ -19057,6 +19057,9 @@ msgstr ""
msgid "Reporting" msgid "Reporting"
msgstr "" msgstr ""
msgid "Reports"
msgstr ""
msgid "Reports|%{combinedString} and %{resolvedString}" msgid "Reports|%{combinedString} and %{resolvedString}"
msgstr "" 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