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
[#43060] Show file links of not connected storages
Eric Schubert71fe6baf4e25
diff --git a/frontend/src/app/core/state/is-defined-entity.ts b/frontend/src/app/core/state/is-defined-entity.tsnew file mode 100644index 00000000000..d4805aaa0aa--- /dev/null+++ b/frontend/src/app/core/state/is-defined-entity.ts@@ -0,0 +1,31 @@+// -- 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.+//++++export default function isDefinedEntity<T>(entity:T|undefined):entity is T {+ return entity !== undefined;+}diff --git a/frontend/src/app/core/state/resource-collection.service.ts b/frontend/src/app/core/state/resource-collection.service.tsindex 1f99b00bb28..5a2c44271dd 100644--- a/frontend/src/app/core/state/resource-collection.service.ts+++ b/frontend/src/app/core/state/resource-collection.service.ts@@ -39,6 +39,7 @@ import {} from 'rxjs/operators';import { CollectionState } from 'core-app/core/state/collection-store';import { omit } from 'lodash';+import isDefinedEntity from 'core-app/core/state/is-defined-entity';export type CollectionStore<T> = EntityStore<CollectionState<T>>;@@ -70,9 +71,7 @@ export abstract class ResourceCollectionService<T> {return this.query.selectEntity(id)- .pipe(- filter((entity) => entity !== undefined),- ) as Observable<T>;+ .pipe(filter(isDefinedEntity));}/**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 6dfd8dcbfcc..e9a4e216afd 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@@ -29,9 +29,10 @@import { Injector } from '@angular/core';import { combineLatest, Observable } from 'rxjs';import { map } from 'rxjs/operators';+import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';-import { AttachmentsResourceService } from 'core-app/core/state/attachments/attachments.service';import { FileLinksResourceService } from 'core-app/core/state/file-links/file-links.service';+import { AttachmentsResourceService } from 'core-app/core/state/attachments/attachments.service';export function workPackageFilesCount(workPackage:WorkPackageResource,diff --git a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.tsindex 2112ecd15d1..616d538d0ae 100644--- a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts+++ b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.component.ts@@ -59,10 +59,10 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {@Input() public fileLink:IFileLink;- @Input() public index:number;-@Input() public allowEditing = false;+ @Input() public disabled = true;+@Output() public removeFileLink = new EventEmitter<void>();@ViewChild('avatar') avatar:ElementRef;@@ -71,7 +71,7 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {fileLinkIcon:IFileIcon;- showFloatingActions:boolean;+ viewAllowed:boolean;text = {title: {@@ -101,7 +101,7 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {this.fileLinkIcon = getIconForMimeType(this.originData.mimeType);- this.showFloatingActions = this.fileLink._links.permission.href === fileLinkViewAllowed;+ this.viewAllowed = this.fileLink._links.permission.href === fileLinkViewAllowed;}ngAfterViewInit():void {diff --git a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.html b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.htmlindex f9f2c43c63f..b77851c8eac 100644--- a/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.html+++ b/frontend/src/app/shared/components/file-links/file-link-list-item/file-link-list-item.html@@ -1,6 +1,7 @@<div class="spot-list--item-floating-wrapper"><aclass="spot-list--item-action op-files-tab--file-list-item-action"+ [ngClass]="{ 'disabled': disabled, 'view-not-allowed': !viewAllowed }"[href]="fileLink._links.staticOriginOpen.href"[title]="fileLink.originData.name"target="_blank"@@ -26,7 +27,7 @@></div></a><div- *ngIf="showFloatingActions"+ *ngIf="!disabled && viewAllowed"class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-actions"><a@@ -47,7 +48,7 @@</button></div><div- *ngIf="!showFloatingActions"+ *ngIf="!disabled && !viewAllowed"class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-text"><span class="spot-icon spot-icon_info2"></span>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 1d6c2d8a9b1..9a0a6c2494f 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@@ -41,7 +41,7 @@ import { IFileLink } from 'core-app/core/state/file-links/file-link.model';import { IStorage } from 'core-app/core/state/storages/storage.model';import { FileLinksResourceService } from 'core-app/core/state/file-links/file-links.service';import {- fileLinkViewAllowed, nextcloud,+ nextcloud,storageAuthorizationError,storageConnected,storageFailedAuthorization,@@ -72,6 +72,8 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInitallowEditing = false;+ disabled = false;+showInformationBox$ = new BehaviorSubject<boolean>(false);showFileLinks$ = new BehaviorSubject<boolean>(false);@@ -113,6 +115,8 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInitthis.initializeStorageTypes();this.initializeLocales();+ this.disabled = this.storage._links.authorizationState.href !== storageConnected;+this.fileLinks$ = this.fileLinkResourceService.collection(this.collectionKey);this.fileLinks$@@ -141,10 +145,6 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInitwindow.open(this.storageLocation, '_blank');}- public isDisabled(fileLink:IFileLink):boolean {- return fileLink._links.permission.href !== fileLinkViewAllowed;- }-private get collectionKey():string {return isNewResource(this.resource) ? 'new' : this.fileLinkSelfLink;}@@ -225,7 +225,7 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInitthis.buttons.next([]);this.showInformationBox$.next(true);- this.showFileLinks$.next(false);+ this.showFileLinks$.next(true);}private setEmptyFileLinkListState():void {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 c8d2a09aded..6869cbfb513 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@@ -19,12 +19,11 @@<li*ngFor="let fileLink of fileLinks$ | async; let i = index;"class="spot-list--item op-files-tab--file-list-item"- [ngClass]="{ 'disabled': isDisabled(fileLink) }"data-qa-selector="op-files-tab--file-list-item"op-file-link-list-item[fileLink]="fileLink"[resource]="resource"- [index]="i"+ [disabled]="disabled"[allowEditing]="allowEditing"(removeFileLink)="removeFileLink(fileLink)"></li>diff --git a/frontend/src/app/shared/components/file-links/file-link-list/storage-action-button.ts b/frontend/src/app/shared/components/file-links/file-link-list/storage-action-button.tsindex 36000b6099d..9655d192640 100644--- a/frontend/src/app/shared/components/file-links/file-link-list/storage-action-button.ts+++ b/frontend/src/app/shared/components/file-links/file-link-list/storage-action-button.ts@@ -1,3 +1,31 @@+// -- 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.+//+++export class StorageActionButton {constructor(public readonly label:string, public readonly action:() => void) { }}diff --git a/frontend/src/global_styles/content/work_packages/tabs/_files.sass b/frontend/src/global_styles/content/work_packages/tabs/_files.sassindex d1b699f59b9..21301e3bfe4 100644--- a/frontend/src/global_styles/content/work_packages/tabs/_files.sass+++ b/frontend/src/global_styles/content/work_packages/tabs/_files.sass@@ -34,6 +34,13 @@padding-left: 0padding-right: 0+ &.view-not-allowed+ opacity: 0.5++ &.disabled+ opacity: 0.5+ pointer-events: none+&:hover .op-files-tab--file-list-item-titletext-decoration: underline@@ -83,9 +90,6 @@height: $spot-spacing-1-5margin-right: $spot-spacing-0-25- &.disabled .op-files-tab--file-list-item-action- opacity: 0.5-&--storage-info-boxmargin-top: 0.875remdisplay: grid