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
Merge branch 'implementation/42157-list-file-links' into implementation/42158-add-direct-action-hover-menu
Eric Schubert7daf6de2dab8
diff --cc config/locales/js-en.ymlindex 5a3bb4782c7,26ef9f5f31e..cf2196ddb4d--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@@ -442,9 -446,8 +446,10 @@@ enlabel_on: "on"label_open_menu: "Open menu"label_open_context_menu: "Open context menu"+ label_open_storage: "Open %{storageType}"label_open_work_packages: "open"+ label_open_file_link: 'Open file on storage'+ label_open_file_link_location: 'Open file in location'label_password: "Password"label_previous: "Previous"label_per_page: "Per page:"diff --cc frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.tsindex cc5db66b477,21f549b9028..82ab55bce79--- 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@@@ -30,13 -30,12 +30,13 @@@ importChangeDetectionStrategy, Component, Input, OnInit,} from '@angular/core';import { Observable } from 'rxjs';- import { tap } from 'rxjs/operators';import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { IFileLink } from 'core-app/core/state/file-links/file-link.model';+ import { IStorage } from 'core-app/core/state/storages/storage.model';import { FileLinkResourceService } from 'core-app/core/state/file-links/file-links.service';+import { CurrentUserService } from 'core-app/core/current-user/current-user.service';- import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';+ import { I18nService } from 'core-app/core/i18n/i18n.service';import isNewResource from 'core-app/features/hal/helpers/is-new-resource';@Component({@@@ -47,49 -46,135 +47,149 @@@export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit {@Input() public resource:HalResource;- $fileLinks:Observable<IFileLink[]>;+ @Input() public storage:IStorage;+ allowEditing = false;++ fileLinks$:Observable<IFileLink[]>;++ informationBoxHeader:string;++ informationBoxContent:string;++ informationBoxButton:string;++ informationBoxIcon:string;++ showInformationBox = false;++ showFileLinks = false;++ private readonly storageTypeMap:{ [urn:string]:string; } = {+ 'urn:openproject-org:api:v3:storages:Nextcloud': 'Nextcloud',+ };++ private text:{+ infoBox:{+ emptyStorageHeader:string,+ emptyStorageContent:string,+ emptyStorageButton:string,+ connectionErrorHeader:string,+ connectionErrorContent:string,+ authenticationFailureHeader:string,+ authenticationFailureContent:string,+ loginButton:string,+ }+ };+constructor(+ private readonly i18n:I18nService,private readonly fileLinkResourceService:FileLinkResourceService,- private currentUserService:CurrentUserService,- private currentProjectService:CurrentProjectService,++ private readonly currentUserService:CurrentUserService,) {super();}ngOnInit():void {+ this.initializeLocales();+this.fileLinkResourceService.fetchCurrent(this.fileLinkSelfLink);- this.$fileLinks = this.fileLinkResourceService.all(this.collectionKey)- .pipe(- tap((fileLinks) => {- if (isNewResource(this.resource)) {- this.resource.fileLinks = { elements: fileLinks.map((a) => a._links?.self) };- }- }),- );-- this- .currentUserService- .hasCapabilities$('file_links/manage', this.currentProjectService.id as string)+ this.fileLinks$ = this.fileLinkResourceService.all(this.collectionKey);++ this.fileLinks$+ .pipe(this.untilDestroyed())+ .subscribe((fileLinks) => {+ if (isNewResource(this.resource)) {+ this.resource.fileLinks = { elements: fileLinks.map((a) => a._links?.self) };+ }++ this.deriveStorageInformation(fileLinks.length);+ });++++ this.currentUserService++ .hasCapabilities$('file_links/manage', (this.resource.project as unknown&{ id:string }).id)+ .pipe(this.untilDestroyed())+ .subscribe((value) => {+ this.allowEditing = value;+ });+ }++ public removeFileLink(fileLink:IFileLink):void {+ this.fileLinkResourceService.remove(this.collectionKey, fileLink);}+ private get collectionKey():string {+ return isNewResource(this.resource) ? 'new' : this.fileLinkSelfLink;+ }+private get fileLinkSelfLink():string {const fileLinks = this.resource.fileLinks as unknown&{ href:string };- return fileLinks.href;+ return `${fileLinks.href}?filters=[{"storage":{"operator":"=","values":["${this.storage.id}"]}}]`;}- private get collectionKey():string {- return isNewResource(this.resource) ? 'new' : this.fileLinkSelfLink;+ private deriveStorageInformation(fileLinkCount:number):void {+ switch (this.storage._links?.connectionState.href) {+ case 'urn:openproject-org:api:v3:storages:connection:FailedAuthentication':+ this.setAuthenticationFailureState();+ break;+ case 'urn:openproject-org:api:v3:storages:connection:Error':+ this.setConnectionErrorState();+ break;+ case 'urn:openproject-org:api:v3:storages:connection:Connected':+ if (fileLinkCount === 0) {+ this.setEmptyFileLinkListState();+ } else {+ this.showInformationBox = false;+ this.showFileLinks = true;+ }+ break;+ default:+ this.showInformationBox = false;+ this.showFileLinks = false;+ }+ }++ private setAuthenticationFailureState():void {+ this.informationBoxHeader = this.text.infoBox.authenticationFailureHeader;+ this.informationBoxContent = this.text.infoBox.authenticationFailureContent;+ this.informationBoxButton = this.text.infoBox.loginButton;+ this.informationBoxIcon = 'info1';+ this.showInformationBox = true;+ this.showFileLinks = true;+ }++ private setConnectionErrorState():void {+ this.informationBoxHeader = this.text.infoBox.connectionErrorHeader;+ this.informationBoxContent = this.text.infoBox.connectionErrorContent;+ this.informationBoxButton = this.text.infoBox.loginButton;+ this.informationBoxIcon = 'info1';+ this.showInformationBox = true;+ this.showFileLinks = false;+ }++ private setEmptyFileLinkListState():void {+ this.informationBoxHeader = this.text.infoBox.emptyStorageHeader;+ this.informationBoxContent = this.text.infoBox.emptyStorageContent;+ this.informationBoxButton = this.text.infoBox.emptyStorageButton;+ this.informationBoxIcon = 'info1';+ this.showInformationBox = true;+ this.showFileLinks = true;+ }++ private initializeLocales():void {+ const storageType = this.storageTypeMap[this.storage._links.type.href];+ this.text = {+ infoBox: {+ emptyStorageHeader: this.i18n.t('js.label_no_file_links_header', { storageType }),+ emptyStorageContent: this.i18n.t('js.label_no_file_links_content', { storageType }),+ emptyStorageButton: this.i18n.t('js.label_open_storage', { storageType }),+ connectionErrorHeader: this.i18n.t('js.label_no_storage_connection', { storageType }),+ connectionErrorContent: this.i18n.t('js.label_storage_connection_error', { storageType }),+ authenticationFailureHeader: this.i18n.t('js.label_login_to_storage', { storageType }),+ authenticationFailureContent: this.i18n.t('js.label_storage_not_connected', { storageType }),+ loginButton: this.i18n.t('js.label_storage_login', { storageType }),+ },+ };}}diff --cc frontend/src/app/shared/components/file-links/file-link-list/file-link-list.htmlindex b62f9c1ac2e,8a6f2a2d90b..cdfdfa7ee4d--- 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,13 -1,23 +1,25 @@@<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"- [allowEditing]="allowEditing"- (removeFileLink)="removeFileLink(fileLink)"+ <op-storage-information+ *ngIf="showInformationBox"+ [infoIcon]="'info1'"+ [infoTextHeader]="informationBoxHeader"+ [infoTextContent]="informationBoxContent"+ [buttonText]="informationBoxButton"+ ></op-storage-information>++ <div+ *ngIf="showFileLinks">- </op-file-link-list-item>+ <op-file-link-list-item+ *ngFor="let fileLink of fileLinks$ | async; let i = index;"+ class="op-files-tab--file-list-item"+ [ngClass]="{ 'inactive': showInformationBox || fileLink._links.permission.href === 'urn:openproject-org:api:v3:file-links:permission:NotAllowed' }"+ data-qa-selector="op-files-tab--file-list-item"+ [fileLink]="fileLink"+ [resource]="resource"+ [index]="i">++ [allowEditing]="allowEditing"++ (removeFileLink)="removeFileLink(fileLink)"+ </op-file-link-list-item>+ </div></div>diff --cc frontend/src/global_styles/content/work_packages/tabs/_files.sassindex c89eb140d2e,94606308977..1b2c86f8b1a--- a/frontend/src/global_styles/content/work_packages/tabs/_files.sass+++ b/frontend/src/global_styles/content/work_packages/tabs/_files.sass@@@ -60,22 -52,47 +63,63 @@@&--file-info-timestampmargin-right: 8px+ &:hover+ background-color: #F3F3F3++ .hover-menu+ display: flex+ justify-content: end++ .spot-link+ margin: 0 8px++ &:last-child+ margin-right: 0++ .file-info+ display: none++ &--storage-info-box+ margin-top: 14px+ display: grid+ grid-template: "icon text" "button button" / auto 1fr++ .icon-box+ height: 54px+ width: 54px+ grid-area: icon+ display: flex+ justify-content: center+ align-items: center++ .icon+ color: #878787+ font-size: 36px++ .text-box+ grid-area: text++ .text-box-header+ font-size: 16px+ font-weight: 700+ line-height: 24px++ .text-box-content+ font-size: 14px+ font-weight: 400+ line-height: 20px+ color: #878787++ .button-box+ grid-area: button+ display: flex+ justify-content: end++ .action-button+ padding: 4px 12px+ font-size: 14px+ line-height: 20px+&--color&-redcolor: #B93A33