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
[#43688] restyle storage file link list
Eric Schubert417ce464bd22
diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.html b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.htmlindex cb55bd5d1f6..dc0730e3ada 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.html+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.html@@ -25,6 +25,8 @@<op-storage[resource]="workPackage"[storage]="storage"+ [allowUploading]="storageFileUploadEnabled"+ [allowLinking]="storageFileLinkingEnabled"></op-storage></section></div>diff --git a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.tsindex ca41bc49aeb..ae43c3c6058 100644--- a/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts+++ b/frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts@@ -46,6 +46,7 @@ import { HookService } from 'core-app/features/plugins/hook-service';import { CurrentUserService } from 'core-app/core/current-user/current-user.service';import { StoragesResourceService } from 'core-app/core/state/storages/storages.service';import { IStorage } from 'core-app/core/state/storages/storage.model';+import { ConfigurationService } from 'core-app/core/config/configuration.service';import { ProjectsResourceService } from 'core-app/core/state/projects/projects.service';import { ToastService } from 'core-app/shared/components/toaster/toast.service';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';@@ -69,12 +70,21 @@ export class WorkPackageFilesTabComponent implements OnInit {storages$:Observable<IStorage[]>;+ get storageFileUploadEnabled():boolean {+ return this.configurationService.activeFeatureFlags.includes('storageFileUpload');+ }++ get storageFileLinkingEnabled():boolean {+ return this.configurationService.activeFeatureFlags.includes('storageFileLinking');+ }+constructor(private readonly i18n:I18nService,private readonly hook:HookService,private readonly currentUserService:CurrentUserService,private readonly projectsResourceService:ProjectsResourceService,private readonly storagesResourceService:StoragesResourceService,+ private readonly configurationService:ConfigurationService,private readonly apiV3:ApiV3Service,private readonly toast:ToastService,) { }diff --git a/frontend/src/app/shared/components/attachments/attachments.component.html b/frontend/src/app/shared/components/attachments/attachments.component.htmlindex 8a483ac802f..ece9617bf3c 100644--- a/frontend/src/app/shared/components/attachments/attachments.component.html+++ b/frontend/src/app/shared/components/attachments/attachments.component.html@@ -1,12 +1,11 @@<op-attachment-list[ngClass]="{- 'op-attachments--list': true,- 'op-attachments--list_dragging': dragging+ 'op-file-section--list': true,+ 'op-file-section--list_dragging': dragging}"*ngIf="(attachments$ | async).length"[attachments]="attachments$ | async"[collectionKey]="collectionKey"- [allowUploading]="allowUploading"></op-attachment-list><input@@ -20,32 +19,16 @@multiple/>-<div- *ngIf="allowUploading && resource.canAddAttachments && (attachments$ | async).length"- class="op-attachments--actions"->- <button- type="button"- class="spot-link"- (click)="triggerFileInput($event)"- data-qa-selector="op-attachments--upload-button"- >- <span class="spot-icon spot-icon_attachment"></span>-- Add attachment- </button>-</div>-<button*ngIf="allowUploading && resource.canAddAttachments"[attr.aria-label]="text.uploadLabel"data-qa-selector="op-attachments--drop-box"[ngClass]="{'hide-when-print': true,- 'op-attachments--drop-box': true,- 'op-attachments--drop-box_dragging': dragging,- 'op-attachments--drop-box_dragging-over': draggingOverDropZone,- 'op-attachments--drop-box_float': (attachments$ | async).length+ 'op-file-section--drop-box': true,+ 'op-file-section--drop-box_dragging': dragging,+ 'op-file-section--drop-box_dragging-over': draggingOverDropZone,+ 'op-file-section--drop-box_float': (attachments$ | async).length}"type="button"(click)="triggerFileInput()"@@ -54,13 +37,29 @@(drop)="onDropFiles($event)"><span- class="spot-icon spot-icon_attachment op-attachments--drop-box-icon"+ class="spot-icon spot-icon_attachment op-file-section--drop-box-icon"></span><labelfor="attachment_files"- class="op-attachments--drop-box-text"+ class="op-file-section--drop-box-text">{{ text.dropFiles }}<br>{{ text.dropFilesHint }}</label></button>++<div+ *ngIf="allowUploading && resource.canAddAttachments"+ class="op-file-section--actions"+>+ <button+ type="button"+ class="spot-link"+ (click)="triggerFileInput()"+ data-qa-selector="op-attachments--upload-button"+ >+ <span class="spot-icon spot-icon_attachment"></span>++ Add attachment+ </button>+</div>diff --git a/frontend/src/app/shared/components/attachments/attachments.component.ts b/frontend/src/app/shared/components/attachments/attachments.component.tsindex ef392762138..e7002210e85 100644--- a/frontend/src/app/shared/components/attachments/attachments.component.ts+++ b/frontend/src/app/shared/components/attachments/attachments.component.ts@@ -62,7 +62,6 @@ export const attachmentsSelector = 'op-attachments';@Component({selector: attachmentsSelector,templateUrl: './attachments.component.html',- styleUrls: ['./attachments.component.sass'],encapsulation: ViewEncapsulation.None,changeDetection: ChangeDetectionStrategy.OnPush,})@@ -71,9 +70,9 @@ export class OpAttachmentsComponent extends UntilDestroyedMixin implements OnIni@HostBinding('id.attachments_fields') public hostId = true;- @HostBinding('class.op-attachments') public className = true;+ @HostBinding('class.op-file-section') public className = true;- @Input('resource') public resource:HalResource;+ @Input() public resource:HalResource;@Input() public allowUploading = true;@@ -162,11 +161,13 @@ export class OpAttachmentsComponent extends UntilDestroyedMixin implements OnInidocument.body.addEventListener('dragover', this.onGlobalDragOver.bind(this));document.body.addEventListener('dragleave', this.onGlobalDragLeave.bind(this));+ document.body.addEventListener('drop', this.onGlobalDrop.bind(this));}ngOnDestroy():void {document.body.removeEventListener('dragover', this.onGlobalDragOver.bind(this));document.body.removeEventListener('dragleave', this.onGlobalDragLeave.bind(this));+ document.body.removeEventListener('drop', this.onGlobalDrop.bind(this));}public triggerFileInput():void {@@ -186,8 +187,6 @@ export class OpAttachmentsComponent extends UntilDestroyedMixin implements OnIni// eslint-disable-next-line no-param-reassignevent.dataTransfer.dropEffect = 'copy';- event.preventDefault();- event.stopPropagation();const dfFiles = event.dataTransfer.files;const length:number = dfFiles ? dfFiles.length : 0;@@ -220,6 +219,12 @@ export class OpAttachmentsComponent extends UntilDestroyedMixin implements OnInithis.cdRef.detectChanges();}+ public onGlobalDrop():void {+ this.dragging = false;++ this.cdRef.detectChanges();+ }+public onGlobalDragOver():void {this.dragging = true;diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.html b/frontend/src/app/shared/components/storages/storage/storage.component.htmlindex 745069fe973..1a13bc054ca 100644--- a/frontend/src/app/shared/components/storages/storage/storage.component.html+++ b/frontend/src/app/shared/components/storages/storage/storage.component.html@@ -2,7 +2,9 @@*ngIf="resource"><div class=op-tab-content--header>- <span class="op-tab-content--header-icon spot-icon spot-icon_nextcloud-circle op-files-tab--icon op-files-tab--icon_nextcloud"></span>+ <span+ class="op-tab-content--header-icon spot-icon spot-icon_nextcloud-circle op-files-tab--icon op-files-tab--icon_nextcloud"+ ></span><span class="op-tab-content--header-text" [textContent]="storage.name"></span><aclass="op-tab-content--header-action spot-link"@@ -16,51 +18,90 @@</div><op-storage-information- *ngFor="let infoBox of storageInformation | async"+ *ngFor="let infoBox of storageErrors | async"class="op-files-tab--storage-info-box"data-qa-selector="op-files-tab--storage-information"[content]="infoBox"></op-storage-information>- <ul- class="spot-list spot-list_compact op-file-list"- data-qa-selector="file-list"- >- <li- *ngFor="let fileLink of fileLinks$ | async; let i = index;"- class="spot-list--item op-file-list--item"- data-qa-selector="file-list--item"- op-file-link-list-item- [fileLink]="fileLink"- [disabled]="disabled"- [allowEditing]="allowEditing$ | async"- (removeFileLink)="removeFileLink(fileLink)"- ></li>- </ul>+ <div class="op-file-section">+ <ul+ class="spot-list spot-list_compact op-file-list"+ [ngClass]="{+ 'op-file-section': true,+ 'op-file-section--list_dragging': dragging+ }"+ data-qa-selector="file-list"+ >+ <li+ *ngFor="let fileLink of fileLinks$ | async; let i = index;"+ class="spot-list--item op-file-list--item"+ data-qa-selector="file-list--item"+ op-file-link-list-item+ [fileLink]="fileLink"+ [disabled]="disabled"+ [allowEditing]="allowEditing$ | async"+ (removeFileLink)="removeFileLink(fileLink)"+ ></li>+ </ul>++ <span+ *ngIf="!allowUploading && (storageErrors | async).length === 0 && (fileLinks$ | async).length === 0"+ class="op-file-section--empty-list-hint"+ [textContent]="text.emptyList()"+ ></span>- <p- *ngIf="(showLinkFilesAction | async) && (allowEditing$ | async)"- class="spot-body-small op-file-list--actions"- ><button- *ngIf="storageFileLinkingEnabled"+ *ngIf="allowUploading && (storageErrors | async).length === 0"+ [attr.aria-label]="text.dropBox.uploadLabel"+ data-qa-selector="op-storage--drop-box"+ [ngClass]="{+ 'hide-when-print': true,+ 'op-file-section--drop-box': true,+ 'op-file-section--drop-box_dragging': dragging,+ 'op-file-section--drop-box_dragging-over': draggingOverDropZone,+ 'op-file-section--drop-box_float': (fileLinks$ | async).length+ }"type="button"- class="spot-link op-file-list--action-button"- data-qa-selector="op-file-list--link-existing-file-button"- (click)="openLinkFilesDialog()"+ (dragover)="onDragOver($event)"+ (dragleave)="onDragLeave($event)"+ (drop)="onDropFiles($event)">- <span class="spot-icon spot-icon_add-link"></span>- <span [textContent]="text.actions.linkExisting"></span>+ <span+ class="spot-icon spot-icon_attachment op-attachments--drop-box-icon"+ ></span>+ <label+ class="op-file-section--drop-box-text"+ >+ {{ text.dropBox.dropFiles }}<br>+ {{ text.dropBox.dropFilesHint }}+ </label></button>- <button- *ngIf="storageFileUploadEnabled"- type="button"- class="spot-link op-file-list--action-button"- data-qa-selector="op-file-list--upload-file-button"- (click)="openSelectLocationDialog()"++ <div+ *ngIf="(allowEditing$ | async) && (storageErrors | async).length === 0"+ class="op-file-section--actions">- <span class="spot-icon spot-icon_upload-arrow"></span>- <span [textContent]="text.actions.uploadFile"></span>- </button>- </p>+ <button+ *ngIf="allowUploading"+ type="button"+ class="spot-link op-file-list--action-button"+ data-qa-selector="op-file-list--upload-file-button"+ (click)="openSelectLocationDialog()"+ >+ <span class="spot-icon spot-icon_upload-arrow"></span>+ <span [textContent]="text.actions.uploadFile"></span>+ </button>+ <button+ *ngIf="allowLinking"+ type="button"+ class="spot-link op-file-list--action-button"+ data-qa-selector="op-file-list--link-existing-file-button"+ (click)="openLinkFilesDialog()"+ >+ <span class="spot-icon spot-icon_add-link"></span>+ <span [textContent]="text.actions.linkExisting"></span>+ </button>+ </div>+ </div></ng-container>diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.tsindex e4de7699c1e..f2ba3b56a9e 100644--- a/frontend/src/app/shared/components/storages/storage/storage.component.ts+++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts@@ -28,8 +28,10 @@import {ChangeDetectionStrategy,+ ChangeDetectorRef,Component,Input,+ OnDestroy,OnInit,} from '@angular/core';import {@@ -74,11 +76,15 @@ import {templateUrl: './storage.component.html',changeDetection: ChangeDetectionStrategy.OnPush,})-export class StorageComponent extends UntilDestroyedMixin implements OnInit {+export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnDestroy {@Input() public resource:HalResource;@Input() public storage:IStorage;+ @Input() public allowUploading = true;++ @Input() public allowLinking = true;+fileLinks$:Observable<IFileLink[]>;allowEditing$:Observable<boolean>;@@ -87,9 +93,11 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {storageType:string;- storageInformation = new BehaviorSubject<StorageInformationBox[]>([]);+ storageErrors = new BehaviorSubject<StorageInformationBox[]>([]);++ draggingOverDropZone = false;- showLinkFilesAction = new BehaviorSubject<boolean>(false);+ dragging = false;private isLoggedIn = false;@@ -97,9 +105,6 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {text = {infoBox: {- emptyStorageHeader: (storageType:string):string => this.i18n.t('js.storages.link_files_in_storage', { storageType }),- emptyStorageContent: (storageType:string):string => this.i18n.t('js.storages.information.no_file_links', { storageType }),- emptyStorageButton: (storageType:string):string => this.i18n.t('js.storages.open_storage', { storageType }),fileLinkErrorHeader: this.i18n.t('js.storages.information.live_data_error'),fileLinkErrorContent: (storageType:string):string => this.i18n.t('js.storages.information.live_data_error_description', { storageType }),connectionErrorHeader: (storageType:string):string => this.i18n.t('js.storages.no_connection', { storageType }),@@ -112,23 +117,22 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {linkExisting: this.i18n.t('js.storages.link_existing_files'),uploadFile: this.i18n.t('js.storages.upload_files'),},+ dropBox: {+ uploadLabel: 'uploadLabel',+ dropFiles: 'dropFiles',+ dropFilesHint: 'dropFilesHint',+ },+ emptyList: ():string => this.i18n.t('js.storages.file_links.empty', { storageType: this.storageType }),openStorage: ():string => this.i18n.t('js.storages.open_storage', { storageType: this.storageType }),};- public get storageFileLinkingEnabled():boolean {- return this.configurationService.activeFeatureFlags.includes('storageFileLinking');- }-- public get storageFileUploadEnabled():boolean {- return this.configurationService.activeFeatureFlags.includes('storageFileUpload');- }-public get storageFilesLocation():string {return this.storage._links.open.href;}constructor(private readonly i18n:I18nService,+ private readonly cdRef:ChangeDetectorRef,private readonly cookieService:CookieService,private readonly opModalService:OpModalService,private readonly currentUserService:CurrentUserService,@@ -158,13 +162,22 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {this.resource.fileLinks = { elements: fileLinks.map((a) => a._links?.self) };}- this.storageInformation.next(this.instantiateStorageInformation(fileLinks));- this.showLinkFilesAction.next(!this.disabled && fileLinks.length > 0);+ this.storageErrors.next(this.getStorageErrors(fileLinks));});this.allowEditing$ = this.currentUserService.hasCapabilities$('file_links/manage', (this.resource.project as unknown&{ id:string }).id);++ document.body.addEventListener('dragover', this.onGlobalDragOver.bind(this));+ document.body.addEventListener('dragleave', this.afterGlobalDragEnd.bind(this));+ document.body.addEventListener('drop', this.afterGlobalDragEnd.bind(this));+ }++ ngOnDestroy():void {+ document.body.removeEventListener('dragover', this.onGlobalDragOver.bind(this));+ document.body.removeEventListener('dragleave', this.afterGlobalDragEnd.bind(this));+ document.body.removeEventListener('drop', this.afterGlobalDragEnd.bind(this));}public removeFileLink(fileLink:IFileLink):void {@@ -200,7 +213,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {this.opModalService.show<LocationPickerModalComponent>(LocationPickerModalComponent, 'global', locals);}- private instantiateStorageInformation(fileLinks:IFileLink[]):StorageInformationBox[] {+ private getStorageErrors(fileLinks:IFileLink[]):StorageInformationBox[] {if (!this.isLoggedIn) {return [];}@@ -211,9 +224,6 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {case storageAuthorizationError:return [this.authorizationErrorInformation];case storageConnected:- if (fileLinks.length === 0) {- return [this.emptyStorageInformation];- }if (fileLinks.filter((fileLink) => fileLink._links.permission?.href === fileLinkViewError).length > 0) {this.disabled = true;return [this.fileLinkErrorInformation];@@ -256,20 +266,6 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {);}- private get emptyStorageInformation():StorageInformationBox {- return new StorageInformationBox(- 'add-link',- this.text.infoBox.emptyStorageHeader(this.storageType),- this.text.infoBox.emptyStorageContent(this.storageType),- [new StorageActionButton(- this.text.infoBox.emptyStorageButton(this.storageType),- () => {- window.open(this.storageFilesLocation, '_blank');- },- )],- );- }-private get fileLinkErrorInformation():StorageInformationBox {return new StorageInformationBox('error',@@ -301,4 +297,39 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit {private initializeStorageTypes() {this.storageTypeMap[nextcloud] = this.i18n.t('js.storages.types.nextcloud');}++ public onDropFiles(event:DragEvent):void {+ if (event.dataTransfer === null) return;++ this.draggingOverDropZone = false;+ this.dragging = false;+ }++ public onDragOver(event:DragEvent):void {+ if (event.dataTransfer !== null && containsFiles(event.dataTransfer)) {+ // eslint-disable-next-line no-param-reassign+ event.dataTransfer.dropEffect = 'copy';+ this.draggingOverDropZone = true;+ }+ }++ public onDragLeave(_event:DragEvent):void {+ this.draggingOverDropZone = false;+ }++ public afterGlobalDragEnd():void {+ this.dragging = false;++ this.cdRef.detectChanges();+ }++ public onGlobalDragOver():void {+ this.dragging = true;++ this.cdRef.detectChanges();+ }+}++function containsFiles(dataTransfer:DataTransfer):boolean {+ return dataTransfer.types.indexOf('Files') >= 0;}diff --git a/frontend/src/global_styles/content/_work_packages.sass b/frontend/src/global_styles/content/_work_packages.sassindex 9fb416a9f49..27453cfe643 100644--- a/frontend/src/global_styles/content/_work_packages.sass+++ b/frontend/src/global_styles/content/_work_packages.sass@@ -60,6 +60,7 @@// Shared@import work_packages/shared/file_list@import work_packages/shared/file_picker+@import work_packages/shared/file_section// Table configuration@import work_packages/table_configuration_modaldiff --git a/frontend/src/global_styles/content/work_packages/shared/_file_list.sass b/frontend/src/global_styles/content/work_packages/shared/_file_list.sassindex 5f259f810ed..06a7a3b9cc3 100644--- a/frontend/src/global_styles/content/work_packages/shared/_file_list.sass+++ b/frontend/src/global_styles/content/work_packages/shared/_file_list.sass@@ -42,9 +42,9 @@&-title@include spot-body-small+ @include text-shortenerword-break: normal- @include text-shortenerpadding-right: $spot-spacing-0_5&-textdiff --git a/frontend/src/app/shared/components/attachments/attachments.component.sass b/frontend/src/global_styles/content/work_packages/shared/_file_section.sasssimilarity index 51%rename from frontend/src/app/shared/components/attachments/attachments.component.sassrename to frontend/src/global_styles/content/work_packages/shared/_file_section.sassindex 73881932b45..2cc7d66e9fd 100644--- a/frontend/src/app/shared/components/attachments/attachments.component.sass+++ b/frontend/src/global_styles/content/work_packages/shared/_file_section.sass@@ -1,12 +1,44 @@+//-- 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.+//+++@import "helpers"-.op-attachments+.op-file-sectiondisplay: flexflex-direction: columnposition: relative&--actions@include spot-body-small+ margin-top: $spot-spacing-0_75++ > :not(:last-child)+ margin-right: $spot-spacing-0_5&--drop-box@include unset-button-styles@@ -45,9 +77,6 @@left: 0width: 100%- left: 0- width: 100%-background: rgba($spot-color-basic-white, 0.9)z-index: -2@@ -83,3 +112,12 @@&--list_draggingmin-height: $spot-spacing-4++ &--empty-list-hint+ //@include spot-body-small($style: italic)+ //margin: $spot-spacing-0_75 $spot-spacing-0_5 0++ @include spot-body-small()++ margin-top: $spot-spacing-0_75+ color: $spot-color-basic-gray-3diff --git a/modules/storages/config/locales/js-en.yml b/modules/storages/config/locales/js-en.ymlindex e67396d352a..c8bdd3797ab 100644--- a/modules/storages/config/locales/js-en.yml+++ b/modules/storages/config/locales/js-en.yml@@ -27,6 +27,9 @@ en:To add a link, see or upload files related to this work package, please login to %{storageType}.file_links:+ empty: >+ Currently there are no linked files to this work package. Start linking files with the action below or from+ within %{storageType}.download: "Download %{fileName}"no_permission: "You have no permission to see this file."open: 'Open file on storage'