Skip to content

Commit

Permalink
Merge pull request #16808 from opf/fix/remove-percent-complete-editio…
Browse files Browse the repository at this point in the history
…n-flag

Remove :percent_complete_edition feature flag
  • Loading branch information
cbliard authored Sep 25, 2024
2 parents 1cf8097 + 4ac1b1c commit 7b45804
Show file tree
Hide file tree
Showing 34 changed files with 27 additions and 3,849 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@
) do |f| %>
<%= flex_layout do |modal_body| %>
<% modal_body.with_row(classes: "FormControl-horizontalGroup--sm-vertical") do |_fields| %>
<% if OpenProject::FeatureDecisions.percent_complete_edition_active? %>
<%= render(WorkPackages::ProgressForm.new(f,
work_package:,
mode:,
focused_field:,
touched_field_map:)) %>
<% else %>
<%# This condition branch to be removed in 15.0 with :percent_complete_edition feature flag removal %>
<%= render(WorkPackages::Pre144ProgressForm.new(f,
work_package:,
mode:,
focused_field:,
touched_field_map:)) %>
<% end %>
<% end %>

<% modal_body.with_row(mt: 3) do |_tooltip| %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,11 @@
) do |f| %>
<%= flex_layout do |modal_body| %>
<% modal_body.with_row(classes: "FormControl-horizontalGroup--sm-vertical") do |_fields| %>
<% if OpenProject::FeatureDecisions.percent_complete_edition_active? %>
<%= render(WorkPackages::ProgressForm.new(f,
work_package:,
mode:,
focused_field:,
touched_field_map:)) %>
<% else %>
<%# This condition branch to be removed in 15.0 with :percent_complete_edition feature flag removal %>
<%= render(WorkPackages::Pre144ProgressForm.new(f,
work_package:,
mode:,
focused_field:,
touched_field_map:)) %>
<% end %>
<% end %>

<% if !OpenProject::FeatureDecisions.percent_complete_edition_active? %>
<%# This condition branch to be removed in 15.0 with :percent_complete_edition feature flag removal %>
<% if should_display_migration_warning? %>
<% modal_body.with_row(mt: 3) do |_migration_warning| %>
<%= render(Primer::Alpha::Banner.new) { t("work_package.progress.modal.migration_warning_text") } %>
<% end %>
<% end %>
<% end %>

<%# This condition branch to be removed in 15.0 with :percent_complete_edition feature flag removal %>
<% unless OpenProject::FeatureDecisions.percent_complete_edition_active? %>
<% modal_body.with_row(mt: 3) do |_tooltip| %>
<%= render(Primer::Beta::Text.new(font_weight: :semibold)) { t("work_package.progress.label_note") } %>
<%= render(Primer::Beta::Text.new) { t("work_package.progress.modal.work_based_help_text_pre_14_4_without_percent_complete_edition") } %>
<%= render(Primer::Beta::Link.new(href: learn_more_href)) { t(:label_learn_more) } %>
<% end %>
<% end %>

