mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
[55946] Activated connection check for Nextcloud storages
This commit is contained in:
+18
-20
@@ -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
|
||||
|
||||
+17
-17
@@ -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|
|
||||
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
|
||||
|
||||
flex_layout do |container|
|
||||
if @result.validation_result_exists?
|
||||
container.with_row(mt: 2) do
|
||||
status = status_indicator
|
||||
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
|
||||
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
|
||||
|
||||
+11
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user