Workflow transition remains restricted after approval definition has been deleted
Description
If users restricts a transition in a Jira space workflow with an approval definition and then deletes that definition from Approval Path, the workflow continues to be blocked even though the approval definition in question no longer exists.
We should unblock the transition in that case.
Change
-
Deleting a definition in Jira lists the workflow conditions, validators and Approval Path actions post functions (Start approval) that use it. Rules in team-managed spaces are named by space ("... in the Marketing space"); company-managed rules keep the workflow name. Users who are not Jira admins see space names only for spaces they can browse.
-
Jira admins pick a replacement in the same dialog: another definition, "All approvals completed" / "Any approval rejected" for conditions and validators, or leave the rules unchanged. Confirming re-reads the rules from Jira and updates the ones that still use the definition, keeping their current settings. The definition is deleted only when Jira updated every rule; otherwise the dialog shows why.
-
Users who can delete the definition but are not Jira admins see the list and "A Jira admin has to update these rules".
-
When no rule uses the definition, the dialog is the usual confirmation. Definitions deleted through the Web API work as before.
Decisions
-
The replacement select starts empty; Delete is enabled once a choice is made, including "Leave the rules unchanged".
-
With "All approvals completed" / "Any approval rejected", Start approval post functions stay unchanged, and the dialog says so.
-
Space admins who are not Jira admins cannot open the app's workflow rule screens. This is Atlassian's limit (ECO-986) and cannot be changed in the app.
-
Rules added through the Jira REST API must include
parameters.id(any UUID), as in Atlassian's REST docs for Forge rules. Jira doesn't return rules without it to the app and doesn't let apps update them, so the Delete definition dialog can't list or replace them. -
Rules in team-managed workflows are replaced through Jira's workflows API (the one Jira's own workflow editor uses), because Jira refuses the workflow rule API for some team-managed workflows. Company-managed workflows are updated as before.
Fixes included
-
The rule editor warns when its definition was deleted and requires picking another one; the rule view shows "a deleted definition" instead of an empty name. A definition from a space the editor cannot view is kept and shown as "a definition from a space you cannot view".
-
The Approval Path actions post function does the same for Start approval.
-
The delete dialog names conditions, validators and post functions, and leaves the sentence out when no rule uses the definition.
-
Delete is disabled with a tooltip while the workflow rules are being checked.
-
Table column headers start from the left in every table; sortable headers (for example ID, Definition Name, Name, Space) and the Actions header were centered.
-
If a workflow rule starts using the definition after the delete dialog listed the rules, Delete changes nothing and shows an error naming the workflow; cancel and delete the definition again to see the current list.
-
A definition used by more than 1,000 workflow rules gets the plain delete confirmation with the rules warning instead of the replace dialog.
-
After a failed replacement, the replacement select stays on the chosen option with a hint that Jira may already have updated some rules; to choose another option, cancel and delete the definition again.
-
The dialog's Close button is disabled while the deletion runs (delete dialog and the plain delete confirmation).
-
If the page, sort or filters change while the Delete action is checking the rules, the list reloads the page shown at that moment after the deletion.
-
A post function saved with an empty evaluator opens again instead of showing "Failed to load definitions".
-
On the Approval Path workflow rule screens (conditions, validators and the post function: create, edit and view), a user who is not a Jira admin sees the warning "Only Jira admins can view or edit Approval Path workflow rules" with "Atlassian lets apps open their workflow rule screens only for Jira admins." instead of an Authorization error and an empty screen.
-
Replacing a definition in rules of a team-managed business space no longer fails with Error 500 ("Cannot persist a workflow where mapping of project configurations is inconsistent").
Manual tester notes
-
In a Jira workflow, add on different transitions: "Approval Path - Block transition until approval" with definition A, "Approval Path Rejection Validator" with A, and "Approval Path actions" Start approval with A. Publish the workflow.
-
As a Jira admin, delete A in Approval Path definitions. The dialog lists the three rules with their transitions and workflow, and Delete stays disabled until you pick a replacement.
-
Pick "All approvals completed / Any approval rejected" and delete. The condition and validator now show the all-approvals / any-rejection setting. The post function shows "a deleted definition", and editing it asks you to pick a definition.
-
Repeat with another definition B as the replacement. All three rules show B, and the transition opens once B is approved.
-
Repeat with "Leave the rules unchanged". The rules show "a deleted definition", and the rule editor warns and does not save until you pick a definition.
-
As a space admin who is not a Jira admin, delete a space definition used by a rule. You see the list and "A Jira admin has to update these rules", and Delete works.
-
As a space admin who is not a Jira admin, open the workflow rule screen of a rule in a team-managed space: you see the warning "Only Jira admins can view or edit Approval Path workflow rules", not an Authorization error.
-
Use a definition in a team-managed space rule and in a company-managed workflow rule, then open Delete as a Jira admin and as a space admin: the team-managed rule is named by its space, the company-managed one by its workflow.
-
Use a definition as a blocker in a team-managed business space and in a company-managed workflow, delete it and pick a replacement: the delete succeeds and both rules use the replacement; the team-managed space's statuses and transitions are unchanged.
-
Add a rule that uses the definition through the Jira REST API with
parameters.idset (any UUID): the delete dialog lists it, and the replacement updates it like a rule added in the workflow editor. -
As a project admin of a team-managed project, open a rule bound to another space's definition. It shows "a definition from a space you cannot view", with no warning, and saving keeps it.
-
Delete a definition no rule uses. The dialog shows the usual text without the workflow sentence.
-
Open Definitions, Conditions and Activity: every column header starts from the left of its column.
-
Delete a definition used by a workflow rule; while the dialog is open, add the same definition to a condition on another workflow, then confirm: nothing is changed and the error names that workflow.
-
In the replace dialog, start a deletion and check the Close (X) button is disabled until it finishes.
-
On the definitions list, click Delete on a definition and switch to page 2 before the dialog opens; after deleting, page 2 is still shown.