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

[#42158] fixed PR issues

Eric Schubertd6a573773693
diff --git a/frontend/src/app/core/state/attachments/attachments.service.ts b/frontend/src/app/core/state/attachments/attachments.service.ts
index ac63347ffb6..9c49f93aa03 100644
--- a/frontend/src/app/core/state/attachments/attachments.service.ts
+++ b/frontend/src/app/core/state/attachments/attachments.service.ts
@@ -56,7 +56,7 @@ import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';
import { HalLink } from 'core-app/features/hal/hal-link/hal-link';
import isNewResource, { HAL_NEW_RESOURCE_ID } from 'core-app/features/hal/helpers/is-new-resource';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
-import { insertCollectionIntoState } from 'core-app/core/state/collection-store';
+import { insertCollectionIntoState, removeEntityFromCollectionAndState } from 'core-app/core/state/collection-store';
import {
CollectionStore,
ResourceCollectionService,
@@ -119,22 +119,7 @@ export class AttachmentsResourceService extends ResourceCollectionService<IAttac
return this.http
.delete<void>(attachment._links.delete.href, { withCredentials: true, headers })
.pipe(
- tap(() => {
- applyTransaction(() => {
- this.store.remove(attachment.id);
- this.store.update(({ collections }) => (
- {
- collections: {
- ...collections,
- [collectionKey]: {
- ...collections[collectionKey],
- ids: (collections[collectionKey]?.ids || []).filter((id) => id !== attachment.id),
- },
- },
- }
- ));
- });
- }),
+ tap(() => removeEntityFromCollectionAndState(this.store, attachment.id, collectionKey)),
catchError((error) => {
this.toastService.addError(error);
throw error;
diff --git a/frontend/src/app/core/state/collection-store.ts b/frontend/src/app/core/state/collection-store.ts
index 928d686e814..cebd0b88fd7 100644
--- a/frontend/src/app/core/state/collection-store.ts
+++ b/frontend/src/app/core/state/collection-store.ts
@@ -85,6 +85,27 @@ export function insertCollectionIntoState<T extends { id:ID }>(
});
}
+export function removeEntityFromCollectionAndState<T extends { id:ID }>(
+ store:EntityStore<CollectionState<T>>,
+ entityId:ID,
+ collectionUrl:string,
+):void {
+ applyTransaction(() => {
+ store.remove(entityId);
+ store.update(({ collections }) => (
+ {
+ collections: {
+ ...collections,
+ [collectionUrl]: {
+ ...collections[collectionUrl],
+ ids: (collections[collectionUrl]?.ids || []).filter((id) => id !== entityId),
+ },
+ },
+ }
+ ));
+ });
+}
+
export function collectionFrom<T>(elements:T[]):IHALCollection<T> {
const count = elements.length;
diff --git a/frontend/src/app/core/state/file-links/file-link.model.ts b/frontend/src/app/core/state/file-links/file-link.model.ts
index aedc6210006..f9dae36804a 100644
--- a/frontend/src/app/core/state/file-links/file-link.model.ts
+++ b/frontend/src/app/core/state/file-links/file-link.model.ts
@@ -44,7 +44,7 @@ export interface IFileLinkHalResourceLinks extends IHalResourceLinks {
staticOriginOpenLocation:IHalResourceLink;
}
-interface IFileLinkOriginData {
+export interface IFileLinkOriginData {
name:string;
mimeType?:string;
size?:number;
diff --git a/frontend/src/app/core/state/file-links/file-links.service.ts b/frontend/src/app/core/state/file-links/file-links.service.ts
index 595983d05ae..9b6d5d45c1d 100644
--- a/frontend/src/app/core/state/file-links/file-links.service.ts
+++ b/frontend/src/app/core/state/file-links/file-links.service.ts
@@ -28,7 +28,6 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
-import { applyTransaction } from '@datorama/akita';
import { from } from 'rxjs';
import {
catchError,
@@ -42,7 +41,7 @@ import { IFileLink } from 'core-app/core/state/file-links/file-link.model';
import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';
import { ToastService } from 'core-app/shared/components/toaster/toast.service';
import { FileLinksStore } from 'core-app/core/state/file-links/file-links.store';
-import { insertCollectionIntoState } from 'core-app/core/state/collection-store';
+import { insertCollectionIntoState, removeEntityFromCollectionAndState } from 'core-app/core/state/collection-store';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
import {
CollectionStore,
@@ -106,21 +105,6 @@ export class FileLinksResourceService extends ResourceCollectionService<IFileLin
throw error;
}),
)
- .subscribe(() => {
- applyTransaction(() => {
- this.store.remove(fileLink.id);
- this.store.update(({ collections }) => (
- {
- collections: {
- ...collections,
- [collectionKey]: {
- ...collections[collectionKey],
- ids: (collections[collectionKey]?.ids || []).filter((id) => id !== fileLink.id),
- },
- },
- }
- ));
- });
- });
+ .subscribe(() => removeEntityFromCollectionAndState(this.store, fileLink.id, collectionKey));
}
}
diff --git a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item-icon.factory.ts b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item-icon.factory.ts
index a97431b4ae3..920910d8dc3 100644
--- a/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item-icon.factory.ts
+++ b/frontend/src/app/shared/components/file-links/file-link-list/file-link-list-item-icon.factory.ts
@@ -28,18 +28,18 @@
export interface IFileLinkListItemIcon {
icon:'image1'|'movie'|'file-text'|'export-pdf-descr'|'file-doc'|'file-sheet'|'file-presentation'|'folder'|'ticket'
- color:'red'|'blue'|'blue-deep'|'blue-dark'|'turquoise'|'green'|'grey-dark'|'grey'|'orange'
+ clazz:'pdf'|'img'|'txt'|'doc'|'sheet'|'presentation'|'form'|'dir'|'default'
}
const mimeTypeIconMap:{ [mimeType:string]:IFileLinkListItemIcon; } = {
- 'image/*': { icon: 'image1', color: 'blue-dark' },
- 'text/plain': { icon: 'file-text', color: 'grey-dark' },
- 'application/pdf': { icon: 'export-pdf-descr', color: 'red' },
- 'application/vnd.oasis.opendocument.text': { icon: 'file-doc', color: 'blue-deep' },
- 'application/vnd.oasis.opendocument.spreadsheet': { icon: 'file-sheet', color: 'green' },
- 'application/vnd.oasis.opendocument.presentation': { icon: 'file-presentation', color: 'turquoise' },
- 'application/x-op-directory': { icon: 'folder', color: 'blue' },
- default: { icon: 'ticket', color: 'grey-dark' },
+ 'image/*': { icon: 'image1', clazz: 'img' },
+ 'text/plain': { icon: 'file-text', clazz: 'txt' },
+ 'application/pdf': { icon: 'export-pdf-descr', clazz: 'pdf' },
+ 'application/vnd.oasis.opendocument.text': { icon: 'file-doc', clazz: 'doc' },
+ 'application/vnd.oasis.opendocument.spreadsheet': { icon: 'file-sheet', clazz: 'sheet' },
+ 'application/vnd.oasis.opendocument.presentation': { icon: 'file-presentation', clazz: 'presentation' },
+ 'application/x-op-directory': { icon: 'folder', clazz: 'dir' },
+ default: { icon: 'ticket', clazz: 'default' },
};
export function getIconForMimeType(mimeType?:string):IFileLinkListItemIcon {
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 9152ada986b..0fae347bd4e 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
@@ -38,7 +38,7 @@ import {
ViewChild,
} from '@angular/core';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
-import { IFileLink } from 'core-app/core/state/file-links/file-link.model';
+import { IFileLink, IFileLinkOriginData } from 'core-app/core/state/file-links/file-link.model';
import {
getIconForMimeType,
IFileLinkListItemIcon,
@@ -84,19 +84,23 @@ export class FileLinkListItemComponent implements OnInit, AfterViewInit {
private readonly principalRendererService:PrincipalRendererService,
) {}
+ private get originData():IFileLinkOriginData {
+ return this.fileLink.originData;
+ }
+
ngOnInit():void {
- if (this.fileLink.originData.lastModifiedAt) {
- this.infoTimestampText = this.timezoneService.parseDatetime(this.fileLink.originData.lastModifiedAt).fromNow();
+ if (this.originData.lastModifiedAt) {
+ this.infoTimestampText = this.timezoneService.parseDatetime(this.originData.lastModifiedAt).fromNow();
}
- this.fileLinkIcon = getIconForMimeType(this.fileLink.originData.mimeType);
+ this.fileLinkIcon = getIconForMimeType(this.originData.mimeType);
}
ngAfterViewInit():void {
- if (this.fileLink.originData.lastModifiedByName) {
+ if (this.originData.lastModifiedByName) {
this.principalRendererService.render(
this.avatar.nativeElement,
- { name: this.fileLink.originData.lastModifiedByName, href: '/users/1' },
+ { name: this.originData.lastModifiedByName, href: '/users/1' },
{ hide: true, link: false },
{ hide: false, size: 'mini' },
);
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 f16438d462a..16ded077feb 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
@@ -2,10 +2,11 @@
<a
class="spot-list--item-action op-files-tab--file-list-item-action"
[href]="fileLink._links.staticOriginOpen.href"
+ [title]="fileLink.originData.name"
target="_blank"
>
<span
- class="spot-icon spot-icon_{{fileLinkIcon.icon}} op-files-tab--color-{{fileLinkIcon.color}}"
+ class="spot-icon spot-icon_{{fileLinkIcon.icon}} op-files-tab--icon_{{fileLinkIcon.clazz}}"
></span>
<span
@@ -14,7 +15,7 @@
></span>
<span
- class="op-files-tab--file-list-item-text op-files-tab--color-grey"
+ class="op-files-tab--file-list-item-text"
[textContent]="infoTimestampText"
></span>
@@ -23,7 +24,7 @@
class="op-files-tab--file-list-item-avatar"
></div>
</a>
- <div class="spot-list--item-floating-actions">
+ <div class="spot-list--item-floating-actions op-files-tab--file-list-item-floating-actions">
<a
class="spot-link"
[title]="text.title.openFileLocation"
diff --git a/frontend/src/app/shared/components/file-links/file-link-list/storage-information.html b/frontend/src/app/shared/components/file-links/file-link-list/storage-information.html
index 619ae6ceaa2..03fdcc4bba3 100644
--- a/frontend/src/app/shared/components/file-links/file-link-list/storage-information.html
+++ b/frontend/src/app/shared/components/file-links/file-link-list/storage-information.html
@@ -1,4 +1,4 @@
-<span class="spot-icon big spot-icon_{{infoIcon}} op-files-tab--color-grey"></span>
+<span class="spot-icon big spot-icon_{{infoIcon}}"></span>
<div
class="text-box"
@@ -9,7 +9,7 @@
<span [textContent]="infoTextHeader"></span>
</div>
<div
- class="text-box-content op-files-tab--color-grey"
+ class="text-box-content"
>
<span [textContent]="infoTextContent"></span>
</div>
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 8011b6fbc2d..851d0dd7367 100644
--- a/frontend/src/global_styles/content/work_packages/tabs/_files.sass
+++ b/frontend/src/global_styles/content/work_packages/tabs/_files.sass
@@ -45,7 +45,10 @@
text-overflow: ellipsis
.op-files-tab--file-list-item-text
- font-size: $spot-spacing-0-75
+ @include spot-caption()
+
+ color: #9A9A9A
+ line-height: $spot-spacing-1-5
flex-shrink: 0
&:not(:last-child)
@@ -63,16 +66,20 @@
width: $spot-spacing-1-5
height: $spot-spacing-1-5
+ .op-files-tab--file-list-item-floating-actions
+ padding-right: 0
+
&--storage-info-box
margin-top: 0.875rem
display: grid
grid-template: "icon text" "button button" / auto 1fr
.spot-icon.big
+ color: #9A9A9A
grid-area: icon
width: 3.375rem
height: 3.375rem
- font-size: $spot-spacing-1-25
+ font-size: 1.25rem
.text-box
grid-area: text
@@ -82,8 +89,9 @@
line-height: $spot-spacing-1-5
.text-box-content
- font-size: 0.875rem
- line-height: $spot-spacing-1-25
+ @include spot-body-small()
+
+ color: #9A9A9A
.button-box
grid-area: button
@@ -91,39 +99,39 @@
justify-content: end
.action-button
+ @include spot-body-small()
+
padding: $spot-spacing-0-25 $spot-spacing-0-75
- font-size: 0.875rem
.spot-icon
margin-right: $spot-spacing-0-5
+ width: $spot-spacing-1-5
+ height: $spot-spacing-1-5
- &--color
- &-red
+ &--icon
+ &_pdf
color: #B93A33
- &-blue
- color: #00BDF3
-
- &-blue-deep
- color: #006E8F
-
- &-blue-dark
+ &_img
color: #0081C7
- &-turquoise
- color: #87E2C1
+ &_txt
+ color: #9A9A9A
- &-green
+ &_doc
+ color: #006E8F
+
+ &_sheet
color: #007528
- &-grey-dark
- color: #9A9A9A
+ &_presentation
+ color: #EF9E56
- &-grey
- color: #878787
+ &_form
+ color: #87E2C1
- &-grey-light
- color: #F3F3F3
+ &_dir
+ color: #00BDF3
- &-orange
- color: #EF9E56
+ &_default
+ color: #9A9A9A