I am trying to update plugin compatibility from Jira 7.0.11 to 8.5.0 . I am getting issues with temporary file upload. Unable to find AJS.InlineAttach class and getting this error on frontend Uncaught TypeError: Cannot read property ‘AjaxPresenter’ of undefined.
File is not being received to the backend upon form submission and receiving null pointer exception .Also tried to load file explicitly by copying into webresource / including directly through script tag but did not work.
Hi @rpatil, InlineAttach comes from Jira codebase, not AUI, so it’s not related to AUI per se.
First, you need to add an explicit dependency on the following web-resource in your atlassian-plugin.xml file to be sure that the code you’re relying on will be provided to the browser:
Then, it’s preferred to use AMD modules over global variables. You can find InlineAttach exposed as jira/attachment/inline-attach.
An example of requiring AMD module:
define('your-prefix/your/amd/module-name', [
'some-amd-module-name-as-a-dependency',
'jira/attachment/inline-attach',
], function(someAmd, InlineAttach) {
// here you can use InlineAttach
});
I am getting two errors on browser console here.
Uncaught ReferenceError: define is not defined
at inline-attach.js:1 (at the start of js file)
and
Uncaught ReferenceError: require is not defined
at Import!showNormalizedTsvImport.jspa:12 where const InlineAttach = require(‘jira/attachment/inline-attach’); is defined
I’m afraid I don’t have a context what you’re building and in which environment.
Can you shed a light on this?
Given you wanted to use Jira modules, I assumed you’re writing an app (P2 plugin) for Jira.
In this context, you shouldn’t write your on script tags, just put explicit dependencies and other entires in your atlassian-plugin.xml (unless you’re using webpack along with Bitbucket then you don’t need to write those entires on your own)
and required assets will be included on the page (strictly speaking, a product makes calls to WRM which generates script and link tags which are put on the page).
The define function is a part of the AMD runtime that you can use to share the code and then require it using the require function.
The your-prefix/your/amd/module-name is an example of the module name that later you can require .e.g.:
define('your-prefix/your/amd/module-name', [], function() {
return function someFunction() {
console.log('Hello there!');
};
});
var someFunction = require('your-prefix/your/amd/module-name');
someFunction() // prints "Hello there!" in the browser console
From the description of your post, it looks like you are trying to inject the JavaScript code without using Web Resouce Manager (WRM).
The define function is part of the server/dc browser runtime, but it’s not registered in the runtime yet when you call it. Try moving all of your inline JS code from <script> tags to the `web-resource you can require later.
You can either use the webpack and atlassian-webresource-webpack-plugin webpack plugin, or you can define the web-resources manually in the atlassian-plugin.xml file.
Hi , I think problem here is I am unable to load webResource to the template. I removed js imported from tags and tried to check if AJS and other dependency js are being loaded to the page, But they are not loading. I do not see AMD modules like require and define being loaded while trying to search from console. Resulting in define / require not found errors.
Do we have any method to validate how we can check If dependency from webresource is being loaded or not ? It seems like WRM is not working here.
I created this web resource in atlassian-plugin.xml
Using <context>atl.general</context> is good for testing, as the resources from that web-resource are going to be present on every page, however it’s not suitable the production, because every page will be affected.
In the current shape, those resources (ajs, inline-attach) will be present on every page (not sure about admin pages, there may be another context such as atl.admin, good for testing too).
Hence, even without the later requireResource you should be able to see those assets loaded on the page.
are there any errors in the console log?
can you share a screenshot?
are you sure the app and its module are installed and enabled? (you can check that in the Manage apps, finding your app, and expanding modules)
are you able to share more of the source code (can be on a private repo or so) or a jar, so that we’d see a bigger picture what’s happening there?
for the production, you can change the atl.general context to some unique name for your feature, and do the following in the template: $webResourceManager.requireResourcesForContext('your.context.name')