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

chore[Op#50737]: Extract button options to methods

Kabiru Mwenja321310078056
diff --git a/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb
index d7a7926c682..dcfb25f133e 100644
--- a/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb
+++ b/modules/storages/app/components/storages/admin/forms/general_info_form_component.html.erb
@@ -25,13 +25,8 @@
Storages::Admin::SubmitOrCancelForm.new(
form,
storage:,
- submit_button_options: {
- disabled: submit_button_disabled?,
- },
- cancel_button_options: {
- href: cancel_button_path,
- target: '_top'
- }
+ submit_button_options:,
+ cancel_button_options:
)
)
end
diff --git a/modules/storages/app/components/storages/admin/forms/general_info_form_component.rb b/modules/storages/app/components/storages/admin/forms/general_info_form_component.rb
index 1b29c699a81..3a68fae1a7a 100644
--- a/modules/storages/app/components/storages/admin/forms/general_info_form_component.rb
+++ b/modules/storages/app/components/storages/admin/forms/general_info_form_component.rb
@@ -40,12 +40,21 @@ module Storages::Admin::Forms
cancel_button_path: Rails.application.routes.url_helpers.admin_settings_storages_path
alias_method :render_host?, :render_host
- alias_method :submit_button_disabled?, :submit_button_disabled
def form_url
options[:form_url] || default_form_url
end
+ def submit_button_options
+ { disabled: submit_button_disabled }
+ end
+
+ def cancel_button_options
+ { href: cancel_button_path }.tap do |options_hash|
+ options_hash[:target] = '_top' if cancel_button_should_break_from_frame
+ end
+ end
+
private
def default_form_url