Review main Abandoned

87999[TASK] Consolidate page tree refresh

Andreas Kienast CR 0 V 0 Normal +35 −57 updated 02/05/25, 07:12

Commit message

This commit replaces all manual dispatches of the custom
`typo3:pagetree:refresh` event with a single method call.

Review

  • Code review CR 0
  • Verified V 0

Issues 1

Files 18

Review log 89

  1. Andreas Kienast uploaded patch set 1 02/03/25, 15:35

  2. Andreas Kienast uploaded patch set 2 02/03/25, 15:36

  3. Andreas Kienast uploaded patch set 3 02/03/25, 15:36

  4. core-ci voted on patch set 3 V +1 02/03/25, 15:43 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/73419

  5. Ayke Halder commented on patch set 3 CR -1 02/04/25, 15:37

    On the general idea: Is the `@typo3/backend/viewport/navigation-container` the right place to implement the event-trigger-action `refreshNavigation()`? By doing this, each place which only needs to *use* the event-trigger-action, must thereby 'import' the complete `navigation-container` + relations (= download the JS-file). IMO this code here is already a very abstract event-trigger: `top.document.dispatchEvent(new CustomEvent('typo3:pagetree:refresh'))` ---- TYPO3 further abstracted the event-trigger concept with: 61788: [FEATURE] Introduce Broadcast Messaging | https://review.typo3.org/c/Packages/TYPO3.CMS/+/61788 Also see: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.1/Feature-89244-BroadcastChannels.html https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Backend/BroadcastChannels.html Unfortunately, the Broadcast Messaging - as implemented right now - can only be used for messages coming *from one specific sender* and being *received by multiple receivers*. `BroadcastMessage::createCustomEvent`: ```js public createCustomEvent(scope: string = 'typo3'): CustomEvent { return new CustomEvent( [scope, this.componentName, this.eventName].join(':'), { detail: this.payload }, ); } ``` Resulting in events like e.g. * `typo3:typo3-backend-editable-page-title:refresh-navigation` * `typo3:typo3-backend-wizard-move-page:refresh-navigation` * `typo3:typo3-backend-ajax-data-handler:refresh-navigation` * `typo3:typo3-backend-context-menu-action:refresh-navigation` * `typo3:typo3-backend-recordlist:refresh-navigation` * `typo3:typo3-recycler:refresh-navigation` * `typo3:typo3-workspaces-menu:refresh-navigation` * `typo3:typo3-workspaces-backend:refresh-navigation` * etc. … which can not be easily tracked by one event receiver. ---- To get a clean solution here, how about extending the Broadcast Messaging to trigger an additional generic event for each action. This generic event provides *events from multiple senders* that are *received by one receiver*: E.g. `BroadcastMessage::createGenericCustomEvent`: ```js public createGenericCustomEvent(scope: string = 'typo3'): CustomEvent { return new CustomEvent( [scope, 'GENERIC', this.eventName].join(':'), { namespace: this.componentName, detail: this.payload, }, ); } ``` Thereby the receiver component can listen to a single event: * `typo3:GENERIC:refresh-navigation` If necessary the event-handling function could still check `namespace` to see which component originally triggered the event.
  6. Andreas Kienast commented on patch set 3 02/04/25, 15:45

    Reply

    `top.document.dispatchEvent(new CustomEvent('typo3:pagetree:refresh')` is indeed very abstract. Too abstract and hard to remember, in my opinion. Since this code is spread all over our modules, consolidating this into a dedicated method makes sense. Downloading the JS file(s) is a non-issue since they are loaded anyway when opening the backend.
  7. Ayke Halder commented on patch set 3 02/04/25, 15:56

    Reply

    If not downloading, then extra running them is a small performance penalty - minor issue. Still I think this is a good use-case to introduce the option for event-listener like this: ```js document.addEventListener( 'typo3:pagetree:refresh-navigation', this.runOnEventRefreshNavigationFromComponentPagetree ); document.addEventListener( 'typo3:pagetree:*', this.runOnAnyEventFromComponentPagetree ); document.addEventListener( 'typo3:*:refresh-navigation', this.runOnEventRefreshNavigationFromAnyComponent ); ```
  8. Andreas Kienast commented on patch set 3 02/05/25, 06:23

    Reply Unresolved

    This is not what the patch aims for. Besides, I don't understand how your proposal _splifies_ things.
  9. Andreas Kienast abandoned the change 02/05/25, 07:12

    The general behavior is different to the file tree. This needs more conceptual work.