Opening a dialog module from web item module

In my atlassian-connect.json I have a module dialog defined:

        "dialogs": [
            {
                "url": "/import-dialog?issueId={issue.id}",
                "options": {
                    "size": "large",
                    "chrome": false
                },
                "key": "import-dialog"
            }
        ],

It opens as defined when I use this JS:

            AP.dialog.create({
                    key: 'import-dialog'
                }).on("close", function() {
                   //do something here
                });

Now I would like to open the very same dialog from an issue action. So I defined:

        "webItems": [
            {
                "key": "issue-action-import",
                "location": "operations-operations",
                "weight": 10,
                "name": {
                    "value": "My Import"
                },
                "url": "import-dialog",
                "context": "page"
            }
        ],

This opens the import dialog with the context variable (issue id and key, which I need), but not as a dialog. When I try to add the target dialog, it opens as dialog, but the context is lost.

What is the correct way to refer to dialogs that are modules?

Here is the correct way:

{
    "key": "issue-action-import",
    "location": "operations-operations",
    "weight": 10,
    "name": {
        "value": "My Import"
    },
    "target": {
        "type": "dialogmodule",
        "options": {
            "key": "import-dialog"
        }
    }
}
1 Like