<% modal_body.with_row(mt: 3) do |_actions_row| %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ def initialize(work_package,

@mode = :work_based
end

# This method can be safely deleted once the feature flag
# :percent_complete_edition is removed, which should happen for
# OpenProject 15.0 release.
def should_display_migration_warning?
return false if OpenProject::FeatureDecisions.percent_complete_edition_active?

work_package.done_ratio.present? && work_package.estimated_hours.nil? && work_package.remaining_hours.nil?
end
end
# rubocop:enable OpenProject/AddPreviewForViewComponent
end
Expand Down
43 changes: 8 additions & 35 deletions app/contracts/work_packages/base_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,27 @@ class BaseContract < ::ModelContract

attribute :done_ratio,
writable: ->(*) {
OpenProject::FeatureDecisions.percent_complete_edition_active? \
&& WorkPackage.work_based_mode?
WorkPackage.work_based_mode?
} do
if OpenProject::FeatureDecisions.percent_complete_edition_active?
next if invalid_work_or_remaining_work_values? # avoid too many error messages at the same time
next if invalid_work_or_remaining_work_values? # avoid too many error messages at the same time

validate_percent_complete_matches_work_and_remaining_work
validate_percent_complete_is_empty_when_work_is_zero
validate_percent_complete_is_set_when_work_and_remaining_work_are_set
end
validate_percent_complete_matches_work_and_remaining_work
validate_percent_complete_is_empty_when_work_is_zero
validate_percent_complete_is_set_when_work_and_remaining_work_are_set
end
attribute :derived_done_ratio,
writable: false

attribute :estimated_hours do
if OpenProject::FeatureDecisions.percent_complete_edition_active?
validate_work_is_set_when_remaining_work_and_percent_complete_are_set
else
# to be removed in 15.0 with :percent_complete_edition feature flag removal
validate_work_is_set_when_remaining_work_is_set
end
validate_work_is_set_when_remaining_work_and_percent_complete_are_set
end
attribute :derived_estimated_hours,
writable: false

attribute :remaining_hours do
validate_remaining_work_is_lower_than_work
if OpenProject::FeatureDecisions.percent_complete_edition_active?
validate_remaining_work_is_zero_or_empty_when_percent_complete_is_100p
validate_remaining_work_is_set_when_work_and_percent_complete_are_set
else
# to be removed in 15.0 with :percent_complete_edition feature flag removal
validate_remaining_work_is_set_when_work_is_set
end
validate_remaining_work_is_zero_or_empty_when_percent_complete_is_100p
validate_remaining_work_is_set_when_work_and_percent_complete_are_set
end
attribute :derived_remaining_hours,
writable: false
Expand Down Expand Up @@ -350,20 +337,6 @@ def validate_remaining_work_is_lower_than_work
end
end

# to be removed in 15.0 with :percent_complete_edition feature flag removal
def validate_remaining_work_is_set_when_work_is_set
if work_set? && !remaining_work_set?
errors.add(:remaining_hours, :must_be_set_when_work_is_set)
end
end

# to be removed in 15.0 with :percent_complete_edition feature flag removal
def validate_work_is_set_when_remaining_work_is_set
if remaining_work_set? && !work_set?
errors.add(:estimated_hours, :must_be_set_when_remaining_work_is_set)
end
end

def validate_work_is_set_when_remaining_work_and_percent_complete_are_set
if remaining_work_set_and_valid? && percent_complete_set_and_valid? && work_empty? && percent_complete != 100
errors.add(:estimated_hours, :must_be_set_when_remaining_work_and_percent_complete_are_set)
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/work_packages/progress_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ def create
], status: :unprocessable_entity
end
end
# following 3 lines to be removed in 15.0 with :percent_complete_edition feature flag removal
elsif !OpenProject::FeatureDecisions.percent_complete_edition_active?
render json: { estimatedTime: formatted_duration(@work_package.estimated_hours),
remainingTime: formatted_duration(@work_package.remaining_hours) }
else
render json: { estimatedTime: formatted_duration(@work_package.estimated_hours),
remainingTime: formatted_duration(@work_package.remaining_hours),
Expand Down Expand Up @@ -163,9 +159,6 @@ def allowed_touched_params
def allowed_params
if WorkPackage.status_based_mode?
%i[estimated_hours status_id]
# two next lines to be removed in 15.0 with :percent_complete_edition feature flag removal
elsif !OpenProject::FeatureDecisions.percent_complete_edition_active?
%i[estimated_hours remaining_hours]
else
%i[estimated_hours remaining_hours done_ratio]
end
Expand Down
212 changes: 0 additions & 212 deletions app/forms/work_packages/pre_14_4_progress_form.rb

This file was deleted.

3 changes: 0 additions & 3 deletions app/forms/work_packages/progress_form/initial_values_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ def initialize(work_package:,
else
hidden_initial_field(form, name: :estimated_hours)
hidden_initial_field(form, name: :remaining_hours)
# next line to be removed in 15.0 with :percent_complete_edition feature flag removal
next unless OpenProject::FeatureDecisions.percent_complete_edition_active?

hidden_initial_field(form, name: :done_ratio)
end
end
Expand Down
Loading

0 comments on commit 7b45804

Please sign in to comment.