I want to add a branch selector to my plugin, however, when I try to use the Stash.template.branchSelector.input template like this:
{template .view} <!DOCTYPE html> <html> <head> <meta name="decorator" content="stash.repository.general"> <meta name="projectKey" content="{$repository.project.key}"> <meta name="repositorySlug" content="{$repository.slug}"> <meta name="activeTab" content="branch-list"> <title>{$repository.slug}</title> </head> <body> {call widget.aui.pageHeader} {param contents} <h2>Branches</h2> {/param} {/call} {call widget.aui.form.form} {param action: '' /} {param contents} {call Stash.template.branchSelector.input} {param id: 'branch' /} {/call} {/param} {/call} </body> </html> {/template}
the selector is being rendered, but when I click on it, nothing happens - i.e. there are no options in the drop down list. Is there something else I need to add to use the branch selector?
Community moderators have prevented the ability to post new answers.
Hi Annie,
In addition to the HTML/JS that is generated from calling that Soy template, you will need the corresponding dependency which looks for those branch selectors in the DOM and 'activates' them.
<dependency>com.atlassian.stash.stash-web-api:branch-selector-field</dependency>
They were primarily intended to be used inside of the repositoy hooks, which has that dependency automatically. I'll update the documentation to ensure we mention this as well.
Cheers,
Charles
I also would like to listen for when the value in the branch selector drop-down changes (and make an ajax call), do you know of any way I can do this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Annie,
Just to warn you - we're starting to head into private API territory here. This stuff isn't documented mainly because haven't yet made the decision to support it officiall. You should keep in mind there is always a chance that it will break on a minor version release. (We do plan on adding more public and stable JS APIs in the future).
But to answer your question:
var events = require('util/events'); events.on('stash.feature.repository.revisionReferenceSelector.revisionRefChanged', function(revisionRef) { var branchSelectorField = this; var id = revisionRef.getId(); // TODO });
Does that help?
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I hit on the same trouble:
selector is being rendered, but when I click on it, nothing happens - i.e. there are no options in the drop down list
But I am deal with repository hook. What does the reason could be?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dana,
Are there any errors in the Chrome console? Do you see any activity in the Network tab?
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Charles,
I have described console errors:
1) https://answers.atlassian.com/questions/187876/why-doesn-t-branchselector-work
2) https://answers.atlassian.com/questions/188719/may-be-bug-in-branchselector
3) https://jira.atlassian.com/browse/STASH-3659
Short:
1. there is no items inside BranchSelector
2. 3 errors in console
2.1. Two of them (as mentioned Adam Ahmed in my question) are not very important, and do not affect on my hook. ( our discussion - in 1st question)
2.2. Third error is really very grave, I have state my thoughts in 2nd question. Because I doesnt get any answer, I had made bug report (3rd).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dana,
I'm sorry you're having problems with the branch selector.
I think Adam has answered your questions on both those points. If you have further questions or comments maybe leave them directly there.
Cheers,
Charles
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Charles,
I have described console errors:
1) https://answers.atlassian.com/questions/187876/why-doesn-t-branchselector-work
2) https://answers.atlassian.com/questions/188719/may-be-bug-in-branchselector
3) https://jira.atlassian.com/browse/STASH-3659
Short:
1. there is no items inside BranchSelector
2. 3 errors in console
2.1. Two of them (as mentioned Adam Ahmed in my question) are not very important, and do not affect on my hook. ( our discussion - in 1st question)
2.2. Third error is really very grave, I have state my thoughts in 2nd question. Because I doesnt get any answer, I had made bug report (3rd).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.