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

[#55960] Add the enabled in projects tab in storage edit view (#15990)

judithroth5c9ba0dcb761
diff --git a/app/components/settings/project_custom_fields/edit_form_header_component.html.erb b/app/components/settings/project_custom_fields/edit_form_header_component.html.erb
index d77783af62a..d4802f1b25f 100644
--- a/app/components/settings/project_custom_fields/edit_form_header_component.html.erb
+++ b/app/components/settings/project_custom_fields/edit_form_header_component.html.erb
@@ -43,7 +43,7 @@ See COPYRIGHT and LICENSE files for more details.
selected: project_custom_field_project_mappings_selected?,
href: project_mappings_admin_settings_project_custom_field_path(@custom_field)
) do |tab|
- tab.with_text { I18n.t("projects.settings.project_custom_fields.project_mappings.header") }
+ tab.with_text { t(:label_project_mappings) }
end
end
end
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 455e0403490..2032e684fab 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -338,8 +338,6 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
new_project_mapping_form:
add_projects: Add projects
include_sub_projects: Include sub-projects
- project_mappings:
- header: Enabled in projects
types:
no_results_title_text: There are currently no types available.
form:
@@ -2316,6 +2314,7 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
label_project_latest: "Latest projects"
label_project_default_type: "Allow empty type"
label_project_hierarchy: "Project hierarchy"
+ label_project_mappings: "Enabled in projects"
label_project_new: "New project"
label_project_plural: "Projects"
label_project_list_plural: "Project lists"
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
new file mode 100644
index 00000000000..0cb7dd59ff7
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/edit_form_header_component.html.erb
@@ -0,0 +1,64 @@
+<%#-- 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.
+
+++#%>
+<%=
+ render(Primer::OpenProject::PageHeader.new) do |header|
+ header.with_title(test_selector: 'storage-new-page-header--title') do
+ render OpTurbo::FrameComponent.new(@storage, context: :edit_storage_header) do
+ label_storage_name_with_provider_label
+ end
+ end
+ header.with_breadcrumbs(breadcrumbs_items)
+ header.with_action_button(scheme: :danger,
+ mobile_icon: :trash,
+ mobile_label: I18n.t("button_delete"),
+ type: :submit,
+ aria: { label: I18n.t("storages.label_delete_storage") },
+ test_selector: "storage-delete-button") do |button|
+ button.with_leading_visual_icon(icon: :trash)
+ I18n.t("button_delete")
+ end
+ if OpenProject::FeatureDecisions.enable_storage_for_multiple_projects_active?
+ header.with_tab_nav(label: nil, test_selector: :project_attribute_detail_header) do |tab_nav|
+ tab_nav.with_tab(
+ selected: tab_selected?(:edit),
+ href: edit_admin_settings_storage_path(@storage)
+ ) do |tab|
+ 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
+ end
+ end
+ end
+%>
diff --git a/modules/storages/app/components/storages/admin/edit_form_header_component.rb b/modules/storages/app/components/storages/admin/edit_form_header_component.rb
new file mode 100644
index 00000000000..f6a923e06e4
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/edit_form_header_component.rb
@@ -0,0 +1,65 @@
+#-- 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.
+#++
+
+module Storages
+ module Admin
+ class EditFormHeaderComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+ TAB_NAVS = %i[
+ edit
+ project_mappings
+ ].freeze
+
+ def initialize(storage:, selected:)
+ super
+ @storage = storage
+ @selected = selected
+ end
+
+ def tab_selected?(tab_name)
+ TAB_NAVS.include?(tab_name) &&
+ tab_name == @selected
+ end
+
+ def label_storage_name_with_provider_label
+ "#{h(@storage.name)} #{label_storage_provider_part}".html_safe # rubocop:disable Rails/OutputSafety
+ end
+
+ def label_storage_provider_part
+ render(Primer::Beta::Text.new(tag: :span, font_weight: :light, color: :muted)) do
+ "(#{I18n.t("storages.provider_types.#{h(@storage.short_provider_type)}.name")})"
+ end
+ end
+
+ def breadcrumbs_items
+ [{ href: admin_index_path, text: t("label_administration") },
+ { href: admin_settings_storages_path, text: t("project_module_storages") },
+ @storage.name]
+ end
+ end
+ 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 13ec7e2007b..c029f3a51a9 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]
+ change_health_notifications_enabled replace_oauth_application project_mappings]
before_action :ensure_valid_provider_type_selected, only: %i[select_provider]
before_action :require_ee_token_for_one_drive, only: %i[select_provider]
@@ -245,6 +245,8 @@ 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/edit.html.erb b/modules/storages/app/views/storages/admin/storages/edit.html.erb
index b5d320e8349..8d8e7f2d2d1 100644
--- a/modules/storages/app/views/storages/admin/storages/edit.html.erb
+++ b/modules/storages/app/views/storages/admin/storages/edit.html.erb
@@ -27,13 +27,6 @@ See COPYRIGHT and LICENSE files for more details.
++#%>
-<%
- label_storage_provider_part = render(Primer::Beta::Text.new(tag: :span, font_weight: :light, color: :muted)) do
- "(#{I18n.t("storages.provider_types.#{@storage.short_provider_type}.name")})"
- end
- label_storage_name_with_provider_label = "#{@storage.name} #{label_storage_provider_part}".html_safe
-%>
-
<% html_title t(:label_administration), t("project_module_storages"), t('label_edit_x', x: @storage.name) %>
<%= primer_form_with(
@@ -41,27 +34,12 @@ See COPYRIGHT and LICENSE files for more details.
url: confirm_destroy_admin_settings_storage_path(@storage),
method: :get
) do %>
- <%= render(Primer::OpenProject::PageHeader.new) do |header| %>
- <% header.with_title(test_selector: 'storage-new-page-header--title') do %>
- <%= render OpTurbo::FrameComponent.new(@storage, context: :edit_storage_header) do %>
- <%= label_storage_name_with_provider_label %>
- <% end %>
- <% end %>
-
- <% header.with_breadcrumbs([{href: admin_index_path, text: t("label_administration")},
- {href: admin_settings_storages_path, text: t("project_module_storages")},
- @storage.name]) %>
-
- <% header.with_action_button(scheme: :danger,
- mobile_icon: :trash,
- mobile_label: I18n.t("button_delete"),
- type: :submit,
- aria: { label: I18n.t("storages.label_delete_storage") },
- test_selector: "storage-delete-button") do |button|
- button.with_leading_visual_icon(icon: :trash)
- I18n.t("button_delete")
- end %>
- <% end %>
+ <%=
+ render(Storages::Admin::EditFormHeaderComponent.new(
+ storage: @storage,
+ selected: :edit
+ ))
+ %>
<% end %>
<% display_sidebar = @storage.provider_type_one_drive? || @storage.automatic_management_enabled? %>
diff --git a/modules/storages/app/views/storages/admin/storages/project_mappings.html.erb b/modules/storages/app/views/storages/admin/storages/project_mappings.html.erb
new file mode 100644
index 00000000000..7dbce914141
--- /dev/null
+++ b/modules/storages/app/views/storages/admin/storages/project_mappings.html.erb
@@ -0,0 +1,36 @@
+<%#-- 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.
+
+++#%>
+
+<%=
+ render(Storages::Admin::EditFormHeaderComponent.new(
+ storage: @storage,
+ selected: :project_mappings
+ )
+ )
+%>
diff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rb
index 04b2d533977..3654c773320 100644
--- a/modules/storages/config/routes.rb
+++ b/modules/storages/config/routes.rb
@@ -58,6 +58,7 @@ 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
diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb
index a0115a9ffa4..55b9948111d 100644
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@ -48,6 +48,7 @@ module OpenProject::Storages
initializer "openproject_storages.feature_decisions" do
OpenProject::FeatureDecisions.add :storage_file_picking_select_all
+ OpenProject::FeatureDecisions.add :enable_storage_for_multiple_projects
end
initializer "openproject_storages.event_subscriptions" do