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

[38113] Handle deleted items in the notifications API and frontend

Oliver Günther6e90929133a8
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
index cea9c430e33..56ed23676ee 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html
@@ -7,7 +7,8 @@
<button
type="button"
class="op-ian-item--row"
- (click)="toggleDetails()"
+ [class.op-ian-item--row_unexpandable]="unexpandable"
+ (click)="toggleDetails()"
>
<div
*ngIf="project"
@@ -44,8 +45,9 @@
</ng-container>
<ng-template #workPackageLoading>
<span
- class="op-ian-item--title"
- [textContent]="text.loading"
+ *ngIf="workPackage$"
+ class="op-ian-item--title"
+ [textContent]="text.loading"
></span>
</ng-template>
<ng-container *ngIf="!workPackage$">
@@ -94,7 +96,7 @@
</ng-container>
<ul
class="work-package-details-activities-messages"
- *ngIf="details.length > 1"
+ *ngIf="details.length > 0"
>
<ng-container *ngFor="let detail of details">
<li *ngIf="detail.html && detail.html !== ''">
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
index 6a8f8f18b19..557ade82113 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass
@@ -38,6 +38,9 @@ $ian-bg-hover-color: #F1F8FF
grid-template-rows: auto 1fr
grid-template-areas: "project actor reason" "title actor date"
+ &_unexpandable
+ cursor: default
+
&--indicator
width: 10px
diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
index a3e9750ef28..f72ebac6d9c 100644
--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts
@@ -35,6 +35,9 @@ export class InAppNotificationEntryComponent implements OnInit {
// custom rendered details, if any
details:InAppNotificationDetail[];
+ // Whether body and details are empty
+ unexpandable = false;
+
// The actor, if any
actor?:PrincipalLike;
@@ -89,6 +92,7 @@ export class InAppNotificationEntryComponent implements OnInit {
const details = this.notification.details || [];
this.body = details.filter((el) => el.format === 'markdown');
this.details = details.filter((el) => el.format === 'custom');
+ this.unexpandable = this.body.length === 0 && this.details.length === 0;
}
private buildTime() {
@@ -101,6 +105,10 @@ export class InAppNotificationEntryComponent implements OnInit {
}
toggleDetails():void {
+ if (this.unexpandable) {
+ return;
+ }
+
if (!this.notification.readIAN) {
this.inAppNotificationsService.markReadKeepAndExpanded(this.notification);
}
diff --git a/lib/api/decorators/polymorphic_resource.rb b/lib/api/decorators/polymorphic_resource.rb
index ccafe041135..618affa0b0b 100644
--- a/lib/api/decorators/polymorphic_resource.rb
+++ b/lib/api/decorators/polymorphic_resource.rb
@@ -55,6 +55,8 @@ module API
next unless embed_links
resource = represented.send(name)
+ next if resource.nil?
+
representer = representer_fn.call(resource)
representer.create(resource, current_user: current_user)
end
@@ -80,6 +82,8 @@ module API
next if instance_exec(&skip_link)
resource = represented.send(name)
+ next if resource.nil?
+
path_name = path_fn.call(resource)
::API::Decorators::LinkObject