How to show "native" BitBucket messages?

Hi everybody. I’ve faced a problem how to show error/success messages.
I’ve used AJS.flag({});

But messages were not “native” (they looked differently as other BitBucket messages)
So I found out that

AP.require('messages', function (messages) {
    messages.error();
});

shows messages the same way as BitBucket does. But in this case I get an error that this approach is deprecated:

DEPRECATED API - AP.messages.error has been deprecated since ACJS 5.0 and will be removed in a future release. Use AP.flag.create instead.

When I use AP.flag.create I got an error

connect-host.js:5820 Uncaught TypeError: AJS.flag is not a function

Can somebody suggest a correct way to show messages? Thank you

1 Like

Unfortunately Bitbucket is in the middle of an upgrade of its Connect JS currently. That change is partially done and some of that partial work is leaking out. The most correct thing to do currently is:

AP.require('messages', function (messages) {
    messages.error();
});

See: https://developer.atlassian.com/cloud/bitbucket/jsapi/messages/. Unfortunately, its reported as a depreciated API but there isn’t a good way around this currently. That function will remain around for the foreseeable future.

I have raised an issue with the development team to correctly implement AP.flag.create. The documentation will be updated with all the good no-depreciated APIs once the upgrade is completely implemented.

1 Like

Thank you for clarification