Adding comments to server actions

I’ve just followed and implemented @Teodor’s excellent ‘Password Reset Functionality’ tutorial.

The process is entirely logical and similar to what I’ve used in the past. Looking through the server action steps, I can see how it works straightaway and at the moment I think it will be just as clear if I come back to it in six months time - perhaps if I need to tweak it a little. However I know I’m wrong. I’ll look at it in six months and I’ll stare at it blankly until I’ve examined it and probably expanded evey branch, looked at the POST parameters, looked at the query conditions, scratched my head etc…

I would never write even this relatively small amount of code without adding quite a few comments - I know I’ll regret it if I don’t and it always pays off.

I think it would be extremely useful if we could add comments - perhaps as another ‘step’. Adding comments to the JSON itself would be another option - but I imagine it might cause problems or be overwritten as changes are made.

I’ve added a screenshot below of just the second server action from Teodor’s tutorial - as an example of what I mean.

Hi @TomD,
Thanks for your suggestion, i cannot disagree with you about checking complex server action in six months.
Where/how do you think these comments should be added (in the UI) and where should they appear after that?
Maybe @George can clarify if it would be possible to add such options.

I think it would work well if there was an option to add ‘comments’ alongside the existing options:

image

Ideally a single summary could be created - corresponding to the information you might add at the top of a script etc. (but perhaps not necessary) - and multiple comments which could be created where needed, or dragged into any position. With the UI as it stands, I imagine there would only be space for a few words to be visible at a glance; more information could be displayed by hovering perhaps - or, better, there could be arrows like the existing ones, to expand the view to a multi-line display.

2 Likes

Excellent feature request @TomD!
My suggestion to implement the comments is a bit different though. Instead of adding another row to the already huge tree, every action could have a comment field, just like every action has a name field.
This comment could be shown as tooltip on hover, without having to click to view the comment in properties below. This will allow to see the comments even while adding or editing actions.

Additional issue/request: the name of action does not show up in the tree for all components.
image

DB query names are shown, but export csv name is not. Same can be seen for Response action in the original post image. These names, if used correctly help a lot to make sense of the tree too.

I think these are good suggestions. If it becomes possible to extend the amount of information which is displayed horizontally - particularly when server connect is viewed full screen - it would be great if comments (and other information) could be displayed without hovering etc…

I was looking at the App Connect tree and thinking how clear it is - and what a big difference it made when the highlight colours were added:

image

If server connect could be updated in a similar way it would be a big improvement - with comments and/or extra information such as values for repeats or conditions appearing like this.

2 Likes

I was just doing that :slight_smile:

4 Likes

Colors :white_check_mark:

3 Likes

there is another topic asking for this too, I can not find,
Really small things that would make a lot of difference.

Needed to comment a server action, more to psuedocode it before implementation rather than the commenting to document.

Came up with the idea of using “Set Value” to add a comment
I simply set a variable ‘comment’ and assign it a value which is the comment i want
The output looks like this, a very simple implementation but enough to show the principal

It’s not ideal having to use a workaround for such an important feature, but that’s a clever idea. I think I might use it - hopefully as a temporary workaround.

I imagine using this idea within a repeat might add some extra overhead and cause things to slow down a little.

Yes, a specific comment item would be useful but at least we have a workaround
i doubt a simple variable assignment is going to make any significant overhead on a server action. actions performed in memory are insignificant compared with database access overheads time wise

I agree - I think it would rarely have any impact. If you put your comments into a repeat with 10,000 iterations, that would be 60,000 unnecessary variable assignments which might have some impact (I have no idea how much).

This was implemented in Wappler 1.9.4 - now we have a comment as core action :slight_smile:

5 Likes

Great. I was looking for this but didn’t find it. I thought perhaps ‘next’ release was not this week’s. Thanks.

It’s under Core Actions in Server Connect :slight_smile:

2 Likes

image

4 Likes