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

Show quarantined hint in attachments list

Oliver Günther16d9a0bf90aa
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 4e53fcf2912..29db9812c92 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -39,6 +39,7 @@ en:
Are you sure you want to delete this file? This action is not reversible.
draggable_hint: |
Drag on editor field to inline image or reference attachment. Closed editor fields will be opened while you keep dragging.
+ quarantined_hint: "The file is quarantined, as a virus was found. It is not available for download."
autocomplete_ng_select:
add_tag: "Add item"
diff --git a/frontend/src/app/core/state/attachments/attachment.model.ts b/frontend/src/app/core/state/attachments/attachment.model.ts
index 96e7efe2aba..4867157ca25 100644
--- a/frontend/src/app/core/state/attachments/attachment.model.ts
+++ b/frontend/src/app/core/state/attachments/attachment.model.ts
@@ -28,7 +28,8 @@
import { ID } from '@datorama/akita';
import {
- IFormattable, IHalMethodResourceLink,
+ IFormattable,
+ IHalMethodResourceLink,
IHalResourceLink,
IHalResourceLinks,
} from 'core-app/core/state/hal-resource';
@@ -55,6 +56,7 @@ export interface IAttachmentUploadHalResourceLinks extends IAttachmentHalResourc
export interface IAttachment {
id:ID;
title:string;
+ status:string;
fileName:string;
fileSize:number;
description:IFormattable;
diff --git a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.html b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.html
index 30a6fb79c28..eec65cf8238 100644
--- a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.html
+++ b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.html
@@ -1,16 +1,21 @@
<div class="spot-list--item-floating-wrapper op-file-list--item-floating-wrapper">
<a
class="spot-list--item-action spot-list--item-action_link op-file-list--item-action"
+ [class.spot-list--item-action_disabled]="attachment.status === 'quarantined'"
[href]="attachment._links.originOpen?.href || attachment._links.staticDownloadLocation.href"
target="_blank"
(dragstart)="setDragData($event)"
>
<div
- [title]="attachment.fileName"
+ [title]="attachment.status === 'quarantined' ? text.quarantinedHint : attachment.fileName"
class="spot-list--item-title op-file-list--item-title"
data-test-selector="op-files-tab--file-list-item-title"
>
<span
+ *ngIf="attachment.status === 'quarantined'"
+ class="spot-icon spot-icon_bug op-files-tab-icon"></span>
+ <span
+ *ngIf="attachment.status !== 'quarantined'"
class="spot-icon spot-icon_{{fileIcon.icon}} op-files-tab--icon op-files-tab--icon_{{fileIcon.clazz}}"
></span>
diff --git a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.ts b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.ts
index adb907690cc..eba957fce10 100644
--- a/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.ts
+++ b/frontend/src/app/shared/components/attachments/attachment-list/attachment-list-item.component.ts
@@ -38,7 +38,7 @@ import {
ViewChild,
} from '@angular/core';
import { BehaviorSubject, combineLatest, Observable } from 'rxjs';
-import { distinctUntilChanged, first } from 'rxjs/operators';
+import { distinctUntilChanged } from 'rxjs/operators';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { IPrincipal } from 'core-app/core/state/principals/principal.model';
import { IAttachment } from 'core-app/core/state/attachments/attachment.model';
@@ -51,7 +51,6 @@ import { ConfirmDialogService } from 'core-app/shared/components/modals/confirm-
import { ConfirmDialogOptions } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.modal';
import { getIconForMimeType } from 'core-app/shared/components/storages/functions/storages.functions';
import { IFileIcon } from 'core-app/shared/components/storages/icons.mapping';
-import idFromLink from 'core-app/features/hal/helpers/id-from-link';
@Component({
// eslint-disable-next-line @angular-eslint/component-selector
@@ -71,6 +70,7 @@ export class OpAttachmentListItemComponent extends UntilDestroyedMixin implement
static imageFileExtensions:string[] = ['jpeg', 'jpg', 'gif', 'bmp', 'png'];
public text = {
+ quarantinedHint: this.I18n.t('js.attachments.quarantined_hint'),
dragHint: this.I18n.t('js.attachments.draggable_hint'),
deleteTitle: this.I18n.t('js.attachments.delete'),
deleteConfirmation: this.I18n.t('js.attachments.delete_confirmation'),
diff --git a/lib/api/v3/attachments/attachment_representer.rb b/lib/api/v3/attachments/attachment_representer.rb
index 0d75c27d2e9..0bc28dd8af3 100644
--- a/lib/api/v3/attachments/attachment_representer.rb
+++ b/lib/api/v3/attachments/attachment_representer.rb
@@ -106,6 +106,7 @@ module API
formattable_property :description,
plain: true
+ property :status
property :content_type
property :digest,
getter: ->(*) {
diff --git a/spec/lib/api/v3/attachments/attachment_representer_spec.rb b/spec/lib/api/v3/attachments/attachment_representer_spec.rb
index 61a34a31c00..d21ac1c975b 100644
--- a/spec/lib/api/v3/attachments/attachment_representer_spec.rb
+++ b/spec/lib/api/v3/attachments/attachment_representer_spec.rb
@@ -42,6 +42,7 @@ RSpec.describe API::V3::Attachments::AttachmentRepresenter do
let(:attachment) do
build_stubbed(:attachment,
container:,
+ status: :uploaded,
author:) do |attachment|
allow(attachment)
.to receive(:filename)
@@ -66,6 +67,7 @@ RSpec.describe API::V3::Attachments::AttachmentRepresenter do
it { is_expected.to be_json_eql(attachment.filename.to_json).at_path('fileName') }
it { is_expected.to be_json_eql(attachment.filesize.to_json).at_path('fileSize') }
it { is_expected.to be_json_eql(attachment.content_type.to_json).at_path('contentType') }
+ it { is_expected.to be_json_eql('uploaded'.to_json).at_path('status') }
it_behaves_like 'API V3 formattable', 'description' do
let(:format) { 'plain' }
diff --git a/spec/requests/api/v3/attachments_spec.rb b/spec/requests/api/v3/attachments_spec.rb
index 231612e4efd..b05203db31f 100644
--- a/spec/requests/api/v3/attachments_spec.rb
+++ b/spec/requests/api/v3/attachments_spec.rb
@@ -115,4 +115,6 @@ RSpec.describe API::V3::Attachments::AttachmentsAPI do
end
end
end
+
+ context 'with an quarantined attachments'
end