Commit 195faf6a authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Unify burnup and burndown chart license checks

These features would always go together so we just use one for all of
these
parent c7ce3789
......@@ -154,9 +154,9 @@ For project milestones in [GitLab Starter](https://about.gitlab.com/pricing/), a
![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
......
......@@ -3,25 +3,25 @@
module EE
module TimeboxesHelper
def burndown_chart(milestone)
if milestone.supports_burndown_charts?
if milestone.supports_milestone_charts?
issues = milestone.issues_visible_to_user(current_user)
Burndown.new(issues, milestone.start_date, milestone.due_date)
end
end
def can_generate_chart?(milestone, burndown)
return false unless milestone.supports_burndown_charts?
return false unless milestone.supports_milestone_charts?
burndown&.valid? && !burndown&.empty?
end
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
def show_burndown_placeholder?(milestone, warning)
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)
end
......
......@@ -14,13 +14,7 @@ module EE
resource_parent&.feature_available?(:issue_weights)
end
def supports_burndown_charts?
feature_name = group_milestone? ? :group_burndown_charts : :burndown_charts
resource_parent&.feature_available?(feature_name) && supports_weight?
end
def supports_burnup_charts?
def supports_milestone_charts?
resource_parent&.feature_available?(:milestone_charts) && supports_weight?
end
......
......@@ -11,7 +11,6 @@ class License < ApplicationRecord
EES_FEATURES = %i[
audit_events
blocked_issues
burndown_charts
code_owners
code_review_analytics
contribution_analytics
......@@ -19,7 +18,6 @@ class License < ApplicationRecord
elastic_search
group_activity_analytics
group_bulk_edit
group_burndown_charts
group_webhooks
issuable_default_templates
issue_weights
......@@ -157,7 +155,6 @@ class License < ApplicationRecord
# introduced.
EARLY_ADOPTER_FEATURES = %i[
audit_events
burndown_charts
contribution_analytics
cross_project_pipelines
deploy_board
......
......@@ -17,7 +17,7 @@ class Milestones::BurnupChartService
end
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: _('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
def milestone_burndown_events_for(parent)
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)
present Burndown.new(issues, milestone.start_date, milestone.due_date).as_json
else
......@@ -21,7 +21,7 @@ module EE
def milestone_burnup_events_for(parent)
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
else
render_api_error!("Milestone does not support burnup chart", 405)
......
......@@ -24,7 +24,7 @@ RSpec.describe 'Burndown charts', :js do
end
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)
......@@ -33,7 +33,7 @@ RSpec.describe 'Burndown charts', :js do
end
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 }
visit project_milestone_path(milestone.project, milestone)
......@@ -52,7 +52,7 @@ RSpec.describe 'Burndown charts', :js do
end
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)
......@@ -61,7 +61,7 @@ RSpec.describe 'Burndown charts', :js do
end
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 }
visit group_milestone_path(milestone.group, milestone)
......
......@@ -30,7 +30,7 @@ RSpec.describe 'Burnup charts', :js do
describe 'licensed feature available' do
before do
stub_licensed_features(group_burndown_charts: true)
stub_licensed_features(milestone_charts: true)
end
it 'shows burnup chart, with a point per day' do
......@@ -42,7 +42,7 @@ RSpec.describe 'Burnup charts', :js do
describe 'licensed feature not available' do
before do
stub_licensed_features(group_burndown_charts: false)
stub_licensed_features(milestone_charts: false)
end
it 'does not show burnup chart' do
......@@ -54,7 +54,7 @@ RSpec.describe 'Burnup charts', :js do
describe 'feature flag disabled' do
before do
stub_licensed_features(group_burndown_charts: true)
stub_licensed_features(milestone_charts: true)
stub_feature_flags(burnup_charts: false)
end
......
......@@ -27,11 +27,11 @@ RSpec.describe 'Milestones on EE' do
due_date: Date.tomorrow)
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 } }
before do
stub_licensed_features(burndown_charts: true)
stub_licensed_features(milestone_charts: true)
end
it 'shows a burndown chart' do
......@@ -123,9 +123,9 @@ RSpec.describe 'Milestones on EE' do
end
end
context 'with the burndown chart feature disabled' do
context 'with the milestone charts feature disabled' do
before do
stub_licensed_features(burndown_charts: false)
stub_licensed_features(milestone_charts: false)
end
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