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
[#55382] validate drive content (only ampf)
Eric Schubertd7e9d6f495fa
diff --git a/modules/storages/app/components/storages/admin/sidebar_component.html.erb b/modules/storages/app/components/storages/admin/sidebar_component.html.erbindex b4f92cfad5f..879910a3132 100644--- a/modules/storages/app/components/storages/admin/sidebar_component.html.erb+++ b/modules/storages/app/components/storages/admin/sidebar_component.html.erb@@ -5,8 +5,10 @@border_grid.with_row { render(Storages::Admin::Sidebar::ConnectionValidationComponent.new(storage: @storage)) }end- border_grid.with_row { render(Storages::Admin::Sidebar::HealthStatusComponent.new(storage: @storage)) }- border_grid.with_row { render(Storages::Admin::Sidebar::HealthNotificationsComponent.new(storage: @storage)) }+ if @storage.automatic_management_enabled?+ border_grid.with_row { render(Storages::Admin::Sidebar::HealthStatusComponent.new(storage: @storage)) }+ border_grid.with_row { render(Storages::Admin::Sidebar::HealthNotificationsComponent.new(storage: @storage)) }+ endendend%>diff --git a/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb b/modules/storages/app/controllers/storages/admin/connection_validation_controller.rbindex b18dcf1c648..28de15ce1e2 100644--- a/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb+++ b/modules/storages/app/controllers/storages/admin/connection_validation_controller.rb@@ -44,6 +44,7 @@ module Storagesbefore_action :find_model_object, only: %i[validate_connection]+ # rubocop:disable Metrics/AbcSizedef validate_connection@result = maybe_is_not_configured.or { drive_id_wrong }@@ -51,6 +52,7 @@ module Storages.or { client_id_wrong }.or { client_secret_wrong }.or { request_failed_with_unknown_error }+ .or { drive_with_unexpected_content }.value_or(ConnectionValidation.new(icon: "check-circle",scheme: :success,description: I18n.t("storages.connection_validation.success")))@@ -60,6 +62,8 @@ module Storagesendend+ # rubocop:enable Metrics/AbcSize+privatedef query@@ -120,6 +124,25 @@ module Storagesdescription: I18n.t("storages.connection_validation.client_secret_wrong")))end+ # rubocop:disable Metrics/AbcSize+ def drive_with_unexpected_content+ return None() if query.failure?+ return None() unless @storage.automatic_management_enabled?++ expected_folder_ids = @storage.project_storages+ .where(project_folder_mode: "automatic")+ .map(&:project_folder_id)++ unexpected_files = query.result.files.reject { |file| expected_folder_ids.include?(file.id) }+ return None() if unexpected_files.empty?++ Some(ConnectionValidation.new(icon: :alert,+ scheme: :warning,+ description: I18n.t("storages.connection_validation.unexpected_content")))+ end++ # rubocop:enable Metrics/AbcSize+def request_failed_with_unknown_errorreturn None() if query.success?diff --git a/modules/storages/app/views/storages/admin/storages/edit.html.erb b/modules/storages/app/views/storages/admin/storages/edit.html.erbindex ecda5f36208..b5d320e8349 100644--- a/modules/storages/app/views/storages/admin/storages/edit.html.erb+++ b/modules/storages/app/views/storages/admin/storages/edit.html.erb@@ -64,7 +64,8 @@ See COPYRIGHT and LICENSE files for more details.<% end %><% end %>-<% if @storage.automatic_management_enabled? %>+<% display_sidebar = @storage.provider_type_one_drive? || @storage.automatic_management_enabled? %>+<% if display_sidebar %><%= render(Primer::Alpha::Layout.new(stacking_breakpoint: :lg)) do |component| %><% component.with_main() do %><%= render(::Storages::Admin::StorageViewComponent.new(@storage)) %>diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex e92dd48a1f7..8c61a1d5aee 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -125,6 +125,7 @@ en: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.unknown_error: The connection could not be validated. An unknown error occurred. Please check the server logs for further information.+ unexpected_content: Unexpected content found in the drive.success: The connection works as expected.help_texts:project_folder: The project folder is the default folder for file uploads for this project. Users can nevertheless still upload files to other locations.