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

[#53718] enabled update action for access management

Eric Schubert52a495f66a9f
diff --git a/modules/storages/app/components/storages/admin/forms/access_management_form_component.html.erb b/modules/storages/app/components/storages/admin/forms/access_management_form_component.html.erb
index dbb415d7edb..158ea595bc5 100644
--- a/modules/storages/app/components/storages/admin/forms/access_management_form_component.html.erb
+++ b/modules/storages/app/components/storages/admin/forms/access_management_form_component.html.erb
@@ -3,7 +3,7 @@
primer_form_with(
model:,
url: admin_settings_storage_access_management_path(storage),
- method: :post
+ method: form_method
) do |form|
flex_layout do |access_management_row|
access_management_row.with_row(mb: 3) do
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 779b1b4fce8..1e7cca85a6c 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
@@ -35,8 +35,16 @@ module Storages::Admin::Forms
private
+ def form_method
+ first_time_configuration? ? :post : :patch
+ end
+
def cancel_button_path
edit_admin_settings_storage_path(storage)
end
+
+ def first_time_configuration?
+ storage.automatic_management_new_record?
+ end
end
end
diff --git a/modules/storages/app/controllers/storages/admin/access_management_controller.rb b/modules/storages/app/controllers/storages/admin/access_management_controller.rb
index bd2e1201fd1..e887fcee1bb 100644
--- a/modules/storages/app/controllers/storages/admin/access_management_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/access_management_controller.rb
@@ -34,7 +34,7 @@ class Storages::Admin::AccessManagementController < ApplicationController
before_action :require_admin
model_object Storages::OneDriveStorage
- before_action :find_model_object, only: %i[new create edit]
+ 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,20 @@ class Storages::Admin::AccessManagementController < ApplicationController
end
end
+ def update
+ service_result = call_update_service
+
+ service_result.on_success do
+ respond_to { |format| format.turbo_stream }
+ end
+
+ service_result.on_failure do
+ respond_to do |format|
+ format.turbo_stream { render :edit }
+ end
+ end
+ end
+
def edit
respond_to do |format|
format.turbo_stream
diff --git a/modules/storages/app/views/storages/admin/access_management/update.turbo_stream.erb b/modules/storages/app/views/storages/admin/access_management/update.turbo_stream.erb
new file mode 100644
index 00000000000..557a02a53c1
--- /dev/null
+++ b/modules/storages/app/views/storages/admin/access_management/update.turbo_stream.erb
@@ -0,0 +1,32 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2024 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 :access_management_section do %>
+ <%= render(Storages::Admin::AccessManagementComponent.new(@storage)) %>
+<% end %>
diff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rb
index 1d78e0b8230..0e6cd5119c8 100644
--- a/modules/storages/config/routes.rb
+++ b/modules/storages/config/routes.rb
@@ -41,7 +41,7 @@ Rails.application.routes.draw do
resource :automatically_managed_project_folders, controller: "/storages/admin/automatically_managed_project_folders",
only: %i[new create edit update]
- resource :access_management, controller: "/storages/admin/access_management", only: %i[new create edit]
+ resource :access_management, controller: "/storages/admin/access_management", only: %i[new create edit update]
get :select_provider, on: :collection