Usage
Import the action you want to open and ask it for its route. Itsparams are typed by that action’s params schema:
actions/accounts/createAccountAction.ts
/actions/accounts/extend_trial?company=Acme+Inc. and Extend trial starts with ctx.params.company filled in.
Routes
action.route() returns the link to that action, an ActionRoute. The same object is what a table’s row menu lists, so one action can be opened from a redirect and from a table alike:
An action without a params schema takes no params:
clearCacheAction.route(). When every param of its schema is optional, the params can be left out too: createIntegratorAction.route({ label: 'Create integrator' }). route() works once listen() has loaded the actions folder, so call it inside a handler, not at the top of a file.
Behaviour
- The run ends with the redirect: the run page opens the other action instead of showing a result, and Back skips the finished run.
- The handler goes on after
await ctx.redirect(), but any io call after it throws, like after a cancel, and what it returns is ignored. Put the redirect last. - After the run has ended, the call does nothing.