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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
chore[Op#50212]: combine common form inputs
Kabiru Mwenja91765d157633
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.erbindex 87f2906f4b1..30f403e74ab 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@@ -6,20 +6,11 @@) do |form|flex_layout do |general_info_row|general_info_row.with_row(mb: 3) do- render(Storages::Admin::ProviderTypeSelectForm.new(form))- end-- general_info_row.with_row(mb: 3) do- render(Storages::Admin::StorageNameInputForm.new(form))- end-- general_info_row.with_row(mb: 3) do- render(Storages::Admin::StorageHostInputForm.new(form))+ render(Storages::Admin::StorageProviderForm.new(form))endgeneral_info_row.with_row do- concat(render(Primer::Beta::Button.new(scheme: :primary, type: :submit)) { I18n.t('storages.buttons.save_and_continue') })- concat(render(Primer::Beta::Button.new(scheme: :default, tag: :a, href: edit_admin_settings_storage_path(storage))) { I18n.t('button_cancel') })+ render(Storages::Admin::SaveOrCancelForm.new(form, storage:))endendenddiff --git a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erbindex 8f080491a1e..664b12915b6 100644--- a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb+++ b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.html.erb@@ -4,8 +4,12 @@url: admin_settings_storage_oauth_client_path(storage)) do |form|flex_layout do |oauth_client_row|+ oauth_client_row.with_row(mb: 3) do+ render(Storages::Admin::OAuthClientForm.new(form, storage:))+ end+oauth_client_row.with_row do- render(Storages::Admin::OAuthClientForm.new(form, storage: storage))+ render(Storages::Admin::SaveOrCancelForm.new(form, storage:))endendenddiff --git a/modules/storages/app/forms/storages/admin/oauth_client_form.rb b/modules/storages/app/forms/storages/admin/oauth_client_form.rbindex 6cacaca303d..8bad45364cd 100644--- a/modules/storages/app/forms/storages/admin/oauth_client_form.rb+++ b/modules/storages/app/forms/storages/admin/oauth_client_form.rb@@ -36,20 +36,9 @@ module Storages::Adminoauth_client_form.text_field(name: :client_secret,label: label_client_secret,required: true)-- oauth_client_form.group(layout: :horizontal) do |button_group|- button_group.submit(name: :submit,- scheme: :primary,- label: I18n.t('storages.buttons.save_and_continue'))- button_group.button(name: :cancel,- scheme: :default,- tag: :a,- href: Rails.application.routes.url_helpers.edit_admin_settings_storage_path(@storage),- label: I18n.t('button_cancel'))- endend- def initialize(storage: false)+ def initialize(storage:)super()@storage = storageenddiff --git a/modules/storages/app/forms/storages/admin/save_or_cancel_form.rb b/modules/storages/app/forms/storages/admin/save_or_cancel_form.rbnew file mode 100644index 00000000000..b05c731219f--- /dev/null+++ b/modules/storages/app/forms/storages/admin/save_or_cancel_form.rb@@ -0,0 +1,49 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module Storages::Admin+ class SaveOrCancelForm < ApplicationForm+ form do |buttons|+ buttons.group(layout: :horizontal) do |button_group|+ button_group.submit(name: :submit,+ scheme: :primary,+ label: I18n.t('storages.buttons.save_and_continue'))+ button_group.button(name: :cancel,+ scheme: :default,+ tag: :a,+ href: Rails.application.routes.url_helpers.edit_admin_settings_storage_path(@storage),+ label: I18n.t('button_cancel'))+ end+ end++ def initialize(storage:)+ super()+ @storage = storage+ end+ end+enddiff --git a/modules/storages/app/forms/storages/admin/storage_provider_form.rb b/modules/storages/app/forms/storages/admin/storage_provider_form.rbnew file mode 100644index 00000000000..c8b92e754e8--- /dev/null+++ b/modules/storages/app/forms/storages/admin/storage_provider_form.rb@@ -0,0 +1,64 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2023 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++module Storages::Admin+ class StorageProviderForm < ApplicationForm+ form do |storage_provider_form|+ storage_provider_form.select_list(+ name: :provider_type,+ label: I18n.t('activerecord.attributes.storages/storage.provider_type'),+ caption: I18n.t('storages.instructions.provider_type',+ type_link_text: I18n.t('storages.instructions.type_link_text')),+ include_blank: false,+ required: true+ ) do |storage_provider_list|+ ::Storages::Storage::PROVIDER_TYPES.each do |provider_type|+ storage_provider_list.option(+ label: I18n.t("storages.provider_types.#{::Storages::Storage.shorten_provider_type(provider_type)}.name"),+ value: provider_type+ )+ end+ end++ storage_provider_form.text_field(+ name: :name,+ label: I18n.t('activerecord.attributes.storages/storage.name'),+ required: true,+ caption: I18n.t('storages.instructions.name')+ )++ storage_provider_form.text_field(+ name: :host,+ label: I18n.t('activerecord.attributes.storages/storage.host'),+ visually_hide_label: false,+ required: true,+ caption: I18n.t('storages.instructions.host')+ )+ end+ end+end