76261[TASK] Introduce state handling with redux and context protocol
Commit message
Review
-
Code review CR 0
-
Verified V 0
Files 50
- Build/Sources/TypeScript/backend/chrome/slices/browser.tsnew+72 −0
- Build/Sources/TypeScript/backend/chrome/slices/module.tsnew+46 −0
- Build/Sources/TypeScript/backend/chrome/slices/navigation.tsnew+47 −0
- Build/Sources/TypeScript/backend/chrome/context.tsnew+79 −0
- Build/Sources/TypeScript/backend/chrome/store.tsnew+76 −0
- Build/Sources/TypeScript/backend/module/router.ts+33 −61
- Build/Sources/TypeScript/backend/viewport/content-container.ts+6 −4
- Build/Sources/TypeScript/backend/viewport/navigation-container.ts+42 −89
- Build/Sources/TypeScript/backend/viewport/resizable-navigation.ts+24 −6
- Build/Sources/TypeScript/backend/module-menu.ts+128 −498
- Build/Sources/TypeScript/backend/viewport.ts+2 −1
- Build/Sources/TypeScript/core/lit-helper.ts+41 −1
- Build/Gruntfile.js+47 −19
- Build/package-lock.json+80 −0
- Build/package.json+2 −0
- typo3/sysext/backend/Classes/Controller/BackendController.php+10 −31
- typo3/sysext/backend/Classes/Module/MenuModule.php+41 −1
- typo3/sysext/backend/Resources/Private/Templates/Backend/Main.html+32 −25
- typo3/sysext/backend/Resources/Public/JavaScript/chrome/slices/browser.jsnew+13 −0
- typo3/sysext/backend/Resources/Public/JavaScript/chrome/slices/module.jsnew+13 −0
Show 30 more files
- typo3/sysext/backend/Resources/Public/JavaScript/chrome/slices/navigation.jsnew+13 −0
- typo3/sysext/backend/Resources/Public/JavaScript/chrome/context.jsnew+14 −0
- typo3/sysext/backend/Resources/Public/JavaScript/chrome/store.jsnew+13 −0
- typo3/sysext/backend/Resources/Public/JavaScript/module/router.js+2 −2
- typo3/sysext/backend/Resources/Public/JavaScript/viewport/content-container.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/viewport/navigation-container.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/viewport/resizable-navigation.js+2 −2
- typo3/sysext/backend/Resources/Public/JavaScript/module-menu.js+46 −1
- typo3/sysext/backend/Resources/Public/JavaScript/viewport.js+1 −1
- typo3/sysext/core/Configuration/JavaScriptModules.php+10 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@babel/runtime@7.19.0/helpers/esm/defineProperty.jsnew+14 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@babel/runtime@7.19.0/helpers/esm/objectSpread2.jsnew+27 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/lib/controllers/context-consumer.jsnew+6 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/lib/controllers/context-provider.jsnew+6 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/lib/decorators/context-provided.jsnew+6 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/lib/decorators/context-provider.jsnew+6 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/lib/context-key.jsnew+6 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/lib/context-request-event.jsnew+6 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/lib/context-root.jsnew+6 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/lib/value-notifier.jsnew+6 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs/context@0.1.3/index.jsnew+1 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@reduxjs/toolkit@1.8.5/dist/query/react/rtk-query-react.esm.jsnew+412 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@reduxjs/toolkit@1.8.5/dist/query/rtk-query.esm.jsnew+1882 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/@reduxjs/toolkit@1.8.5/dist/redux-toolkit.esm.jsnew+1779 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/immer@9.0.15/dist/immer.esm.jsnew+1 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/redux-thunk@2.4.1/es/index.jsnew+32 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/redux@4.2.0/es/redux.jsnew+716 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/reselect@4.1.6/es/defaultMemoize.jsnew+147 −0
- typo3/sysext/core/Resources/Public/JavaScript/Contrib/reselect@4.1.6/es/index.jsnew+130 −0
- typo3/sysext/core/Resources/Public/JavaScript/lit-helper.js+1 −1
Review log 1114
-
Thomas Maroschik uploaded patch set 1 10/25/22, 13:20
-
Thomas Maroschik marked it work in progress 10/25/22, 13:20
-
Thomas Maroschik commented on patch set 1 10/25/22, 13:21
Special thanks to Sascha Nowak, which helped me out in building this. -
core-ci voted on patch set 1 V -1 10/25/22, 13:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/32741
-
Andreas Kienast commented on patch set 1 11/08/22, 14:01
I'm unable to test this patch. The directory typo3/sysext/core/Resources/Public/JavaScript/Contrib/@lit-labs is missing and I cannot get it in place. I already ran `npm ci` and `npm run build` but no luck. -
Andreas Kienast uploaded patch set 2 11/08/22, 14:42
-
Andreas Kienast commented on patch set 2 V -1 11/08/22, 14:43
It's currently not possible to collapse the module menu groups. -
core-ci voted on patch set 2 V -1 11/08/22, 15:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33320
-
Benjamin Franzke commented on patch set 2 11/09/22, 08:01
Random notes from my side: * @lit-labs/context is fine to solve the issue of passing context to grand(grand)-child components, and I think we can easily agree on that – but we should ideally wait for it to become an official package, that's currently being discussed, see https://github.com/lit/lit/discussions/3302 and https://youtu.be/l6Gn5uV83sw?t=465 * The term "chrome" is quite overloaded: a) chrome browser, b) the browsers UI is called "chrome" and c) now TYPO3 would provide a chrome as well. alternatives: app/shell/application or maybe simply dropping that term? * I'm not sure redux is actually needed here, distinct context values can bound to the DOM via @lit-labs/context and every component is authoritative for the distinct context that it provides. (router provides current module, app-shell provides BEuser for example). The redux theory of using deterministic states is nice, but in real life redux middleware like redux-thunk render state changes into implicit actions. So I'd like to see the vision, what is planned and how redux is supposed to be used here. I personally think it's fine for webcomponents to contain states (that's why lit has @state) – they are not just views, but I have a feeling that with redux we'll start a boilerplate like extbase MVC, where webcomponents would only be a VIEW, but they are both, Controller and View (where all the heavy lifting is provided by LitElement, and the Controller part *will* be made available by https://github.com/lit/lit/tree/main/packages/labs/task - I'm waiting for that to become ready for inclusion in TYPO3) -
Andreas Kienast uploaded patch set 3 11/09/22, 09:22
-
core-ci voted on patch set 3 V -1 11/09/22, 09:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33387
-
Thomas Maroschik commented on patch set 3 11/14/22, 13:32
Reply
* Regarding lit-labs/context, the lib is so simple, that just using it now and forking it, if it doesn't become an official package should be a viable solution. It provides value now, and if you delay the decision, nothing is provided. * Decide upon whichever term fits best for the solution. I dislike chrome myself, but its the most fitting term that defines best what fits into the scope of the chrome context and more important what not. * As this is an incomplete implementation and stuff like local storage and APIs are left out currently, redux might look overkill. Webcomponents are fine if they manage only their own state and lit implements this pattern to the best extent. Where you don't get any support at all is with shared state and even more with shared state transitions (unidirectional data flow to the rescue). Just look at the weird interdependencies between the module menu, the router and other components. It's very hard to track down when and if things change and whether all edge-cases are covered and every interested party got the updates. This is where each part of this proposed architecture is independently testable and reduces cognitive load during development. It's about a separation of concerns and providing a simple pattern that can be applied fractally throughout the system (every component is a MVC stack of their own, and part of an micro-frontend MVC stack, and part of the application MVC stack) even by less skilled JS devs (most of TYPO3 contributors probably). So the vision for redux is to handle inter-component state (micro frontend/app state) and not local state (webcomponent state). Thus the separation into store(redux) - messages(context) - components is a solution to that problem. * Maybe I can provide you another vision, that helps in understanding the presented solution. Most of the TYPO3 Devs, that I know aren't very experienced in modern JS or even JS at all. But what they know from day 1 is HTML. Give them the opportunity to assemble Backend Applications by tying together HTML tags like a <typo3-record-provider> and a nested <typo3-datagrid>. It doesn't matter how the <typo3-record-provider> retrieves/manages data as long as the <typo3-datagrid> interacts with it via an uniform interface (a context in this case). This decouples both implementations and enables the reusability/flexibility I would expect of a content management framework. I could switch out the datagrid for a card-collection or switch the record-provider for a solr-provider. A mix and match ecosystem within the application can evolve. By striving for "eat your own dogfood" the CMS should use those components for its own applications, so those elements come out as a byproduct and allow custom applications from third parties to fit into the application naturally. Otherwise developing this set of elements would be a tremendous effort. -
Thomas Maroschik commented on patch set 3 10/11/23, 20:30
By the way, lit/context just graduated from lit-labs https://www.npmjs.com/package/@lit/context -
Thomas Maroschik abandoned the change 03/25/25, 07:43