This commit allows users to re-add widgets. At this point it's only possible to recover removed widgets by clicking on "Reset to default".
To do this I populate the 'Add widgets' list by getting a diff between the current widgets and the available ones. The code calls any available widget 'default_widget', so keep that in mind.
After removing a widget, we reload the page, which is fairly fast thanks to turbolinks. This is so that we populate the 'Add widgets' list.
Clicking on the widget to add will trigger a POST call that will add the widget to User.current.widgets and reload the page. The reason why I need to reload the page is to get the data in the new widget, otherwise we would load an empty widget. It's not optimal but turbolinks makes it fast.
Fixes #10929 - Add removed widgets to dashboard
This commit allows users to re-add widgets. At this point it's only
possible to recover removed widgets by clicking on "Reset to default".
To do this I populate the 'Add widgets' list by getting a diff
between the current widgets and the available ones. The code calls any
available widget 'default_widget', so keep that in mind.
After removing a widget, we reload the page, which is fairly fast thanks
to turbolinks. This is so that we populate the 'Add widgets' list.
Clicking on the widget to add will trigger a POST call that will add the
widget to User.current.widgets and reload the page. The reason why I
need to reload the page is to get the data in the new widget, otherwise
we would load an empty widget. It's not optimal but turbolinks makes it
fast.