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

[55946] Activated connection check for Nextcloud storages

Andreas Pfohlf4cf981445cb
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.erb
index 2d1abf098db..d28d71db805 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
@@ -33,27 +33,25 @@ See COPYRIGHT and LICENSE files for more details.
section.with_title { I18n.t("storages.health.title") }
flex_layout do |health_status_container|
- if @storage.provider_type_one_drive?
- health_status_container.with_row(mt: 2) do
- render(Storages::Admin::SidePanel::ValidationResultComponent.new(result: validation_result_placeholder))
- end
+ 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: @storage,
- url: validate_connection_admin_settings_storage_connection_validation_path(@storage),
- 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
+ health_status_container.with_row(mt: 2) do
+ primer_form_with(
+ model: @storage,
+ url: validate_connection_admin_settings_storage_connection_validation_path(@storage),
+ 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
diff --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.erb
index c92d05827ac..4355c9c6f2b 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
@@ -29,28 +29,28 @@ See COPYRIGHT and LICENSE files for more details.
<%=
component_wrapper do
- render(Primer::OpenProject::SidePanel::Section.new) do |section|
- section.with_title(test_selector: "validation-result--subtitle") { I18n.t("storages.health.connection_validation.subtitle") }
-
- flex_layout do |container|
- if @result.validation_result_exists?
- container.with_row(mt: 2) do
- status = status_indicator
-
- 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] })
- end
+ flex_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
+
+ 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] })
end
+ end
- if @result.description.present?
- prefix = @result.error_code? ? "#{@result.error_code.upcase}: " : ""
+ if @result.description.present?
+ prefix = @result.error_code? ? "#{@result.error_code.upcase}: " : ""
- container.with_row(mt: 2) do
- render(Primer::Beta::Text.new(color: :muted, test_selector: "validation-result--description")) do
- prefix + @result.description
- end
+ container.with_row(mt: 2) do
+ render(Primer::Beta::Text.new(color: :muted, test_selector: "validation-result--description")) do
+ prefix + @result.description
end
end
end
diff --git a/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb b/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb
index 612dda1c2a6..d43cb0aa163 100644
--- a/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb
@@ -37,14 +37,21 @@ module Storages
before_action :require_admin
- model_object OneDriveStorage
+ model_object Storage
before_action :find_model_object, only: %i[validate_connection]
def validate_connection
- @result = Peripherals::OneDriveConnectionValidator
- .new(storage: @storage)
- .validate
+ 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
update_via_turbo_stream(component: SidePanel::ValidationResultComponent.new(result: @result))
respond_to_with_turbo_streams
end