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

[#43696] Add modal navigation on chevrons

Andreas Pfohl08560beb770c
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.yml
index 190381ef1e5..d126b94a7e0 100644
--- a/docs/api/apiv3/openapi-spec.yml
+++ b/docs/api/apiv3/openapi-spec.yml
@@ -353,11 +353,8 @@ paths:
"$ref": "./paths/status.yml"
"/api/v3/storages/{id}":
"$ref": "./paths/storage.yml"
-# Temporarily removed for release 12.3 as the specification is not finished.
-# Also the implementation is not yet ready.
-# Discussion is tracked here: https://community.openproject.org/work_packages/43694
-# "/api/v3/storages/{id}/files":
-# "$ref": "./paths/storage_files.yml"
+ "/api/v3/storages/{id}/files":
+ "$ref": "./paths/storage_files.yml"
"/api/v3/time_entries":
"$ref": "./paths/time_entries.yml"
"/api/v3/time_entries/{id}/form":
@@ -557,11 +554,8 @@ components:
"$ref": "./components/schemas/example_schema_model.yml"
Execute_custom_action:
"$ref": "./components/schemas/execute_custom_action.yml"
-# Temporarily removed for the 12.3 release as it is not yet
-# implemented.
-# Discussion is tracked here: https://community.openproject.org/work_packages/43694
-# FileCollectionModel:
-# $ref: './components/schemas/file_collection_model.yml'
+ FileCollectionModel:
+ $ref: './components/schemas/file_collection_model.yml'
FileLinkCollectionReadModel:
$ref: './components/schemas/file_link_collection_read_model.yml'
FileLinkCollectionWriteModel:
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud_storage_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud_storage_query.rb
index 546f9ddff6d..bb23f977b0f 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud_storage_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud_storage_query.rb
@@ -28,6 +28,8 @@
module Storages::Peripherals::StorageInteraction
class NextcloudStorageQuery
+ using Storages::Peripherals::ServiceResultRefinements
+
def initialize(base_uri:, origin_user_id:, token:, with_refreshed_token:)
@uri = base_uri
@origin_user_id = origin_user_id
@@ -36,13 +38,16 @@ module Storages::Peripherals::StorageInteraction
@base_path = "/remote.php/dav/files/#{@origin_user_id}/"
end
- def files
+ def files(parent)
http = Net::HTTP.new(@uri.host, @uri.port)
http.use_ssl = @uri.scheme == 'https'
result = @with_refreshed_token.call do
response = http.propfind(
- @base_path,
+ parent.match(
+ on_success: ->(p) { "#{@base_path}#{p}" },
+ on_failure: ->(_) { @base_path }
+ ),
requested_properties,
{
'Depth' => '1',
@@ -100,7 +105,7 @@ module Storages::Peripherals::StorageInteraction
::Storages::StorageFile.new(
id(file_element),
- CGI.unescape(name),
+ CGI.unescape(name.split('/').last),
size(file_element),
mime_type(file_element),
nil,
diff --git a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb b/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
index d6019345b3f..82f5ff94f2d 100644
--- a/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
+++ b/modules/storages/lib/api/v3/storage_files/storage_files_api.rb
@@ -41,6 +41,10 @@ module API::V3::StorageFiles
raise API::Errors::InternalError.new
end
end
+
+ def find_param(symbol)
+ params[symbol] ? ServiceResult.success(result: params[symbol]) : ServiceResult.failure
+ end
end
resources :files do
@@ -51,7 +55,7 @@ module API::V3::StorageFiles
.match(
on_success: ->(files_query) {
files_query
- .call
+ .call(find_param(:parent))
.map do |files|
API::V3::StorageFiles::StorageFileCollectionRepresenter.new(
files,
diff --git a/modules/storages/spec/common/peripherals/storage_requests_spec.rb b/modules/storages/spec/common/peripherals/storage_requests_spec.rb
index 86f280083e1..ed416f0f036 100644
--- a/modules/storages/spec/common/peripherals/storage_requests_spec.rb
+++ b/modules/storages/spec/common/peripherals/storage_requests_spec.rb
@@ -130,7 +130,7 @@ describe Storages::Peripherals::StorageRequests, webmock: true do
.files_query(user:)
.match(
on_success: ->(query) do
- result = query.call
+ result = query.call(ServiceResult.failure)
expect(result).to be_success
expect(result.result.size).to eq(2)
end,
@@ -145,7 +145,7 @@ describe Storages::Peripherals::StorageRequests, webmock: true do
.files_query(user:)
.match(
on_success: ->(query) do
- result = query.call
+ result = query.call(ServiceResult.failure)
expect(result).to be_success
expect(result.result[1].name).to eq('Documents')
expect(result.result[1].mime_type).to eq('application/x-op-directory')
@@ -162,7 +162,7 @@ describe Storages::Peripherals::StorageRequests, webmock: true do
.files_query(user:)
.match(
on_success: ->(query) do
- result = query.call
+ result = query.call(ServiceResult.failure)
expect(result).to be_success
expect(result.result[0].name).to eq('Nextcloud Manual.pdf')
expect(result.result[0].mime_type).to eq('application/pdf')
@@ -173,6 +173,26 @@ describe Storages::Peripherals::StorageRequests, webmock: true do
end
)
end
+
+ describe 'with parent query parameter' do
+ let(:parent) { 'Photos/Birds' }
+ let(:request_url) { "#{url}/remote.php/dav/files/#{origin_user_id}/#{parent}" }
+
+ before do
+ stub_request(:propfind, request_url).to_return(status: 207, body: xml, headers: {})
+ end
+
+ it do
+ subject
+ .files_query(user:)
+ .match(
+ on_success: ->(query) { query.call(ServiceResult.success(result: parent)) },
+ on_failure: ->(error) { raise "Files query could not be created: #{error}" }
+ )
+
+ assert_requested(:propfind, request_url)
+ end
+ end
end
describe 'with not supported storage type selected' do
@@ -206,7 +226,7 @@ describe Storages::Peripherals::StorageRequests, webmock: true do
.files_query(user:)
.match(
on_success: ->(query) do
- result = query.call
+ result = query.call(ServiceResult.failure)
expect(result).to be_failure
expect(result.result).to be(symbol)
end,
diff --git a/modules/storages/spec/requests/api/v3/storages/storages_spec.rb b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb
index acedfcd9526..8821585e89a 100644
--- a/modules/storages/spec/requests/api/v3/storages/storages_spec.rb
+++ b/modules/storages/spec/requests/api/v3/storages/storages_spec.rb
@@ -219,7 +219,7 @@ describe 'API v3 storages resource', type: :request, content_type: :json do
describe 'with query failed' do
let(:files_query) do
Struct.new('FilesQuery', :error) do
- def files
+ def files(_)
ServiceResult.failure(result: error)
end
end.new(error)