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
[#56892] Storage link not showing
Eric Schubert570804596f40
diff --git a/app/controllers/oauth_clients_controller.rb b/app/controllers/oauth_clients_controller.rbindex f01596c47b3..448059bb4c7 100644--- a/app/controllers/oauth_clients_controller.rb+++ b/app/controllers/oauth_clients_controller.rb@@ -82,11 +82,7 @@ class OAuthClientsController < ApplicationControllerstorage = oauth_client.integration# check if the origin is the same- destination_url = if params.fetch(:destination_url, "").start_with?(root_url)- params[:destination_url]- else- root_url- end+ destination_url = destination_url(params.fetch(:destination_url, ""))auth_state = ::Storages::Peripherals::StorageInteraction::Authentication.authorization_state(storage:, user: User.current)@@ -103,6 +99,20 @@ class OAuthClientsController < ApplicationControllerprivate+ def relative_url?(url)+ url.starts_with?("/")+ end++ def destination_url(url)+ if ::API::V3::Utilities::PathHelper::ApiV3Path.same_origin?(url)+ url+ elsif relative_url?(url)+ root_url.chomp("/") + url+ else+ root_url+ end+ end+def handle_absent_oauth_clientflash[:error] = [I18n.t("oauth_client.errors.oauth_client_not_found"),I18n.t("oauth_client.errors.oauth_client_not_found_explanation")]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.erbindex 5e8b6876393..5b112178dd7 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@@ -9,10 +9,10 @@grid.with_area(:description, tag: :div, color: :subtle, test_selector: 'storage-description') doconcat(render(Primer::Beta::Text.new) { storage_description })- if open_link_was_generated+ if can_show_open_link?concat(render(Primer::Beta::Text.new) { " - " })- concat(render(Primer::Beta::Link.new(href: open_href)) do- concat(render(Primer::Beta::Text.new) { "Open storage " })+ concat(render(Primer::Beta::Link.new(href: open_href, target: "_blank")) do+ concat(render(Primer::Beta::Text.new) { "#{I18n.t('storages.buttons.open_storage')} " })concat(render(Primer::Beta::Octicon.new(icon: "link-external", size: :small)))end)enddiff --git a/modules/storages/app/components/storages/admin/general_info_component.rb b/modules/storages/app/components/storages/admin/general_info_component.rbindex 4fcf0d8ff4e..7791c397a34 100644--- a/modules/storages/app/components/storages/admin/general_info_component.rb+++ b/modules/storages/app/components/storages/admin/general_info_component.rb@@ -38,25 +38,20 @@ module Storages::Admindef self.wrapper_key = :storage_general_info_section- def initialize(model = nil, **options)- auth_strategy = ::Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken- .strategy- .with_user(User.current)-- @href_result = ::Storages::Peripherals::Registry- .resolve("#{model.short_provider_type}.queries.open_storage")- .call(storage: model, auth_strategy:)+ def open_href+ url = ::API::V3::Utilities::PathHelper::ApiV3Path.storage_open(storage.id)- super- end+ return url if storage.provider_type_nextcloud?- def open_link_was_generated- @href_result.on_success { return true }- @href_result.on_failure { return false }+ oauth_clients_ensure_connection_url(+ oauth_client_id: storage.oauth_client.client_id,+ storage_id: storage.id,+ destination_url: url+ )end- def open_href- @href_result.result+ def can_show_open_link?+ storage.provider_type_nextcloud? || storage.oauth_client.present?endendenddiff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.ymlindex 50edddef985..5aa1162bafa 100644--- a/modules/storages/config/locales/en.yml+++ b/modules/storages/config/locales/en.yml@@ -141,6 +141,7 @@ en:complete_without_setup: Complete without itdone_complete_setup: Done, complete setupdone_continue: Done, continue+ open_storage: Open file storagereplace_oauth_application: Replace OpenProject OAuthreplace_oauth_client: Replace %{provider_type} OAuthsave_and_continue: Save and continue