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
enable immediate notification center and bell update through ianCenterService usage and enhancement
Jonas Jabari5efae3d4e9a5
diff --git a/app/components/work_packages/activities_tab/journals/item_component.html.erb b/app/components/work_packages/activities_tab/journals/item_component.html.erbindex c1c0f60d7db..9419133d802 100644--- a/app/components/work_packages/activities_tab/journals/item_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component.html.erb@@ -36,7 +36,7 @@:"dot-fill", # color is set via CSS as requested by UI/UX Teamclasses: "work-packages-activities-tab-journals-item-component--notification-dot-icon",size: :medium,- data: { test_selector: "op-journal-unread-notification" }+ data: { test_selector: "op-journal-unread-notification", "op-ian-center-update-immediate": true }))endenddiff --git a/app/components/work_packages/activities_tab/journals/item_component/details.rb b/app/components/work_packages/activities_tab/journals/item_component/details.rbindex 4fd23af862b..c6e3838f0f9 100644--- a/app/components/work_packages/activities_tab/journals/item_component/details.rb+++ b/app/components/work_packages/activities_tab/journals/item_component/details.rb@@ -155,7 +155,7 @@ module WorkPackages:"dot-fill", # color is set via CSS as requested by UI/UX Teamclasses: "work-packages-activities-tab-journals-item-component-details--notification-dot-icon",size: :medium,- data: { test_selector: "op-journal-unread-notification" }+ data: { test_selector: "op-journal-unread-notification", "op-ian-center-update-immediate": true }))endenddiff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.tsindex b218e377801..a567c0bbd3f 100644--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts@@ -61,6 +61,7 @@ import { ApiV3ListFilter, ApiV3ListParameters } from 'core-app/core/apiv3/paths/import { FrameElement } from '@hotwired/turbo';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import { UrlParamsService } from 'core-app/core/navigation/url-params.service';+import { IanBellService } from 'core-app/features/in-app-notifications/bell/state/ian-bell.service';export interface INotificationPageQueryParameters {filter?:string|null;@@ -192,6 +193,7 @@ export class IanCenterService extends UntilDestroyedMixin {readonly state:StateService,readonly deviceService:DeviceService,readonly pathHelper:PathHelperService,+ readonly ianBellService:IanBellService,) {super();this.reload.subscribe();@@ -267,6 +269,13 @@ export class IanCenterService extends UntilDestroyedMixin {});}+ /**+ * Pull latest notifications from API directly and trigger all related UI updates+ */+ updateImmediate() {+ this.ianBellService.fetchUnread().subscribe();+ }+/*** Handle updates after bell count changed (+/-)*/diff --git a/frontend/src/app/features/plugins/plugin-context.ts b/frontend/src/app/features/plugins/plugin-context.tsindex 8b15f1968b9..56550723912 100644--- a/frontend/src/app/features/plugins/plugin-context.ts+++ b/frontend/src/app/features/plugins/plugin-context.ts@@ -33,7 +33,7 @@ import { AttachmentsResourceService } from 'core-app/core/state/attachments/attaimport { HttpClient } from '@angular/common/http';import { TimezoneService } from 'core-app/core/datetime/timezone.service';import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';-+import { IanCenterService } from 'core-app/features/in-app-notifications/center/state/ian-center.service';/*** Plugin context bridge for plugins outside the CLI compiler context* in order to access services and parts of the core application@@ -69,6 +69,7 @@ export class OpenProjectPluginContext {attachmentsResourceService: this.injector.get(AttachmentsResourceService),http: this.injector.get(HttpClient),turboRequests: this.injector.get(TurboRequestsService),+ ianCenter: this.injector.get(IanCenterService),};public readonly helpers = {diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.tsindex 09a826e09bd..6197e3ccf03 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts@@ -4,7 +4,8 @@ import {} from 'core-app/shared/components/editor/components/ckeditor/ckeditor.types';import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';-import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';+import { IanCenterService } from 'core-app/features/in-app-notifications/center/state/ian-center.service';+import { IanBellService } from 'core-app/features/in-app-notifications/bell/state/ian-bell.service';interface CustomEventWithIdParam extends Event {params:{@@ -54,11 +55,13 @@ export default class IndexController extends Controller {private turboRequests:TurboRequestsService;private apiV3Service:ApiV3Service;+ private ianCenterService:IanCenterService;async connect() {const context = await window.OpenProject.getPluginContext();this.turboRequests = context.services.turboRequests;this.apiV3Service = context.services.apiV3Service;+ this.ianCenterService = context.services.ianCenter;this.setLocalStorageKey();this.setLastUpdateTimestamp();@@ -160,7 +163,8 @@ export default class IndexController extends Controller {const journalsContainerAtBottom = this.isJournalsContainerScrolledToBottom(this.journalsContainerTarget);- void this.performUpdateStreamsRequest(this.prepareUpdateStreamsUrl()).then((html) => {+ void this.performUpdateStreamsRequest(this.prepareUpdateStreamsUrl())+ .then((html) => {this.handleUpdateStreamsResponse(html as string, journalsContainerAtBottom);}).catch((error) => {console.error('Error updating activities list:', error);@@ -189,6 +193,7 @@ export default class IndexController extends Controller {private handleUpdateStreamsResponse(html:string, journalsContainerAtBottom:boolean) {this.setLastUpdateTimestamp();this.checkForAndHandleWorkPackageUpdate(html);+ this.checkForNewNotifications(html);this.performAutoScrolling(html, journalsContainerAtBottom);}@@ -198,11 +203,21 @@ export default class IndexController extends Controller {}}+ private checkForNewNotifications(html:string) {+ if (html.includes('data-op-ian-center-update-immediate')) {+ this.updateNotificationCenter();+ }+ }+private updateDisplayedWorkPackageAttributes() {const wp = this.apiV3Service.work_packages.id(this.workPackageIdValue);void wp.refresh();}+ private updateNotificationCenter() {+ this.ianCenterService.updateImmediate();+ }+private performAutoScrolling(html:string, journalsContainerAtBottom:boolean) {// only process append, prepend and update actionsif (!(html.includes('action="append"') || html.includes('action="prepend"') || html.includes('action="update"'))) {