The dashboards:widget and dashboards:backgroundScript modules are generally available for new Jira dashboards and replace the legacy jira:dashboardGadget and jira:dashboardBackgroundScript modules.
If you don't already see the dual-create option on your Jira development or test site, you can enroll the site in the Developer Canary Program to enable creation of either a classic Jira dashboard or a new dashboard. For rollout, migration, and deprecation details, see the Jira Dashboards announcement.
Use the widgetEdit APIs for dashboard widget edit operations and lifecycle management.
For module configuration and setup instructions, see Dashboard widget.
Registers a callback function that executes when the user saves the widget. Since the "Save" button is owned by the platform, you'll need to register this callback if you want to be notified when the user intends to save changes. This allows you to, for example, store the modifications on your own service.
1 2 3 4 5 6 7import { widgetEdit } from "@forge/dashboards-bridge"; widgetEdit.onSave(async (config, { widgetId }) => { console.log("Widget saved!", config, widgetId); // Perform custom save logic here });
Parameters:
1 2 3 4 5 6 7 8function onSave(callback: OnSave): void; type OnSave = ( config: WidgetConfig, widgetContext: Omit<WidgetContext, "widgetId"> & { widgetId: string }, context: Context, ) => Promise<void>;
Registers a callback that executes before the widget is saved in the product. Use this to transform config data or prevent product-level saves. Since the "Save" button is owned by the platform, you'll need to register this callback if you want to save the changes made by the user (or other relevant information) in the product dashboard itself. By default, no data is saved.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20import { widgetEdit } from "@forge/dashboards-bridge"; // Transform config before saving widgetEdit.onProductSave(async (config) => { return { ...config, timestamp: Date.now(), }; }); // Clear the widget configuration by returning null widgetEdit.onProductSave((config) => { return null; }); // Registering onSaveError is required to handle errors from onProductSave widgetEdit.onSaveError((error) => { console.error("Save failed:", error.message); });
Parameters:
null/undefined to clear the widget configuration.1 2 3 4 5 6 7 8 9function onProductSave(callback: OnProductSave): void; type OnProductSave = ( config: WidgetConfig, widgetContext: WidgetContext, context: Context, ) => Promise<WidgetConfig | null | undefined>; type WidgetConfig = Record<string, unknown>;
Registers a callback for handling save errors of the widget to the dashboard.
Registering widgetEdit.onSaveError is recommended for handling save errors, including validation errors, and required when using widgetEdit.onProductSave. Without this handler, save errors trigger the default failure mode, which crashes the form.
1 2 3 4 5 6 7import { widgetEdit } from "@forge/dashboards-bridge"; widgetEdit.onSaveError((error, widgetContext, context) => { console.error("Save failed:", error.message); // Handle error appropriately });
Parameters:
1 2 3 4 5 6 7 8function onSaveError(callback: OnSaveError): void; type OnSaveError = ( error: Error, widgetContext: WidgetContext, context: Context, ) => void;
Rate this page: