What happened to the ACJS v5 migration guide?

Last year Atlassian published a guide on updating Connect apps from atlassian-connect-js (ACJS) from v3 to v5. I wanted to check on it now because we’re still using some deprecated methods, but that guide seems to be gone.

It was published https://developer.atlassian.com/static/connect/docs/latest/tutorials/migrating-from-acjs-v3-to-v5.html but is no longer there. Is it still available somewhere?

(ps. when are you going to get a site search on developer.atlassian.com?)

3 Likes

Hi @charlie,

I’ve reached out to our team. Will let you know once I get the answer regarding the migration document.

Cheers,
Anne Calantog

It seems to have gotten lost in the migration to developer.atlassian.com. We’ll make sure it gets published again, but until then, I’ll just post it here.

Migrate to Atlassian Connect JavaScript V5

The Atlassian Connect JavaScript library has been updated to version 5. In this version we have overhauled and deprecated a lot of existing methods that were considered redundant.

You should update your JavaScript to use the new syntax as deprecated methods are no longer supported and will be removed after August 2017.

AMD: require and define

AP.require and AP.define has been deprecated in this version of Atlassian Connect JavaScript API.
The available modules can now be called directly from AP, such as AP.request or AP.jira.
No alternative will be provided for AP.define.

Old syntax

AP.require(['request', 'dialog'], function (request, dialog) {
    request({
        url: '/rest/api/content/123',
        success: function (data) {
            dialog.create({
                key: 'add-dialog-key',
                customData: {
                    contentData: data
                }
            });
        }
    });
});

New syntax

AP.request({
    url: '/rest/api/content/123',
    success: function (data) {
        AP.dialog.create({
            key: 'add-dialog-key',
            customData: {
                contentData: data
            }
        });
    }
});

If you have used AP.define, it recommended that you use another library such almond.js or require.js instead.

Messages

The Messages module has been deprecated and the Flag module should be used instead.

Old syntax using Messages

AP.require("messages", function(messages){
    var message = messages.info('plain text title', 'plain text body');
});

New syntax using Flag

var flag = AP.flag.create({
    title: 'plain text title',
    body: 'plain text body',
    type: 'info'
});

Dialog

customData

Dialog’s static customData member has been deprecated and has been replaced with the getCustomData(callback) method.

Old syntax using customData

AP.require('dialog', function(dialog){
    var myDataVariable = dialog.customData.myDataVariable;
});

New syntax using getCustomData(callback)

AP.dialog.getCustomData(function (customData) {
    var myDataVariable = customData.myDataVariable
});

onDialogMessage()

The onDialogMessage() method has been deprecated and the AP.events module should be used instead.

Old Syntax using onDialogMessage()

AP.require('dialog', function(dialog){
    dialog.onDialogMessage('submit', function() {
        console.log('dialog submitted!');
    });
});

New syntax using Events.on()

AP.events.on('dialog.submit', function () {
    console.log('dialog submitted!');
})

Dialog.on()

The Dialog.on() method has been deprecated and the AP.events module should be used instead.

Old syntax using Dialog.on()

AP.require('dialog', function(dialog){
    dialog.create(opts).on("close", function() {
        console.log('dialog closed!');
    });
});

New syntax using Events.on()

AP.events.on('dialog.close', function () {
    console.log('dialog closed!');
});

DialogButton.bind()

The DialogButton.bind() method has been deprecated the AP.events module should be used instead.

Old syntax using DialogButton.bind()

AP.require('dialog', function(dialog){
    dialog.getButton('submit').bind(function(){
        alert('clicked!');
    });
});

New syntax using Events.on()

AP.events.on('dialog.submit', function () {
    console.log('dialog submitted!');
})
5 Likes

Worth mentioning that in case of listening to dialog.submit event you most likely need to disable closing it on submission:

AP.dialog.disableCloseOnSubmit();
AP.events.on('dialog.submit', function () {
    console.log('dialog submitted!');
});
1 Like

Thanks! I appreciate the copy being posted here.

The documentation under Bitbucket Cloud Developer for the JavaScript API still has AP.require() in the examples.

1 Like