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

stabilize file link removal link

ulfertsbd45359d0c80
diff --git a/frontend/src/app/shared/components/storages/file-link-list-item/file-link-list-item.component.ts b/frontend/src/app/shared/components/storages/file-link-list-item/file-link-list-item.component.ts
index 41d12a412d2..1b0c0c344e9 100644
--- a/frontend/src/app/shared/components/storages/file-link-list-item/file-link-list-item.component.ts
+++ b/frontend/src/app/shared/components/storages/file-link-list-item/file-link-list-item.component.ts
@@ -33,8 +33,10 @@ import {
ElementRef,
EventEmitter,
Input,
+ OnChanges,
OnInit,
Output,
+ SimpleChanges,
ViewChild,
} from '@angular/core';
@@ -60,7 +62,7 @@ import SpotDropAlignmentOption from 'core-app/spot/drop-alignment-options';
templateUrl: './file-link-list-item.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class FileLinkListItemComponent implements OnInit, AfterViewInit {
+export class FileLinkListItemComponent implements OnInit, OnChanges, AfterViewInit {
@Input() public fileLink:IFileLink;
@Input() public allowEditing = false;
@@ -132,8 +134,16 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
'js.storages.file_links.download',
{ fileName: this.fileLink.originData.name },
);
+ }
- this.floatingActions = this.getFloatingActions();
+ // Before, the getFloatingActions() method was called in the ngOnInit() method.
+ // The value of the allowEditing property can be calculated after the component is already initialized (in fact it is determined
+ // asynchronously, by getting a value from the server in a separate request). Therefore, the available actions need
+ // to be calculated whenever the value is set.
+ ngOnChanges(changes:SimpleChanges):void {
+ if (changes.allowEditing) {
+ this.floatingActions = this.getFloatingActions();
+ }
}
ngAfterViewInit():void {
diff --git a/modules/storages/spec/features/create_file_links_spec.rb b/modules/storages/spec/features/create_file_links_spec.rb
index 7074bb7df4b..0221ffaabf7 100644
--- a/modules/storages/spec/features/create_file_links_spec.rb
+++ b/modules/storages/spec/features/create_file_links_spec.rb
@@ -129,7 +129,7 @@ RSpec.describe 'Managing file links in work package', :js, :webmock do
end
it 'must enable the user to remove a file link' do
- within_test_selector('op-tab-content--tab-section', text: 'MY STORAGE', wait: 25) do
+ within_test_selector('op-tab-content--tab-section', text: 'MY STORAGE') do
within(:list_item, text: 'jingle.ogg') do
page.find('span', text: 'jingle.ogg').hover
page.click_on('Remove file link')