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

fix[Op#50737]: configuration check inclusive of one drive

Kabiru Mwenja111d68bf4344
diff --git a/modules/storages/app/components/storages/admin/general_info_component.html.erb b/modules/storages/app/components/storages/admin/general_info_component.html.erb
index 0b3752c92ce..5fbcd3219dc 100644
--- a/modules/storages/app/components/storages/admin/general_info_component.html.erb
+++ b/modules/storages/app/components/storages/admin/general_info_component.html.erb
@@ -2,7 +2,7 @@
grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|
grid.with_area(:item, tag: :div, mr: 3) do
concat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1, test_selector: 'storage-provider-label')) { I18n.t('storages.file_storage_view.storage_provider') })
- concat(configuration_check_label_for(:host_name_configured))
+ concat(configuration_check_label)
end
grid.with_area(:description, tag: :div, color: :subtle, test_selector: 'storage-description') do
diff --git a/modules/storages/app/components/storages/admin/storage_view_information.rb b/modules/storages/app/components/storages/admin/storage_view_information.rb
index 2b2669d0f4d..fefbd2365c9 100644
--- a/modules/storages/app/components/storages/admin/storage_view_information.rb
+++ b/modules/storages/app/components/storages/admin/storage_view_information.rb
@@ -14,9 +14,17 @@ module Storages::Admin
storage.host].compact.join(' - ')
end
- def configuration_check_label_for(config)
- if storage.configuration_checks[config.to_sym]
- status_label(I18n.t('storages.label_connected'), scheme: :success, test_selector: "label-#{config}-status")
+ def configuration_check_label
+ if storage.provider_type_nextcloud?
+ configuration_check_label_for(:host_name_configured)
+ elsif storage.provider_type_one_drive?
+ configuration_check_label_for(:host_name_configured, :storage_tenant_drive_configured)
+ end
+ end
+
+ def configuration_check_label_for(*configs)
+ if storage.configuration_checks.slice(configs.map(&:to_sym)).values.all?
+ status_label(I18n.t('storages.label_completed'), scheme: :success, test_selector: "label-#{config}-status")
else
status_label(I18n.t('storages.label_incomplete'), scheme: :attention, test_selector: "label-#{config}-status")
end
diff --git a/modules/storages/app/models/storages/one_drive_storage.rb b/modules/storages/app/models/storages/one_drive_storage.rb
index 1d2e116cc32..d6c6e0ccc6b 100644
--- a/modules/storages/app/models/storages/one_drive_storage.rb
+++ b/modules/storages/app/models/storages/one_drive_storage.rb
@@ -36,7 +36,11 @@ module Storages
using ::Storages::Peripherals::ServiceResultRefinements
def configuration_checks
- { storage_oauth_client_configured: oauth_client.present? }
+ {
+ storage_oauth_client_configured: oauth_client.present?,
+ storage_tenant_drive_configured: tenant_id.present? && drive_id.present?,
+ host_name_configured: name.present?
+ }
end
def oauth_configuration
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index 51af55ffb94..fdad9b5a8e8 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -182,7 +182,7 @@ en:
label_file_links: "File links"
label_file_storage: "File storage"
label_creation_time: "Creation time"
- label_connected: "Connected"
+ label_completed: "Completed"
label_incomplete: "Incomplete"
label_name: "Name"
label_host: "Host URL"
diff --git a/modules/storages/spec/factories/storage_factory.rb b/modules/storages/spec/factories/storage_factory.rb
index 7f10d56c559..7e1b1e445a8 100644
--- a/modules/storages/spec/factories/storage_factory.rb
+++ b/modules/storages/spec/factories/storage_factory.rb
@@ -38,6 +38,7 @@ FactoryBot.define do
trait :with_oauth_client do
oauth_client { build(:oauth_client) }
end
+ # rubocop:enable FactoryBot/FactoryAssociationWithStrategy
trait :as_generic do
provider_type { 'Storages::Storage' }
@@ -109,6 +110,8 @@ FactoryBot.define do
parent: :storage,
class: '::Storages::OneDriveStorage' do
host { nil }
+ tenant_id { SecureRandom.uuid }
+ drive_id { SecureRandom.uuid }
end
factory :sharepoint_dev_drive_storage,
diff --git a/modules/storages/spec/models/one_drive_storage_spec.rb b/modules/storages/spec/models/one_drive_storage_spec.rb
index 47d4f45980b..417994ff1df 100644
--- a/modules/storages/spec/models/one_drive_storage_spec.rb
+++ b/modules/storages/spec/models/one_drive_storage_spec.rb
@@ -50,7 +50,9 @@ RSpec.describe Storages::OneDriveStorage do
aggregate_failures 'configuration_checks' do
expect(storage.configuration_checks)
- .to eq(storage_oauth_client_configured: true)
+ .to eq(host_name_configured: true,
+ storage_oauth_client_configured: true,
+ storage_tenant_drive_configured: true)
end
end
end