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
feat[#50212]: Retrieve status labels from configuration checks
Kabiru Mwenjaab953b51c891
diff --git a/modules/storages/app/components/storages/admin/storage_view_component.html.erb b/modules/storages/app/components/storages/admin/storage_view_component.html.erbindex b769364081a..4e3ea699f82 100644--- a/modules/storages/app/components/storages/admin/storage_view_component.html.erb+++ b/modules/storages/app/components/storages/admin/storage_view_component.html.erb@@ -12,12 +12,7 @@grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|grid.with_area(:item, tag: :div, mr: 3) doconcat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.storage_provider') })-- if storage.configured?- concat(render(Primer::Beta::Label.new(scheme: :success, data: { 'test-selector': 'label-configuration-status' })) { I18n.t('storages.label_completed') })- else- concat(render(Primer::Beta::Label.new(scheme: :attention, data: { 'test-selector': 'label-configuration-status' })) { I18n.t('storages.label_incomplete') })- end+ concat(configuration_check_label_for(:host_name_configured))endgrid.with_area(:description, tag: :div, color: :subtle, data: { 'test-selector': 'storage-description' }) do@@ -42,12 +37,7 @@grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|grid.with_area(:item, tag: :div, mr: 3) doconcat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.openproject_oauth') })-- if storage.configured?- concat(render(Primer::Beta::Label.new(scheme: :success, data: { 'test-selector': 'label-configuration-status' })) { I18n.t('storages.label_completed') })- else- concat(render(Primer::Beta::Label.new(scheme: :attention, data: { 'test-selector': 'label-configuration-status' })) { I18n.t('storages.label_incomplete') })- end+ concat(configuration_check_label_for(:openproject_oauth_application_configured))endgrid.with_area(:description, tag: :div, color: :subtle, data: { 'test-selector': 'storage-openproject-oauth-client-description' }) do@@ -64,12 +54,7 @@grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|grid.with_area(:item, tag: :div, mr: 3) doconcat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.nextcloud_oauth') })-- if storage.configured?- concat(render(Primer::Beta::Label.new(scheme: :success, data: { 'test-selector': 'label-configuration-status' })) { I18n.t('storages.label_completed') })- else- concat(render(Primer::Beta::Label.new(scheme: :attention, data: { 'test-selector': 'label-configuration-status' })) { I18n.t('storages.label_incomplete') })- end+ concat(configuration_check_label_for(:storage_oauth_client_configured))endgrid.with_area(:description, tag: :div, color: :subtle, data: { 'test-selector': 'storage-oauth-client-id-description' }) do@@ -94,12 +79,7 @@grid_layout('op-storage-view--row', tag: :div, align_items: :center) do |grid|grid.with_area(:item, tag: :div, mr: 3) doconcat(render(Primer::Beta::Text.new(font_weight: :semibold, mr: 1)) { I18n.t('storages.file_storage_view.automatically_managed_folders') })-- if storage.configured?- concat(render(Primer::Beta::Label.new(scheme: :success, data: { 'test-selector': 'label-configuration-status' })) { I18n.t('storages.label_active') })- else- concat(render(Primer::Beta::Label.new(scheme: :attention, data: { 'test-selector': 'label-configuration-status' })) { I18n.t('storages.label_incomplete') })- end+ concat(automatically_managed_project_folders_status_label)endgrid.with_area(:description, tag: :div, color: :subtle, data: { 'test-selector': 'storage-oauth-client-id-description' }) dodiff --git a/modules/storages/app/components/storages/admin/storage_view_component.rb b/modules/storages/app/components/storages/admin/storage_view_component.rbindex c9b5ade84ad..c7f9f39ac67 100644--- a/modules/storages/app/components/storages/admin/storage_view_component.rb+++ b/modules/storages/app/components/storages/admin/storage_view_component.rb@@ -41,6 +41,34 @@ module Storages::Adminstorage.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")+ else+ status_label(I18n.t('storages.label_incomplete'), scheme: :attention, test_selector: "label-#{config}-status")+ end+ end++ def automatically_managed_project_folders_status_label+ test_selector = 'label-managed-project-folders-status'++ if storage.automatically_managed?+ status_label(I18n.t('storages.label_active'), scheme: :success, test_selector:)+ elsif storage.automatic_management_unspecified?+ status_label(I18n.t('storages.label_incomplete'), scheme: :attention, test_selector:)+ else+ status_label(I18n.t('storages.label_inactive'), scheme: :secondary, test_selector:)+ end+ end++ def openproject_oauth_client?+ storage.oauth_application.present?+ end++ def provider_oauth_client?+ storage.oauth_client.present?+ end+def openproject_oauth_client_descriptionreturn unless storage.oauth_application@@ -48,9 +76,15 @@ module Storages::Adminenddef provider_oauth_client_description- return unless storage.oauth_client+ if storage.oauth_client+ "#{I18n.t('storages.label_oauth_client_id')}: #{storage.oauth_client.client_id}"+ else+ I18n.t('storages.configuration_checks.oauth_client_incomplete', provider: storage.short_provider_type.capitalize)+ end+ end- "#{I18n.t('storages.label_oauth_client_id')}: #{storage.oauth_client.client_id}"+ def status_label(label, scheme:, test_selector:)+ render(Primer::Beta::Label.new(scheme:, data: { 'test-selector': test_selector })) { label }endendenddiff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex 351adb3d05f..bfe7d1128f0 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -137,6 +137,7 @@ en:Users can nevertheless still upload files to other locations.configuration_checks:incomplete: "The setup of this storage is incomplete."+ oauth_client_incomplete: "Allow OpenProject to access %{provider} data using an OAuth."delete_warning:storage: >Are you sure you want to delete this storage? This will also delete the storage from all projects where it is used.@@ -160,7 +161,7 @@ en:label_file_link: "File link"label_file_links: "File links"label_creation_time: "Creation time"- label_completed: "Completed"+ label_connected: "Connected"label_incomplete: "Incomplete"label_name: "Name"label_host: "Host URL"