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

Make bellStore global so that we can access the information on how many unread notifications there are in total can be accessed elsewhere, too. Thus we can show the user a hint to change the filter, as there are more notifications which are currently not visible.

Henriette Darge67eb54ba8d9e
diff --git a/config/locales/js-en.yml b/config/locales/js-en.yml
index 61ebb4332fd..e2af859f8d0 100644
--- a/config/locales/js-en.yml
+++ b/config/locales/js-en.yml
@@ -578,6 +578,7 @@ en:
total_count_warning: "Showing the %{newest_count} most recent notifications. %{more_count} more are not displayed."
empty_state:
no_notification: "Looks like you're all caught up."
+ no_notification_with_current_filter: "Change of involvement or go back to the Inbox to view notifications"
no_selection: "Click on a notification to view all activity details."
menu:
accountable: 'Accountable'
@@ -1243,5 +1244,3 @@ en:
load_error_message: 'There was an error loading the form'
validation_error_message: 'Please fix the errors present in the form'
advanced_settings: 'Advanced settings'
-
-
diff --git a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts
index 098412e2b8f..b8fdd9b8ee1 100644
--- a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts
+++ b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts
@@ -25,9 +25,6 @@ const POLLING_INTERVAL = 10000;
templateUrl: './in-app-notification-bell.component.html',
styleUrls: ['./in-app-notification-bell.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
- providers: [
- IanBellService,
- ],
})
export class InAppNotificationBellComponent {
polling$ = timer(10, POLLING_INTERVAL).pipe(
diff --git a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
index 5b161f5c1a4..706ed568722 100644
--- a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
+++ b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.service.ts
@@ -15,7 +15,12 @@ import {
import { notificationsMarkedRead } from 'core-app/core/state/in-app-notifications/in-app-notifications.actions';
import { ActionsService } from 'core-app/core/state/actions/actions.service';
-@Injectable()
+/**
+ * The BellService is injected into root here (and the store is thus made global),
+ * because we are dependent in many places on the information about how many notifications there are in total.
+ * Instead of repeating these requests, we prefer to use the global store for now.
+ */
+@Injectable({ providedIn: 'root' })
@EffectHandler
export class IanBellService {
readonly id = 'ian-center';
diff --git a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.store.ts b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.store.ts
index a82b9c484cf..8b353ab3c9f 100644
--- a/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.store.ts
+++ b/frontend/src/app/features/in-app-notifications/bell/state/ian-bell.store.ts
@@ -1,4 +1,3 @@
-import { Injectable } from '@angular/core';
import {
Store,
StoreConfig,
@@ -14,7 +13,6 @@ export function createInitialState():IanBellState {
};
}
-@Injectable({ providedIn: 'root' })
@StoreConfig({ name: 'ian-bell' })
export class IanBellStore extends Store<IanBellState> {
constructor() {
diff --git a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html
index 81bb151fb9d..45e71228440 100644
--- a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html
+++ b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.html
@@ -16,7 +16,7 @@
<ng-template #noNotification>
<img [src]="image.no_notification" class="op-empty-state--content--image"/>
<p class="op-empty-state--content--text">
- <span> {{ text.no_notification }}</span>
+ <span [textContent]="noNotificationText()"></span>
</p>
</ng-template>
</ng-template>
diff --git a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.sass b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.sass
index 79faee04a37..da88c2d8ff9 100644
--- a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.sass
+++ b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.sass
@@ -12,9 +12,8 @@
position: absolute
&--text
- white-space: nowrap
color: var(--gray-dark)
- font-size: larger
+ font-size: 18px
&--image
max-height: 130px
diff --git a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts
index 78e3a53451a..86687589fee 100644
--- a/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts
+++ b/frontend/src/app/features/in-app-notifications/center/empty-state/empty-state.component.ts
@@ -35,7 +35,12 @@ import {
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { imagePath } from 'core-app/shared/helpers/images/path-helper';
import { IanCenterService } from '../state/ian-center.service';
-import { debounceTime } from 'rxjs/operators';
+import {
+ debounceTime,
+ distinctUntilChanged,
+} from 'rxjs/operators';
+import { IanBellService } from 'core-app/features/in-app-notifications/bell/state/ian-bell.service';
+import { combineLatest } from 'rxjs';
@Component({
templateUrl: './empty-state.component.html',
@@ -52,29 +57,50 @@ export class EmptyStateComponent implements OnInit {
text = {
no_notification: this.I18n.t('js.notifications.center.empty_state.no_notification'),
+ no_notification_with_current_filter: this.I18n.t('js.notifications.center.empty_state.no_notification_with_current_filter'),
no_selection: this.I18n.t('js.notifications.center.empty_state.no_selection'),
};
hasNotifications:boolean;
+ notificationsFiltered = false;
+
loading = true;
private hasNotifications$ = this.storeService.query.hasNotifications$;
+ private totalCount$ = this.bellService.unread$;
+
constructor(
readonly I18n:I18nService,
readonly storeService:IanCenterService,
+ readonly bellService:IanBellService,
readonly cdRef:ChangeDetectorRef,
) {
}
ngOnInit():void {
- this.hasNotifications$.pipe(
- debounceTime(700),
- ).subscribe((val:boolean) => {
- this.loading = false;
- this.hasNotifications = val;
- this.cdRef.detectChanges();
- });
+ combineLatest([
+ this.hasNotifications$,
+ this.totalCount$,
+ ])
+ .pipe(
+ distinctUntilChanged(),
+ debounceTime(250),
+ )
+ .subscribe(([hasNotification, total]) => {
+ this.loading = false;
+ this.hasNotifications = hasNotification;
+
+ if (!hasNotification && total > 0) {
+ this.notificationsFiltered = true;
+ }
+
+ this.cdRef.detectChanges();
+ });
+ }
+
+ noNotificationText():string {
+ return this.notificationsFiltered ? this.text.no_notification_with_current_filter : this.text.no_notification;
}
}
diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
index ea6bdb609bd..33f6df8f511 100644
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
@@ -1,5 +1,6 @@
import { Query } from '@datorama/akita';
import {
+ distinctUntilChanged,
map,
switchMap,
} from 'rxjs/operators';
@@ -46,6 +47,7 @@ export class IanCenterQuery extends Query<IanCenterState> {
hasNotifications$ = this
.notifications$
.pipe(
+ distinctUntilChanged(),
map((items) => items.length > 0),
);
diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
index d2be657c270..f191185278b 100644
--- a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
@@ -19,6 +19,7 @@ import { ActivateFacetButtonComponent } from './center/toolbar/facet/activate-fa
import { MarkAllAsReadButtonComponent } from './center/toolbar/mark-all-as-read/mark-all-as-read-button.component';
import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';
import { EmptyStateComponent } from './center/empty-state/empty-state.component';
+import { IanBellService } from 'core-app/features/in-app-notifications/bell/state/ian-bell.service';
@NgModule({
declarations: [
@@ -47,6 +48,9 @@ import { EmptyStateComponent } from './center/empty-state/empty-state.component'
OpenprojectContentLoaderModule,
ScrollingModule,
],
+ providers: [
+ IanBellService,
+ ],
})
export class OpenProjectInAppNotificationsModule {
}