Commit 65a2e194 authored by James Fargher's avatar James Fargher

Merge branch '241371-unify-milestone-charts-licenses' into 'master'

Unify burnup and burndown chart license checks

Closes #241371

See merge request gitlab-org/gitlab!40941
parents 620fc2d0 195faf6a
...@@ -154,9 +154,9 @@ For project milestones in [GitLab Starter](https://about.gitlab.com/pricing/), a ...@@ -154,9 +154,9 @@ For project milestones in [GitLab Starter](https://about.gitlab.com/pricing/), a
![burndown chart](img/burndown_chart.png) ![burndown chart](img/burndown_chart.png)
### Group Burndown Charts **(PREMIUM)** ### Group Burndown Charts **(STARTER)**
For group milestones in [GitLab Premium](https://about.gitlab.com/pricing/), a [burndown chart](burndown_charts.md) is in the milestone view, showing the progress of completing a milestone. For group milestones in [GitLab Starter](https://about.gitlab.com/pricing/), a [burndown chart](burndown_charts.md) is in the milestone view, showing the progress of completing a milestone.
### Milestone sidebar ### Milestone sidebar
......
...@@ -3,25 +3,25 @@ ...@@ -3,25 +3,25 @@
module EE module EE
module TimeboxesHelper module TimeboxesHelper
def burndown_chart(milestone) def burndown_chart(milestone)
if milestone.supports_burndown_charts? if milestone.supports_milestone_charts?
issues = milestone.issues_visible_to_user(current_user) issues = milestone.issues_visible_to_user(current_user)
Burndown.new(issues, milestone.start_date, milestone.due_date) Burndown.new(issues, milestone.start_date, milestone.due_date)
end end
end end
def can_generate_chart?(milestone, burndown) def can_generate_chart?(milestone, burndown)
return false unless milestone.supports_burndown_charts? return false unless milestone.supports_milestone_charts?
burndown&.valid? && !burndown&.empty? burndown&.valid? && !burndown&.empty?
end end
def show_burndown_charts_promotion?(milestone) def show_burndown_charts_promotion?(milestone)
milestone.is_a?(EE::Milestone) && !milestone.supports_burndown_charts? && show_promotions? milestone.is_a?(EE::Milestone) && !milestone.supports_milestone_charts? && show_promotions?
end end
def show_burndown_placeholder?(milestone, warning) def show_burndown_placeholder?(milestone, warning)
return false if cookies['hide_burndown_message'].present? return false if cookies['hide_burndown_message'].present?
return false unless milestone.supports_burndown_charts? return false unless milestone.supports_milestone_charts?
warning.nil? && can?(current_user, :admin_milestone, milestone.resource_parent) warning.nil? && can?(current_user, :admin_milestone, milestone.resource_parent)
end end
......
...@@ -14,13 +14,7 @@ module EE ...@@ -14,13 +14,7 @@ module EE
resource_parent&.feature_available?(:issue_weights) resource_parent&.feature_available?(:issue_weights)
end end
def supports_burndown_charts? def supports_milestone_charts?
feature_name = group_milestone? ? :group_burndown_charts : :burndown_charts
resource_parent&.feature_available?(feature_name) && supports_weight?
end
def supports_burnup_charts?
resource_parent&.feature_available?(:milestone_charts) && supports_weight? resource_parent&.feature_available?(:milestone_charts) && supports_weight?
end end
......
...@@ -11,7 +11,6 @@ class License < ApplicationRecord ...@@ -11,7 +11,6 @@ class License < ApplicationRecord
EES_FEATURES = %i[ EES_FEATURES = %i[
audit_events audit_events
blocked_issues blocked_issues
burndown_charts
code_owners code_owners
code_review_analytics code_review_analytics
contribution_analytics contribution_analytics
...@@ -19,7 +18,6 @@ class License < ApplicationRecord ...@@ -19,7 +18,6 @@ class License < ApplicationRecord
elastic_search elastic_search
group_activity_analytics group_activity_analytics
group_bulk_edit group_bulk_edit
group_burndown_charts
group_webhooks group_webhooks
issuable_default_templates issuable_default_templates
issue_weights issue_weights
...@@ -156,7 +154,6 @@ class License < ApplicationRecord ...@@ -156,7 +154,6 @@ class License < ApplicationRecord
# introduced. # introduced.
EARLY_ADOPTER_FEATURES = %i[ EARLY_ADOPTER_FEATURES = %i[
audit_events audit_events
burndown_charts
contribution_analytics contribution_analytics
cross_project_pipelines cross_project_pipelines
deploy_board deploy_board
......
...@@ -17,7 +17,7 @@ class Milestones::BurnupChartService ...@@ -17,7 +17,7 @@ class Milestones::BurnupChartService
end end
def execute def execute
return ServiceResponse.error(message: _('Milestone does not support burnup charts')) unless milestone.supports_burnup_charts? return ServiceResponse.error(message: _('Milestone does not support burnup charts')) unless milestone.supports_milestone_charts?
return ServiceResponse.error(message: _('Milestone must have a start and due date')) if milestone.start_date.blank? || milestone.due_date.blank? return ServiceResponse.error(message: _('Milestone must have a start and due date')) if milestone.start_date.blank? || milestone.due_date.blank?
return ServiceResponse.error(message: _('Burnup chart could not be generated due to too many events')) if resource_events.num_tuples > EVENT_COUNT_LIMIT return ServiceResponse.error(message: _('Burnup chart could not be generated due to too many events')) if resource_events.num_tuples > EVENT_COUNT_LIMIT
......
...@@ -10,7 +10,7 @@ module EE ...@@ -10,7 +10,7 @@ module EE
def milestone_burndown_events_for(parent) def milestone_burndown_events_for(parent)
milestone = parent.milestones.find(params[:milestone_id]) milestone = parent.milestones.find(params[:milestone_id])
if milestone.supports_burndown_charts? if milestone.supports_milestone_charts?
issues = milestone.issues_visible_to_user(current_user) issues = milestone.issues_visible_to_user(current_user)
present Burndown.new(issues, milestone.start_date, milestone.due_date).as_json present Burndown.new(issues, milestone.start_date, milestone.due_date).as_json
else else
...@@ -21,7 +21,7 @@ module EE ...@@ -21,7 +21,7 @@ module EE
def milestone_burnup_events_for(parent) def milestone_burnup_events_for(parent)
milestone = parent.milestones.find(params[:milestone_id]) milestone = parent.milestones.find(params[:milestone_id])
if milestone.supports_burndown_charts? if milestone.supports_milestone_charts?
present BurnupChartService.new(milestone: milestone, user: current_user).execute present BurnupChartService.new(milestone: milestone, user: current_user).execute
else else
render_api_error!("Milestone does not support burnup chart", 405) render_api_error!("Milestone does not support burnup chart", 405)
......
...@@ -24,7 +24,7 @@ RSpec.describe 'Burndown charts', :js do ...@@ -24,7 +24,7 @@ RSpec.describe 'Burndown charts', :js do
end end
it 'presents burndown charts when available' do it 'presents burndown charts when available' do
stub_licensed_features(burndown_charts: true) stub_licensed_features(milestone_charts: true)
visit project_milestone_path(milestone.project, milestone) visit project_milestone_path(milestone.project, milestone)
...@@ -33,7 +33,7 @@ RSpec.describe 'Burndown charts', :js do ...@@ -33,7 +33,7 @@ RSpec.describe 'Burndown charts', :js do
end end
it 'presents burndown charts promotion correctly' do it 'presents burndown charts promotion correctly' do
stub_licensed_features(burndown_charts: false) stub_licensed_features(milestone_charts: false)
allow(License).to receive(:current) { nil } allow(License).to receive(:current) { nil }
visit project_milestone_path(milestone.project, milestone) visit project_milestone_path(milestone.project, milestone)
...@@ -52,7 +52,7 @@ RSpec.describe 'Burndown charts', :js do ...@@ -52,7 +52,7 @@ RSpec.describe 'Burndown charts', :js do
end end
it 'presents burndown charts when available' do it 'presents burndown charts when available' do
stub_licensed_features(group_burndown_charts: true) stub_licensed_features(milestone_charts: true)
visit group_milestone_path(milestone.group, milestone) visit group_milestone_path(milestone.group, milestone)
...@@ -61,7 +61,7 @@ RSpec.describe 'Burndown charts', :js do ...@@ -61,7 +61,7 @@ RSpec.describe 'Burndown charts', :js do
end end
it 'presents burndown charts promotion correctly' do it 'presents burndown charts promotion correctly' do
stub_licensed_features(group_burndown_charts: false) stub_licensed_features(milestone_charts: false)
allow(License).to receive(:current) { nil } allow(License).to receive(:current) { nil }
visit group_milestone_path(milestone.group, milestone) visit group_milestone_path(milestone.group, milestone)
......
...@@ -30,7 +30,7 @@ RSpec.describe 'Burnup charts', :js do ...@@ -30,7 +30,7 @@ RSpec.describe 'Burnup charts', :js do
describe 'licensed feature available' do describe 'licensed feature available' do
before do before do
stub_licensed_features(group_burndown_charts: true) stub_licensed_features(milestone_charts: true)
end end
it 'shows burnup chart, with a point per day' do it 'shows burnup chart, with a point per day' do
...@@ -42,7 +42,7 @@ RSpec.describe 'Burnup charts', :js do ...@@ -42,7 +42,7 @@ RSpec.describe 'Burnup charts', :js do
describe 'licensed feature not available' do describe 'licensed feature not available' do
before do before do
stub_licensed_features(group_burndown_charts: false) stub_licensed_features(milestone_charts: false)
end end
it 'does not show burnup chart' do it 'does not show burnup chart' do
...@@ -54,7 +54,7 @@ RSpec.describe 'Burnup charts', :js do ...@@ -54,7 +54,7 @@ RSpec.describe 'Burnup charts', :js do
describe 'feature flag disabled' do describe 'feature flag disabled' do
before do before do
stub_licensed_features(group_burndown_charts: true) stub_licensed_features(milestone_charts: true)
stub_feature_flags(burnup_charts: false) stub_feature_flags(burnup_charts: false)
end end
......
...@@ -27,11 +27,11 @@ RSpec.describe 'Milestones on EE' do ...@@ -27,11 +27,11 @@ RSpec.describe 'Milestones on EE' do
due_date: Date.tomorrow) due_date: Date.tomorrow)
end end
context 'with the burndown chart feature available' do context 'with the milestone charts feature available' do
let(:issue_params) { { project: project, assignees: [user], author: user, milestone: milestone } } let(:issue_params) { { project: project, assignees: [user], author: user, milestone: milestone } }
before do before do
stub_licensed_features(burndown_charts: true) stub_licensed_features(milestone_charts: true)
end end
it 'shows a burndown chart' do it 'shows a burndown chart' do
...@@ -123,9 +123,9 @@ RSpec.describe 'Milestones on EE' do ...@@ -123,9 +123,9 @@ RSpec.describe 'Milestones on EE' do
end end
end end
context 'with the burndown chart feature disabled' do context 'with the milestone charts feature disabled' do
before do before do
stub_licensed_features(burndown_charts: false) stub_licensed_features(milestone_charts: false)
end end
include_examples 'burndown charts disabled' include_examples 'burndown charts disabled'
......
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