Skip to content

Migrate WebSocket stack to data-access and react to site CRUD events #35350

@fmontes

Description

@fmontes

Description

The legacy WebSocket layer in @dotcms/dotcms-js (Protocol, WebSocketProtocol, LongPollingProtocol, DotWebSocketConfig, DotcmsEventsService) is an outdated abstraction that predates our current Angular/NgRx patterns. It's also missing reactivity to site CRUD events — when a site is published, archived, stopped, or deleted, the UI doesn't reflect the change without a manual refresh, and the UN_PUBLISH_SITE system event isn't even defined on the backend so stop-site events are silently swallowed.

This task replaces the legacy stack with a modern, typed WebSocket service and wires site CRUD events into the global store so the UI reacts automatically.

Acceptance Criteria

  • New DotEventsSocket in libs/data-access: native WebSocket, exponential backoff with jitter, typed on<T>(eventType) API, reactive status$() stream
  • New withWebSocket() NgRx signal store feature in libs/global-store: manages connection lifecycle, exposes wsStatus signal and typed event observables
  • Legacy Protocol, WebSocketProtocol, LongPollingProtocol, DotWebSocketConfig, and getWebSocketConfig() are removed
  • All DotcmsEventsService.subscribeTo() / subscribeToEvents() call sites migrated to DotEventsSocket.on<T>() (DotMessageDisplayService, DotToolbarNotificationsComponent, DotLargeMessageDisplayComponent, IframeComponent, IframePortletLegacyComponent)
  • DotSiteComponent refreshes the site list (debounced) on any site WebSocket event and auto-switches to the default site when the selected site is archived/stopped/deleted
  • Java SystemEventType.UN_PUBLISH_SITE added so stop-site events are dispatched
  • Toolbar reacts to SWITCH_SITE events via a dedicated DotSiteNavigationEffect
  • WebSocket reconnects automatically after server restart, with a visible reconnecting indicator
  • yarn nx test data-access and yarn nx test global-store pass

Additional Context

Tracking PR: #34990

Metadata

Metadata

Type

No fields configured for Task.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions