Community
Participate
Working Groups
I wanted to convert the "rename" command to use parameters. The trouble is that the default name shown in the box should be the current name of the item. We need a way to express the default based on the item in the command invocation. Probably just supply a default value function for the parameter which takes the command invocation (so that it could look at anything needed)...
tooltip has the same issue. If we wanted to distinguish, say, single vs. plural. Or provide more contextual tooltips for git, it would be nice to know the commandInvocation/items.
bug 370978 is more general case of this: not only do we want to supply the parameter value, but we may choose to remove a parameter completely because we don't need it. (ie, a non-private repo doesn't need credentials, but secure one does.)
there may be something simple we could try. We could put a function in the parameters description that computes the command parameters when the item is known (before doing the slideout). This would be a callback *in* the parameter description not in the command. That way we aren't penalizing commands who don't use parameters. I will investigate.
I'm not sure this bug truly blocks 370255 but would probably simplify it
We need to remember that Git commands know that credentials are needed once #callback is already called. For instance GitFetch command #callback does the following: tries to fetch, it gets a request for credentials from the server, shows the dialog and still being in #callback the command retries the fetch call.
fixed. what I've done is define a function that can be attached to the parameters. This function is called before the command service decides whether a slideout should be invoked before a callback. So the parameters can be defined on the fly. So where you before had: var gitAuthParameters = new mCommands.ParametersDescription([new mCommands.CommandParameter("sshuser", "text", "SSH User Name:"), new mCommands.CommandParameter("sshpassword", "password", "SSH Password:")], true); you can now say var gitAuthParameters = new mCommands.ParametersDescription([new mCommands.CommandParameter("sshuser", "text", "SSH User Name:"), new mCommands.CommandParameter("sshpassword", "password", "SSH Password:")], true, function(data) { if (data.items.... means no need to authenticate) { return null; } else if (data.items.....means we know the user but not password) { return [new mCommands.CommandParameter("sshpassword", password", "SSH Password:"]; } else { // we really need both return [new mCommands.CommandParameter("sshuser", "text", "SSH User Name:"), new mCommands.CommandParameter("sshpassword", "password", "SSH Password:")] } }); I tested this for some simple cases and verified that it was called before the slideout opens and changes the content/values of slideout. There might be things I didn't think about, please open bugs if this doesn't work for you. (In reply to comment #5) > We need to remember that Git commands know that credentials are needed once > #callback is already called. For instance GitFetch command #callback does the > following: tries to fetch, it gets a request for credentials from the server, > shows the dialog and still being in #callback the command retries the fetch > call. It can't work the way you describe. By definition, parameters are used to determine what should be collected by the command *before* a callback is called. However you should still be fine, move the credential logic to the parameter callback. I will annotate more in the dependent bugs.
fixed.