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

[chore] added style for file links with no permission

Eric Schubertccd1d89a2ad1
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index a405a6f0001..ca4e8867753 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -399,6 +399,8 @@ en:
label_expand_project_menu: "Expand project menu"
label_export: "Export"
label_export_preparing: "The export is being prepared and will be downloaded shortly."
+ label_file_link_no_permission: "No permission to see this file."
+ label_file_link_error: "Error fetching view permissions."
label_filename: "File"
label_filesize: "Size"
label_general: "General"
diff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item.component.ts b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item.component.ts
index 445ce915ed5..28b1d9d620c 100644
--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item.component.ts
+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item.component.ts
@@ -70,12 +70,15 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
public fileLinkIcon:IFileIcon;
+ public showFloatingActions:boolean;
+
public text = {
title: {
openFile: this.i18n.t('js.label_open_file_link'),
openFileLocation: this.i18n.t('js.label_open_file_link_location'),
removeFileLink: this.i18n.t('js.label_remove_file_link'),
},
+ floatingText: '',
};
constructor(
@@ -94,6 +97,8 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
}
this.fileLinkIcon = getIconForMimeType(this.originData.mimeType);
+
+ this.derivePermissionState();
}
ngAfterViewInit():void {
@@ -106,4 +111,24 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
);
}
}
+
+ private derivePermissionState():void {
+ switch (this.fileLink._links.permission.href) {
+ case 'urn:openproject-org:api:v3:file-links:permission:View':
+ this.showFloatingActions = true;
+ this.text.floatingText = '';
+ break;
+ case 'urn:openproject-org:api:v3:file-links:permission:NotAllowed':
+ this.showFloatingActions = false;
+ this.text.floatingText = this.i18n.t('js.label_file_link_no_permission');
+ break;
+ case 'urn:openproject-org:api:v3:file-links:permission:Error':
+ this.showFloatingActions = false;
+ this.text.floatingText = this.i18n.t('js.label_file_link_error');
+ break;
+ default:
+ this.showFloatingActions = true;
+ this.text.floatingText = '';
+ }
+ }
}
diff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item.html b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item.html
index 2c76141a7b3..bb9bd972228 100644
--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item.html
+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item.html
@@ -25,7 +25,10 @@
class="op-files-tab--file-list-item-avatar"
></div>
</a>
- <div class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-actions">
+ <div
+ *ngIf="showFloatingActions"
+ class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-actions"
+ >
<a
class="spot-link"
[title]="text.title.openFileLocation"
@@ -43,4 +46,11 @@
<span class="spot-icon spot-icon_remove-link"></span>
</button>
</div>
+ <div
+ *ngIf="!showFloatingActions"
+ class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-text"
+ >
+ <span class="spot-icon spot-icon_info2"></span>
+ <span [textContent]="text.floatingText"></span>
+ </div>
</div>
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.html
index 227126728c6..cfbcd5ddef9 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,6 +19,7 @@
<li
*ngFor="let fileLink of fileLinks$ | async; let i = index;"
class="spot-list--item op-files-tab--file-list-item"
+ [ngClass]="{ 'disabled': fileLink._links.permission.href !== 'urn:openproject-org:api:v3:file-links:permission:View' }"
data-qa-selector="op-files-tab--file-list-item"
op-file-link-list-item
[fileLink]="fileLink"
diff --git a/frontend/src/global_styles/content/work_packages/tabs/_files.sass b/frontend/src/global_styles/content/work_packages/tabs/_files.sass
index 5b53fd9a47b..f716b7b3f73 100644
--- a/frontend/src/global_styles/content/work_packages/tabs/_files.sass
+++ b/frontend/src/global_styles/content/work_packages/tabs/_files.sass
@@ -71,6 +71,20 @@
.op-files-tab--file-list-item-floating-actions
padding-right: 0
+ .op-files-tab--file-list-item-floating-text
+ @include spot-body-small()
+
+ padding-right: $spot-spacing-0-25
+ color: #1A67A3
+
+ .spot-icon:first-child:not(:last-child)
+ width: $spot-spacing-1-5
+ height: $spot-spacing-1-5
+ margin-right: $spot-spacing-0-25
+
+ &.disabled
+ opacity: 0.5
+
&--storage-info-box
margin-top: 0.875rem
display: grid