JavaScript resource not loaded for web panel in view issue screen

Hi,

I have created a plugin which uses a web panel within the view issue screen, and within this web panel a RESTful table should display. However, for some reason the JavaScript resource doesn’t seem to be loaded.

My web panel and main-resources are defined in the atlassian-plugin.xml as follows:

<web-resource key="main_resources" name="Main Web Resources">
    <dependency>com.atlassian.auiplugin:ajs</dependency>
    <dependency>com.atlassian.auiplugin:aui-experimental-restfultable</dependency>
    <context>main-resources</context>
</web-resource>
<web-panel name="Steps" key="steps" location="atl.jira.view.issue.left.context" weight="400">
    <description key="steps.description">Steps</description>
    <resource name="view" type="velocity" location="/templates/steps.vm"/>
    <resource type="download" name="steps.js" location="/js/steps.js"/>
</web-panel>

The velocity template file, steps.vm is as follows:

$webResourceManager.requireResourcesForContext("main-resources")
<div>
    <table id="steps-table"></table>
</div>

The JavaScript file, steps.js is as follows:

AJS.toInit(function() {
    // Basic Parameters

    new AJS.RestfulTable({
        autoFocus: true,
        el: jQuery("#steps-table"),
        allowReorder: true,
        noEntriesMsg: "Please add a Step.",
        resources: {
            all: "/rest/myplugin/1.0/step",
            self: "/rest/myplugin/1.0/step"
        },
        columns: [
            {
                id: "id",
                header: "Id",
                allowEdit: false
            },
            {
                id: "num",
                header: "#"
            },
            {
                id: "name",
                header: "Name"
            },
            {
                id: "description",
                header: "Description"
            }
        ]
    });
});

Looking at the developer tools in the browser, for the console I see no errors and I see that the ‘main-resources’ seem to be loaded. When looking at the network and the JS files that are loaded I don’t see the ‘steps.js’ resource at all. The path to the ‘steps.js’ file is 100% correct.

Does anyone have any idea whats going wrong here?

The solution I have found thus far is to include the JavaScript resource in a the web-resource section instead, in the atlassian-plugin.xml, like so:

<web-resource key="main_resources" name="Main Web Resources">
    <dependency>com.atlassian.auiplugin:ajs</dependency>
    <dependency>com.atlassian.auiplugin:aui-experimental-restfultable</dependency>
    <resource type="download" name="steps.js" location="/js/steps.js"/>
    <context>main-resources</context>
</web-resource>
<web-panel name="Steps" key="steps" location="atl.jira.view.issue.left.context" weight="400">
    <description key="steps.description">Steps</description>
    <resource name="view" type="velocity" location="/templates/steps.vm"/>
</web-panel>

I thought I would be able to include it as a resource directly in the web panel but I guess not.

What’s also important to note is you can declare multiple <web-resource> sections, so you can have a main <web-resource> for the things that are common to all web panels, and then other <web-resource> sections which are specific to certain web panels. Then you include the common <web-resource> in all VM templates, but only include the relevant specific <web-resource> in each VM template.