Definitions: record the change reason and show the version history
Description
Goal
Every save of a definition already creates a new version with its number, date and author. Admins can't see why or from where a version was made, and they can't list a definition's versions. This ticket records the source of every change, shows the version history in the app, and exposes it in the Web API.
AP-2562 builds on this ticket: it adds viewing an earlier version and restoring it. It goes on its own branch, stacked on this one.
Product decisions
-
Change reason. Every new version records its source: made in the app, made through the Web API, or restored from an earlier version (that last one is used by AP-2562). A restored version also records which version it came from.
-
Labels shown to users: "Created in the app", "Updated in the app", "Created via Web API", "Updated via Web API", "Restored from version N". Versions saved before this release show just "Created" (version 1) or "Updated".
-
Author. The author is the person who saved: the signed-in user in the app, or the owner of the API key for Web API changes.
-
Version history page. It has its own page, built like Conditions / Configuration history. It is opened from:
-
a new "Version history" action on the definitions list (next to Edit / View);
-
a "Version history" link in the Audit section of the definition form, with the "New" badge.
-
-
History columns: version number (the current one marked "Current"), change, changed by, number of approvals still in progress on that version, and date. Newest first, paged.
-
Audit section. It gets a "Change" row showing the change reason of the shown version.
-
Who can see the history. Everyone who can open the definition from the definitions list today (Edit or View), with the same access rules. JSM customers and embedded previews have no access.
-
Web API (v2).
-
GET /definitions/{definitionId}/versions: paged list of versions with number, date, author, change reason, restored-from version, current flag and approvals in progress. -
GET /definitions/{definitionId}/versions/{version}: the full definition as it was in that version, in the same format asGET /definitions/{definitionId}. -
Both need the "Read definitions" permission. Listing history requires access to the current collection. Reading a full version also requires access to the collection it belonged to when saved.
-
GET /definitions/{definitionId}also returns the change reason of the current version.
-
-
Conditions. An earlier version is returned with today's condition, because conditions have their own history.
Acceptance criteria
-
Saving a definition in the app creates a version marked "Updated in the app" (or "Created in the app" for a new one) with the signed-in user as author.
-
Creating or updating a definition through the Web API creates a version marked "Created via Web API" / "Updated via Web API" with the API key owner as author.
-
The definitions list has a "Version history" row action for every definition that shows Edit or View. The Audit section has a "Change" row and a "Version history" link with the "New" badge.
-
The version history page lists all versions newest first, with paging, the "Current" marker on the latest version, the change label, the author with avatar, approvals in progress on each version, and the date. "Back to Definitions" returns to the list.
-
Approvals in progress count only running approvals on that exact version, not deleted, archived or finished ones.
-
Users who can't open the definition can't open its history (404 or 403), also through a crafted URL.
-
Both Web API endpoints work as described, return 404 for an unknown definition or version, and deny a key without access to the required collection. Jira may mask an inaccessible resource with 404. A key without Read definitions receives 403.
-
Works in the Jira and Confluence apps, and texts don't mention the other product.
Out of scope (possible follow-ups)
Viewing and restoring a version (AP-2562), comparing two versions, skipping a save that changes nothing, a warning when two people edit at the same time, recording which API key made a change.
Change
-
The Jira and Confluence definition lists and the form’s Audit section now open version history. The page supports paging and reload. The header stays visible while paging, and the table uses the same cell spacing as Definitions. A history page that fails to load shows no rows from the previous page.
-
New saves store the change source alongside the existing author and timestamp. The database adds two nullable columns, so earlier versions keep their original metadata.
-
Both product Web API specifications document the history endpoints with their parameters (limit max 200), responses, change labels and errors. Not-found messages name the definition and version, and
Definition.versionis described as "Version number of this definition."
Decisions taken
-
History summaries follow current collection access. Reading the full historical definition checks both collections when a definition has moved.
-
In the Audit section, the "Version history" link becomes "Save your changes..." whenever any setting differs from when the form opened (the deadline or validity type included), and is a link again after the change is reverted.
Fixes included
-
Serialize simultaneous definition saves and return the exact version created by each request.
-
Recheck collection access under the write lock if the definition moved. Reject a stale update if protected decision settings changed. Deletion remains available after a decision-setting change in the same collection.
-
Bound each history page to the version authorized for that request. Fetch its authors in a batch and count ongoing approvals only on the exact configurations returned, excluding outdated and expired approvals as well.
-
Enforce history access independently of portal enablement and preview flags. Changing the view parameter cannot grant history access.
Manual tester notes
-
In Jira and Confluence, create a definition, open Audit and follow Version history. Verify the date, author, Created in the app label and Current marker.
-
Start an approval, then update the definition through the Web API. Open history from the Definitions row. The original version should retain the running approval. The newer version should show the key owner and Updated via Web API.
-
Edit a name, leave the field, and check Audit. Revert the edit and open history. Repeat with Business time in a space with a work calendar.
-
Change the deadline type and see the Version history link turn into the save hint. Revert the change and see the link again.
-
With six versions, show five per page. Open page two and reload. The original version should appear there and only the newest version should show Current.
-
Check access as a delegated editor and a read-only viewer with Definitions access. Also check that the history action is absent in an embedded preview and the JSM customer portal.
-
Move a definition between collections and request its earlier version. Verify that only a caller authorized in both collections can read it.