Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Branch Selector

Annie May 24, 2013

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?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2013

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

Annie May 25, 2013

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?

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 25, 2013

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

Annie May 26, 2013

It does, that's what I'm looking for, and I accept the risks :)

Dana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2013

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?

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2013

Hi Dana,

Are there any errors in the Chrome console? Do you see any activity in the Network tab?

Cheers,

Charles

Dana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2013

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).

cofarrell
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 15, 2013

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

0 votes
Dana
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 14, 2013

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).

TAGS
AUG Leaders

Atlassian Community Events