How to add client web items as Dropdown 2 button

We created a new client web item for the file toolbar:

<web-resource key="file-resources" name="Web Resources for Files">
	[...]
</web-resource>
<client-web-item key="file-toolbar" name="File toolbar" section="bitbucket.file-content.source.toolbar.primary">
	<dependency>${atlassian.plugin.key}:file-resources</dependency>
	[...]
	<styleClass>aui-dropdown2-trigger</styleClass>
</client-web-item>


How can we add it as a real Dropdown 2 button, i.e. how can we popolate its list of values?
We would obtain something similar to the History button…

Thanks in advance.
Cheers.

We saw that the History dropdown button is populated by an async call to REST endpoint /rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/commits?followRenames&path&until&start&limit&avatarSize, so we created our own REST endpoint, too.
How should we popolate the dropdown list with those retrieved values?
Thanks in advance.
Cheers.

I don’t think this use case about using dropdown markup is supported with web-items.

What you could try to do, is to load additional JS files that can update the HTML on the page and then initialize the dropdown again.