Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To explain how to create an extension for dashboard gadgets, we will base this on an example using the Show Saved Filter with Columns for Jira plugin and its Show Saved Filter with Columns gadget.

 Step 1: Create the gadget feature and export it with PCJ

First create an example of a gadget in a dashboard in Jira, configuring it as required. The screenshot below shows an example configuration.

...

Notice how each gadget has several parameters that represent how you configured the gadget at the Jira user interface, setting preferences like the filter, the number of results to display, and the refresh period.

Step 2: Implement interface HookPointCollection

This step is the same as the example in Workflow Extensionsextensions. It is even possible to have workflow and gadget extensions within the same instance of HookPointCollection.

Step 3: Implement the gadget extension

Analyze

First, check which of the parameter elements in your gadget contain references to other entities in Jira. As with workflows, you have to specify how these references can be found in the configuration for dashboards and what their content is. In this example, you can find two references:

...

Focus on the parameter "filterId". If you check the filter setup during dashboard configuration, you will notice this parameter contains a string with the internal Jira ID for the selected filter. This means that this parameter will have to be translated to a different ID for a successful migration. This implies you will implement this extension as a GadgetTranslationPoint. If this parameter contained a reference to another entity that never requires a translation, then you would use a GadgetReferencePoint.

Define location

To identify a gadget extension point, you must specify two things:

...

This means the gadget type is identified by its URI (otherwise, it would contain a child <completeModuleKey> element). Use the text of the <type> element as a return value for the getTypeURIString() method of the associated GadgetTranslationPoint.

Define the content of the reference

This is described the same way as with workflow extensions. Navigate to the available predefined TranslateOption values that describe built-in translators and identify one that handles a filter ID:

...

Code Block
languagejava
package com.adaptavist.projectconfigurator.ssscextension;

import com.atlassian.plugin.spring.scanner.annotation.Profile;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; 
import com.awnaba.projectconfigurator.extensionpoints.common.HookPointCollection;
import com.awnaba.projectconfigurator.extensionpoints.extensionservices.ReferenceMarkerFactory; 
import com.awnaba.projectconfigurator.extensionpoints.extensionservices.TranslatorFactory; 
import com.awnaba.projectconfigurator.extensionpoints.gadget.GadgetTranslationPoint;
import com.awnaba.projectconfigurator.extensionpoints.gadget.GadgetTranslationPointImpl; 
import org.springframework.stereotype.Component;

import javax.inject.Inject; 

@Profile("pc4j-extensions")
@Component
public class SSSCExtensionModule implements HookPointCollection {

	private TranslatorFactory translatorFactory;
	private ReferenceMarkerFactory referenceMarkerFactory;
	@Inject
	public SSSCExtensionModule(@ComponentImport TranslatorFactory translatorFactory,
			@ComponentImport ReferenceMarkerFactory referenceMarkerFactory) { 
		this.translatorFactory = translatorFactory;
		this.referenceMarkerFactory = referenceMarkerFactory;
}

	public GadgetTranslationPoint getSSSCGadgetFilterHookPoint() { 
		return new GadgetTranslationPointImpl.Builder().
		withTranslator(translatorFactory.fromOption(TranslatorFactory.TranslateOption.FILTER_ID)).
		withUri("rest/gadgets/1.0/g/com.ja.jira.plugin.searchrequest:sswc-gadget/gadget_wc.xml"). 
		withParamKey("filterId").build();
	}
}
Infotip

And that's it!

You have now completed an integration of this gadget type with Project Configurator.

...