Last updated Apr 3, 2024

Branch Selector Field Soy template

bitbucket.component.branchSelector.field

Renders a full AUI form field with label, hidden input, and branch selector. In order to read the value selected in the branch selector you can get the value of the hidden input, which is automatically populated when users interact with the paired branch selector, or listen for the bitbucket.component.branchSelector.change event.

Non repository-hook users of this field will need to add a plugin dependency on com.atlassian.bitbucket.server.bitbucket-web-api:branch-selector-field to ensure required components are loaded.

Example usage

In your Soy template:

1
2
{call bitbucket.component.branchSelector.field}
  {param id: 'test-selector' /}
  {param labelText: 'Branch' /}
{/call}

In your JavaScript:

1
2
var branch = $('#test-selector').val();

Or alternatively listen for the bitbucket.component.branchSelector.change event. Note that this assumes the web resource containing your JavaScript depends on com.atlassian.bitbucket.server.bitbucket-web-api:events:

1
2
require([
    'bitbucket/util/events'
], function (events) {
    events.on('bitbucket.component.branchSelector.change', function (data) {
        console.log("The branch selector with id " + data.elementId + " was changed to  " + data.ref.displayId);
    });
});

Parameters

NameRequired?Description
idYesThe id of the input. Will default to name. At least one of id and name is required.
nameNoThe name of the input. Will default to id. At least one of id and name is required.
labelTextYesThe text to use as the label for this field
isRequiredNoWhether this field is required
descriptionTextNoDescription string for the field
errorTextsNoA list of strings for any errors that need to be displayed.
showTagsNoWhether to allow the user to select tags, as well as branches. False by default
initialValueNoa branch name (fully qualified with the refs/heads/ prefix) that is initially selected (or null)

bitbucket.component.branchSelector.input

Renders a hidden input and branch selector. The input will be automatically populated when users interact with the paired branch selector.

Parameters

NameRequired?Description
idYesThe id of the input. Will default to name. At least one of id and name is required.
nameNoThe name of the input. Will default to id. At least one of id and name is required.
initialValueNoa branch name (fully qualified with the refs/heads/ prefix) that is initially selected (or null)
showTagsNoWhether to allow the user to select tags, as well as branches. False by default

Rate this page: