Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix missing helpers proxy in LifeCycle::Form

Alexander Brandon Coles73963cf6d6c8
diff --git a/app/forms/application_form.rb b/app/forms/application_form.rb
index a45ed39c78d..dca8cc16204 100644
--- a/app/forms/application_form.rb
+++ b/app/forms/application_form.rb
@@ -42,9 +42,6 @@ class ApplicationForm < Primer::Forms::Base
Rails.application.routes.url_helpers
end
- # @return [ActionView::Base] the view helper instance
- delegate :helpers, to: :@view_context
-
# @return [ActiveRecord::Base] the model instance given to the form builder
def model
@builder.object
diff --git a/app/forms/projects/life_cycle/form.rb b/app/forms/projects/life_cycle/form.rb
index a8e16555e0c..6f4b0ff763a 100644
--- a/app/forms/projects/life_cycle/form.rb
+++ b/app/forms/projects/life_cycle/form.rb
@@ -146,11 +146,21 @@ module Projects::LifeCycle
# when you enter a start date after today, and then open the datepicker for finish date,
# it will reset the start date because the finish date is set automatically to today,
# but the finish date can't be before the start date.
- helpers.browser.device.mobile? && !helpers.browser.safari? ? :date : :text
+ browser.device.mobile? && !browser.safari? ? :date : :text
end
def placeholder
- helpers.browser.device.mobile? ? "yyyy-mm-dd" : nil
+ browser.device.mobile? ? "yyyy-mm-dd" : nil
+ end
+
+ # N.B. This is an inelegant, and very likely brittle solution.
+ #
+ # The Browser gem uses `helper_method(:browser)` to declare a
+ # controller method as a helper. This helper is available in classic
+ # Rails views, but since upgrading to ViewComponent 4.0, no longer
+ # works with Primer Forms.
+ def browser
+ @view_context.controller.send(:browser)
end
end
end