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

[#62103] enabled one drive validation

Eric Schubert966ea5a39b63
diff --git a/lib/open_project/static/links.rb b/lib/open_project/static/links.rb
index 0d0ad9d1f31..958b01a8e91 100644
--- a/lib/open_project/static/links.rb
+++ b/lib/open_project/static/links.rb
@@ -46,8 +46,8 @@ module OpenProject
@links ||= static_links.merge(dynamic_links)
end
- def url_for(item)
- links.dig(item, :href)
+ def url_for(*items)
+ links.dig(*items, :href)
end
def has?(name)
diff --git a/modules/storages/app/components/storages/admin/health/check_result_component.rb b/modules/storages/app/components/storages/admin/health/check_result_component.rb
index 7aa11a5d443..a88da2d90d5 100644
--- a/modules/storages/app/components/storages/admin/health/check_result_component.rb
+++ b/modules/storages/app/components/storages/admin/health/check_result_component.rb
@@ -47,7 +47,7 @@ module Storages
status_color:,
status_text:,
error_text: model.message,
- docs_href: ::OpenProject::Static::Links[:storage_docs][:health_status][:href]
+ docs_href: ::OpenProject::Static::Links.url_for(:storage_docs, :health_status)
}
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.rb
index a25f138b24d..083e5d8b0a2 100644
--- a/modules/storages/app/components/storages/admin/health/health_report_component.rb
+++ b/modules/storages/app/components/storages/admin/health/health_report_component.rb
@@ -82,9 +82,17 @@ module Storages
def summary_with_icon(check_tally)
case check_tally
in { failure: 1.. }
- { icon: :alert, icon_color: :danger, text: I18n.t("storages.health.checks.failures", count: failure) }
+ {
+ icon: :alert,
+ icon_color: :danger,
+ text: I18n.t("storages.health.checks.failures", count: check_tally[:failure])
+ }
in { warning: 1.. }
- { icon: :alert, icon_color: :attention, text: I18n.t("storages.health.checks.warnings", count: warning) }
+ {
+ icon: :alert,
+ icon_color: :attention,
+ text: I18n.t("storages.health.checks.warnings", count: check_tally[:warning])
+ }
else
{ icon: :"check-circle", icon_color: :success, text: I18n.t("storages.health.checks.failures", count: 0) }
end
diff --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.rb
index 79dfa84b1dc..c104f859a60 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
@@ -39,15 +39,7 @@ module Storages
private
def report
- validator = case model.provider_type
- when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD
- Peripherals::ConnectionValidators::NextcloudValidator.new(storage: model)
- when ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE
- raise "Unsupported provider type: #{model.provider_type}"
- else
- raise "Unsupported provider type: #{model.provider_type}"
- end
-
+ validator = Peripherals::Registry.resolve("#{model}.validators.connection").new(model)
Rails.cache.read(validator.report_cache_key)
end
end
diff --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.rb
index 10942025991..4a48be6525f 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
@@ -43,11 +43,20 @@ module Storages
private
def summary_header
- case @result.tally
+ tally = @result.tally
+ case tally
in { failure: 1.. }
- { icon: :alert, icon_color: :danger, text: I18n.t("storages.health.checks.failures", count: failure) }
+ {
+ icon: :alert,
+ icon_color: :danger,
+ text: I18n.t("storages.health.checks.failures", count: tally[:failure])
+ }
in { warning: 1.. }
- { icon: :alert, icon_color: :attention, text: I18n.t("storages.health.checks.warnings", count: warning) }
+ {
+ icon: :alert,
+ icon_color: :attention,
+ text: I18n.t("storages.health.checks.warnings", count: tally[:warning])
+ }
else
{ icon: :"check-circle", icon_color: :success, text: I18n.t("storages.health.checks.failures", count: 0) }
end
diff --git a/modules/storages/app/controllers/storages/admin/health_status_controller.rb b/modules/storages/app/controllers/storages/admin/health_status_controller.rb
index 957ba672ee0..6aea5296080 100644
--- a/modules/storages/app/controllers/storages/admin/health_status_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/health_status_controller.rb
@@ -71,21 +71,14 @@ module Storages
end
def create_and_cache_report
- report = validator.validate
+ report = validator.call
Rails.cache.write(validator.report_cache_key, report, expires_in: 6.hours)
report
end
def validator
- @validator ||= case @storage.provider_type
- when ::Storages::Storage::PROVIDER_TYPE_NEXTCLOUD
- Peripherals::ConnectionValidators::NextcloudValidator.new(storage: @storage)
- when ::Storages::Storage::PROVIDER_TYPE_ONE_DRIVE
- raise "Unsupported provider type: #{@storage.provider_type}"
- else
- raise "Unsupported provider type: #{@storage.provider_type}"
- end
+ @validator ||= Peripherals::Registry.resolve("#{@storage}.validators.connection").new(@storage)
end
end
end