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

Introduce superclasses for info and form components of storages UI

Jan Sandbrink8fa40780fdf6
diff --git a/modules/storages/app/components/storages/admin/access_management_component.rb b/modules/storages/app/components/storages/admin/access_management_component.rb
index 0dacab42253..6852984e967 100644
--- a/modules/storages/app/components/storages/admin/access_management_component.rb
+++ b/modules/storages/app/components/storages/admin/access_management_component.rb
@@ -29,13 +29,7 @@
#++
#
module Storages::Admin
- class AccessManagementComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
- include StorageViewInformation
-
- alias_method :storage, :model
-
+ class AccessManagementComponent < StorageInfoComponent
def self.wrapper_key = :access_management_section
private
diff --git a/modules/storages/app/components/storages/admin/automatically_managed_project_folders_info_component.rb b/modules/storages/app/components/storages/admin/automatically_managed_project_folders_info_component.rb
index 6a57f4b971c..49d80d83d50 100644
--- a/modules/storages/app/components/storages/admin/automatically_managed_project_folders_info_component.rb
+++ b/modules/storages/app/components/storages/admin/automatically_managed_project_folders_info_component.rb
@@ -29,12 +29,7 @@
#++
#
module Storages::Admin
- class AutomaticallyManagedProjectFoldersInfoComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
- include StorageViewInformation
-
- alias_method :storage, :model
+ class AutomaticallyManagedProjectFoldersInfoComponent < StorageInfoComponent
def self.wrapper_key = :automatically_managed_project_folders_section
diff --git a/modules/storages/app/components/storages/admin/forms/access_management_form_component.rb b/modules/storages/app/components/storages/admin/forms/access_management_form_component.rb
index 009971e3aef..0bfe1023e29 100644
--- a/modules/storages/app/components/storages/admin/forms/access_management_form_component.rb
+++ b/modules/storages/app/components/storages/admin/forms/access_management_form_component.rb
@@ -29,14 +29,7 @@
#++
#
module Storages::Admin::Forms
- class AccessManagementFormComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
-
- alias_method :storage, :model
-
- options in_wizard: false
-
+ class AccessManagementFormComponent < StorageFormComponent
def self.wrapper_key = :access_management_section
def form_url
diff --git a/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.rb b/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.rb
index 5f8dd9e11f3..4f526f2194a 100644
--- a/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.rb
+++ b/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.rb
@@ -29,14 +29,7 @@
#++
#
module Storages::Admin::Forms
- class AutomaticallyManagedProjectFoldersFormComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
-
- alias_method :storage, :model
-
- options in_wizard: false
-
+ class AutomaticallyManagedProjectFoldersFormComponent < StorageFormComponent
def self.wrapper_key = :automatically_managed_project_folders_section
def form_method
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 7efdfa86cb3..354e0bdfcc6 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
@@ -29,17 +29,11 @@
#++
#
module Storages::Admin::Forms
- class GeneralInfoFormComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
-
- alias_method :storage, :model
+ class GeneralInfoFormComponent < StorageFormComponent
+ def self.wrapper_key = :storage_general_info_section
options form_method: :post,
- submit_button_disabled: false,
- in_wizard: false
-
- def self.wrapper_key = :storage_general_info_section
+ submit_button_disabled: false
def form_url
query = { continue_wizard: storage.id } if in_wizard
diff --git a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb
index 01574e16714..02f4cf8db7c 100644
--- a/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb
+++ b/modules/storages/app/components/storages/admin/forms/oauth_client_form_component.rb
@@ -29,14 +29,7 @@
#++
#
module Storages::Admin::Forms
- class OAuthClientFormComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
-
- alias_method :storage, :model
-
- options in_wizard: false
-
+ class OAuthClientFormComponent < StorageFormComponent
def self.wrapper_key = :storage_oauth_client_section
def form_url
diff --git a/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.rb b/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.rb
index dbab6ee3504..947a61472f8 100644
--- a/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.rb
+++ b/modules/storages/app/components/storages/admin/forms/redirect_uri_form_component.rb
@@ -29,17 +29,11 @@
#++
#
module Storages::Admin::Forms
- class RedirectUriFormComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
+ class RedirectUriFormComponent < StorageFormComponent
+ def self.wrapper_key = :storage_redirect_uri_section
- alias_method :storage, :model
delegate :oauth_client, to: :storage
- options in_wizard: false
-
- def self.wrapper_key = :storage_redirect_uri_section
-
def form_url
query = { continue_wizard: storage.id } if in_wizard
finish_setup_admin_settings_storage_oauth_client_path(storage, query)
diff --git a/modules/storages/app/components/storages/admin/forms/storage_form_component.rb b/modules/storages/app/components/storages/admin/forms/storage_form_component.rb
new file mode 100644
index 00000000000..62eacb7287b
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/forms/storage_form_component.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 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::Forms
+ class StorageFormComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
+
+ alias_method :storage, :model
+
+ options in_wizard: false
+ end
+end
diff --git a/modules/storages/app/components/storages/admin/general_info_component.rb b/modules/storages/app/components/storages/admin/general_info_component.rb
index 922690e9d91..045e9a6e3af 100644
--- a/modules/storages/app/components/storages/admin/general_info_component.rb
+++ b/modules/storages/app/components/storages/admin/general_info_component.rb
@@ -30,13 +30,7 @@
module Storages
module Admin
- class GeneralInfoComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
- include StorageViewInformation
-
- alias_method :storage, :model
-
+ class GeneralInfoComponent < StorageInfoComponent
def self.wrapper_key = :storage_general_info_section
def open_href
diff --git a/modules/storages/app/components/storages/admin/oauth_application_info_component.rb b/modules/storages/app/components/storages/admin/oauth_application_info_component.rb
index 5942b42fb55..0720101d63d 100644
--- a/modules/storages/app/components/storages/admin/oauth_application_info_component.rb
+++ b/modules/storages/app/components/storages/admin/oauth_application_info_component.rb
@@ -29,14 +29,9 @@
#++
#
module Storages::Admin
- class OAuthApplicationInfoComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
- include StorageViewInformation
+ class OAuthApplicationInfoComponent < StorageInfoComponent
+ def self.wrapper_key = :storage_openproject_oauth_section
- alias_method :storage, :model
delegate :oauth_application, to: :storage
-
- def self.wrapper_key = :storage_openproject_oauth_section
end
end
diff --git a/modules/storages/app/components/storages/admin/oauth_client_info_component.rb b/modules/storages/app/components/storages/admin/oauth_client_info_component.rb
index 917957b5a1f..bd22b75ff7a 100644
--- a/modules/storages/app/components/storages/admin/oauth_client_info_component.rb
+++ b/modules/storages/app/components/storages/admin/oauth_client_info_component.rb
@@ -29,16 +29,11 @@
#++
#
module Storages::Admin
- class OAuthClientInfoComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
- include StorageViewInformation
+ class OAuthClientInfoComponent < StorageInfoComponent
+ def self.wrapper_key = :storage_oauth_client_section
- alias_method :storage, :model
delegate :oauth_client, to: :storage
- def self.wrapper_key = :storage_oauth_client_section
-
def edit_icon_button_options
label = I18n.t("storages.buttons.replace_oauth_client",
provider_type: I18n.t("storages.provider_types.#{storage}.name"))
diff --git a/modules/storages/app/components/storages/admin/redirect_uri_component.rb b/modules/storages/app/components/storages/admin/redirect_uri_component.rb
index 56b79da3359..03f28972d0d 100644
--- a/modules/storages/app/components/storages/admin/redirect_uri_component.rb
+++ b/modules/storages/app/components/storages/admin/redirect_uri_component.rb
@@ -29,16 +29,11 @@
#++
#
module Storages::Admin
- class RedirectUriComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include OpTurbo::Streamable
- include StorageViewInformation
+ class RedirectUriComponent < StorageInfoComponent
+ def self.wrapper_key = :storage_redirect_uri_section
- alias_method :storage, :model
delegate :oauth_client, to: :storage
- def self.wrapper_key = :storage_redirect_uri_section
-
def show_icon_button_options
{
icon: :eye,
diff --git a/modules/storages/app/components/storages/admin/storage_view_information.rb b/modules/storages/app/components/storages/admin/storage_Info_component.rb
similarity index 96%
rename from modules/storages/app/components/storages/admin/storage_view_information.rb
rename to modules/storages/app/components/storages/admin/storage_Info_component.rb
index 9dab58231e8..3335a401b5e 100644
--- a/modules/storages/app/components/storages/admin/storage_view_information.rb
+++ b/modules/storages/app/components/storages/admin/storage_Info_component.rb
@@ -29,7 +29,12 @@
#++
module Storages::Admin
- module StorageViewInformation
+ class StorageInfoComponent < ApplicationComponent
+ include OpPrimer::ComponentHelpers
+ include OpTurbo::Streamable
+
+ alias_method :storage, :model
+
private
def editable_storage?
diff --git a/modules/storages/app/components/storages/admin/storage_view_component.rb b/modules/storages/app/components/storages/admin/storage_view_component.rb
index 98f57b89db1..86d76a94144 100644
--- a/modules/storages/app/components/storages/admin/storage_view_component.rb
+++ b/modules/storages/app/components/storages/admin/storage_view_component.rb
@@ -29,10 +29,7 @@
#++
#
module Storages::Admin
- class StorageViewComponent < ApplicationComponent
- include OpPrimer::ComponentHelpers
- include StorageViewInformation
-
+ class StorageViewComponent < StorageInfoComponent
options wizard: nil,
wizard_step: nil
@@ -41,7 +38,5 @@ module Storages::Admin
raise ArgumentError, "wizard is required" if wizard.nil?
end
-
- alias_method :storage, :model
end
end