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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Allow notifications bell to be hidden, and interval to be configurable
Oliver Güntherbbb4efee7a51
diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rbindex eec8dcf5b24..b3c25318601 100644--- a/config/constants/settings/definition.rb+++ b/config/constants/settings/definition.rb@@ -648,6 +648,13 @@ module Settingsdefault: nil,allowed: -> { Role.pluck(:id) }},+ notifications_hidden: {+ default: false+ },+ notifications_polling_interval: {+ format: :integer,+ default: 60000+ },oauth_allow_remapping_of_existing_users: {description: 'When set to false, prevent users from other identity providers to take over accounts connected ' \'to another identity provider.',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.tsindex 3fee2ed225a..3266e8cbe9f 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@@ -1,27 +1,13 @@-import {- ChangeDetectionStrategy,- Component,-} from '@angular/core';-import {- combineLatest,- merge,- timer,-} from 'rxjs';-import {- filter,- map,- shareReplay,- switchMap,- throttleTime,-} from 'rxjs/operators';+import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core';+import { combineLatest, merge, Observable, timer } from 'rxjs';+import { filter, map, shareReplay, switchMap, throttleTime } from 'rxjs/operators';import { ActiveWindowService } from 'core-app/core/active-window/active-window.service';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { IanBellService } from 'core-app/features/in-app-notifications/bell/state/ian-bell.service';+import { populateInputsFromDataset } from 'core-app/shared/components/dataset-inputs';export const opInAppNotificationBellSelector = 'op-in-app-notification-bell';-const ACTIVE_POLLING_INTERVAL = 10000;-const INACTIVE_POLLING_INTERVAL = 120000;@Component({selector: opInAppNotificationBellSelector,@@ -29,46 +15,59 @@ const INACTIVE_POLLING_INTERVAL = 120000;styleUrls: ['./in-app-notification-bell.component.sass'],changeDetection: ChangeDetectionStrategy.OnPush,})-export class InAppNotificationBellComponent {- polling$ = merge(- timer(10, ACTIVE_POLLING_INTERVAL).pipe(filter(() => this.activeWindow.isActive)),- timer(10, INACTIVE_POLLING_INTERVAL).pipe(filter(() => !this.activeWindow.isActive)),- )- .pipe(- throttleTime(ACTIVE_POLLING_INTERVAL),- switchMap(() => this.storeService.fetchUnread()),- );-- unreadCount$ = combineLatest([- this.storeService.unread$,- this.polling$,- ]).pipe(- map(([count]) => count),- shareReplay(1),- );+export class InAppNotificationBellComponent implements OnInit {+ @Input() interval = 50000;- unreadCountText$ = this- .unreadCount$- .pipe(- map((count) => {- if (count > 99) {- return '99+';- }+ polling$:Observable<number>;- if (count <= 0) {- return '';- }+ unreadCount$:Observable<number>;- return count;- }),- );+ unreadCountText$:Observable<number|string>;constructor(+ readonly elementRef:ElementRef,readonly storeService:IanBellService,readonly apiV3Service:ApiV3Service,readonly activeWindow:ActiveWindowService,readonly pathHelper:PathHelperService,- ) { }+ ) {+ populateInputsFromDataset(this);+ }++ ngOnInit() {+ this.polling$ = merge(+ timer(10, this.interval).pipe(filter(() => this.activeWindow.isActive)),+ timer(10, this.interval * 10).pipe(filter(() => !this.activeWindow.isActive)),+ )+ .pipe(+ throttleTime(this.interval),+ switchMap(() => this.storeService.fetchUnread()),+ );++ this.unreadCount$ = combineLatest([+ this.storeService.unread$,+ this.polling$,+ ]).pipe(+ map(([count]) => count),+ shareReplay(1),+ );++ this.unreadCountText$ = this+ .unreadCount$+ .pipe(+ map((count) => {+ if (count > 99) {+ return '99+';+ }++ if (count <= 0) {+ return '';+ }++ return count;+ }),+ );+ }notificationsPath():string {return this.pathHelper.notificationsPath();diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rbindex 28035e9d797..7134ab89fa5 100644--- a/lib/redmine/menu_manager/top_menu_helper.rb+++ b/lib/redmine/menu_manager/top_menu_helper.rb@@ -86,9 +86,13 @@ module Redmine::MenuManager::TopMenuHelperdef render_notification_top_menu_nodereturn ''.html_safe unless User.current.logged?+ return ''.html_safe if Setting.notifications_hidden?content_tag('li', class: 'op-app-menu--item', title: I18n.t('mail.notification.center')) do- tag('op-in-app-notification-bell')+ angular_component_tag 'op-in-app-notification-bell',+ inputs: {+ interval: Setting.notifications_polling_interval+ }endend