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
[#62103] health status report for storages
Eric Schubertc192429a1c50
diff --git a/app/components/enterprise_edition/banner_component.rb b/app/components/enterprise_edition/banner_component.rbindex 757198892bd..6f8c0bedc9d 100644--- a/app/components/enterprise_edition/banner_component.rb+++ b/app/components/enterprise_edition/banner_component.rb@@ -87,7 +87,7 @@ module EnterpriseEditionenddef link_title- @link_title || I18n.t("ee.upsale.#{feature_key}.link_title", default: I18n.t("ee.upsale.link_title"))+ @link_title || I18n.t("ee.upsale.#{feature_key}.link_title", default: I18n.t(:label_more_information))enddef hrefdiff --git a/app/views/homescreen/blocks/_upsale.html.erb b/app/views/homescreen/blocks/_upsale.html.erbindex ce836da768a..44f86f1fc67 100644--- a/app/views/homescreen/blocks/_upsale.html.erb+++ b/app/views/homescreen/blocks/_upsale.html.erb@@ -25,7 +25,7 @@target: "_blank",rel: "noopener" do %><%= spot_icon("external-link") %>- <span class="button--text"><%= t("homescreen.blocks.upsale.more_info") %></span>+ <span class="button--text"><%= t(:label_more_information) %></span><% end %>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 79a9a73312e..3b854135842 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -2070,7 +2070,6 @@ en:ee:upsale:title: "Enterprise add-on"- link_title: "More information"automatic_subject_generation:description: "Create automatically generated subjects using referenced attributes and text."customize_life_cycle:@@ -2314,7 +2313,6 @@ en:community: "OpenProject community"upsale:title: "Upgrade to Enterprise edition"- more_info: "More information"links:upgrade_enterprise_edition: "Upgrade to Enterprise edition"postgres_migration: "Migrating your installation to PostgreSQL"@@ -2801,6 +2799,7 @@ en:label_modules: "Modules"label_months_from: "months from"label_more: "More"+ label_more_information: "More information"label_more_than_ago: "more than days ago"label_move_column_left: "Move column left"label_move_column_right: "Move column right"diff --git a/modules/storages/app/common/storages/peripherals/connection_validators/validation_group_result.rb b/modules/storages/app/common/storages/peripherals/connection_validators/validation_group_result.rbindex c6c22e59b3d..c5953f62ab4 100644--- a/modules/storages/app/common/storages/peripherals/connection_validators/validation_group_result.rb+++ b/modules/storages/app/common/storages/peripherals/connection_validators/validation_group_result.rb@@ -33,15 +33,18 @@ module Storagesmodule ConnectionValidatorsclass ValidationGroupResult# TODO: remove []=- delegate :[], :[]=, :each, to: :@results+ delegate :[], :[]=, :each_pair, to: :@resultsdef initialize@results = {}enddef success? = @results.values.all?(&:success?)+def non_failure? = @results.values.none?(&:failure?)+def failure? = @results.values.any?(&:failure?)+def warning? = @results.values.any?(&:warning?)def tally@@ -63,6 +66,10 @@ module Storages@results[key] = valueend++ def timestamp+ @results.values.filter_map(&:timestamp).max+ endendendenddiff --git a/modules/storages/app/common/storages/peripherals/connection_validators/validator_result.rb b/modules/storages/app/common/storages/peripherals/connection_validators/validator_result.rbindex 5dd26295ad6..b4e659d498e 100644--- a/modules/storages/app/common/storages/peripherals/connection_validators/validator_result.rb+++ b/modules/storages/app/common/storages/peripherals/connection_validators/validator_result.rb@@ -52,6 +52,16 @@ module Storagesgroup_results[key] = resultend++ def tally+ group_results.reduce({}) do |tally, (_, group)|+ tally.merge(group.tally) { |_, v1, v2| v1 + v2 }+ end+ end++ def latest_timestamp+ group_results.values.filter_map(&:timestamp).max+ endendendenddiff --git a/modules/storages/app/components/storages/admin/health/check_result_component.html.erb b/modules/storages/app/components/storages/admin/health/check_result_component.html.erbnew file mode 100644index 00000000000..75803712c73--- /dev/null+++ b/modules/storages/app/components/storages/admin/health/check_result_component.html.erb@@ -0,0 +1,60 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 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.++++#%>++<%=+ flex_layout do |cell|+ cell.with_row do+ flex_layout(justify_content: :space_between) do |row|+ row.with_column(flex_layout: true) do |text|+ text.with_column do+ render(Primer::Beta::Text.new(font_weight: :bold)) { data[:text] }+ end+ text.with_column(ml: 2) do+ render(Primer::Beta::Text.new(font_size: :small, color: data[:status_color])) { data[:status_text] }+ end+ end++ if data[:error_text].present?+ row.with_column do+ render(Primer::Beta::Link.new(href: data[:docs_href])) do |link|+ link.with_trailing_visual_icon(icon: :"link-external")+ I18n.t(:label_more_information)+ end+ end+ end+ end+ end++ if data[:error_text].present?+ cell.with_row(mt: 1) do+ render(Primer::Beta::Text.new) { data[:error_text] }+ end+ end+ end+%>diff --git a/modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.rb b/modules/storages/app/components/storages/admin/health/check_result_component.rbsimilarity index 52%rename from modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.rbrename to modules/storages/app/components/storages/admin/health/check_result_component.rbindex 8dc3689d790..7aa11a5d443 100644--- a/modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.rb+++ b/modules/storages/app/components/storages/admin/health/check_result_component.rb@@ -30,22 +30,51 @@module Storagesmodule Admin- module SidePanel- class HealthReportDialogComponent < ApplicationComponent- include OpTurbo::Streamable+ module Health+ class CheckResultComponent < ApplicationComponentinclude OpPrimer::ComponentHelpers- TEST_SELECTOR = "op-storages--health-report-dialog"-- def initialize(storage:, report:)- super(storage)- @report = report+ def initialize(group:, result:)+ super(result)+ @group = groupendprivate- def subtitle- "Last check: 28.03.2025 6:40 PM"+ def data+ @data ||= {+ text: I18n.t("storages.health.checks.#{@group}.#{model.key}"),+ status_color:,+ status_text:,+ error_text: model.message,+ docs_href: ::OpenProject::Static::Links[:storage_docs][:health_status][:href]+ }+ end++ def status_color+ if model.success?+ :success+ elsif model.failure?+ :danger+ elsif model.warning? || model.skipped?+ :attention+ else+ raise ArgumentError, "invalid check result state"+ end+ end++ def status_text+ if model.success?+ I18n.t("storages.health.label_passed")+ elsif model.failure?+ I18n.t("storages.health.label_failed")+ elsif model.warning?+ I18n.t("storages.health.label_warning")+ elsif model.skipped?+ I18n.t("storages.health.label_skipped")+ else+ raise ArgumentError, "invalid check result state"+ endendendenddiff --git a/modules/storages/app/components/storages/admin/health/health_report_component.html.erb b/modules/storages/app/components/storages/admin/health/health_report_component.html.erbnew file mode 100644index 00000000000..1be63b06bbf--- /dev/null+++ b/modules/storages/app/components/storages/admin/health/health_report_component.html.erb@@ -0,0 +1,92 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 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.++++#%>++<%=+ component_wrapper do+ render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |page|+ page.with_main do+ if @report.nil?+ render(Primer::Beta::Blankslate.new(border: true)) do |placeholder|+ placeholder.with_visual_icon(icon: :meter)+ placeholder.with_heading(tag: :h3) { data[:heading] }+ placeholder.with_description { data[:description] }+ placeholder.with_primary_action(+ tag: :a,+ href: admin_settings_storage_health_status_report_path(model),+ data: { turbo_method: :post, turbo: true },+ aria: { label: I18n.t("storages.health.actions.run_checks") }+ ) do+ I18n.t("storages.health.actions.run_checks")+ end+ end+ else+ flex_layout do |report_container|+ report_container.with_row do+ summary = data[:summary]+ concat(render(Primer::Beta::Octicon.new(icon: summary[:icon], color: summary[:icon_color], mr: 2)))+ concat(render(Primer::Beta::Text.new(font_weight: :bold)) { summary[:text] })+ end++ report_container.with_row(mt: 2) do+ render(Primer::Beta::Text.new) { data[:description] }+ end++ @report.each_pair do |group, checks|+ report_container.with_row(mt: 3) do+ render(Primer::Beta::BorderBox.new) do |box|+ box.with_header do+ flex_layout(justify_content: :space_between) do |header|+ header.with_column do+ render(Primer::Beta::Text.new(font_weight: :bold)) do+ I18n.t("storages.health.checks.#{group}.header")+ end+ end++ header.with_column do+ summary = summary_with_icon(checks.tally)+ concat(render(Primer::Beta::Octicon.new(icon: summary[:icon], color: summary[:icon_color], mr: 2)))+ concat(render(Primer::Beta::Text.new) { summary[:text] })+ end+ end+ end++ checks.each_pair do |_key, value|+ box.with_row { render(Storages::Admin::Health::CheckResultComponent.new(group:, result: value)) }+ end+ end+ end+ end+ end+ end+ end++ page.with_sidebar(col_placement: :end, row_placement: :end)+ end+ end+%>diff --git a/modules/storages/app/components/storages/admin/health/health_report_component.rb b/modules/storages/app/components/storages/admin/health/health_report_component.rbnew file mode 100644index 00000000000..68b876fc1cb--- /dev/null+++ b/modules/storages/app/components/storages/admin/health/health_report_component.rb@@ -0,0 +1,107 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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+ module Health+ class HealthReportComponent < ApplicationComponent+ include OpPrimer::ComponentHelpers+ include OpTurbo::Streamable++ def initialize(storage:, report:)+ super(storage)+ @report = report+ end++ private++ def data+ @data ||= compute_display_data+ end++ def compute_display_data+ if @report.nil?+ return {+ heading: I18n.t("storages.health.no_report"),+ description: I18n.t("storages.health.no_report_description")+ }+ end++ checks_tally = @report.tally+ if @report.healthy?+ {+ summary: summary_with_icon(checks_tally),+ description: I18n.t("storages.health.summary.success")+ }+ else+ description = if @report.unhealthy?+ I18n.t("storages.health.summary.failure")+ else+ I18n.t("storages.health.summary.warning")+ end+ {+ summary: summary_with_icon(checks_tally),+ description:+ }+ end+ end++ def group_summary(group)+ icon = group.failure? || group.warning? ? :alert : "check-circle"+ icon_color = if group.failure?+ :danger+ elsif group.warning?+ :attention+ else+ :success+ end++ checks = group.tally+ key = group.failure? || group.success? ? :failure : :warning++ { icon:, icon_color:, text: I18n.t("storages.health.checks.#{key.to_s.pluralize}", count: checks[key]) }+ end++ def summary_with_icon(check_tally)+ failure = check_tally[:failure] || 0+ warning = check_tally[:warning] || 0++ if failure > 0+ { icon: :alert, icon_color: :danger, text: I18n.t("storages.health.checks.failures", count: failure) }+ elsif warning > 0+ { icon: :alert, icon_color: :attention, text: I18n.t("storages.health.checks.warnings", count: warning) }+ else+ { icon: :"check-circle", icon_color: :success, text: I18n.t("storages.health.checks.failures", count: 0) }+ end+ end+ end+ end+ end+enddiff --git a/modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.html.erb b/modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.html.erbdeleted file mode 100644index b159c3028cd..00000000000--- a/modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.html.erb+++ /dev/null@@ -1,95 +0,0 @@-<%#-- copyright-OpenProject is an open source project management software.-Copyright (C) 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::Alpha::Dialog.new(- title: "Health report for #{model.name}",- subtitle:,- size: :large,- test_selector: TEST_SELECTOR- )- ) do |dialog|- dialog.with_show_button(- scheme: :link,- color: :default,- font_weight: :bold- ) do- "Open full health report"- end- dialog.with_header(show_divider: true)- dialog.with_body do- component_wrapper do- flex_layout do |modal_body|- modal_body.with_row do- flex_layout(align_items: :center, justify_content: :space_between) do |summary|- summary.with_column(flex_layout: true) do |container|- container.with_row do- concat(render(Primer::Beta::Octicon.new(icon: :"check-circle", color: :success, mr: 2)))- concat(render(Primer::Beta::Text.new(font_weight: :bold)) { "All checks successful" })- end-- container.with_row(mt: 2) do- render(Primer::Beta::Text.new) { "All connections and systems are working as expected. " }- end- end-- summary.with_column do- primer_form_with(- model:,- url: validate_connection_admin_settings_storage_connection_validation_path(model),- method: :post,- data: { turbo: true }- ) do- render(Primer::Beta::Button.new(scheme: :primary, type: :submit)) do- I18n.t("storages.health.connection_validation.action")- end- end- end- end- end-- @report.each_pair do |group, checks|- modal_body.with_row(mt: 3) do- render(Primer::Beta::BorderBox.new) do |box|- box.with_header { group.to_s.humanize }-- checks.each do |key, value|- box.with_row do- "#{key.to_s.humanize} - #{value.state.to_s.humanize}"- end- end- end- end- end- end- end- end- end-%>diff --git a/modules/storages/app/components/storages/admin/side_panel/health_status_component.html.erb b/modules/storages/app/components/storages/admin/side_panel/health_status_component.html.erbindex af2db8555c4..cb134f97a5f 100644--- a/modules/storages/app/components/storages/admin/side_panel/health_status_component.html.erb+++ b/modules/storages/app/components/storages/admin/side_panel/health_status_component.html.erb@@ -34,7 +34,7 @@ See COPYRIGHT and LICENSE files for more details.flex_layout do |health_status_container|health_status_container.with_row do- render(Storages::Admin::SidePanel::ValidationResultComponent.new(storage: model, result: nil))+ render(Storages::Admin::SidePanel::ValidationResultComponent.new(storage: model, result: report))endendenddiff --git a/modules/storages/app/components/storages/admin/side_panel/health_status_component.rb b/modules/storages/app/components/storages/admin/side_panel/health_status_component.rbindex 54c5df4c295..dc01abec961 100644--- a/modules/storages/app/components/storages/admin/side_panel/health_status_component.rb+++ b/modules/storages/app/components/storages/admin/side_panel/health_status_component.rb@@ -35,6 +35,12 @@ module Storagesinclude ApplicationHelperinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers++ private++ def report+ Rails.cache.read("storage_#{model.id}_health_status_report")+ endendendenddiff --git a/modules/storages/app/components/storages/admin/side_panel/validation_result_component.html.erb b/modules/storages/app/components/storages/admin/side_panel/validation_result_component.html.erbindex 0ee677c2626..8095eed46db 100644--- a/modules/storages/app/components/storages/admin/side_panel/validation_result_component.html.erb+++ b/modules/storages/app/components/storages/admin/side_panel/validation_result_component.html.erb@@ -30,28 +30,37 @@ See COPYRIGHT and LICENSE files for more details.<%=component_wrapper doflex_layout do |container|- if validation_result?- container.with_row(test_selector: "validation-result--subtitle") do- header = status_summary+ if @result.present?+ container.with_row do+ header = summary_header- concat(render(Primer::Beta::Octicon.new(icon: header[:icon], color: header[:color], mr: 2)))+ concat(render(Primer::Beta::Octicon.new(icon: header[:icon], color: header[:icon_color], mr: 2)))concat(render(Primer::Beta::Text.new(font_weight: :bold)) { header[:text] })endcontainer.with_row(mt: 2) do- render(Primer::Beta::Text.new(color: :muted, test_selector: "validation-result--description")) do- "All connections and systems are working as expected. Last check: 28.03.2025 6:40 PM."- end+ render(Primer::Beta::Text.new(color: :muted)) { summary_description }endcontainer.with_row(mt: 2) do- render(Storages::Admin::SidePanel::HealthReportDialogComponent.new(storage: model, report: @result))+ render(+ Primer::Beta::Button.new(+ scheme: :link,+ color: :default,+ font_weight: :bold,+ tag: :a,+ href: admin_settings_storage_health_status_report_path(model)+ )+ ) do |button|+ button.with_leading_visual_icon(icon: :meter)+ I18n.t("storages.health.open_report")+ endendelsecontainer.with_row doprimer_form_with(model:,- url: validate_connection_admin_settings_storage_connection_validation_path(model),+ url: create_health_status_report_admin_settings_storage_health_status_report_path(model),method: :post,data: { turbo: true }) do@@ -63,8 +72,8 @@ See COPYRIGHT and LICENSE files for more details.type: :submit)) do |button|- button.with_leading_visual_icon(icon: "meter")- I18n.t("storages.health.connection_validation.action")+ button.with_leading_visual_icon(icon: :meter)+ I18n.t("storages.health.actions.run_checks")endendenddiff --git a/modules/storages/app/components/storages/admin/side_panel/validation_result_component.rb b/modules/storages/app/components/storages/admin/side_panel/validation_result_component.rbindex 5053f8db79b..7f647c76f89 100644--- a/modules/storages/app/components/storages/admin/side_panel/validation_result_component.rb+++ b/modules/storages/app/components/storages/admin/side_panel/validation_result_component.rb@@ -42,21 +42,31 @@ module Storagesprivate- def status_summary- if @result.nil?- { icon: nil, color: :success, text: "Run connection validation" }- elsif @result.healthy?- { icon: :"check-circle", color: :success, text: "All checks passed" }- elsif @result.unhealthy?- { icon: :alert, color: :danger, text: "2 checks failed" }- elsif @result.warning?- { icon: :alert, color: :warning, text: "3 checks failed" }+ def summary_header+ tally = @result.tally+ failure = tally[:failure] || 0+ warning = tally[:warning] || 0++ if failure > 0+ { icon: :alert, icon_color: :danger, text: I18n.t("storages.health.checks.failures", count: failure) }+ elsif warning > 0+ { icon: :alert, icon_color: :attention, text: I18n.t("storages.health.checks.warnings", count: warning) }else- raise ArgumentError, "Unknown validation result type: #{@result.type}"+ { icon: :"check-circle", icon_color: :success, text: I18n.t("storages.health.checks.failures", count: 0) }endend- def validation_result? = @result.present?+ def summary_description+ text = if @result.healthy?+ I18n.t("storages.health.summary.success")+ elsif @result.unhealthy?+ I18n.t("storages.health.summary.failure")+ else+ I18n.t("storages.health.summary.warning")+ end++ "#{text} #{I18n.t('storages.health.checked', datetime: @result.latest_timestamp)}"+ endendendenddiff --git a/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb b/modules/storages/app/controllers/storages/admin/connection_validation_controller.rbdeleted file mode 100644index f1aa324f507..00000000000--- a/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb+++ /dev/null@@ -1,103 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 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 ConnectionValidationController < ApplicationController- include OpTurbo::ComponentStream-- layout "admin"-- before_action :require_admin-- model_object Storage-- before_action :find_model_object, only: %i[validate_connection]-- def validate_connection- case @storage.provider_type- when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD- validator = Peripherals::NextcloudConnectionValidator.new(storage: @storage)- when ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE- validator = Peripherals::OneDriveConnectionValidator.new(storage: @storage)- else- raise "Unsupported provider type: #{@storage.provider_type}"- end-- # @result = validator.validate- @result = test_success-- update_via_turbo_stream(component: SidePanel::ValidationResultComponent.new(storage: @storage, result: @result))- respond_to_with_turbo_streams- end-- private-- def find_model_object(object_id = :storage_id)- super- @storage = @object- end-- def test_success # rubocop:disable Metrics/AbcSize- r = Peripherals::ConnectionValidators::ValidatorResult.new-- base_configuration = Peripherals::ConnectionValidators::ValidationGroupResult.new- base_configuration[:storage_configured] =- Peripherals::ConnectionValidators::CheckResult.success(:storage_configured)- base_configuration[:capabilities_request] =- Peripherals::ConnectionValidators::CheckResult.success(:capabilities_request)- base_configuration[:host_url_accessible] =- Peripherals::ConnectionValidators::CheckResult.success(:host_url_accessible)- base_configuration[:dependencies_check] =- Peripherals::ConnectionValidators::CheckResult.success(:dependencies_check)- base_configuration[:dependencies_versions] =- Peripherals::ConnectionValidators::CheckResult.success(:dependencies_versions)-- authentication = Peripherals::ConnectionValidators::ValidationGroupResult.new- authentication[:existing_token] = Peripherals::ConnectionValidators::CheckResult.success(:existing_token)- authentication[:user_bound_request] = Peripherals::ConnectionValidators::CheckResult.success(:user_bound_request)-- ampf_configuration = Peripherals::ConnectionValidators::ValidationGroupResult.new- ampf_configuration[:files_request] = Peripherals::ConnectionValidators::CheckResult.success(:files_request)- ampf_configuration[:userless_access] = Peripherals::ConnectionValidators::CheckResult.success(:userless_access)- ampf_configuration[:group_folder_presence] =- Peripherals::ConnectionValidators::CheckResult.success(:group_folder_presence)- ampf_configuration[:group_folder_contents] =- Peripherals::ConnectionValidators::CheckResult.success(:group_folder_contents)-- r.add_group_result(:base_configuration, base_configuration)- r.add_group_result(:authentication, authentication)- r.add_group_result(:ampf_configuration, ampf_configuration)-- r- end- end- end-enddiff --git a/modules/storages/app/controllers/storages/admin/health_status_controller.rb b/modules/storages/app/controllers/storages/admin/health_status_controller.rbnew file mode 100644index 00000000000..249f9df6cdb--- /dev/null+++ b/modules/storages/app/controllers/storages/admin/health_status_controller.rb@@ -0,0 +1,91 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 HealthStatusController < ApplicationController+ include OpTurbo::ComponentStream++ layout :admin_or_frame_layout++ model_object Storage++ before_action :require_admin+ before_action :find_model_object++ def admin_or_frame_layout+ return "turbo_rails/frame" if turbo_frame_request?++ "admin"+ end++ def show+ @report = Rails.cache.read(cache_key)+ end++ def create+ create_and_cache_report++ redirect_to admin_settings_storage_health_status_report_path(@storage), status: :see_other+ end++ def create_health_status_report+ report = create_and_cache_report++ update_via_turbo_stream(component: SidePanel::ValidationResultComponent.new(storage: @storage, result: report))+ respond_to_with_turbo_streams+ end++ private++ def find_model_object(object_id = :storage_id)+ super+ @storage = @object+ end++ def create_and_cache_report+ case @storage.provider_type+ when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD+ report = Peripherals::ConnectionValidators::NextcloudValidator.new(storage: @storage).validate+ when ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE+ raise "Unsupported provider type: #{@storage.provider_type}"+ else+ raise "Unsupported provider type: #{@storage.provider_type}"+ end++ Rails.cache.write(cache_key, report, expires_in: 6.hours)++ report+ end++ def cache_key = "storage_#{@storage.id}_health_status_report"+ end+ end+enddiff --git a/modules/storages/app/views/storages/admin/health_status/show.html.erb b/modules/storages/app/views/storages/admin/health_status/show.html.erbnew file mode 100644index 00000000000..7d00f910917--- /dev/null+++ b/modules/storages/app/views/storages/admin/health_status/show.html.erb@@ -0,0 +1,76 @@+<%#-- copyright+OpenProject is an open source project management software.+Copyright (C) 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.++++#%>++<% page_title = I18n.t("storages.health.title") %>++<% html_title(t(:label_administration), t(:project_module_storages), @storage.name, page_title) -%>++<%= turbo_frame_tag "health_status_report", refresh: :morph do %>+ <%=+ render(Primer::OpenProject::PageHeader.new) do |header|+ header.with_title { page_title }+ header.with_description do+ if @report.present?+ I18n.t("storages.health.checked", datetime: format_time(@report.latest_timestamp))+ else+ I18n.t("storages.health.no_report")+ end+ end+ header.with_breadcrumbs(+ [+ { href: admin_index_path, text: t("label_administration") },+ { href: admin_settings_storages_path, text: t("project_module_storages") },+ { href: edit_admin_settings_storage_path(@storage), text: @storage.name },+ page_title+ ]+ )+ end+ %>++ <%=+ if @report.present?+ button_label = I18n.t("storages.health.actions.rerun_checks")++ render(Primer::OpenProject::SubHeader.new) do |subheader|+ subheader.with_action_button(+ scheme: :primary,+ tag: :a,+ href: admin_settings_storage_health_status_report_path(@storage),+ data: { turbo_method: :post, turbo: true },+ aria: { label: button_label }+ ) do+ button_label+ end+ end+ end+ %>++ <%= render(Storages::Admin::Health::HealthReportComponent.new(storage: @storage, report: @report)) %>++<% end %>diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex b444f8424dc..9ee6f5bc02c 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -231,9 +231,36 @@ en:storage_oauth: Nextcloud OAuthstorage_provider: Storage providerhealth:+ actions:+ run_checks: Run tests now+ rerun_checks: Re-run all checks+ checks:+ failures:+ zero: "All checks passed"+ one: "%{count} check failed"+ other: "%{count} checks failed"+ warnings:+ one: "%{count} check returned a warning"+ other: "%{count} checks returned a warning"+ base_configuration:+ capabilities_request: "Remote file storage capabilities"+ dependencies_check: "Dependencies"+ dependencies_versions: "Dependencies (version)"+ header: "Basic configuration"+ host_url_accessible: "Host URL accessible"+ storage_configured: "Configuration complete"+ authentication:+ existing_token: "User token"+ header: "Authentication"+ user_bound_request: "Sample request for user"+ ampf_configuration:+ files_request: "Check for file storage content"+ group_folder_contents: "Group folder content"+ group_folder_presence: "Group folder"+ header: "Automatically managed project folder configuration"+ userless_access: "Sample request without a user"checked: Last checked %{datetime}connection_validation:- action: Recheck connectionapp_version_mismatch: The Integration OpenProject app version is not supported. Please update your Nextcloud server.client_id_wrong: The configured OAuth 2 client id is invalid. Please check the configuration.client_secret_wrong: The configured OAuth 2 client secret is invalid. Please check the configuration.@@ -241,7 +268,7 @@ en:group_folder_not_found: The group folder could not be found.group_folder_version_mismatch: The Group Folder version is not supported. Please update your Nextcloud server.host_not_found: No Nextcloud server found at the configured host url. Please check the configuration.- missing_dependencies: 'A required dependency is missing on the file storage. Please add the following dependency: %{dependency}.'+ missing_dependencies: "A required dependency is missing on the file storage. Please add the following dependency: %{dependency}."not_configured: The connection could not be validated. Please finish configuration first.oauth_request_not_found: OpenProject couldn't find the root folder of Nextcloud using the current logged-in user. Please check the server logs for further information.oauth_request_unauthorized: The current user isn't authorized to see the main folder of Nextcloud or we couldn't acquire a token. Please check the server logs for further information.@@ -251,8 +278,6 @@ en:oidc_cant_refresh_token: There was an error while trying to check your access to the storage. Please check the server logs for further information.oidc_non_oidc_user: The current user, while provisioned, wasn't provisioned by an OpenID Connect (OIDC) Identity Provider. Please re-run the check with an OIDC provisioned user.oidc_non_provisioned_user: The current user isn't provided by an OpenID Connect Identity Provider. Please re-run the check with a provided user.- placeholder: Check your connection against the server.- subtitle: Connection validationtenant_id_wrong: The configured directory (tenant) id is invalid. Please check the configuration.unexpected_content:nextcloud: Unexpected content found in the managed group folder.@@ -260,13 +285,24 @@ en:unknown_error: The connection could not be validated. An unknown error occurred. Please check the server logs for further information.userless_access_denied: The configured app password is invalid.label_error: Error+ label_failed: Failedlabel_healthy: Healthy+ label_passed: Passedlabel_pending: Pending+ label_skipped: Skippedlabel_warning: Warning+ no_report: No report available+ no_report_description: "Run the tests now for a full health status report for this file storage."+ open_report: "Open full health report"project_folders:subtitle: Automatically managed project folderssince: since %{datetime}- title: Health status+ summary:+ success: "All connections and systems are working as expected."+ failure: "Some checks failed and the system does not work as expected."+ warning: "Some checks returned a warning. This can lead to unexpected behaviour."+ pending: "Some checks are still running."+ title: Health status reporthealth_email_notifications:description_subscribed: All administrators receive health status email notifications for this storage.description_unsubscribed: Health status email notifications for this storage have been turned off for all administrators.diff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rbindex d048ea5edf4..3507d9aca8d 100644--- a/modules/storages/config/routes.rb+++ b/modules/storages/config/routes.rb@@ -53,10 +53,8 @@ Rails.application.routes.draw doendend- resource :connection_validation,- controller: "/storages/admin/connection_validation",- only: [] do- post :validate_connection, on: :member+ resource :health_status_report, controller: "/storages/admin/health_status", only: %i[show create] do+ post :create_health_status_reportendmember do