vmware-tanzu-labs / educates-training-platform

A platform for hosting interactive workshop environments in Kubernetes, or on top of a local container runtime.
https://docs.educates.dev
Apache License 2.0
63 stars 15 forks source link

Option for clickable actions to run only once #398

Closed jorgemoralespou closed 4 weeks ago

jorgemoralespou commented 4 weeks ago

Is your feature request related to a problem? Please describe.

When you click on a clickable action, every time you do the action is executed. Sometimes, there's not a big issue with that, but sometimes the actions being executed are not idempotent so they should not be executed multiple times.

Describe the solution you'd like

I would like to have a flag/param to the clickable action that would prevent the action from running if it has already be run. Currently there's no way to know what clickable action has been executed as there's no state saved anywhere. It'll be ideal to provide them with an id (or similar) and use the browser's storage area, so that when navigating back and forth the state of the executions of the actions is preserved, and then add a once: true or similar param to the action that would prevent to run when clicked a second time.

Describe alternatives you've considered

No response

Additional information

No response

GrahamDumpleton commented 4 weeks ago

Easiest way will be to expose the "cooldown" setting which is configurable when a clickable action is registered but not when used (I don't think). It defaults to 2 seconds but you could override the delay or set to INF if want to prevent it altogether. Reloading a page would allow you to click it again.