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

feat[#50921] Add storage health information in admin page

Dominic Bräunlein602110732c28
diff --git a/modules/storages/app/components/storages/admin/health_status_component.html.erb b/modules/storages/app/components/storages/admin/health_status_component.html.erb
new file mode 100644
index 00000000000..ca512118b1f
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/health_status_component.html.erb
@@ -0,0 +1,24 @@
+<%= render(Primer::Box.new) do %>
+ <%= render(Primer::Beta::Heading.new(tag: :h4, mb: 2)) { I18n.t('storages.health.title') } %>
+
+ <%= render(Primer::Box.new(py: 1)) do %>
+ <%= render(Primer::Beta::Text.new) { I18n.t('storages.health.checked', datetime: helpers.format_time(storage.health_changed_at)) } %>
+ <% if storage.health_healthy? %>
+ <%= render(Primer::Beta::Label.new(scheme: :success, test_selector: "label-healthy")) {
+ I18n.t('storages.health.label_healthy')
+ } %>
+ <% elsif storage.health_unhealthy? %>
+ <%= render(Primer::Beta::Label.new(scheme: :danger, test_selector: "label-error")) {
+ I18n.t('storages.health.label_error')
+ } %>
+ <% else %>
+ <%= render(Primer::Beta::Label.new(scheme: :attention, test_selector: "label-pending")) {
+ I18n.t('storages.health.label_pending')
+ } %>
+ <% end %>
+ <% end %>
+
+ <% if storage.health_unhealthy? %>
+ <%= render(Primer::Beta::Text.new(tag: :div, color: :muted, py: 1)) { storage.formatted_health_reason } %>
+ <% end %>
+<% end %>
diff --git a/modules/storages/app/components/storages/admin/health_status_component.rb b/modules/storages/app/components/storages/admin/health_status_component.rb
new file mode 100644
index 00000000000..efd92ea08cf
--- /dev/null
+++ b/modules/storages/app/components/storages/admin/health_status_component.rb
@@ -0,0 +1,35 @@
+# 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 HealthStatusComponent < ApplicationComponent
+ alias_method :storage, :model
+ end
+end
diff --git a/modules/storages/app/components/storages/admin/storage_list_component.html.erb b/modules/storages/app/components/storages/admin/storage_list_component.html.erb
index aac5abb311e..d83bdcb353b 100644
--- a/modules/storages/app/components/storages/admin/storage_list_component.html.erb
+++ b/modules/storages/app/components/storages/admin/storage_list_component.html.erb
@@ -28,7 +28,11 @@
concat(render(Primer::Beta::Link.new(href: edit_admin_settings_storage_path(storage), scheme: :primary, mr: 1, data: { 'test-selector': 'storage-name' })) { storage.name })
unless storage.configured?
- concat(render(Primer::Beta::Label.new(scheme: :attention, data: { 'test-selector': 'label-incomplete' })) { I18n.t('storages.label_incomplete') })
+ concat(render(Primer::Beta::Label.new(scheme: :attention, test_selector: "label-incomplete", mr: 1)) { I18n.t('storages.label_incomplete') })
+ end
+
+ if storage.health_unhealthy?
+ concat(render(Primer::Beta::Label.new(scheme: :danger, test_selector: "label-error")) { I18n.t('storages.health.label_error') })
end
end
diff --git a/modules/storages/app/models/storages/storage.rb b/modules/storages/app/models/storages/storage.rb
index efc53171eaf..5bc4d9f0691 100644
--- a/modules/storages/app/models/storages/storage.rb
+++ b/modules/storages/app/models/storages/storage.rb
@@ -131,5 +131,14 @@ module Storages
def provider_type_one_drive?
provider_type == ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE
end
+
+ def formatted_health_reason
+ split_reason = health_reason.split('|')
+ if split_reason.length === 3
+ "#{split_reason[0].strip.capitalize}: #{split_reason[1]}"
+ else
+ health_reason
+ end
+ end
end
end
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 8ea5244d179..b06bc99be6e 100644
--- a/modules/storages/app/views/storages/admin/storages/edit.html.erb
+++ b/modules/storages/app/views/storages/admin/storages/edit.html.erb
@@ -67,4 +67,19 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% end %>
-<%= render(::Storages::Admin::StorageViewComponent.new(@storage)) %>
+<% if @storage.provider_type_nextcloud? && @storage.automatically_managed? %>
+ <%= render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |component| %>
+ <% component.with_main() do %>
+ <%= render(::Storages::Admin::StorageViewComponent.new(@storage)) %>
+ <% end %>
+ <% component.with_sidebar(col_placement: :end, row_placement: :end) do %>
+ <%= render(Primer::OpenProject::BorderGrid.new(spacious: true)) do |grid| %>
+ <% grid.with_row do %>
+ <%= render(::Storages::Admin::HealthStatusComponent.new(@storage)) %>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% end %>
+<% else %>
+ <%= render(::Storages::Admin::StorageViewComponent.new(@storage)) %>
+<% end %>
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index d5e1772e27e..975d72f8008 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -249,3 +249,9 @@ en:
automatically_managed_project_folder_missing: "To complete the setup, please configure automatically managed project folders for your storage."
notice_oauth_application_replaced: "The OpenProject OAuth application was successfully replaced."
notice_successful_storage_connection: "Storage connected successfully! Remember to activate the module and the specific storage in the project settings of each desired project to use it."
+ health:
+ title: "Managed folders status"
+ label_pending: "Pending"
+ label_error: "Error"
+ label_healthy: "Healthy"
+ checked: "Checked %{datetime}"