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

[#47874] Open project folder from main menu storage entry

Eric Schubertb504c12c428f
diff --git a/modules/storages/app/common/storages/peripherals/storage_url_helper.rb b/modules/storages/app/common/storages/peripherals/storage_url_helper.rb
index 8ee2b3ccddf..54c435b0992 100644
--- a/modules/storages/app/common/storages/peripherals/storage_url_helper.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_url_helper.rb
@@ -29,10 +29,12 @@
module Storages::Peripherals
# Helper for open links for a file link object.
module StorageUrlHelper
- def storage_url_open_file(file_link, open_location: false)
+ module_function
+
+ def storage_url_open_file(storage, file_id, open_location: false)
location_flag = ActiveModel::Type::Boolean.new.cast(open_location) ? 0 : 1
- "#{file_link.storage.host}/index.php/f/#{file_link.origin_id}?openfile=#{location_flag}"
+ "#{storage.host}/index.php/f/#{file_id}?openfile=#{location_flag}"
end
def storage_url_open(storage)
diff --git a/modules/storages/lib/api/v3/file_links/file_link_representer.rb b/modules/storages/lib/api/v3/file_links/file_link_representer.rb
index f39fee65c9f..88af64f2e06 100644
--- a/modules/storages/lib/api/v3/file_links/file_link_representer.rb
+++ b/modules/storages/lib/api/v3/file_links/file_link_representer.rb
@@ -92,7 +92,7 @@ module API::V3::FileLinks
link :originOpen do
{
- href: storage_url_open_file(represented)
+ href: storage_url_open_file(represented.storage, represented.origin_id)
}
end
@@ -104,7 +104,7 @@ module API::V3::FileLinks
link :originOpenLocation do
{
- href: storage_url_open_file(represented, open_location: true)
+ href: storage_url_open_file(represented.storage, represented.origin_id, open_location: true)
}
end
diff --git a/modules/storages/lib/api/v3/file_links/file_links_open_api.rb b/modules/storages/lib/api/v3/file_links/file_links_open_api.rb
index 8fb55c50418..70d29ac6a5e 100644
--- a/modules/storages/lib/api/v3/file_links/file_links_open_api.rb
+++ b/modules/storages/lib/api/v3/file_links/file_links_open_api.rb
@@ -31,7 +31,7 @@ class API::V3::FileLinks::FileLinksOpenAPI < API::OpenProjectAPI
resources :open do
get do
- url = storage_url_open_file(@file_link, open_location: params[:location])
+ url = storage_url_open_file(@file_link.storage, @file_link.origin_id, open_location: params[:location])
redirect url, body: "The requested resource can be viewed at #{url}"
status 303 # The follow-up request to the resource must be GET
end
diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb
index 27e53891434..1f5a10693cf 100644
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@ -108,10 +108,17 @@ module OpenProject::Storages
if project.present? &&
User.current.logged? &&
User.current.allowed_to?(:view_file_links, project)
- project.storages.each do |storage|
+ project.projects_storages.each do |project_storage|
+ storage = project_storage.storage
+ href = if project_storage.project_folder_inactive?
+ storage.host
+ else
+ ::Storages::Peripherals::StorageUrlHelper.storage_url_open_file(storage, project_storage.project_folder_id)
+ end
+
menu.push(
:"storage_#{storage.id}",
- storage.host,
+ href,
caption: storage.name,
before: :members,
icon: "#{storage.provider_type}-circle",