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
[#42552] reverted the concept of live file links
Eric Schubert03860fad6b4a
diff --git a/docs/api/apiv3/components/schemas/file_link_read_model.yml b/docs/api/apiv3/components/schemas/file_link_read_model.ymlindex 80089013017..7cb5f55e006 100644--- a/docs/api/apiv3/components/schemas/file_link_read_model.yml+++ b/docs/api/apiv3/components/schemas/file_link_read_model.yml@@ -38,8 +38,10 @@ properties:type: objectrequired:- self+ - storage- container- creator+ - permission- originOpen- staticOriginOpen- originOpenLocation@@ -81,6 +83,16 @@ properties:- description: |-The uri to delete the file link.+ **Resource**: N/A+ permission:+ allOf:+ - $ref: './link.yml'+ - description: |-+ The urn of the user specific file link permission on its storage. Can be one of:++ - urn:openproject-org:api:v3:file-links:permission:View+ - urn:openproject-org:api:v3:file-links:permission:NotAllowed+**Resource**: N/AoriginOpen:allOf:@@ -175,6 +187,9 @@ example:title: Obi-Wan Kenobidelete:href: /api/v3/work_package/17/file_links/1337+ permission:+ href: urn:openproject-org:api:v3:file-links:permission:View+ title: VieworiginOpen:href: https://nextcloud.deathstar.rocks/index.php/f/5503?openfile=1staticOriginOpen:diff --git a/docs/api/apiv3/components/schemas/live_file_link_collection_model.yml b/docs/api/apiv3/components/schemas/live_file_link_collection_model.ymldeleted file mode 100644index 4f61c70c456..00000000000--- a/docs/api/apiv3/components/schemas/live_file_link_collection_model.yml+++ /dev/null@@ -1,117 +0,0 @@-# Schema: LiveFileLinkCollectionModel-----allOf:- - $ref: './collection_model.yml'- - type: object- required:- - _links- - _embedded- properties:- _links:- type: object- required:- - self- - storage- - connectionState- properties:- self:- allOf:- - $ref: "./link.yml"- - description: |-- This file links collection-- **Resource**: FileLinkCollectionReadModel- storage:- allOf:- - $ref: "./link.yml"- - description: |-- The storage resource of this live link collection-- **Resource**: Storage- connectionState:- allOf:- - $ref: "./link.yml"- - description: |-- The urn of the storage connection state. Can be one of:-- - urn:openproject-org:api:v3:storages:connection:connected- - urn:openproject-org:api:v3:storages:connection:missing-authentication- - urn:openproject-org:api:v3:storages:connection:failed-authentication- - urn:openproject-org:api:v3:storages:connection:error-- **Resource**: N/A- _embedded:- type: object- required:- - elements- - storage- properties:- elements:- type: array- items:- $ref: './live_file_link_model.yml'- storage:- $ref: './storage_model.yml'--example:- _type: Collection- total: 2- count: 2- _links:- self:- href: '/api/v3/work_packages/42/file_links'- _embedded:- storage:- id: 42- _type: Storage- name: It's no moon- createdAt: '2021-12-20T13:37:00.211Z'- updatedAt: '2021-12-20T13:37:00.211Z'- _links:- self:- href: /api/v3/storages/42- title: It's no moon- type:- href: urn:openproject-org:api:v3:storages:nextcloud- title: Nextcloud- origin:- href: https://nextcloud.deathstar.rocks/- elements:- - id: 1337- _type: FileLink- createdAt: '2021-12-20T13:37:00.211Z'- updatedAt: '2021-12-20T13:37:00.211Z'- originData:- id: 5503- name: logo.png- mimeType: image/png- size: 16042- createdAt: '2021-12-19T09:42:10.170Z'- lastModifiedAt: '2021-12-20T14:00:13.987Z'- createdByName: Luke Skywalker- lastModifiedByName: Anakin Skywalker- _links:- self:- href: /api/v3/work_package/17/file_links/1337- title: file link- storage:- href: /api/v3/storage/42- title: It's no moon- container:- href: /api/v3/work_package/17- title: work package- creator:- href: /api/v3/users/33- title: Obi-Wan Kenobi- delete:- href: /api/v3/work_package/17/file_links/1337- method: delete- originOpen:- href: https://nextcloud.deathstar.rocks/index.php/f?fileid=5503- staticOriginOpen:- href: /api/v3/work_package/17/file_links/1337/open- permission:- href: urn:openproject-org:api:v3:file-links:permission:not-allowed- title: Not Allowed- - _hint: File Link resource shortened for brevity- id: 1338diff --git a/docs/api/apiv3/components/schemas/live_file_link_model.yml b/docs/api/apiv3/components/schemas/live_file_link_model.ymldeleted file mode 100644index 66cf1998930..00000000000--- a/docs/api/apiv3/components/schemas/live_file_link_model.yml+++ /dev/null@@ -1,99 +0,0 @@-# Schema: LiveFileLinkModel-----allOf:- - $ref: './file_link_read_model.yml'- - type: object- required:- - permission- properties:- _links:- type: object- required:- - permission- properties:- permission:- allOf:- - $ref: './link.yml'- - description: |-- The urn of the user specific file link permission on this storage. Can be:-- - urn:openproject-org:api:v3:file-links:permission:view- - urn:openproject-org:api:v3:file-links:permission:not-allowed-- **Resource**: N/A--example:- id: 1337- _type: FileLink- createdAt: '2021-12-20T13:37:00.211Z'- updatedAt: '2021-12-20T13:37:00.211Z'- originData:- id: 5503- name: logo.png- mimeType: image/png- size: 16042- createdAt: '2021-12-19T09:42:10.170Z'- lastModifiedAt: '2021-12-20T14:00:13.987Z'- createdByName: Luke Skywalker- lastModifiedByName: Anakin Skywalker- _embedded:- storage:- id: 1337- _type: Storage- name: It's no moon- createdAt: '2021-12-20T13:37:00.211Z'- updatedAt: '2021-12-20T13:37:00.211Z'- _links:- self:- href: /api/v3/storages/1337- title: It's no moon- type:- href: urn:openproject-org:api:v3:storages:nextcloud- title: Nextcloud- origin:- href: https://nextcloud.deathstar.rocks/- container:- _hint: Work package resource shortened for brevity- _type: WorkPackage- _links:- self:- href: "/api/v3/work_packages/1528"- title: Develop API- schema:- href: "/api/v3/work_packages/schemas/11-2"- id: 1528- subject: Develop API- description:- format: markdown- raw: Develop super cool OpenProject API.- html: "<p>Develop super cool OpenProject API.</p>"- scheduleManually: false- startDate:- dueDate:- createdAt: '2014-08-29T12:40:53Z'- updatedAt: '2014-08-29T12:44:41Z'- _links:- self:- href: /api/v3/work_package/17/file_links/1337- storage:- href: /api/v3/storage/42- title: It's no moon- container:- href: /api/v3/work_package/17- title: Develop API- creator:- href: /api/v3/users/33- title: Obi-Wan Kenobi- delete:- href: /api/v3/work_package/17/file_links/1337- originOpen:- href: https://nextcloud.deathstar.rocks/index.php/f/5503?openfile=1- staticOriginOpen:- href: /api/v3/work_package/17/file_links/1337/open- originOpenLocation:- href: https://nextcloud.deathstar.rocks/index.php/f/5503?openfile=0- staticOriginOpenLocation:- href: /api/v3/work_package/17/file_links/1337/open?location=true- permission:- href: urn:openproject-org:api:v3:file-links:permission:not-allowed- title: Not Alloweddiff --git a/docs/api/apiv3/components/schemas/storage_model.yml b/docs/api/apiv3/components/schemas/storage_model.ymlindex b369102b478..0ca98c32101 100644--- a/docs/api/apiv3/components/schemas/storage_model.yml+++ b/docs/api/apiv3/components/schemas/storage_model.yml@@ -5,7 +5,7 @@ required:- id- _type- name- - storageType+ - _linksproperties:id:type: integer@@ -31,7 +31,7 @@ properties:- self- type- origin- - liveFileLinks+ - connectionStateproperties:self:allOf:@@ -54,13 +54,17 @@ properties:Web uri of the storage instance**Resource**: N/A- liveFileLinks:+ connectionState:allOf:- - $ref: './link.yml'+ - $ref: "./link.yml"- description: |-- A templated link to fetch the file links with live data for a given container.-- **Resource**: LiveFileLinkCollection+ The urn of the storage connection state. Can be one of:++ - urn:openproject-org:api:v3:storages:connection:Connected+ - urn:openproject-org:api:v3:storages:connection:FailedAuthentication+ - urn:openproject-org:api:v3:storages:connection:Error++ **Resource**: N/Aexample:id: 1337_type: Storage@@ -76,6 +80,6 @@ example:title: Nextcloudorigin:href: https://nextcloud.deathstar.rocks/- liveFileLinks:- href: '/api/v3/storages/1337/file_links?filters=[{"container_id":{"operator":"=","values":["%{container_id}"]}},{"container_type":{"operator":"=","values":["%{container_type}"]}}]'- templated: true+ connectionState:+ href: urn:openproject-org:api:v3:storages:connection:FailedAuthentication+ title: Failed Authenticationdiff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.ymlindex 5bd466aeae2..a9841e7fef8 100644--- a/docs/api/apiv3/openapi-spec.yml+++ b/docs/api/apiv3/openapi-spec.yml@@ -351,8 +351,6 @@ paths:"$ref": "./paths/status.yml""/api/v3/storages/{id}":"$ref": "./paths/storage.yml"- "/api/v3/storages/{id}/live_file_links":- "$ref": "./paths/live_file_links.yml""/api/v3/time_entries":"$ref": "./paths/time_entries.yml""/api/v3/time_entries/{id}/form":@@ -594,10 +592,6 @@ components:"$ref": "./components/schemas/list_projects_by_version_model.yml"List_time_entriesModel:"$ref": "./components/schemas/list_time_entries_model.yml"- LiveFileLinkCollectionModel:- "$ref": "./components/schemas/live_file_link_collection_model.yml"- LiveFileLinkModel:- "$ref": "./components/schemas/live_file_link_model.yml"Lock_user:"$ref": "./components/schemas/lock_user.yml"Markdown:diff --git a/docs/api/apiv3/paths/live_file_links.yml b/docs/api/apiv3/paths/live_file_links.ymldeleted file mode 100644index d2bef0418e2..00000000000--- a/docs/api/apiv3/paths/live_file_links.yml+++ /dev/null@@ -1,38 +0,0 @@-# /api/v3/storages/{id}/live_file_links-----get:- summary: Gets a file link collection with live data.- operationId: list_storage_live_file_links- tags:- - File links- description: |-- Gets a storage resource. TBD- parameters:- - name: id- description: Storage id- in: path- required: true- schema:- type: integer- example: 1337- responses:- '200':- description: OK- content:- application/hal+json:- schema:- $ref: '../components/schemas/storage_model.yml'- '404':- content:- application/hal+json:- schema:- $ref: "../components/schemas/error_response.yml"- example:- _type: Error- errorIdentifier: urn:openproject-org:api:v3:errors:NotFound- message: The requested resource could not be found.- description: |-- Returned if the storage does not exist or the client does not have sufficient permissions to see it.-- **Required permission:** view file links-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 8f46188e76b..385f5ccfd97 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@@ -29,6 +29,9 @@module APImodule V3module FileLinks+ URN_PERMISSION_VIEW = "#{::API::V3::URN_PREFIX}file-links:permission:View".freeze+ URN_PERMISSION_NOT_ALLOWED = "#{::API::V3::URN_PREFIX}file-links:permission:NotAllowed".freeze+class FileLinkRepresenter < ::API::Decorators::Singleinclude API::Decorators::LinkedResourceinclude API::Decorators::DateProperty@@ -66,6 +69,14 @@ module API}end+ link :permission do+ # TODO: replace with service to check real permission state+ {+ href: URN_PERMISSION_VIEW,+ title: 'View'+ }+ end+link :originOpen do{href: storage_url_open(represented)diff --git a/modules/storages/lib/api/v3/storages/storage_representer.rb b/modules/storages/lib/api/v3/storages/storage_representer.rbindex ca4defde83b..a96dd5a2822 100644--- a/modules/storages/lib/api/v3/storages/storage_representer.rb+++ b/modules/storages/lib/api/v3/storages/storage_representer.rb@@ -33,6 +33,11 @@module APImodule V3module Storages+ URN_TYPE_NEXTCLOUD = "#{::API::V3::URN_PREFIX}storages:Nextcloud".freeze+ URN_CONNECTION_CONNECTED = "#{::API::V3::URN_PREFIX}storages:connection:Connected".freeze+ URN_CONNECTION_AUTH_FAILED = "#{::API::V3::URN_PREFIX}storages:connection:FailedAuthentication".freeze+ URN_CONNECTION_ERROR = "#{::API::V3::URN_PREFIX}storages:connection:Error".freeze+class StorageRepresenter < ::API::Decorators::Single# LinkedResource module defines helper methods to describe attributesinclude API::Decorators::LinkedResource@@ -51,7 +56,7 @@ module APIlink :type do{- href: "#{::API::V3::URN_PREFIX}storages:nextcloud",+ href: URN_TYPE_NEXTCLOUD,title: 'Nextcloud'}end@@ -62,6 +67,14 @@ module API}end+ link :connectionState do+ # TODO: replace with service to check real connection state+ {+ href: URN_CONNECTION_CONNECTED,+ title: 'Connected'+ }+ end+def _type'Storage'enddiff --git a/modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.rb b/modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.rbindex 44fd6331d25..376e1221af0 100644--- a/modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.rb+++ b/modules/storages/spec/lib/api/v3/file_links/file_link_representer_rendering_spec.rb@@ -83,6 +83,14 @@ describe ::API::V3::FileLinks::FileLinkRepresenter, 'rendering' doendend+ describe 'permission' do+ it_behaves_like 'has a titled link' do+ let(:link) { 'permission' }+ let(:href) { 'urn:openproject-org:api:v3:file-links:permission:View' }+ let(:title) { 'View' }+ end+ end+describe 'originOpen' doit_behaves_like 'has an untitled link' dolet(:link) { 'originOpen' }diff --git a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rbindex 6926e3c050c..83bd1d850a5 100644--- a/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb+++ b/modules/storages/spec/lib/api/v3/storages/storages_representer_rendering_spec.rb@@ -43,6 +43,21 @@ describe ::API::V3::Storages::StorageRepresenter, 'rendering' dolet(:title) { storage.name }endend++ describe 'origin' do+ it_behaves_like 'has an untitled link' do+ let(:link) { 'origin' }+ let(:href) { storage.host }+ end+ end++ describe 'connectionState' do+ it_behaves_like 'has a titled link' do+ let(:link) { 'connectionState' }+ let(:href) { 'urn:openproject-org:api:v3:storages:connection:Connected' }+ let(:title) { 'Connected' }+ end+ endenddescribe 'properties' do