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
Fixed translation lookup for StorageRepresenter
Andreas Pfohl0acfcfd9eb54
diff --git a/modules/storages/lib/api/v3/storages/storage_authorizer.rb b/modules/storages/lib/api/v3/storages/storage_authorizer.rbindex 6d0a59c0d14..8bbb0328b01 100644--- a/modules/storages/lib/api/v3/storages/storage_authorizer.rb+++ b/modules/storages/lib/api/v3/storages/storage_authorizer.rb@@ -26,30 +26,15 @@# See COPYRIGHT and LICENSE files for more details.#++-# This class provides definitions for API routes and endpoints for the storages namespace. It inherits the-# functionality from the Grape REST API framework. It is mounted in lib/api/v3/root.rb.-# `modules/storages/lib/` is a defined root directory for grape, providing a root level look up for the namespaces.-# Hence, the modules of the class have to be represented in the directory structure.module APImodule V3module Storages- URN_CONNECTION_CONNECTED = "#{::API::V3::URN_PREFIX}storages:authorization:Connected".freeze- URN_CONNECTION_AUTH_FAILED = "#{::API::V3::URN_PREFIX}storages:authorization:FailedAuthorization".freeze- URN_CONNECTION_ERROR = "#{::API::V3::URN_PREFIX}storages:authorization:Error".freeze-class StorageAuthorizerclass << selfdef authorize(storage)oauth_client = storage.oauth_clientconnection_manager = ::OAuthClients::ConnectionManager.new(user: User.current, oauth_client:)- case connection_manager.authorization_state- when :connected- URN_CONNECTION_CONNECTED- when :failed_authorization- URN_CONNECTION_AUTH_FAILED- else- URN_CONNECTION_ERROR- end+ connection_manager.authorization_stateendendenddiff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rbindex 269140263af..ca3f3528ea9 100644--- a/modules/storages/lib/api/v3/storages/storage_representer.rb+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb@@ -33,6 +33,10 @@module APImodule V3module Storages+ URN_CONNECTION_CONNECTED = "#{::API::V3::URN_PREFIX}storages:authorization:Connected".freeze+ URN_CONNECTION_AUTH_FAILED = "#{::API::V3::URN_PREFIX}storages:authorization:FailedAuthorization".freeze+ URN_CONNECTION_ERROR = "#{::API::V3::URN_PREFIX}storages:authorization:Error".freeze+class StorageRepresenter < ::API::Decorators::Single# LinkedResource module defines helper methods to describe attributesinclude API::Decorators::LinkedResource@@ -61,9 +65,18 @@ module APIlink :authorizationState dostate = ::API::V3::Storages::StorageAuthorizer.authorize represented- title = I18n.t(:"oauth_client.urn_connection_status.#{state.split(':').last}")- { href: state, title: }+ urn = case state+ when :connected+ URN_CONNECTION_CONNECTED+ when :failed_authorization+ URN_CONNECTION_AUTH_FAILED+ else+ URN_CONNECTION_ERROR+ end+ title = I18n.t(:"oauth_client.urn_connection_status.#{state}")++ { href: urn, title: }enddef _typediff --git a/modules/storages/spec/features/show_file_links_spec.rb b/modules/storages/spec/features/show_file_links_spec.rbindex c18ffbd3d89..1ee03fd2db3 100644--- a/modules/storages/spec/features/show_file_links_spec.rb+++ b/modules/storages/spec/features/show_file_links_spec.rb@@ -42,7 +42,7 @@ describe 'Showing of file links in work package', with_flag: { storages_module_abefore doallow(::API::V3::Storages::StorageAuthorizer)- .to receive(:authorize).and_return(::API::V3::Storages::URN_CONNECTION_CONNECTED)+ .to receive(:authorize).and_return(:connected)project_storagefile_link