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

[56045] Added href to storage link in edit page

Andreas Pfohla66d3bc2a863
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 0b60b0845f4..5e8b6876393 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
@@ -8,11 +8,14 @@
grid.with_area(:description, tag: :div, color: :subtle, test_selector: 'storage-description') do
concat(render(Primer::Beta::Text.new) { storage_description })
- concat(render(Primer::Beta::Text.new) { " - " })
- concat(render(Primer::Beta::Link.new(href: "#")) do
- concat(render(Primer::Beta::Text.new) { "Open storage " })
- concat(render(Primer::Beta::Octicon.new(icon: "link-external", size: :small)))
- end)
+
+ if open_link_was_generated
+ 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::Octicon.new(icon: "link-external", size: :small)))
+ end)
+ end
end
if editable_storage?
diff --git a/modules/storages/app/components/storages/admin/general_info_component.rb b/modules/storages/app/components/storages/admin/general_info_component.rb
index 57494887956..292faab9133 100644
--- a/modules/storages/app/components/storages/admin/general_info_component.rb
+++ b/modules/storages/app/components/storages/admin/general_info_component.rb
@@ -37,5 +37,26 @@ module Storages::Admin
alias_method :storage, :model
def self.wrapper_key = :storage_general_info_section
+
+ def initialize(model = nil, **options)
+ super
+
+ auth_strategy = ::Storages::Peripherals::StorageInteraction::AuthenticationStrategies::OAuthUserToken
+ .strategy
+ .with_user(User.current)
+
+ @href_result = ::Storages::Peripherals::Registry
+ .resolve("#{storage.short_provider_type}.queries.open_storage")
+ .call(storage:, auth_strategy:)
+ end
+
+ def open_link_was_generated
+ @href_result.on_success { return true }
+ @href_result.on_failure { return false }
+ end
+
+ def open_href
+ @href_result.result
+ end
end
end