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

[#55966] Define "Enabled in Projects" as a fully qualified nested resource

Kabiru Mwenja15095e4e1cac
diff --git a/modules/storages/app/components/storages/admin/edit_form_header_component.html.erb b/modules/storages/app/components/storages/admin/edit_form_header_component.html.erb
index 0cb7dd59ff7..d2ee53ce85c 100644
--- a/modules/storages/app/components/storages/admin/edit_form_header_component.html.erb
+++ b/modules/storages/app/components/storages/admin/edit_form_header_component.html.erb
@@ -52,12 +52,11 @@ See COPYRIGHT and LICENSE files for more details.
tab.with_text { t(:label_details) }
end
- tab_nav.with_tab(
- selected: tab_selected?(:project_mappings),
- href: project_mappings_admin_settings_storage_path(@storage)
- ) do |tab|
- tab.with_text { t(:label_project_mappings) }
- end
+ tab_nav.with_tab(
+ selected: tab_selected?(:project_mappings),
+ href: admin_settings_storage_projects_project_storages_path(@storage)
+ ) do |tab|
+ tab.with_text { t(:label_project_mappings) }
end
end
end
diff --git a/modules/storages/app/controllers/storages/admin/projects/project_storages_controller.rb b/modules/storages/app/controllers/storages/admin/projects/project_storages_controller.rb
new file mode 100644
index 00000000000..467f4fda754
--- /dev/null
+++ b/modules/storages/app/controllers/storages/admin/projects/project_storages_controller.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+#-- 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.
+#++
+
+class Storages::Admin::Projects::ProjectStoragesController < ApplicationController
+ include OpTurbo::ComponentStream
+
+ layout "admin"
+
+ model_object Storages::Storage
+
+ before_action :require_admin
+ before_action :find_model_object
+
+ menu_item :external_file_storages
+
+ def index; end
+ def new; end
+ def create; end
+ def show; end
+ def destroy; end
+
+ private
+
+ def find_model_object(object_id = :storage_id)
+ super
+ @storage = @object
+ end
+end
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index f084e2ffb1e..bacb294a174 100644
--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb
@@ -46,7 +46,7 @@ class Storages::Admin::StoragesController < ApplicationController
before_action :require_admin
before_action :find_model_object,
only: %i[show_oauth_application destroy edit edit_host confirm_destroy update
- change_health_notifications_enabled replace_oauth_application project_mappings]
+ change_health_notifications_enabled replace_oauth_application]
before_action :ensure_valid_provider_type_selected, only: %i[select_provider]
before_action :require_ee_token_for_one_drive, only: %i[select_provider]
@@ -208,8 +208,6 @@ class Storages::Admin::StoragesController < ApplicationController
end
end
- def project_mappings; end
-
def default_breadcrumb; end
def show_local_breadcrumb
diff --git a/modules/storages/app/views/storages/admin/storages/project_mappings.html.erb b/modules/storages/app/views/storages/admin/projects/project_storages/index.html.erb
similarity index 71%
rename from modules/storages/app/views/storages/admin/storages/project_mappings.html.erb
rename to modules/storages/app/views/storages/admin/projects/project_storages/index.html.erb
index 7dbce914141..82ce89b5aaa 100644
--- a/modules/storages/app/views/storages/admin/storages/project_mappings.html.erb
+++ b/modules/storages/app/views/storages/admin/projects/project_storages/index.html.erb
@@ -34,3 +34,19 @@ See COPYRIGHT and LICENSE files for more details.
)
)
%>
+
+<%=
+ render(Primer::OpenProject::SubHeader.new) do |component|
+ component.with_action_component do
+ render(Primer::Beta::Button.new(
+ scheme: :primary,
+ tag: :a,
+ href: new_admin_settings_storage_projects_project_storage_path(@storage),
+ data: { controller: "async-dialog" }
+ )) do |button|
+ button.with_leading_visual_icon(icon: 'op-include-projects')
+ I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.add_projects")
+ end
+ end
+ end
+%>
diff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rb
index 3654c773320..a8b268bb90b 100644
--- a/modules/storages/config/routes.rb
+++ b/modules/storages/config/routes.rb
@@ -40,10 +40,16 @@ Rails.application.routes.draw do
resource :automatically_managed_project_folders,
controller: "/storages/admin/automatically_managed_project_folders",
- only: %i[new create edit update]
+ only: %i[index new create edit update]
resource :access_management, controller: "/storages/admin/access_management", only: %i[new create edit update]
+ namespace :projects do
+ resources :project_storages,
+ controller: "/storages/admin/projects/project_storages",
+ only: %i[index new create destroy]
+ end
+
resource :connection_validation,
controller: "/storages/admin/connection_validation",
only: [] do
@@ -58,7 +64,6 @@ Rails.application.routes.draw do
patch :change_health_notifications_enabled
get :confirm_destroy
delete :replace_oauth_application
- get :project_mappings
end
get :upsale, on: :collection