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

[#43181] new open storage link (#10963)

Eric Schubert3a6d626394ec
diff --git a/docs/api/apiv3/components/schemas/storage_model.yml b/docs/api/apiv3/components/schemas/storage_model.yml
index 1809279e9ee..cc49e6d2836 100644
--- a/docs/api/apiv3/components/schemas/storage_model.yml
+++ b/docs/api/apiv3/components/schemas/storage_model.yml
@@ -31,6 +31,7 @@ properties:
- self
- type
- origin
+ - open
- authorizationState
properties:
self:
@@ -51,7 +52,14 @@ properties:
allOf:
- $ref: './link.yml'
- description: |-
- Web uri of the storage instance.
+ Web URI of the storage instance.
+
+ **Resource**: N/A
+ open:
+ allOf:
+ - $ref: './link.yml'
+ - description: |-
+ URI of the file storage location, from where the user usually starts browsing files.
**Resource**: N/A
authorizationState:
@@ -93,6 +101,8 @@ example:
title: Nextcloud
origin:
href: https://nextcloud.deathstar.rocks/
+ open:
+ href: https://nextcloud.deathstar.rocks/apps/files
authorizationState:
href: urn:openproject-org:api:v3:storages:authorization:FailedAuthorization
title: Failed Authorization
diff --git a/frontend/src/app/core/state/storages/storage.model.ts b/frontend/src/app/core/state/storages/storage.model.ts
index 6d48c799963..b99ae935753 100644
--- a/frontend/src/app/core/state/storages/storage.model.ts
+++ b/frontend/src/app/core/state/storages/storage.model.ts
@@ -33,6 +33,7 @@ export interface IStorageHalResourceLinks extends IHalResourceLinks {
self:IHalResourceLink;
type:IHalResourceLink;
origin:IHalResourceLink;
+ open:IHalResourceLink;
authorizationState:IHalResourceLink;
authorize?:IHalResourceLink;
}
diff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts
index d53ac6a19a6..910d80d1ca6 100644
--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts
+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts
@@ -96,8 +96,8 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
},
};
- private get storageLocation():string {
- return this.storage._links.origin.href;
+ private get storageFilesLocation():string {
+ return this.storage._links.open.href;
}
constructor(
@@ -141,7 +141,7 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
}
public openStorageLocation():void {
- window.open(this.storageLocation, '_blank');
+ window.open(this.storageFilesLocation, '_blank');
}
private instantiateStorageInformation(fileLinks:IFileLink[]):StorageInformationBox[] {
@@ -204,7 +204,7 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
[new StorageActionButton(
this.text.infoBox.emptyStorageButton(this.storageType),
() => {
- window.open(this.storageLocation, '_blank');
+ window.open(this.storageFilesLocation, '_blank');
},
)],
);
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 70fd7ece31b..7b3787c59c8 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
@@ -94,7 +94,7 @@ module API
link :originOpen do
{
- href: storage_url_open(represented)
+ href: storage_url_open_file(represented)
}
end
@@ -106,7 +106,7 @@ module API
link :originOpenLocation do
{
- href: storage_url_open(represented, open_location: true)
+ href: storage_url_open_file(represented, 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 d3a1ef11779..a36b3cb05e6 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
@@ -34,7 +34,7 @@ module API
resources :open do
get do
- url = storage_url_open(@file_link, open_location: params[:location])
+ url = storage_url_open_file(@file_link, 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/api/v3/file_links/storage_url_helper.rb b/modules/storages/lib/api/v3/file_links/storage_url_helper.rb
index 319793cc03e..e0fde803ef5 100644
--- a/modules/storages/lib/api/v3/file_links/storage_url_helper.rb
+++ b/modules/storages/lib/api/v3/file_links/storage_url_helper.rb
@@ -28,12 +28,16 @@
# Helper for open and download links for a file link object.
module API::V3::FileLinks::StorageUrlHelper
- def storage_url_open(file_link, open_location: false)
+ def storage_url_open_file(file_link, open_location: false)
location_flag = ActiveModel::Type::Boolean.new.cast(open_location) ? 0 : 1
"#{file_link.storage.host}/f/#{file_link.origin_id}?openfile=#{location_flag}"
end
+ def storage_url_open(storage)
+ "#{storage.host}/apps/files"
+ end
+
# rubocop:disable Metrics/AbcSize
def make_download_url(file_link:, user:)
storage = file_link.storage
diff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rb
index 4e68f06ac42..4ad2d7573e4 100644
--- a/modules/storages/lib/api/v3/storages/storage_representer.rb
+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb
@@ -41,6 +41,7 @@ module API
# LinkedResource module defines helper methods to describe attributes
include API::Decorators::LinkedResource
include API::Decorators::DateProperty
+ include API::V3::FileLinks::StorageUrlHelper
def initialize(model, current_user:, embed_links: nil)
@connection_manager =
@@ -70,6 +71,10 @@ module API
{ href: represented.host }
end
+ link :open do
+ { href: storage_url_open(represented) }
+ end
+
link :authorizationState do
state = @connection_manager.authorization_state
urn = case state