Dashboard gadget: approval charts framework and pie chart

Description

Add a configurable Jira dashboard gadget that presents approvals as charts, complementing the list/detailed gadget (AP-626). This ticket covers the shared visualization framework and the first chart type: pie. The other types (bar / grouped bar / stacked bar, line, table / 2D table) are covered by separate follow-up tasks and reuse this framework.

The gadget author configures everything in the edit view; viewers only look at the result. Visibility, space scoping, and filtering follow the same rules and controls as AP-626.

Framework (shared across all chart types)

Top bar

  • Approval source (data scope selection, analogous to the source selection on the list).

  • Filters as on the approvals list (Approval name, Definition, Status, Priority, Space, JQL, More filters), including the awaiting-decision-by-user filter with the "current user" option (a dynamic filter that uses the context of the user viewing the gadget).

  • Chart type selection: pie, bar, grouped bar, stacked bar, line, table, 2D table. (This ticket implements pie; the other types are added in follow-up.)

  • Group by: the field the values are split by, placed in the top bar after the chart type.

Layout (split)

  • Live preview of the chart on the left (expandable to full width). The preview reflects the author's own permissions and is indicative only; actual content for each viewer is computed per viewer.

  • Configuration on the right in tabs. The set of tabs depends on the chart type; tabs common to all types are chart name and description, and auto-refresh.

Visibility model (computed server-side, per viewing user)

Chart aggregates are computed only over the set of approvals the viewing user is entitled to see, using the same rules as AP-626:

  • Global admin: all approvals.

  • Space admin of the configured space (if a space is configured; otherwise as a regular user): all approvals in that space.

  • Regular user: only their own approvals matching the filter criteria.

Hard requirement: a chart must never aggregate or count approvals the viewer could not see as a list. Aggregations are built server-side on the already-filtered set (author's configured filters AND viewer entitlement), so the chart cannot become a side channel revealing counts of approvals the viewer has no access to. The "current user" filter resolves to the viewing user, not the author. JQL filters only within the already-resolved set; it never widens visibility.

Viewer experience (view mode, read-only)

  • Viewers do not see any configuration controls.

  • Edit configuration: shown only to users who can edit the dashboard (native gadget behaviour, i.e. dashboard Editors).

  • Refresh the chart.

  • Clicking a value in the chart legend (the approval count or its percentage share) opens, in a new tab, the approvals list with the chart's filters and narrowed to the selected Group by value. The count link and the percentage link are the same. The data scope on the list follows the viewer's context (it is the same list view whose scope depends on permissions: a global admin sees a wider set, a regular user a narrower one).

Persistence

  • Gadget configuration: per gadget instance, native gadget configuration (edit view): chart type, filters, type-specific configuration, name/description, display options.

  • Auto-refresh interval: stored via the refresh field on edit-view submit.

Pie chart (type in scope for this ticket)

Group by

The pie requires a Group by field (in the top bar) that the values are split by. Available fields are grouped into approval fields (e.g. Status, Priority, Originator, Definition, Current step, Space, Approver, Decision deadline and Validity expiration bucketed by time) and work item / Confluence page fields (e.g. Assignee, Reporter, Issue type, Project, custom fields; for Confluence, space and page author).

Presentation

  • Chart title: "Approvals by [Group by]" (default, editable).

  • Pie chart on the left; on the right a list of values split by the Group by criterion, each with a count and a percentage share.

  • A total row below (overall value).

  • When there are more values than the default chart height, a "Show all" option expands all values.

Pie configuration (tabs on the right)

  • Group by tab: the list of all chart values, each with an assigned color (color can be changed) and support for reordering the values.

  • Name tab: change the chart name and description.

  • Display tab: disable the total row, enable auto-refresh.

Acceptance criteria

  • The gadget has a top bar with the approval source, filters as on the list (including the "current user" option), chart type selection (pie, bar, grouped bar, stacked bar, line, table, 2D table), and Group by after the chart type.

  • This ticket implements the pie type; the framework allows the other types to be added as separate tasks.

  • The edit view has a split layout: live preview on the left (expandable to full width) and tabbed configuration on the right, depending on the chart type.

  • The pie requires selecting a Group by field; approval fields and work item / Confluence page fields are available.

  • The pie title defaults to "Approvals by [Group by]" and is editable.

  • The pie shows the chart on the left and a list of values with count and percentage share on the right, with a total row below.

  • When there are more values than the default height, a "Show all" option expands all values.

  • The Group by tab lists all chart values and allows changing each value's color and reordering the values.

  • The Name tab allows changing the chart name and description; the Display tab allows disabling the total row and enabling auto-refresh.

  • Each chart respects the viewer's permissions (global admin all; space admin of the configured space all in that space; regular user only their own approvals matching the filter); the "current user" filter resolves to the viewing user.

  • Aggregates are never computed over approvals the viewer is not entitled to see; aggregation is done server-side on the already-filtered, entitled set.

  • Clicking a legend value (count or percentage) opens, in a new tab, the approvals list with the chart's filters and narrowed to the selected Group by value; the count and percentage links are identical, and the data scope follows the viewer's context.

  • The view is read-only for configuration; the Edit action is available only to users who can edit the dashboard.

  • Per-instance configuration is stored in the gadget configuration; the auto-refresh interval via the refresh field.

Notes / open points

  • The refresh field / JIRA_DASHBOARD_GADGET_REFRESH handling should filter by gadgetId, since the event is broadcast to all Forge gadgets.

  • Follow-up: bar / grouped bar / stacked bar, line, table / 2D table as separate tasks reusing this framework.