The jira:dashboardGadget
module creates a dashboard gadget that is displayed on the Dashboards page.
This module can be used in Jira Work Management, Jira Software, and Jira Service Management. See the DashboardGadget component documentation for an example.
Dashboard Gadgets can be configured using their edit mode.
Dashboard Gadgets can be refreshed manually by your users and automatically. The automatic refresh interval (in minutes) is configured by submitting a refresh
field as part of an edit view (the API accepts positive integers for this field).
When using the onSubmit
method in the DashboardGadgetEdit component, provide a refresh
field to the object returned by your onSubmit function.
1 2const onSubmit = () => ({ ...otherFieldsToSubmit, refresh: 15 });
When using Custom UI and UI Kit to work with the Dashboard Gadget module, use the submit API as part of your edit view to provide a refresh
field to the submit function:
1 2await view.submit({ ...otherFieldsToSubmit, refresh: 15 });
refreshable
property to false
in the gadget's manifest file.JIRA_DASHBOARD_GADGET_REFRESH
event using the events.on()
function from the Forge bridge.origin
and gadgetId
properties of the payload satisfy a condition.1 2import { events } from '@forge/bridge'; import { useEffect } from 'react'; function App() { useEffect(() => { const subscription = events.on('JIRA_DASHBOARD_GADGET_REFRESH', (payload) => { // the payload contains the following properties: // - payload.origin - either 'dashboard' or 'gadget' depending on which refresh button was clicked // - payload.gadgetId - the ID of the gadget initiating the refresh (only available if payload.origin === 'gadget') // you can obtain the ID of the currently rendered gadget using the view.getContext() function }); return () => { subscription.then(({ unsubscribe }) => unsubscribe()); }; }, []); // render the gadget }
When the user clicks the refresh button of any Forge dashboard gadget that has overridden the default refresh behavior, the
JIRA_DASHBOARD_GADGET_REFRESH
event will be triggered and all Forge gadgets will receive it. You can limit the scope of the refresh logic based on the available payload, for example withpayload.origin === 'dashboard' || payload.gadgetId === thisGadgetId
.
With Custom UI, you can define the same resource for viewing and editing your dashboard gadget.
First, define your manifest:
1 2modules: jira:dashboardGadget: - key: hello-world-gadget title: Hello world! description: A hello world dashboard gadget. thumbnail: https://developer.atlassian.com/platform/forge/images/icons/issue-panel-icon.svg resource: main # the resource used to view our dashboardGadget resolver: function: resolver edit: resource: main # the same resource, used to edit our dashboardGadget configuration resources: - key: main path: static/hello-world/build
Then in your Custom UI, use the view API to determine whether to display the view mode or edit mode:
1 2// App.jsx import React, { useEffect, useState } from 'react'; import { view } from '@forge/bridge'; import View from './View'; import Edit from './Edit'; function App() { const [context, setContext] = useState(); useEffect(() => { view.getContext().then(setContext); }, []); if (!context) { return 'Loading...'; } return context.extension.entryPoint === 'edit' ? <Edit/> : <View/>; } export default App;
Property | Type | Required | Description |
---|---|---|---|
key |
| Yes |
A key for the module, which other modules can refer to. Must be unique within the manifest. Regex: |
resource | string | If using Custom UI or modern versions of UI Kit | The key of a static resources entry that your module will display. See resources for more details. |
render | 'native' | If using modern versions of UI Kit | Indicates the module uses UI Kit. |
function | string | Deprecated Required if using UI Kit 1 | The key of a function module that returns a UI Kit 1 component. |
resolver | { function: string } or{ endpoint: string } |
Set the Set the | |
title | string or i18n object or { text: string, href: string } | Yes | Can be:
The |
description | string or i18n object | Yes |
A description of what the gadget does. The |
thumbnail | string | Yes | The absolute URL of the icon that's displayed next to the gadget's name and description in the list of gadgets that can be added to a dashboard. |
edit.function | string | If your editing experience uses UI Kit 1 | The key of a UI Kit 1 function module that provides the editing experience for your dashboard gadget. |
edit.resource | string | If your editing experience uses Custom UI or modern versions of UI Kit | The key of a static resources entry that provides the editing experience for your dashboard gadget. See Resources for more details.
To submit the view, use the submit API. |
edit.render | 'native' | If using modern versions of UI Kit | Indicates the editing experience uses UI Kit. |
refreshable | boolean | Set the refreshable property of the dashboard item to false to override the native Jira refresh behavior. | |
displayConditions | object | An object that defines whether the gadget is displayed on the list of gadgets available to install. If a gadget is already added to the dashboard, users without the permission to use it will see an error message. See display conditions. |
Internationalization (i18n) for Forge apps is now available through Forge's Early Access Program (EAP). For details on how to sign up for the EAP, see the changelog announcement.
EAPs are offered to selected users for testing and feedback purposes. APIs and features under EAP are unsupported and subject to change without notice. APIs and features under EAP are not recommended for use in production environments.
For more details, see Forge EAP, Preview, and GA.
Key | Type | Required | Description |
---|---|---|---|
i18n | string | Yes | A key referencing a translated string in the translation files. For more details, see Translations. |
Property | Type | Description |
---|---|---|
gadgetConfiguration | object | Object containing gadget configuration. |
dashboard.id | string | ID of the dashboard. |
gadget.id | string | ID of the gadget. |
type | string | The type of the module. |
Rate this page: