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
[#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.ymlindex 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- authorizationStateproperties: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/AauthorizationState:@@ -93,6 +101,8 @@ example:title: Nextcloudorigin:href: https://nextcloud.deathstar.rocks/+ open:+ href: https://nextcloud.deathstar.rocks/apps/filesauthorizationState:href: urn:openproject-org:api:v3:storages:authorization:FailedAuthorizationtitle: Failed Authorizationdiff --git a/frontend/src/app/core/state/storages/storage.model.ts b/frontend/src/app/core/state/storages/storage.model.tsindex 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.tsindex 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.rbindex 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 APIlink :originOpen do{- href: storage_url_open(represented)+ href: storage_url_open_file(represented)}end@@ -106,7 +106,7 @@ module APIlink :originOpenLocation do{- href: storage_url_open(represented, open_location: true)+ href: storage_url_open_file(represented, open_location: true)}enddiff --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.rbindex 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 APIresources :open doget 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 GETenddiff --git a/modules/storages/lib/api/v3/file_links/storage_url_helper.rb b/modules/storages/lib/api/v3/file_links/storage_url_helper.rbindex 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/AbcSizedef make_download_url(file_link:, user:)storage = file_link.storagediff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rbindex 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 attributesinclude API::Decorators::LinkedResourceinclude API::Decorators::DateProperty+ include API::V3::FileLinks::StorageUrlHelperdef 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 dostate = @connection_manager.authorization_stateurn = case state