Review main Abandoned

61776[WIP][FEATURE] Update Backend URLs when navigating

Benni Mack CR 0 V 0 Hard +229 −31 updated 04/19/21, 18:40

Commit message

Wouldn't it be cool if editors could share their current URL just by clicking in the browser?

This patch adds a iframe listener so every time a module gets changed, the URL in the browser
is updated.

We use history.replaceState to decorate iframe state
changes with an according URL in the browser URL bar.
We avoid history.pushState as that would result in
two state changes for every new iframe load.

Note: Browser back button does not fire popstate when
navigating between iframes, therefore we handle
module navigation as result of the iframe load.

Every iframe is expected to indicate it's module via the data-module-name
tag. Therefore all core modules are adapted to fill the module name
(which was already available since ever, but mostly unused – only
EXT:form used it for customized styling, this is changed to a css class)

To Be Done:
+ push/replaceState should remove the token query parameter
+ push/replaceState also should work for non-modules / regular routes
+ resolve active module menu entry when using browser back button
- evaluate the query parameter (re-auth) when the link is used in another browser
- Adding tests when a user visits a non-authenticated URL, authenticate (and show error or redirect etc)
- Fix popups (in EditDocumentController)
- Test .htaccess check when TYPO3 is installed in subfolders
- Test Install Tool
- Fix module name advertisement in install tool backend module controller

Not needed right now, because browser handles history for module iframes automatically
- Resolve URLs handled in push state
- Resolve URLs when using the browser back button

Review

  • Code review CR 0
  • Verified V 0

Files 37

Show 17 more files

Review log 2239

Show 814 earlier messages
  1. Benni Mack uploaded patch set 1 09/23/19, 10:52

  2. TYPO3com voted on patch set 1 V -1 09/23/19, 11:02 Completed build in 10m 46s on Mon, 23 Sep, 11:02 AM Test Summary: 47739 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-36655

  3. Benni Mack uploaded patch set 2 09/17/20, 07:30

  4. TYPO3com voted on patch set 2 V -1 09/17/20, 07:42 Completed build in 11m 11s on Thu, 17 Sep, 07:41 AM Test Summary: 189 of 73772 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-5651

  5. Benni Mack uploaded patch set 3 10/22/20, 11:31

  6. TYPO3com voted on patch set 3 V -1 10/22/20, 11:46 Completed build in 14m 28s on Thu, 22 Oct, 11:46 AM Test Summary: 202 of 73979 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-6790

  7. Benni Mack uploaded patch set 4 11/03/20, 09:07

  8. TYPO3com voted on patch set 4 V -1 11/03/20, 09:08 Completed build in 24s on Tue, 3 Nov, 09:08 AM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7080

  9. Benni Mack uploaded patch set 5 11/07/20, 19:27

  10. TYPO3com voted on patch set 5 V -1 11/07/20, 19:29 Completed build in 01m 28s on Sat, 7 Nov, 07:29 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7178

  11. Benni Mack uploaded patch set 6 11/07/20, 21:08

  12. TYPO3com voted on patch set 6 V -1 11/07/20, 21:08 Completed build in 30s on Sat, 7 Nov, 09:08 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7179

  13. Benni Mack uploaded patch set 7 11/07/20, 21:36

  14. Benni Mack uploaded patch set 8 11/07/20, 21:48

  1. TYPO3com voted on patch set 7 V -1 11/07/20, 21:58 Completed build in 21m 34s on Sat, 7 Nov, 09:58 PM Test Summary: 247 of 72318 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7181

  2. TYPO3com voted on patch set 8 V -1 11/07/20, 22:15 Completed build in 26m 55s on Sat, 7 Nov, 10:15 PM Test Summary: 255 of 73918 failed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-7183

  3. Benni Mack uploaded patch set 9 12/19/20, 14:28

  4. TYPO3com voted on patch set 9 V -1 12/19/20, 14:38 Completed build in 09m 41s on Sat, 19 Dec, 02:37 PM Test Summary: 32411 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8314

  5. Benjamin Franzke commented on patch set 9 12/23/20, 10:38

    cool change so far, but it's always a mess to use the history API in non single-page application. Real break back actions will not fire, so most times the "state" is useless. See comment below

    Viewport.ts:51

    When an iframe is changed, the browser already pushes a new state internally, but as a new context (so browser back will not fire popstate event – at least in chrome). (BTW: That's why we are already able to use the browser back button to navigate between iframes right now.) Now, that means we shouldn't push another state, but rather annotate the browsers URL with history.replaceState(). if we push another state, the user has to click the back button twice. That means we should sync everything to the iframe load/unload event and rather not to the popstate(), and annoate the URL with replaceState instead of pushState. I don't want to usurp this change, therefore I've pushed the diff that demonstrates that to a branch of mine: https://github.com/bnf/TYPO3.CMS/commit/backend-url-navigation-replace-state Note: Another possiblity may be to use `iframe.contentWindow.location = newUurl` instead of $(iframe).attr('src') – that could avoid a new browser context/state and then pushState could be fine. On the other hand: Using replaceState, the browser will take care of most state handling for us – as before.
  6. Benni Mack commented on patch set 9 01/04/21, 10:40

    Thanks bnf for your remarks, I think this is totally valid, feel free to merge your changes into this one.
  7. Benjamin Franzke commented on patch set 9 01/12/21, 06:38

    Viewport.ts:47

    Note: According to the BroadcastService event structure this would need to include a @payload@ subproperty, so it would be @evt.detail.payload.url@. Because of a bug in @BroadcastMessage.fromData()@ (not being idempotent), this "new" local broadcast (send with BroadcastServce.post(…, senfToSelf: true)) message event has another signature than a broadcast message that is actually send via the Browsers broadcastchannel. Documented that bug in: https://forge.typo3.org/issues/93270 (will provide a fix) Now, what does that mean? If the signature would be correct, this event would be handled in *all* browser tabs and all browser tab URLs would be updated. (curently it's send there as well, but results in a javascript error, because event.detail.url is not available in CustomEvent received via broadcastchannel. So, that's actually not what we strive for (broadcasting this to all TYPO3 browser tabs), threfore a BroadcastMessage is not right tool here, we should just use iframe load/unload Handlers + CustomEvents.
  8. Benjamin Franzke uploaded patch set 10 01/14/21, 19:59

  9. TYPO3com voted on patch set 10 V +1 01/14/21, 20:11 Completed build in 11m 21s on Thu, 14 Jan, 08:11 PM Test Summary: 32575 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8861

  10. Benjamin Franzke commented on patch set 10 01/14/21, 20:15

    Viewport.ts:47 Reply

    Switched to pure CustomEvent in patchset 10.

    Viewport.ts:51 Reply

    Went with replaceState now (patchset 10). pushState would work with iframes for backward navigation, when we'd call history.go(-1) in window.onpopstate then, but thats really hacky and means only backwards navigation will work. Forward navigation ends up in loops. pushState will be interesting in case we introduce non-iframes modules at some point (I'm playing around with that), and I will try/see whether we can combine that – using replaceState for iframe based auto history changes and pushState for non-iframe modules (=html/lit component based modules).
  11. Benjamin Franzke uploaded patch set 11 01/14/21, 21:23

  12. TYPO3com voted on patch set 11 V -1 01/14/21, 21:35 Completed build in 11m 40s on Thu, 14 Jan, 09:35 PM Test Summary: 32208 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8862

  13. TYPO3com voted on patch set 11 V +1 01/14/21, 21:47 Completed build in 35m 07s on Thu, 14 Jan, 09:47 PM Test Summary: 32575 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8862

  14. Benjamin Franzke uploaded patch set 12 01/15/21, 20:48

  15. TYPO3com voted on patch set 12 V +1 01/15/21, 21:00 Completed build in 11m 20s on Fri, 15 Jan, 09:00 PM Test Summary: 32575 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-8871

  16. Benni Mack commented on patch set 12 01/17/21, 11:55

    Thanks bnf, for the changes. As previously mentioned, I think we should move the "do proper redirects when a URL is accessed" out of this change as a "pre-patch" (separate feature) and then add the "auto-updating URLs when updating" on top. Agreed?
  17. Benjamin Franzke commented on patch set 12 01/19/21, 15:26

    Reply

    Ack, I agree, we should do deeplinking as a pre-flight patch, auto-updating is a separate feature. Still, one remark: I'm not 100% happy with the implicity of re-intepreting an invalid token of a route (that was intended for iframe-only usage) as an intention for a deeplink. I'd like that distinction to be more explicit – but your solution is very simple and elegant ;) – so it's probably fine. Definetly a good and unintrusive change. Furthermore I'm very happy *not* to rush the URL auto-updating in, as I actually worked the last couple of days on (possible) subsequent patches/features, especially custom component based modules (SPA style). I'm trying to experiment with iframe vs SPA compatbility regarding history state replacements and pushes (when to use pushState, when to use replaceState), in order to not introduce an URL update API here, that conflict with SPA enhancements later on. And therefore I have no intention to rush this in, because as demonstrated in following POC – https://review.typo3.org/c/Packages/TYPO3.CMS/+/67464 – I'd probably move the navigationchange event handler (which pushes state) into a designated router component later on, add flags for state/replace intention and I think those more complicated examples then help to find the right API for state propagation.
  18. Benjamin Franzke uploaded patch set 13 01/22/21, 21:33

    Rebase on master
  19. Benjamin Franzke uploaded patch set 14 01/22/21, 21:35

  20. TYPO3com voted on patch set 13 V +1 01/22/21, 21:42 Completed build in 09m 16s on Fri, 22 Jan, 09:42 PM Test Summary: 32601 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9007

  21. TYPO3com voted on patch set 14 V +1 01/22/21, 21:47 Completed build in 10m 45s on Fri, 22 Jan, 09:47 PM Test Summary: 32601 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-9008

  22. Benni Mack uploaded patch set 15 03/10/21, 09:43

  23. TYPO3com voted on patch set 15 V +1 03/10/21, 09:50 Completed build in 06m 25s on Wed, 10 Mar, 09:50 AM Test Summary: 32680 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-10001

  24. core-ci voted on patch set 15 V +1 03/10/21, 09:53 Core CI is happy: https://core.b13.com/typo3-core/typo3.cms/-/pipelines/1359

  25. Benni Mack abandoned the change 04/19/21, 18:40