Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

web-resource contexts

Stefan Gränitz September 6, 2011

I recently explored the possibility to include web-resources automatically on certain pages using contexts:

<web-resource key="some-scripts" name="Required for some operation">
<resource type="download" name="title.js" location="path/to/file.js" />
<context>jira.view.issue</context>
<context>jira.issue.create</context>
<context>jira.navigator.advanced</context>
<context>jira.navigator.simple</context>
<context>atl.error</context>
<context>atl.dashboard</context>
</web-resource>

The first tests work fine. Available context-names are documented here: http://confluence.atlassian.com/display/JIRADEV/Web+Resource+Plugin+Module#WebResourcePluginModule-contextsforjira

My questions:

Is this the complete list of ALL available contexts?

Can I use arbitrary substrings of this contexts? (If not, what are the limitatins?)

So e.g. can I use "jira.navigator" when I want "jira.navigator.advanced" AND "jira.navigator.simple", or "jira" when I want my resources being included everywhere?
Already tried the "jira.navigator" example and it worked (scripts were included in simple and advanced view), but when I tried "jira" for global scripts it failed..

This feature is very useful and exactly what I was looking for, so clarification would be nice.
Thanks in advice. Cheers, Stefan

7 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Wojciech Seliga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2011

Guys i think that it is impossible to list ALL available contexts. That would depend on:

  • JIRA version
  • plugins installed

Remember that JIRA consits of many bundled plugins (e.g. new project administration is a plugin, REST API too). In the future you can expect even more plugins constituting standard JIRA package.

Context is something which anything can request. It's just a string. It's not something pre-defined/hard-coded.

If you scan for the invocation of com.atlassian.plugin.webresource.WebResourceManager#requireResourcesForContext you will see thigs like:

  • jira.create.issue (not jira.issue.create)
  • jira.admin.conf

Any plugin in its page (while rendering it on the server side) can call WebResourceManager.requireResourcesForContext(...) "creating" by itself another custom context this plugin (or other) would prepare.

So as always: docs are great, but... use the force, read the source. JIRA makes it possible - you have the source code with any commercial license (even Starter).

Cheers,

Wojtek

Stefan Gränitz September 7, 2011

Ok, this might be a solution. And yes, obviously custom contexts cannot be documented. But I do not think that stepping through hundreds of WebResourceModuleDescriptor's looking for context strings is an appropriate development approach for all of your customers.

It would save us much time and headache if even the contexts of the plugins bundled with Jira by default were documented completely.

However, now I found the "jira.navigator" context as well as some more that could be useful - "jira.inline.dialog" for example. I will create a remark on the documentation page with a listing.

Wojciech Seliga
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 7, 2011

Sure, documentation should be up to date. Just I wanted to raise the fact that the list of available contexts is in flux.

Neverthess I hope it's visible that plugin documentation is getting better and better (e.g. visual examples of what can be hooked where and how).

4 votes
Adrien Ragot 2
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 13, 2016

Take this list with care:

  • That's the context which were used in bundled plugins. It says nothing about all contexts available.
  • If you start wanting to use a lot of contexts, then atl.general becomes a sensible choice, otherwise you may miss one situation (Check the issue view, check the sprint view, check the search, the new search, the new-new search, the kanbans, etc...)

 

&lt;context&gt;atl.admin&lt;/context&gt;
&lt;context&gt;atl.dashboard&lt;/context&gt;
&lt;context&gt;atl.general&lt;/context&gt;
&lt;context&gt;atl.global&lt;/context&gt;
&lt;context&gt;atl.plugins.webhooks.admin&lt;/context&gt;
&lt;context&gt;atl.userprofile&lt;/context&gt;
&lt;context&gt;browse-user&lt;/context&gt;
&lt;context&gt;com.atlassian.jira.board&lt;/context&gt;
&lt;context&gt;gh-rapid-config&lt;/context&gt;
&lt;context&gt;gh-rapid-exception&lt;/context&gt;
&lt;context&gt;gh-rapid-welcome&lt;/context&gt;
&lt;context&gt;gh-rapid&lt;/context&gt;
&lt;context&gt;global&lt;/context&gt;
&lt;context&gt;greenhopper-rapid-non-gadget&lt;/context&gt;
&lt;context&gt;greenhopper&lt;/context&gt;
&lt;context&gt;issue&lt;/context&gt;
&lt;context&gt;issueaction&lt;/context&gt;
&lt;context&gt;issuenavigation&lt;/context&gt;
&lt;context&gt;issuenavigationF&lt;/context&gt;
&lt;context&gt;jira-g-common-lite&lt;/context&gt;
&lt;context&gt;jira.edit.issue&lt;/context&gt;
&lt;context&gt;jira.global&lt;/context&gt;
&lt;context&gt;jira.navigator.advanced&lt;/context&gt;
&lt;context&gt;jira.navigator.simple&lt;/context&gt;
context&gt;jira.view.issue&lt;/context&gt;
&lt;context&gt;jira.workflow.administration&lt;/context&gt;
&lt;context&gt;jira.workflow.view&lt;/context&gt;
&lt;context&gt;scheduler-admin&lt;/context&gt;
Tim Eddelbüttel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 24, 2017

Thanks for this command smile

I need a context for JIRA Service Desk and the documentation has nothing about this:

So i extracted all plugins and run the command.

&lt;context&gt;admin.mail.incoming&lt;/context&gt;
&lt;context&gt;customerportal&lt;/context&gt;
&lt;context&gt;jira.admin&lt;/context&gt;
&lt;context&gt;jira.general&lt;/context&gt;
&lt;context&gt;jira.userprofile&lt;/context&gt;
&lt;context&gt;jira.view.issue&lt;/context&gt;
&lt;context&gt;sd.agent.view&lt;/context&gt;
&lt;context&gt;sd.error.page&lt;/context&gt;
&lt;context&gt;sd.project.admin&lt;/context&gt;
&lt;context&gt;sd.project.reports&lt;/context&gt;
&lt;context&gt;sd.project.settings&lt;/context&gt;
&lt;context&gt;sd.project.sidebar.content&lt;/context&gt;
&lt;context&gt;sd.project.view&lt;/context&gt;
Like # people like this
1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 6, 2011

"but when I tried "jira" for global scripts it failed" - it should be jira.general, there is no context called "jira".

0 votes
Stefan Gränitz September 7, 2011

Nevertheless clarification is appreciated.

0 votes
Stefan Gränitz September 6, 2011

I don't think the match method has much to do with handling the contexts. There is only one implementation com.atlassian.plugin.webresource.DefaultWebResourceFilter. Setting a breakpoint shows that it receives just filenames like "jquery.js" and checks whether it is a .js or .css file.

After looking through the sources a bit deeper, I found the com.atlassian.plugin.webresource.WebResourceManagerImpl::requireResourcesForContext method, which iterates over all webResourceModuleDescriptors and checks whether the given context-name is in a java.util.Set<String> collection returned by getContexts(). The comparison is done using the contains method of the Set, which usually only fires on equality.

So my conclusion is, that there is no provision for such a generalization approach (although this would make the mechanism extremely flexible). As a result I guess in real there are more contexts than docs listing provides.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 6, 2011

true. com.atlassian.plugin.webresource.WebResourceFilter has one method called "match", which makes me think maybe you're right about substrings, but I can't find any source for it.

0 votes
Stefan Gränitz September 6, 2011

ok thats right. but..there is also no context called "jira.navigator" listed in the docs. may this listing be incomplete?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events