I’m surprised I haven’t seen this topic discussed much in these forums, making me wonder if I’m somehow doing this wrong - but how does one disable a “page load” workflow while editing?
I have several pages, redirected from a logon page to a different page based on the authState and associated user roles. This is to ensure if a currently authenticated user accesses a page they shouldn’t be at, they are directed to the correct place based on their role. This part works perfectly - but it makes it literally impossible to edit any page with this workflow, as the editor also invokes workflows and pushes me to another page! I have never seen this in any other platform, surely this isn’t by design?
I’m completely baffled and frustrated at the fact workflows run while editing, since if you make a mistake and get redirected somewhere in the process, it completely throws off your train of thought and working environment. It also makes me wonder - what is the point of “Preview” mode? If the code fully runs all the time, in edit mode or preview mode - the only difference is that I’m disabling the editing features, in which case - why not have ALL “run-mode” functionality running ONLY in preview mode, with the editor reserved for JUST editing?!?
Can somebody please help me understand this logic, as it is driving me crazy…
EDIT: I know I can simply disable the workflow, but then I have to remember to re-enable them every time I test or deploy. If I then re-enable the flow or change a page, I’m again stuck back in my unwanted redirect loop again…
Hey @aemondis
I don’t have the answer to your question, but at the beginning of your worfklow, you can also add a pass-through condition based on the env you are in — and only run the worfklow if env === “prod” . That would reduce a bit the friction your are experimenting I think
The only times I runned into that issue, I just logged in with a user account that has the proper rights. But the apps were not very complex in those regards.
Thanks Jean-Philippe, I had played with this but it seems to be mainly relevant for deployed vs. not deployed, so not entirely what I’m looking for.
Am I missing something in how people manage redirects from their pages? Based on the user role, they are redirected to the appropriate page, which AFAIK can only be done through a page load event (e.g. user re-opens a browser and the session cookie is still valid).
Is there some other way people do this? And if so, do I assume they never test it using “preview”?
Open the project in Safe Mode with no workflows (also comes with its downside but maybe more easy to maintain):
Both approaches are imperfect but I can’t think of a better solution at the moment I’ll investigate further with the product team to see if I’m missing anything!
UPDATE:
The product team confirmed that option 2 is the best way to handle this use case at the moment. You can enable Safe Mode directly from inside the project like this:
Thanks all, especially @Joyce for passing this on to the product team. I really hope this behaviour gets changed, as it’s extremely unintuitive to have run-mode functionality in an editor (I’ve never encountered this with any other tool). I’m just a little baffled that nobody seems to have ever raised a concern about this, particularly with page redirects?
It sounds like the safe mode is the best option, just quite a lot of messing around. Not ideal…