Bug 8252

Summary: Pages using ToasterTables break the back button
Product: [Build System, Metadata & Runtime] Toaster Reporter: Belen Barros Pena <belen.barros.pena>
Component: toasterAssignee: Elliot Smith <elliot.smith>
Status: VERIFIED FIXED QA Contact: Alexandru Roman <alexandru.costinx.roman>
Severity: normal    
Priority: Medium CC: alexandru.costinx.roman, belen.barros.pena, elliot.smith, jessica.zhang, stanciux.mihail
Version: 1.8   
Target Milestone: 2.0   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Belen Barros Pena 2015-09-03 17:04:50 UTC
Found in master:bc6a1a23e3d1af3861288a7abdbc9d5010470204

To reproduce, visit any of the following pages in Toaster:

* Compatible layers
* Compatible targets
* Compatible machines
* Layer details

Then click the back button: that removes the parameters in the URL, but does not bring you to the previous page.

The above pages happen to be the ones using ToasterTables, but I don't know if the problem is connected to that or to something else.
Comment 1 Elliot Smith 2015-09-04 10:38:43 UTC
I think it's to do with the fact that if you request a page which requires URL parameters (page, orderby etc.) but don't provide those parameters, Toaster adds them to the URL, then redirects you to that URL instead.

This means that if you are at

  /project/2/

and follow the machines link, which points at

  /project/2/machines/

you actually end up at

  /project/2/machines/?limit=25&page=1&orderby=name&

So then you have to use the back button twice to get back to /project/2/ (once to get back to /project/2/machines, then again to get back to /project/2/).

I guess that we need to maintain limit, page, orderby etc. for each table separately (some orderby fields won't apply to all tables, for example). We could do this several ways:

1. We add the params to all of the URLs when they are constructed.

2. We set some defaults which don't show in the URL, but which can be overridden by the user (and will then show up in the URL). NB This can be combined with option 1. It's really a case of whether we want explicit URLs all the time (so that they always contain the parameters) or whether we're OK with implicit default parameters (which don't necessarily show in the URL).

3. We rewrite the URL in place to add the parameters, without using a redirect, via the history API. This seems unnecessarily fiddly though and is probably better suited to single-page apps.

I would have to try each to see which worked best in our context, but I'd probably go for 1 and 2 in combination (I don't have any issue with implicit default parameters which don't always show in the URL).
Comment 2 Elliot Smith 2015-09-16 07:27:28 UTC
I think this is fixed in elliot/toaster/bad_caching-7660, as it has the same root cause as https://bugzilla.yoctoproject.org/show_bug.cgi?id=7660.
Comment 3 Belen Barros Pena 2015-09-16 09:50:34 UTC
(In reply to comment #2)
> I think this is fixed in elliot/toaster/bad_caching-7660, as it has the same
> root cause as https://bugzilla.yoctoproject.org/show_bug.cgi?id=7660.

That branch seems to fix the problem everywhere except in one case. This is it:

* Visit the layer details page
* Select the 'Machines' (or 'Recipes') tab
* Click the back button

You stay in the same tab: clicking the back button removes the internal anchor in the url.
Comment 4 Elliot Smith 2015-09-16 10:34:40 UTC
I think this is a bootstrap issue, as bootstrap tab elements don't support the back button. I think I can fix it via the history API though (e.g. see http://www.redotheweb.com/2012/05/17/enable-back-button-handling-with-twitter-bootstrap-tabs-plugin.html, https://gist.github.com/josheinstein/5586469).
Comment 5 Elliot Smith 2015-09-16 10:36:03 UTC
I should have mentioned, I'll do this in a separate branch (this is the only part of the back button problem which isn't down to caching, it seems). I'll leave the fix for the caching issue in elliot/toaster/bad_caching-7660.
Comment 6 Elliot Smith 2015-09-16 11:24:28 UTC
This problem is being further compounded by the RedirectException stuff I mentioned above, which breaks the history while you're trying to fix the interaction between Bootstrap tabs and the history.
Comment 7 Elliot Smith 2015-09-16 11:27:42 UTC
Also note that the page you mention as still being broken (layer details) isn't a ToasterTable: it's implemented via the layerdetails view in views.py.
Comment 8 Belen Barros Pena 2015-09-16 11:38:02 UTC
(In reply to comment #7)
> Also note that the page you mention as still being broken (layer details)
> isn't a ToasterTable: it's implemented via the layerdetails view in views.py.

my bad: sorry. I thought the layer details page was also using ToasterTables.
Comment 9 Elliot Smith 2015-09-22 07:28:17 UTC
Submitted to mailing list for review: https://lists.yoctoproject.org/pipermail/toaster/2015-September/002740.html
Comment 10 Elliot Smith 2015-09-22 07:28:56 UTC
Note that http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=elliot/toaster/bad_caching-7660 also fixes this issue.
Comment 11 Alexandru Roman 2015-11-03 16:11:10 UTC
Verified on master: fc45deac89ef63ca1c44e763c38ced7dfd72cbe1