Closed jgaehring closed 4 years ago
I took a stab at this and it wasn't too hard. However, this made me realize we're not really taking into account the buildtimeMods
, not only for evaluating whether to redirect to the home screen or not, but also when it comes to adding the modules to localStorage
.
This also has me thinking more about how we could move this whole process to after Vue is instantiated. Specifically, I think we really need to be able to check for modules and load them after a successful login request. I'll open a separate issue for this.
We're expecting to roll out the Field Modules architecture shortly, so we can deliver some custom modules to certain users, but for the majority of Field Kit users, the only Field Module available will be the My Logs module. Even when the Precipitation module, becomes available, it will be as a contrib module that admins will have to install into farmOS before it's available in FK.
This creates a dilemma of where to redirect the root (
/
) route to. Right now, FK redirects to the/logs
route. I had been hoping to change that to the/home
route, but that might be premature if that only presents My Logs module. Users might find that confusing and redundant, since it will basically just add taps to their normal workflow without any real gains.So, as @mstenta suggested in an email, we could just add some logic to redirect to the My Logs screen if that's the only module present.
This could be a little tricky. My first instinct is to simply use a redirect function in the routes configuration, but that would require a reference to the Vuex store in that file, and last time I tried that, it created a circular dependency that broke everything. I think instead we'll have to use a navigation guard to intercept the
/
route and push it to/logs
. But as the docs on the redirects warns:So in order for the guard to work, we'll have to remove the redirect in our routes configuration.
This is a bit of an awkward way to wire up the routing, but I think it should be fine. Just trying to think if there are any edge cases that might bite us in the butt. :thinking: