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
[#621030] add UI to display group connection validation reports
Eric Schubert105786265491
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 7b87cd1b589..c6c22e59b3d 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@@ -32,7 +32,8 @@ module Storagesmodule Peripheralsmodule ConnectionValidatorsclass ValidationGroupResult- delegate :[], to: :@results+ # TODO: remove []=+ delegate :[], :[]=, :each, to: :@resultsdef initialize@results = {}diff --git a/modules/storages/app/components/storages/admin/side_panel/health_notifications_component.html.erb b/modules/storages/app/components/storages/admin/side_panel/health_notifications_component.html.erbindex f2d298fd24a..452bcd00939 100644--- a/modules/storages/app/components/storages/admin/side_panel/health_notifications_component.html.erb+++ b/modules/storages/app/components/storages/admin/side_panel/health_notifications_component.html.erb@@ -30,9 +30,40 @@ See COPYRIGHT and LICENSE files for more details.<%=component_wrapper(data: { turbo: true }) dorender(Primer::OpenProject::SidePanel::Section.new) do |section|- section.with_title { t("storages.health_email_notifications.title") }+ section.with_title { t("storages.health.project_folders.subtitle") }flex_layout do |notifications_container|+ notifications_container.with_row do+ concat(+ render(Primer::Beta::Text.new(pr: 2, test_selector: "storage-health-checked-at")) do+ I18n.t("storages.health.checked", datetime: helpers.format_time(@storage.health_checked_at))+ end+ )++ concat(+ render(+ Primer::Beta::Label.new(+ scheme: health_status_indicator[:scheme],+ test_selector: "storage-health-status"+ )+ ) do+ health_status_indicator[:label]+ end+ )+ end++ if @storage.health_unhealthy?+ notifications_container.with_row(mt: 2) do+ render(Primer::Beta::Text.new(color: :muted, test_selector: "storage-health-error")) do+ formatted_health_reason+ end+ end+ end++ notifications_container.with_row(mt: 2) do+ render(Primer::Beta::Text.new(font_weight: :bold)) { t("storages.health_email_notifications.title") }+ end+notifications_container.with_row(mt: 2) doform_for(@storage, method: :patch,diff --git a/modules/storages/app/components/storages/admin/side_panel/health_notifications_component.rb b/modules/storages/app/components/storages/admin/side_panel/health_notifications_component.rbindex 8a071bff0d1..ca6a1a3667b 100644--- a/modules/storages/app/components/storages/admin/side_panel/health_notifications_component.rb+++ b/modules/storages/app/components/storages/admin/side_panel/health_notifications_component.rb@@ -44,6 +44,8 @@ module Storages@storage.automatic_management_enabled?end+ private+def notification_statusif @storage.health_notifications_should_be_sent?{ icon: :"bell-slash",@@ -55,6 +57,31 @@ module Storagesdescription: I18n.t("storages.health_email_notifications.description_unsubscribed") }endend++ def health_status_indicator+ case @storage.health_status+ when "healthy"+ { scheme: :success, label: I18n.t("storages.health.label_healthy") }+ when "unhealthy"+ { scheme: :danger, label: I18n.t("storages.health.label_error") }+ else+ { scheme: :attention, label: I18n.t("storages.health.label_pending") }+ end+ end++ # This method returns the health identifier, description and the time since when the error occurs in a+ # formatted manner. e.g. "Not found: Outbound request destination not found since 12/07/2023 03:45 PM"+ def formatted_health_reason+ identifier = @storage.health_reason_identifier.tr("_", " ").strip+ description = @storage.health_reason_description++ if description.present?+ identifier.capitalize!+ identifier << ": #{description}"+ end++ "#{identifier} #{I18n.t('storages.health.since', datetime: helpers.format_time(@storage.health_changed_at))}"+ endendendenddiff --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.erbnew file mode 100644index 00000000000..b159c3028cd--- /dev/null+++ b/modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.html.erb@@ -0,0 +1,95 @@+<%#-- 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_report_dialog_component.rb b/modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.rbnew file mode 100644index 00000000000..8dc3689d790--- /dev/null+++ b/modules/storages/app/components/storages/admin/side_panel/health_report_dialog_component.rb@@ -0,0 +1,53 @@+# 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 SidePanel+ class HealthReportDialogComponent < ApplicationComponent+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ TEST_SELECTOR = "op-storages--health-report-dialog"++ def initialize(storage:, report:)+ super(storage)+ @report = report+ end++ private++ def subtitle+ "Last check: 28.03.2025 6:40 PM"+ end+ end+ end+ end+enddiff --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 15cea3bfb15..af2db8555c4 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,50 +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(result: validation_result_placeholder))- end-- health_status_container.with_row(mt: 2) 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: :link,- color: :default,- font_weight: :bold,- type: :submit,- )) do |button|- button.with_leading_visual_icon(icon: "meter")- I18n.t("storages.health.connection_validation.action")- end- end- end-- if model.automatic_management_enabled?- health_status_container.with_row(mt: 2) do- render(Primer::Beta::Text.new(font_weight: :bold)) { I18n.t("storages.health.project_folders.subtitle") }- end-- health_status_container.with_row(mt: 2) do- concat(render(Primer::Beta::Text.new(pr: 2, test_selector: "storage-health-checked-at")) do- I18n.t('storages.health.checked', datetime: helpers.format_time(model.health_checked_at))- end)-- concat(render(Primer::Beta::Label.new(scheme: health_status_indicator[:scheme], test_selector: "storage-health-status")) do- health_status_indicator[:label]- end)- end-- if model.health_unhealthy?- health_status_container.with_row(mt: 2) do- render(Primer::Beta::Text.new(color: :muted, test_selector: "storage-health-error")) do- formatted_health_reason- end- end- end+ render(Storages::Admin::SidePanel::ValidationResultComponent.new(storage: model, result: nil))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 1de2253d289..54c5df4c295 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,40 +35,6 @@ module Storagesinclude ApplicationHelperinclude OpTurbo::Streamableinclude OpPrimer::ComponentHelpers-- private-- def health_status_indicator- case model.health_status- when "healthy"- { scheme: :success, label: I18n.t("storages.health.label_healthy") }- when "unhealthy"- { scheme: :danger, label: I18n.t("storages.health.label_error") }- else- { scheme: :attention, label: I18n.t("storages.health.label_pending") }- end- end-- # This method returns the health identifier, description and the time since when the error occurs in a- # formatted manner. e.g. "Not found: Outbound request destination not found since 12/07/2023 03:45 PM"- def formatted_health_reason- identifier = model.health_reason_identifier.tr("_", " ").strip- description = model.health_reason_description-- if description.present?- identifier.capitalize!- identifier << ": #{description}"- end-- "#{identifier} #{I18n.t('storages.health.since', datetime: helpers.format_time(model.health_changed_at))}"- end-- def validation_result_placeholder- ConnectionValidation.new(type: :none,- error_code: :none,- timestamp: Time.current,- description: I18n.t("storages.health.connection_validation.placeholder"))- 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 e87512c53dc..0ee677c2626 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,27 +30,42 @@ See COPYRIGHT and LICENSE files for more details.<%=component_wrapper doflex_layout do |container|- container.with_row(test_selector: "validation-result--subtitle") do- render(Primer::Beta::Text.new(font_weight: :bold)) { I18n.t("storages.health.connection_validation.subtitle") }- end-- if @result.validation_result_exists?- container.with_row(mt: 2) do- status = status_indicator+ if validation_result?+ container.with_row(test_selector: "validation-result--subtitle") do+ header = status_summary- concat(render(Primer::Beta::Text.new(pr: 2, test_selector: "validation-result--timestamp")) do- I18n.t('storages.health.checked', datetime: helpers.format_time(@result.timestamp))- end)- concat(render(Primer::Beta::Label.new(scheme: status[:scheme])) { status[:label] })+ concat(render(Primer::Beta::Octicon.new(icon: header[:icon], color: header[:color], mr: 2)))+ concat(render(Primer::Beta::Text.new(font_weight: :bold)) { header[:text] })end- end-- if @result.description.present?- prefix = @result.error_code? ? "#{@result.error_code.upcase}: " : ""container.with_row(mt: 2) dorender(Primer::Beta::Text.new(color: :muted, test_selector: "validation-result--description")) do- prefix + @result.description+ "All connections and systems are working as expected. Last check: 28.03.2025 6:40 PM."+ end+ end++ container.with_row(mt: 2) do+ render(Storages::Admin::SidePanel::HealthReportDialogComponent.new(storage: model, report: @result))+ end+ else+ container.with_row 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: :link,+ color: :default,+ font_weight: :bold,+ type: :submit+ )+ ) do |button|+ button.with_leading_visual_icon(icon: "meter")+ I18n.t("storages.health.connection_validation.action")+ endendendenddiff --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 f0f9f9e5008..5053f8db79b 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@@ -31,29 +31,32 @@module Storagesmodule Adminmodule SidePanel- class ValidationResultComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent+ class ValidationResultComponent < ApplicationComponentinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable- def initialize(result:)- super(result)+ def initialize(storage:, result:)+ super(storage)@result = resultendprivate- def status_indicator- case @result.type- when :healthy- { scheme: :success, label: I18n.t("storages.health.label_healthy") }- when :warning- { scheme: :attention, label: I18n.t("storages.health.label_warning") }- when :error- { scheme: :danger, label: I18n.t("storages.health.label_error") }+ 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" }else- raise ArgumentError, "Unknown validation result type for status indicator: #{@result.type}"+ raise ArgumentError, "Unknown validation result type: #{@result.type}"endend++ def validation_result? = @result.present?endendenddiff --git a/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb b/modules/storages/app/controllers/storages/admin/connection_validation_controller.rbindex cccf2887da2..f1aa324f507 100644--- a/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb+++ b/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb@@ -51,8 +51,10 @@ module Storagesraise "Unsupported provider type: #{@storage.provider_type}"end- @result = validator.validate- update_via_turbo_stream(component: SidePanel::ValidationResultComponent.new(result: @result))+ # @result = validator.validate+ @result = test_success++ update_via_turbo_stream(component: SidePanel::ValidationResultComponent.new(storage: @storage, result: @result))respond_to_with_turbo_streamsend@@ -62,6 +64,40 @@ module Storagessuper@storage = @objectend++ 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+ endendendend