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

feat[Op#50737]: Expand GeneralInfo form options

Kabiru Mwenja7c68bfb87168
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 a11d1c1ecc0..360cb8dff9a 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
@@ -1,9 +1,9 @@
<%=
render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-general-info-form')) do
primer_form_with(
- model: storage,
- url: admin_settings_storage_path(storage),
- method: :patch
+ model:,
+ url: form_url,
+ method: form_method
) do |form|
flex_layout do |general_info_row|
general_info_row.with_row(mb: 3) do
@@ -14,8 +14,10 @@
render(Storages::Admin::ProviderNameInputForm.new(form))
end
- general_info_row.with_row(mb: 3) do
- render(Storages::Admin::ProviderHostInputForm.new(form))
+ if render_host?
+ general_info_row.with_row(mb: 3) do
+ render(Storages::Admin::ProviderHostInputForm.new(form))
+ end
end
general_info_row.with_row do
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 cd8de8524c6..9031a49a714 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
@@ -32,5 +32,27 @@ module Storages::Admin::Forms
class GeneralInfoFormComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
alias_method :storage, :model
+
+ options form_method: :post,
+ render_host: true,
+ cancel_button_should_break_from_frame: false,
+ cancel_button_path: Rails.application.routes.url_helpers.admin_settings_storages_path
+
+ alias_method :render_host?, :render_host
+
+ def form_url
+ options[:form_url] || default_form_url
+ end
+
+ private
+
+ def default_form_url
+ case form_method
+ when :get, :post
+ Rails.application.routes.url_helpers.admin_settings_storages_path
+ when :patch, :put
+ Rails.application.routes.url_helpers.admin_settings_storage_path(storage)
+ end
+ end
end
end
diff --git a/modules/storages/app/views/storages/admin/storages/edit_host.html.erb b/modules/storages/app/views/storages/admin/storages/edit_host.html.erb
index 6c566f6fdb9..f101a26d038 100644
--- a/modules/storages/app/views/storages/admin/storages/edit_host.html.erb
+++ b/modules/storages/app/views/storages/admin/storages/edit_host.html.erb
@@ -1,5 +1,11 @@
<%=
render(OpTurbo::FrameComponent.new(@storage, context: :storage_view_general_info)) do
- render(Storages::Admin::Forms::GeneralInfoFormComponent.new(@storage))
+ render(
+ Storages::Admin::Forms::GeneralInfoFormComponent.new(
+ @storage,
+ form_method: :patch,
+ cancel_button_path: edit_admin_settings_storage_path(@storage)
+ )
+ )
end
%>