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
feat[Op#50737]: Continue to decompose the StorageViewComponent
Kabiru Mwenja43d460a38732
diff --git a/modules/storages/app/components/storages/admin/automatically_managed_project_folders_info_component.html.erb b/modules/storages/app/components/storages/admin/automatically_managed_project_folders_info_component.html.erbnew file mode 100644index 00000000000..ae298466de3--- /dev/null+++ b/modules/storages/app/components/storages/admin/automatically_managed_project_folders_info_component.html.erb@@ -0,0 +1,31 @@+<%=+ grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|+ grid.with_area(:item, tag: :div, mr: 3) do+ concat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1, test_selector: 'storage-managed-project-folders-label')) { I18n.t('storages.file_storage_view.automatically_managed_folders') })+ concat(automatically_managed_project_folders_status_label)+ end++ grid.with_area(:description, tag: :div, color: :subtle, test_selector: 'storage-automatically-managed-project-folders-description') do+ render(Primer::Beta::Truncate.new(font_weight: :light)) { I18n.t('storages.page_titles.managed_project_folders.subtitle_short') }+ end++ if editable_storage?+ grid.with_area(:"icon-button", tag: :div, color: :subtle) do+ flex_layout(justify_content: :flex_end) do |icons_container|+ icons_container.with_column do+ render(+ Primer::Beta::IconButton.new(+ icon: :pencil,+ tag: :a,+ href: new_admin_settings_storage_automatically_managed_project_folders_path(storage),+ scheme: :invisible,+ aria: { label: I18n.t('storages.label_edit_storage_automatically_managed_folders') },+ test_selector: 'storage-edit-automatically-managed-project-folders-button'+ )+ )+ end+ end+ end+ end+ end+%>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.rbnew file mode 100644index 00000000000..6ac63c8ab74--- /dev/null+++ b/modules/storages/app/components/storages/admin/automatically_managed_project_folders_info_component.rb@@ -0,0 +1,38 @@+# frozen_string_literal: true++#-- 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 AutomaticallyManagedProjectFoldersInfoComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers+ include StorageViewInformation++ alias_method :storage, :model+ end+enddiff --git a/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.html.erbindex 96a24726bfd..a69713a023c 100644--- a/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.html.erb+++ b/modules/storages/app/components/storages/admin/forms/automatically_managed_project_folders_form_component.html.erb@@ -1,9 +1,9 @@<%=render(Primer::Beta::Text.new(tag: :div, test_selector: 'storage-automatically-managed-project-folders-form')) doprimer_form_with(- model: storage,- url: admin_settings_storage_automatically_managed_project_folders_path(storage),- method: :patch,+ model:,+ url: form_url,+ method: form_method,data: {controller: "storages--automatically-managed-project-folders-form",'application-target': "dynamic",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.rbindex f962f4819aa..571824be92c 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@@ -33,8 +33,18 @@ module Storages::Admin::Formsinclude OpPrimer::ComponentHelpersalias_method :storage, :model+ options form_method: :patch++ def form_url+ options[:form_url] || default_form_url+ end+private+ def default_form_url+ admin_settings_storage_automatically_managed_project_folders_path(storage)+ end+def storage_provider_credentials_copy_instructions"#{I18n.t('storages.instructions.copy_from')}: #{provider_credentials_instructions_link}".html_safeenddiff --git a/modules/storages/app/components/storages/admin/oauth_application_info_copy_component.html.erb b/modules/storages/app/components/storages/admin/oauth_application_info_copy_component.html.erbindex b49ea02251a..69adf695cb7 100644--- a/modules/storages/app/components/storages/admin/oauth_application_info_copy_component.html.erb+++ b/modules/storages/app/components/storages/admin/oauth_application_info_copy_component.html.erb@@ -32,8 +32,8 @@endcredentials_row.with_row do- concat(render(Primer::Beta::Button.new(scheme: :primary, tag: :a, href: submit_button_path)) { I18n.t('storages.buttons.done_continue') })- concat(render(Primer::Beta::Button.new(scheme: :default, tag: :a, href: cancel_button_path)) { I18n.t('button_cancel') })+ concat(render(Primer::Beta::Button.new(**submit_button_options)) { I18n.t('storages.buttons.done_continue') })+ concat(render(Primer::Beta::Button.new(**cancel_button_options)) { I18n.t('button_cancel') })endendenddiff --git a/modules/storages/app/components/storages/admin/oauth_application_info_copy_component.rb b/modules/storages/app/components/storages/admin/oauth_application_info_copy_component.rbindex b84cb125794..7833cab7b19 100644--- a/modules/storages/app/components/storages/admin/oauth_application_info_copy_component.rb+++ b/modules/storages/app/components/storages/admin/oauth_application_info_copy_component.rb@@ -35,6 +35,8 @@ module Storages::Adminattr_reader :storagealias_method :oauth_application, :model+ options cancel_button_should_break_from_frame: false+def initialize(oauth_application:, storage:, **options)super(oauth_application, **options)@storage = storage@@ -50,6 +52,24 @@ module Storages::Admin) { I18n.t('storages.instructions.oauth_application_details_link_text') }end+ def submit_button_options+ {+ scheme: :primary,+ tag: :a,+ href: submit_button_path+ }.merge(options.fetch(:submit_button_options, {}))+ end++ def cancel_button_options+ { scheme: :default,+ tag: :a,+ href: cancel_button_path }.tap do |options_hash|+ options_hash[:target] = '_top' if cancel_button_should_break_from_frame+ end+ end++ private+def submit_button_pathoptions[:submit_button_path] || edit_admin_settings_storage_path(storage)enddiff --git a/modules/storages/app/components/storages/admin/storage_view_component.html.erb b/modules/storages/app/components/storages/admin/storage_view_component.html.erbindex 12c29cc9190..135b96f3809 100644--- a/modules/storages/app/components/storages/admin/storage_view_component.html.erb+++ b/modules/storages/app/components/storages/admin/storage_view_component.html.erb@@ -60,35 +60,7 @@component.with_row(scheme: :default) dorender(OpTurbo::FrameComponent.new(id: :automatically_managed_project_folders_section)) do- grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|- grid.with_area(:item, tag: :div, mr: 3) do- concat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1, test_selector: 'storage-managed-project-folders-label')) { I18n.t('storages.file_storage_view.automatically_managed_folders') })- concat(automatically_managed_project_folders_status_label)- end-- grid.with_area(:description, tag: :div, color: :subtle, test_selector: 'storage-automatically-managed-project-folders-description') do- render(Primer::Beta::Truncate.new(font_weight: :light)) { I18n.t('storages.page_titles.managed_project_folders.subtitle_short') }- end-- if editable_storage?- grid.with_area(:"icon-button", tag: :div, color: :subtle) do- flex_layout(justify_content: :flex_end) do |icons_container|- icons_container.with_column do- render(- Primer::Beta::IconButton.new(- icon: :pencil,- tag: :a,- href: new_admin_settings_storage_automatically_managed_project_folders_path(storage),- scheme: :invisible,- aria: { label: I18n.t('storages.label_edit_storage_automatically_managed_folders') },- test_selector: 'storage-edit-automatically-managed-project-folders-button'- )- )- end- end- end- end- end+ render(Storages::Admin::AutomaticallyManagedProjectFoldersInfoComponent.new(storage))endendenddiff --git a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rbindex fa33ed89365..84e6153ad2c 100644--- a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb+++ b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb@@ -41,7 +41,7 @@ class Storages::Admin::AutomaticallyManagedProjectFoldersController < Applicatio# specify which model #find_model_object should look upmodel_object Storages::NextcloudStorage- before_action :find_model_object, only: %i[new edit update]+ before_action :find_model_object, only: %i[new create edit update]# menu_item is defined in the Redmine::MenuManager::MenuController# module, included from ApplicationController.@@ -66,6 +66,18 @@ class Storages::Admin::AutomaticallyManagedProjectFoldersController < Applicatiorender '/storages/admin/storages/automatically_managed_project_folders/edit'end+ def create+ service_result = call_update_service++ if service_result.success?+ redirect_to edit_admin_settings_storage_path(@storage)+ else+ respond_to do |format|+ format.turbo_stream { render partial: '/storages/admin/storages/automatically_managed_project_folders/form' }+ end+ end+ end+# Renders an edit page (allowing the user to change automatically_managed bool and password).# Used by: The StoragesController#edit, when user wants to update application credentials.# Called by: Global app/config/routes.rb to serve Web page@@ -77,10 +89,7 @@ class Storages::Admin::AutomaticallyManagedProjectFoldersController < Applicatio# See also: create above# Called by: Global app/config/routes.rb to serve Web pagedef update- service_result = ::Storages::Storages::UpdateService- .new(user: current_user,- model: @storage)- .call(permitted_storage_params_with_defaults)+ service_result = call_update_serviceif service_result.success?flash[:notice] = I18n.t(:notice_successful_update)@@ -113,6 +122,13 @@ class Storages::Admin::AutomaticallyManagedProjectFoldersController < Applicatio@storage = @objectend+ def call_update_service+ ::Storages::Storages::UpdateService+ .new(user: current_user,+ model: @storage)+ .call(permitted_storage_params_with_defaults)+ end+def permitted_storage_params_with_defaultspermitted_storage_params.tap do |permitted_params|# If a checkbox is unchecked when its form is submitted, neither the name nor the value is submitted to the server.diff --git a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rbindex 2bb256f6610..0c28e1bcae7 100644--- a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb+++ b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb@@ -46,12 +46,17 @@ class Storages::Admin::OAuthClientsController < ApplicationController# Show the admin page to create a new OAuthClient object.def new- @oauth_client = ::OAuthClients::SetAttributesService.new(user: User.current,- model: OAuthClient.new,- contract_class: EmptyContract)- .call- .result- render '/storages/admin/storages/new_oauth_client'+ @oauth_client = ::OAuthClients::SetAttributesService+ .new(user: User.current,+ model: OAuthClient.new,+ contract_class: EmptyContract)+ .call+ .result++ respond_to do |format|+ format.html { render '/storages/admin/storages/new_oauth_client' }+ format.turbo_stream+ endend# Actually create a OAuthClient object.@@ -61,6 +66,7 @@ class Storages::Admin::OAuthClientsController < ApplicationControllerservice_result = ::OAuthClients::CreateService.new(user: User.current).call(oauth_client_params.merge(integration: @storage))@oauth_client = service_result.result+ @storage = @storage.reloadservice_result.on_failure dorender '/storages/admin/storages/new_oauth_client'@@ -71,7 +77,10 @@ class Storages::Admin::OAuthClientsController < ApplicationControllerif @storage.provider_type_nextcloud? && @storage.automatic_management_unspecified?if OpenProject::FeatureDecisions.storage_primer_design_active?- redirect_to edit_admin_settings_storage_path(@storage)+ respond_to do |format|+ format.html { redirect_to edit_admin_settings_storage_path(@storage) }+ format.turbo_stream+ endelseredirect_to new_admin_settings_storage_automatically_managed_project_folders_path(@storage)enddiff --git a/modules/storages/app/views/storages/admin/oauth_clients/create.turbo_stream.erb b/modules/storages/app/views/storages/admin/oauth_clients/create.turbo_stream.erbnew file mode 100644index 00000000000..d6deb913f62--- /dev/null+++ b/modules/storages/app/views/storages/admin/oauth_clients/create.turbo_stream.erb@@ -0,0 +1,34 @@+<%#-- 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.++++#%>++<%= turbo_stream.update :storage_oauth_client_section do %>+ <%= render(Storages::Admin::OAuthClientInfoComponent.new(oauth_client: @oauth_client, storage: @storage)) %>+<% end %>++<%= render partial: 'form' %>diff --git a/modules/storages/app/views/storages/admin/oauth_clients/new.turbo_stream.erb b/modules/storages/app/views/storages/admin/oauth_clients/new.turbo_stream.erbnew file mode 100644index 00000000000..0b9c1ba7c6f--- /dev/null+++ b/modules/storages/app/views/storages/admin/oauth_clients/new.turbo_stream.erb@@ -0,0 +1,43 @@+<%#-- 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.++++#%>++<%= turbo_stream.update :storage_openproject_oauth_section do %>+ <%=+ render(+ Storages::Admin::OAuthApplicationInfoComponent.new(+ oauth_application: @oauth_application,+ storage: @storage,+ )+ )+ %>+<% end %>++<%= turbo_stream.update :storage_oauth_client_section do %>+ <%= render(Storages::Admin::Forms::OAuthClientFormComponent.new(oauth_client: @oauth_client, storage: @storage)) %>+<% end %>diff --git a/modules/storages/app/views/storages/admin/storages/automatically_managed_project_folders/_form.html.erb b/modules/storages/app/views/storages/admin/storages/automatically_managed_project_folders/_form.html.erbnew file mode 100644index 00000000000..0bcde24a4cc--- /dev/null+++ b/modules/storages/app/views/storages/admin/storages/automatically_managed_project_folders/_form.html.erb@@ -0,0 +1,32 @@+<%#-- 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.++++#%>++<%= turbo_stream.update :automatically_managed_project_folders_section do %>+ <%= render(Storages::Admin::Forms::AutomaticallyManagedProjectFoldersFormComponent.new(@storage, form_method: :post)) %>+<% end %>diff --git a/modules/storages/app/views/storages/admin/storages/show_oauth_application.turbo_stream.erb b/modules/storages/app/views/storages/admin/storages/show_oauth_application.turbo_stream.erbindex b610c4bc5df..9bc710790bb 100644--- a/modules/storages/app/views/storages/admin/storages/show_oauth_application.turbo_stream.erb+++ b/modules/storages/app/views/storages/admin/storages/show_oauth_application.turbo_stream.erb@@ -27,7 +27,7 @@ See COPYRIGHT and LICENSE files for more details.++#%>-<%= turbo_stream.update :storage_general_info_section do %>+<%= turbo_stream.update :storage_general_info_section do %><%= render(Storages::Admin::GeneralInfoComponent.new(@storage)) %><% end %>@@ -37,20 +37,13 @@ See COPYRIGHT and LICENSE files for more details.Storages::Admin::OAuthApplicationInfoCopyComponent.new(oauth_application: @oauth_application,storage: @storage,+ submit_button_options: {+ data: { turbo_stream: true }+ },+ submit_button_path: new_admin_settings_storage_oauth_client_path(@storage),+ cancel_button_path: admin_settings_storages_path,+ cancel_button_should_break_from_frame: true))%><% end %>--<% if @storage.provider_type_nextcloud? %>- <%= turbo_stream.update :storage_oauth_client_section do %>- <%=- render(- Storages::Admin::Forms::OAuthClientFormComponent.new(- oauth_client: @storage.build_oauth_client,- storage: @storage- )- )- %>- <% end %>-<% end %>diff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rbindex 0909bd8e9a6..49d29a48594 100644--- a/modules/storages/config/routes.rb+++ b/modules/storages/config/routes.rb@@ -34,7 +34,7 @@ OpenProject::Application.routes.draw doresources :storages, controller: '/storages/admin/storages', except: [:show] doresource :oauth_client, controller: '/storages/admin/oauth_clients', only: %i[new create]resource :automatically_managed_project_folders, controller: '/storages/admin/automatically_managed_project_folders',- only: %i[new edit update]+ only: %i[new create edit update]post :select_provider, on: :collection