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

[#43124] show file link error

Eric Schubert4f258fdf5701
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 62a118745a7..fa094452bdb 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -381,7 +381,6 @@ en:
label_description: "Description"
label_details: "Details"
label_display: "Display"
- label_download_file: "Download %{fileName}"
label_cancel_comment: "Cancel comment"
label_closed_work_packages: "closed"
label_collapse: "Collapse"
@@ -402,7 +401,6 @@ 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: "You have no permission to see this file."
label_filename: "File"
label_filesize: "Size"
label_general: "General"
@@ -425,9 +423,7 @@ en:
label_learn_more_link: "Learn more"
label_less_or_equal: "<="
label_less_than_ago: "less than days ago"
- label_link_files_in_storage: "Link files in %{storageType}"
label_loading: "Loading..."
- label_login_to_storage: "Login to %{storageType}"
label_mail_notification: "Email notifications"
label_me: "me"
label_meeting_agenda: "Agenda"
@@ -440,19 +436,14 @@ en:
label_no_data: "No data to display"
label_no_due_date: "no finish date"
label_no_start_date: "no start date"
- label_no_storage_connection: "No %{storageType} connection"
label_no_value: "No value"
- label_no_file_links: "In order to link files to this work package please do it via %{storageType}."
label_none: "none"
label_not_contains: "doesn't contain"
label_not_equals: "is not"
label_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:"
@@ -467,7 +458,6 @@ en:
label_remove: "Remove"
label_remove_column: "Remove column"
label_remove_columns: "Remove selected columns"
- label_remove_file_link: "Remove file link"
label_remove_row: "Remove row"
label_report: "Report"
label_repository_plural: "Repositories"
@@ -484,9 +474,6 @@ en:
label_sorting: "Sorting"
label_spent_time: "Spent time"
label_star_query: "Favored"
- label_storage_connection_error: "Some %{storageType} settings are not working. Please try to login again or contact your %{storageType} administrator."
- label_storage_login: "%{storageType} login"
- label_storage_not_connected: "To add a link, see or upload files related to this work package, please login to %{storageType}."
label_press_enter_to_save: "Press enter to save."
label_public_query: "Public"
label_sum: "Sum"
@@ -523,7 +510,6 @@ en:
label_custom_queries: "Private"
label_columns: "Columns"
label_attachments: Attachments
- label_nextcloud: Nextcloud
label_drop_files: Drop files here
label_drop_files_hint: or click to add files
label_drop_folders_hint: You cannot upload folders as an attachment. Please select single files.
@@ -1315,6 +1301,3 @@ en:
remove: 'Remove'
drop_modal:
Close: 'Close'
-
- storages:
- enter_oauth2_client_secret: 'Please enter your OAuth2 client secret'
diff --git a/frontend/src/app/shared/components/file-links/file-link-icons/icon-mappings.ts b/frontend/src/app/shared/components/file-links/file-link-icons/icon-mappings.ts
index 1b9b686e2a7..51cb1cdae34 100644
--- a/frontend/src/app/shared/components/file-links/file-link-icons/icon-mappings.ts
+++ b/frontend/src/app/shared/components/file-links/file-link-icons/icon-mappings.ts
@@ -47,6 +47,7 @@ export const fileIconMappings:Record<string, IFileIcon> = {
'image/cgm': { icon: 'image1', clazz: 'img' },
'text/plain': { icon: 'file-text', clazz: 'txt' },
+ 'text/markdown': { icon: 'file-text', clazz: 'txt' },
'text/html': { icon: 'file-text', clazz: 'txt' },
'application/rtf': { icon: 'file-text', clazz: 'txt' },
'application/xml': { icon: 'file-text', clazz: 'txt' },
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.ts
index 29f8483e431..c29449376c5 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
@@ -73,13 +73,13 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
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'),
+ openFile: this.i18n.t('js.storages.file_links.open'),
+ openFileLocation: this.i18n.t('js.storages.file_links.open_location'),
+ removeFileLink: this.i18n.t('js.storages.file_links.remove'),
downloadFileLink: '',
},
floatingText: {
- noViewPermission: this.i18n.t('js.label_file_link_no_permission'),
+ noViewPermission: this.i18n.t('js.storages.file_links.no_permission'),
},
};
@@ -100,7 +100,10 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
this.fileLinkIcon = getIconForMimeType(this.originData.mimeType);
- this.text.title.downloadFileLink = this.i18n.t('js.label_download_file', { fileName: this.fileLink.originData.name });
+ this.text.title.downloadFileLink = this.i18n.t(
+ 'js.storages.file_links.download',
+ { fileName: this.fileLink.originData.name },
+ );
this.viewAllowed = this.fileLink._links.permission.href === fileLinkViewAllowed;
}
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.ts
index c7c8b2ad2c6..8a2b1a4fd78 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,6 +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 {
+ fileLinkViewError,
nextcloud,
storageAuthorizationError,
storageConnected,
@@ -50,7 +51,10 @@ import { CurrentUserService } from 'core-app/core/current-user/current-user.serv
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';
-import { StorageActionButton } from 'core-app/shared/components/file-links/file-link-list/storage-action-button';
+import { StorageActionButton } from 'core-app/shared/components/file-links/storage-information/storage-action-button';
+import {
+ StorageInformationBox,
+} from 'core-app/shared/components/file-links/storage-information/storage-information-box';
@Component({
selector: 'op-file-link-list',
@@ -64,21 +68,11 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
fileLinks$:Observable<IFileLink[]>;
- informationBoxHeader:string;
-
- informationBoxContent:string;
-
- informationBoxIcon:string;
-
allowEditing = false;
disabled = false;
- showInformationBox$ = new BehaviorSubject<boolean>(false);
-
- showFileLinks$ = new BehaviorSubject<boolean>(false);
-
- buttons = new BehaviorSubject<StorageActionButton[]>([]);
+ storageInformation = new BehaviorSubject<StorageInformationBox[]>([]);
private readonly storageTypeMap:Record<string, string> = {};
@@ -87,6 +81,8 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
emptyStorageHeader:string,
emptyStorageContent:string,
emptyStorageButton:string,
+ fileLinkErrorHeader:string,
+ fileLinkErrorContent:string,
connectionErrorHeader:string,
connectionErrorContent:string,
authorizationFailureHeader:string,
@@ -126,7 +122,7 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
this.resource.fileLinks = { elements: fileLinks.map((a) => a._links?.self) };
}
- this.deriveStorageInformation(fileLinks.length);
+ this.storageInformation.next(this.instantiateStorageInformation(fileLinks));
});
this.currentUserService
@@ -145,46 +141,32 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
window.open(this.storageLocation, '_blank');
}
- 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}?filters=[{"storage":{"operator":"=","values":["${this.storage.id}"]}}]`;
- }
-
- private deriveStorageInformation(fileLinkCount:number):void {
+ private instantiateStorageInformation(fileLinks:IFileLink[]):StorageInformationBox[] {
switch (this.storage._links.authorizationState.href) {
case storageFailedAuthorization:
- this.setAuthorizationFailureState(fileLinkCount);
- break;
+ return [this.failedAuthorizationInformation];
case storageAuthorizationError:
- this.setConnectionErrorState();
- break;
+ return [this.authorizationErrorInformation];
case storageConnected:
- if (fileLinkCount === 0) {
- this.setEmptyFileLinkListState();
- } else {
- this.showInformationBox$.next(false);
- this.showFileLinks$.next(true);
+ if (fileLinks.length === 0) {
+ return [this.emptyStorageInformation];
}
- break;
+ if (fileLinks.filter((fileLink) => fileLink._links.permission.href === fileLinkViewError).length > 0) {
+ this.disabled = true;
+ return [this.fileLinkErrorInformation];
+ }
+ return [];
default:
- this.showInformationBox$.next(false);
- this.showFileLinks$.next(false);
+ return [];
}
}
- private setAuthorizationFailureState(fileLinkCount:number):void {
- this.prepareInformationBox(
+ private get failedAuthorizationInformation():StorageInformationBox {
+ return new StorageInformationBox(
+ 'import',
this.text.infoBox.authorizationFailureHeader,
this.text.infoBox.authorizationFailureContent,
- 'import',
- );
-
- this.buttons.next([
- new StorageActionButton(
+ [new StorageActionButton(
this.text.infoBox.loginButton,
() => {
if (this.storage._links.authorize) {
@@ -198,82 +180,83 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
throw new Error('Authorize link is missing!');
}
},
- ),
- ]);
-
- this.showInformationBox$.next(true);
- this.showFileLinks$.next(fileLinkCount > 0);
- }
-
- private setAuthorizationCallbackCookie(nonce:string):void {
- this.cookieService.set(`oauth_state_${nonce}`, window.location.href, {
- path: '/',
- });
- }
-
- private static authorizationFailureActionUrl(baseUrl:string, nonce:string):string {
- return `${baseUrl}&state=${nonce}`;
+ )],
+ );
}
- private setConnectionErrorState():void {
- this.prepareInformationBox(
+ private get authorizationErrorInformation():StorageInformationBox {
+ return new StorageInformationBox(
+ 'remove-link',
this.text.infoBox.connectionErrorHeader,
this.text.infoBox.connectionErrorContent,
- 'remove-link',
+ [],
);
-
- this.buttons.next([]);
-
- this.showInformationBox$.next(true);
- this.showFileLinks$.next(true);
}
- private setEmptyFileLinkListState():void {
- this.prepareInformationBox(
+ private get emptyStorageInformation():StorageInformationBox {
+ return new StorageInformationBox(
+ 'add-link',
this.text.infoBox.emptyStorageHeader,
this.text.infoBox.emptyStorageContent,
- 'add-link',
- );
-
- this.buttons.next([
- new StorageActionButton(
+ [new StorageActionButton(
this.text.infoBox.emptyStorageButton,
() => {
window.open(this.storageLocation, '_blank');
},
- ),
- ]);
+ )],
+ );
+ }
+
+ private get fileLinkErrorInformation():StorageInformationBox {
+ return new StorageInformationBox(
+ 'error',
+ this.text.infoBox.fileLinkErrorHeader,
+ this.text.infoBox.fileLinkErrorContent,
+ [],
+ );
+ }
- this.showInformationBox$.next(true);
- this.showFileLinks$.next(false);
+ 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}?filters=[{"storage":{"operator":"=","values":["${this.storage.id}"]}}]`;
}
- private prepareInformationBox(header:string, content:string, icon:string):void {
- this.informationBoxHeader = header;
- this.informationBoxContent = content;
- this.informationBoxIcon = icon;
+ private setAuthorizationCallbackCookie(nonce:string):void {
+ this.cookieService.set(`oauth_state_${nonce}`, window.location.href, {
+ path: '/',
+ });
+ }
+
+ private static authorizationFailureActionUrl(baseUrl:string, nonce:string):string {
+ return `${baseUrl}&state=${nonce}`;
}
private initializeLocales():void {
const storageType = this.storageTypeMap[this.storage._links.type.href];
this.text = {
infoBox: {
- emptyStorageHeader: this.i18n.t('js.label_link_files_in_storage', { storageType }),
- emptyStorageContent: this.i18n.t('js.label_no_file_links', { 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 }),
- authorizationFailureHeader: this.i18n.t('js.label_login_to_storage', { storageType }),
- authorizationFailureContent: this.i18n.t('js.label_storage_not_connected', { storageType }),
- loginButton: this.i18n.t('js.label_storage_login', { storageType }),
+ emptyStorageHeader: this.i18n.t('js.storages.link_files_in_storage', { storageType }),
+ emptyStorageContent: this.i18n.t('js.storages.information.no_file_links', { storageType }),
+ emptyStorageButton: this.i18n.t('js.storages.open_storage', { storageType }),
+ fileLinkErrorHeader: this.i18n.t('js.storages.information.live_data_error'),
+ fileLinkErrorContent: this.i18n.t('js.storages.information.live_data_error_description', { storageType }),
+ connectionErrorHeader: this.i18n.t('js.storages.no_connection', { storageType }),
+ connectionErrorContent: this.i18n.t('js.storages.information.connection_error', { storageType }),
+ authorizationFailureHeader: this.i18n.t('js.storages.login_to', { storageType }),
+ authorizationFailureContent: this.i18n.t('js.storages.information.not_logged_in', { storageType }),
+ loginButton: this.i18n.t('js.storages.login', { storageType }),
},
actions: {
- linkFile: this.i18n.t('js.label_link_files_in_storage', { storageType }),
+ linkFile: this.i18n.t('js.storages.link_files_in_storage', { storageType }),
},
};
}
private initializeStorageTypes() {
- this.storageTypeMap[nextcloud] = this.i18n.t('js.label_nextcloud');
+ this.storageTypeMap[nextcloud] = this.i18n.t('js.storages.types.nextcloud');
}
}
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 6869cbfb513..a9638e7d000 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
@@ -2,17 +2,13 @@
*ngIf="resource"
>
<op-storage-information
- *ngIf="showInformationBox$ | async"
+ *ngFor="let infoBox of storageInformation | async"
class="op-files-tab--storage-info-box"
data-qa-selector="op-files-tab--storage-information"
- [infoIcon]="informationBoxIcon"
- [infoTextHeader]="informationBoxHeader"
- [infoTextContent]="informationBoxContent"
- [buttons]="buttons | async"
+ [viewModel]="infoBox"
></op-storage-information>
<ul
- *ngIf="showFileLinks$ | async"
class="spot-list spot-list_compact op-files-tab--file-list"
data-qa-selector="op-files-tab--file-list"
>
@@ -22,7 +18,6 @@
data-qa-selector="op-files-tab--file-list-item"
op-file-link-list-item
[fileLink]="fileLink"
- [resource]="resource"
[disabled]="disabled"
[allowEditing]="allowEditing"
(removeFileLink)="removeFileLink(fileLink)"
@@ -30,7 +25,7 @@
</ul>
<p
- *ngIf="(showInformationBox$ | async) === false"
+ *ngIf="!disabled"
class="spot-body-small"
>
<a
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/storage-information/storage-action-button.ts
similarity index 100%
rename from frontend/src/app/shared/components/file-links/file-link-list/storage-action-button.ts
rename to frontend/src/app/shared/components/file-links/storage-information/storage-action-button.ts
diff --git a/frontend/src/app/shared/components/file-links/storage-information/storage-information-box.ts b/frontend/src/app/shared/components/file-links/storage-information/storage-information-box.ts
new file mode 100644
index 00000000000..8beac7c85fa
--- /dev/null
+++ b/frontend/src/app/shared/components/file-links/storage-information/storage-information-box.ts
@@ -0,0 +1,38 @@
+// -- 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 { StorageActionButton } from 'core-app/shared/components/file-links/storage-information/storage-action-button';
+
+export class StorageInformationBox {
+ constructor(
+ public readonly iconClass:string,
+ public readonly header:string,
+ public readonly content:string,
+ public readonly buttons:StorageActionButton[],
+ ) { }
+}
diff --git a/frontend/src/app/shared/components/file-links/storage-information/storage-information.component.ts b/frontend/src/app/shared/components/file-links/storage-information/storage-information.component.ts
index 222cddc12f4..3134c8651f9 100644
--- a/frontend/src/app/shared/components/file-links/storage-information/storage-information.component.ts
+++ b/frontend/src/app/shared/components/file-links/storage-information/storage-information.component.ts
@@ -29,7 +29,9 @@
import {
ChangeDetectionStrategy, Component, Input,
} from '@angular/core';
-import { StorageActionButton } from 'core-app/shared/components/file-links/file-link-list/storage-action-button';
+import {
+ StorageInformationBox,
+} from 'core-app/shared/components/file-links/storage-information/storage-information-box';
@Component({
selector: 'op-storage-information',
@@ -37,11 +39,5 @@ import { StorageActionButton } from 'core-app/shared/components/file-links/file-
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class StorageInformationComponent {
- @Input() infoIcon:string;
-
- @Input() infoTextHeader:string;
-
- @Input() infoTextContent:string;
-
- @Input() buttons:StorageActionButton[];
+ @Input() viewModel:StorageInformationBox;
}
diff --git a/frontend/src/app/shared/components/file-links/storage-information/storage-information.html b/frontend/src/app/shared/components/file-links/storage-information/storage-information.html
index af155715db6..497e1e25154 100644
--- a/frontend/src/app/shared/components/file-links/storage-information/storage-information.html
+++ b/frontend/src/app/shared/components/file-links/storage-information/storage-information.html
@@ -1,4 +1,4 @@
-<span class="spot-icon big spot-icon_{{infoIcon}}"></span>
+<span class="spot-icon big spot-icon_{{viewModel.iconClass}}"></span>
<div
class="text-box"
@@ -6,19 +6,19 @@
<div
class="text-box-header"
>
- <span [textContent]="infoTextHeader"></span>
+ <span [textContent]="viewModel.header"></span>
</div>
<div
class="text-box-content"
>
- <span [textContent]="infoTextContent"></span>
+ <span [textContent]="viewModel.content"></span>
</div>
</div>
<div
class="button-box"
>
- <button *ngFor="let button of buttons"
+ <button *ngFor="let button of viewModel.buttons"
class="button op-files-tab--storage-info-box-button"
(click)="button.action()"
>
diff --git a/modules/storages/config/locales/js-en.yml b/modules/storages/config/locales/js-en.yml
index b8aff290128..7c9665125f4 100644
--- a/modules/storages/config/locales/js-en.yml
+++ b/modules/storages/config/locales/js-en.yml
@@ -1,4 +1,31 @@
# English strings go here
en:
js:
- storages:
\ No newline at end of file
+ storages:
+ link_files_in_storage: "Link files in %{storageType}"
+ login: "%{storageType} login"
+ login_to: "Login to %{storageType}"
+ no_connection: "No %{storageType} connection"
+ open_storage: "Open %{storageType}"
+
+ types:
+ nextcloud: "Nextcloud"
+
+ information:
+ connection_error: >
+ Some %{storageType} settings are not working. Please try to login again or contact your %{storageType}
+ administrator.
+ live_data_error: "Error fetching file details"
+ live_data_error_description: >
+ Some %{storageType} data could not be fetched. Please try to reload this page or contact your %{storageType}
+ administrator.
+ no_file_links: "In order to link files to this work package please do it via %{storageType}."
+ not_logged_in: >
+ To add a link, see or upload files related to this work package, please login to %{storageType}.
+
+ file_links:
+ download: "Download %{fileName}"
+ no_permission: "You have no permission to see this file."
+ open: 'Open file on storage'
+ open_location: 'Open file in location'
+ remove: "Remove file link"