Skip to content

A platform for community discussion. Free, open, simple.

FIX: Unclaim reviewables when an action modal is cancelled. (#33377)

Gary Pendergastf1e9723e9619
diff --git a/app/assets/javascripts/discourse/app/components/reviewable-item.gjs b/app/assets/javascripts/discourse/app/components/reviewable-item.gjs
index f33dc46b087..d39521ee239 100644
--- a/app/assets/javascripts/discourse/app/components/reviewable-item.gjs
+++ b/app/assets/javascripts/discourse/app/components/reviewable-item.gjs
@@ -528,17 +528,19 @@ export default class ReviewableItem extends Component {
this.dialog.confirm({
message,
didConfirm: () => this._performConfirmed(performableAction),
+ didCancel: () => this.#unclaimAutomaticReviewable(),
});
}
} else if (actionModalClass) {
if (await this.#claimReviewable()) {
- this.modal.show(actionModalClass, {
+ await this.modal.show(actionModalClass, {
model: {
reviewable: this.reviewable,
performConfirmed: this._performConfirmed,
action: performableAction,
},
});
+ await this.#unclaimAutomaticReviewable();
}
} else {
return this._performConfirmed(performableAction);
diff --git a/spec/system/reviewables_spec.rb b/spec/system/reviewables_spec.rb
index ea399257983..e47f3d5014f 100644
--- a/spec/system/reviewables_spec.rb
+++ b/spec/system/reviewables_spec.rb
@@ -242,6 +242,26 @@ describe "Reviewables", type: :system do
)
end
+ it "claims the reviewable while revising, and unclaims it when cancelling" do
+ revise_modal = PageObjects::Modals::Base.new
+
+ review_page.visit_reviewable(queued_post_reviewable)
+
+ expect(queued_post_reviewable).to be_pending
+ expect(queued_post_reviewable.target_created_by).to be_present
+
+ review_page.select_action(queued_post_reviewable, "revise_and_reject_post")
+
+ expect(revise_modal).to be_open
+
+ expect(page).to have_css(".claimed-actions")
+
+ revise_modal.close
+
+ expect(revise_modal).to be_closed
+ expect(page).to have_no_css(".claimed-actions")
+ end
+
it "allows selecting a custom reason for revise and reject" do
revise_modal = PageObjects::Modals::Base.new