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
Added first file link specs
Andreas Pfohl15f9117cc491
diff --git a/frontend/src/app/features/hal/resources/work-package-resource.ts b/frontend/src/app/features/hal/resources/work-package-resource.tsindex ff3972d3aaf..01560f67bf7 100644--- a/frontend/src/app/features/hal/resources/work-package-resource.ts+++ b/frontend/src/app/features/hal/resources/work-package-resource.ts@@ -51,6 +51,7 @@ export interface WorkPackageResourceEmbedded {ancestors:WorkPackageResource[];assignee:HalResource|any;attachments:AttachmentCollectionResource;+ fileLinks:CollectionResource;author:HalResource|any;availableWatchers:HalResource|any;category:HalResource|any;diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.htmlindex 7708d31f54c..4526559df16 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.html@@ -1,5 +1,5 @@<div class="op-tab-content--container">- <div>+ <section data-qa-selector="op-tab-content--tab-section"><!-- The condition below will get replaced when implementing #41905. --><div *ngIf="true" class="op-tab-content--header"><h3 class="op-tab-content--header-text" [textContent]="text.attachments.label"></h3>@@ -8,14 +8,14 @@<op-attachment-list [resource]="workPackage"></op-attachment-list><op-attachments-upload [resource]="workPackage"></op-attachments-upload>- </div>+ </section>- <div *ngIf="true">+ <section *ngIf="true" data-qa-selector="op-tab-content--tab-section"><div class=op-tab-content--header><op-icon icon-classes="icon3 icon-nextcloud-circle op-files-tab--color-blue-deep"></op-icon><h3 class="op-tab-content--header-text" [textContent]="text.file_links.label"></h3></div><op-file-link-list [resource]="workPackage"></op-file-link-list>- </div>+ </section></div>diff --git a/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-files-count.function.ts b/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-files-count.function.tsindex 1b34049712e..d102f8e8c94 100644--- a/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-files-count.function.ts+++ b/frontend/src/app/features/work-packages/components/wp-tabs/services/wp-tabs/wp-files-count.function.ts@@ -40,14 +40,10 @@ export function workPackageFilesCount(const attachmentService = injector.get(AttachmentsResourceService);const fileLinkService = injector.get(FileLinkResourceService);- // TODO: enable keys when work package resource is providing those- // const attachmentsKey = workPackage.$links.attachments.href;- // const fileLinksKey = workPackage.$links.fileLinks.href;-return combineLatest([- attachmentService.all(`/api/v3/work_packages/${workPackage.id}/attachments`),- fileLinkService.all(`/api/v3/work_packages/${workPackage.id}/file_links`),+ attachmentService.all(workPackage.$links.attachments.href || ''),+ fileLinkService.all(workPackage.$links.fileLinks.href || ''),],).pipe(map(([a, f]) => a.length + f.length),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 fcd2da97f82..1bfcf170470 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@@ -62,10 +62,8 @@ export class FileLinkListComponent implements OnInit {}private get fileLinkSelfLink():string {- // TODO: replace if work package resource contains file links link- // const fileLinks = this.resource.fileLinks as unknown&{ href:string };- // return fileLinks.href;- return `/api/v3/work_packages/${this.resource.id}/file_links`;+ const fileLinks = this.resource.fileLinks as unknown&{ href:string };+ return fileLinks.href;}private get collectionKey():string {diff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.html b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.htmlindex f48113c62f5..10d84ea0457 100644--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.html+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list.html@@ -1,7 +1,8 @@-<div class="work-package--attachments--files" *ngIf="resource">+<div class="work-package--attachments--files" *ngIf="resource" data-qa-selector="op-files-tab--file-link-list"><op-file-link-list-item*ngFor="let fileLink of $fileLinks | async; let i = index;"class="op-files-tab--file-list-item"+ data-qa-selector="op-files-tab--file-list-item"[fileLink]="fileLink"[resource]="resource"[index]="i">diff --git a/modules/storages/spec/features/show_file_links_spec.rb b/modules/storages/spec/features/show_file_links_spec.rbnew file mode 100644index 00000000000..b98af1b61e1--- /dev/null+++ b/modules/storages/spec/features/show_file_links_spec.rb@@ -0,0 +1,75 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2022 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+#++++require_relative '../spec_helper'++describe 'Showing of file links in work package', :enable_storages, type: :feature, js: true do+ let(:permissions) { %i(view_work_packages view_file_links) }+ let(:project) { create(:project) }+ let(:current_user) do+ create(:user, member_in_project: project, member_with_permissions: permissions)+ end+ let(:work_package) { create(:work_package, project: project, description: 'Initial description') }+ let(:storage) { create(:storage) }+ let(:project_storage) { create(:project_storage, project: project, storage: storage) }+ let(:file_link) { create(:file_link, container: work_package, storage: storage) }+ let(:wp_page) { ::Pages::FullWorkPackage.new(work_package, project) }++ before do+ file_link++ login_as current_user+ wp_page.visit_tab! :files+ end++ context 'if work package has associated file links' do+ before do+ project_storage+ end++ it "must show associated file links" do+ expect(page).to have_selector('[data-qa-selector="op-tab-content--tab-section"]', count: 2)+ expect(page.find('[data-qa-selector="op-files-tab--file-link-list"]'))+ .to have_selector('[data-qa-selector="op-files-tab--file-list-item"]', text: file_link.origin_name, count: 1)+ end+ end++ context 'if user has no permission to see file links' do+ let(:permissions) { %i(view_work_packages view_file_links) }++ it 'must not show a file links section' do+ expect(page).to have_selector('[data-qa-selector="op-tab-content--tab-section"]', count: 1)+ end+ end++ context 'if project has no storage' do+ it 'must not show a file links section' do+ expect(page).to have_selector('[data-qa-selector="op-tab-content--tab-section"]', count: 1)+ end+ end+end