Skip to content

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

FIX: Restore post editing in the new reviewable UI (#35784)

Krzysztof Kotlarekb1154494f87d
diff --git a/app/assets/stylesheets/common/base/review.scss b/app/assets/stylesheets/common/base/review.scss
index 2c4f6a8ffe5..79d0c1dbafc 100644
--- a/app/assets/stylesheets/common/base/review.scss
+++ b/app/assets/stylesheets/common/base/review.scss
@@ -399,6 +399,10 @@
label {
display: block;
}
+
+ button {
+ justify-content: left;
+ }
}
.review-resources {
diff --git a/app/models/concerns/reviewable_action_builder.rb b/app/models/concerns/reviewable_action_builder.rb
index fecc17b6e94..f745e9fc013 100644
--- a/app/models/concerns/reviewable_action_builder.rb
+++ b/app/models/concerns/reviewable_action_builder.rb
@@ -82,7 +82,7 @@ module ReviewableActionBuilder
@guardian = guardian
@action_args = args
- if guardian.can_see_reviewable_ui_refresh?
+ if guardian.can_see_reviewable_ui_refresh? && !SiteSetting.reviewable_old_moderator_actions
build_new_separated_actions
else
build_legacy_combined_actions(actions, guardian, args)
diff --git a/config/site_settings.yml b/config/site_settings.yml
index ce0605c1f9a..276a15a77c3 100644
--- a/config/site_settings.yml
+++ b/config/site_settings.yml
@@ -4270,6 +4270,10 @@ experimental:
type: group_list
default: ""
area: "experimental"
+ reviewable_old_moderator_actions:
+ default: true
+ hidden: true
+ client: true
enable_upcoming_changes:
default: false
hidden: true
diff --git a/frontend/discourse/app/components/reviewable-refresh/item.gjs b/frontend/discourse/app/components/reviewable-refresh/item.gjs
index e1905e61d38..82bf4ae046c 100644
--- a/frontend/discourse/app/components/reviewable-refresh/item.gjs
+++ b/frontend/discourse/app/components/reviewable-refresh/item.gjs
@@ -1,7 +1,7 @@
/* eslint-disable ember/no-classic-components */
import { tracked } from "@glimmer/tracking";
import Component from "@ember/component";
-import { fn } from "@ember/helper";
+import { concat, fn } from "@ember/helper";
import { on } from "@ember/modifier";
import { action, set } from "@ember/object";
import { alias } from "@ember/object/computed";
@@ -24,6 +24,8 @@ import ReviewableInsights from "discourse/components/reviewable-refresh/insights
import ReviewableTimeline from "discourse/components/reviewable-refresh/timeline";
import concatClass from "discourse/helpers/concat-class";
import icon from "discourse/helpers/d-icon";
+import dasherizeHelper from "discourse/helpers/dasherize";
+import editableValue from "discourse/helpers/editable-value";
import { newReviewableStatus } from "discourse/helpers/reviewable-status";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
@@ -153,16 +155,19 @@ export default class ReviewableItem extends Component {
"reviewable.status",
"claimOptional",
"claimRequired",
- "reviewable.claimed_by"
+ "reviewable.claimed_by",
+ "siteSettings.reviewable_old_moderator_actions"
)
displayContextQuestion(
createdFromFlag,
status,
claimOptional,
claimRequired,
- claimedBy
+ claimedBy,
+ oldModeratorActions
) {
return (
+ oldModeratorActions &&
createdFromFlag &&
status === 0 &&
(claimOptional || (claimRequired && claimedBy !== null))
@@ -711,16 +716,37 @@ export default class ReviewableItem extends Component {
{{icon "d-post-share"}}
</button>
</div>
+ {{#if this.editing}}
+ <div class="editable-fields">
+ {{#each this.reviewable.editable_fields as |f|}}
+ <div class="editable-field {{dasherizeHelper f.id}}">
+ {{#let
+ (lookupComponent this (concat "reviewable-field-" f.type))
+ as |FieldComponent|
+ }}
+ <FieldComponent
+ @tagName=""
+ @value={{editableValue this.reviewable f.id}}
+ @tagCategoryId={{this.tagCategoryId}}
+ @valueChanged={{fn this.valueChanged f.id}}
+ @categoryChanged={{this.categoryChanged}}
+ />
+ {{/let}}
+ </div>
+ {{/each}}
+ </div>
+ {{else}}
- {{#let
- (lookupComponent this this.reviewableComponent)
- as |ReviewableComponent|
- }}
- <ReviewableComponent
- @reviewable={{this.reviewable}}
- @tagName=""
- />
- {{/let}}
+ {{#let
+ (lookupComponent this this.reviewableComponent)
+ as |ReviewableComponent|
+ }}
+ <ReviewableComponent
+ @reviewable={{this.reviewable}}
+ @tagName=""
+ />
+ {{/let}}
+ {{/if}}
</div>
<div class="review-item__insights">
@@ -773,9 +799,13 @@ export default class ReviewableItem extends Component {
{{#unless this.reviewable.last_performing_username}}
{{#if this.canPerform}}
<div class="review-item__moderator-actions">
- <h3 class="review-item__aside-title">{{i18n
- "review.moderator_actions"
- }}</h3>
+ <h3 class="review-item__aside-title">
+ {{#if this.displayContextQuestion}}
+ {{this.reviewable.flaggedReviewableContextQuestion}}
+ {{else}}
+ {{i18n "review.moderator_actions"}}
+ {{/if}}
+ </h3>
{{#if this.editing}}
<DButton
@disabled={{this.disabled}}
diff --git a/plugins/discourse-post-voting/spec/system/viewing_reviewable_spec.rb b/plugins/discourse-post-voting/spec/system/viewing_reviewable_spec.rb
index 9aee291b8ab..e5b8e737bdd 100644
--- a/plugins/discourse-post-voting/spec/system/viewing_reviewable_spec.rb
+++ b/plugins/discourse-post-voting/spec/system/viewing_reviewable_spec.rb
@@ -10,6 +10,7 @@ describe "Viewing reviewable post voting comment", type: :system do
let(:refreshed_review_page) { PageObjects::Pages::RefreshedReview.new }
before do
+ SiteSetting.reviewable_old_moderator_actions = false
SiteSetting.reviewable_ui_refresh = group.name
group.add(admin)
sign_in(admin)
diff --git a/spec/models/reviewable_flagged_post_spec.rb b/spec/models/reviewable_flagged_post_spec.rb
index 85728d1640f..4ff8f7e7695 100644
--- a/spec/models/reviewable_flagged_post_spec.rb
+++ b/spec/models/reviewable_flagged_post_spec.rb
@@ -316,6 +316,7 @@ RSpec.describe ReviewableFlaggedPost, type: :model do
context "when reviewable_ui_refresh enabled (separated bundles)" do
before do
+ SiteSetting.reviewable_old_moderator_actions = false
# Stub guardian check on reviewable to simulate feature flag on
allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
end
diff --git a/spec/models/reviewable_post_spec.rb b/spec/models/reviewable_post_spec.rb
index d422ea9aed2..3a50fc9cd2d 100644
--- a/spec/models/reviewable_post_spec.rb
+++ b/spec/models/reviewable_post_spec.rb
@@ -69,6 +69,7 @@ RSpec.describe ReviewablePost do
let(:admin_guardian) { Guardian.new(admin) }
before do
+ SiteSetting.reviewable_old_moderator_actions = false
allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
end
@@ -238,6 +239,7 @@ RSpec.describe ReviewablePost do
context "with new separated actions" do
before do
+ SiteSetting.reviewable_old_moderator_actions = false
allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
end
diff --git a/spec/models/reviewable_queued_post_spec.rb b/spec/models/reviewable_queued_post_spec.rb
index 57daeef8744..79d85f49d90 100644
--- a/spec/models/reviewable_queued_post_spec.rb
+++ b/spec/models/reviewable_queued_post_spec.rb
@@ -377,6 +377,7 @@ RSpec.describe ReviewableQueuedPost, type: :model do
context "when reviewable_ui_refresh feature is enabled" do
before do
+ SiteSetting.reviewable_old_moderator_actions = false
allow_any_instance_of(Guardian).to receive(:can_see_reviewable_ui_refresh?).and_return(true)
end
diff --git a/spec/system/page_objects/pages/refreshed_review.rb b/spec/system/page_objects/pages/refreshed_review.rb
index ede0e735468..c107b42a5d2 100644
--- a/spec/system/page_objects/pages/refreshed_review.rb
+++ b/spec/system/page_objects/pages/refreshed_review.rb
@@ -56,6 +56,18 @@ module PageObjects
end
end
+ def click_edit_post_button
+ find(".reviewable-action.edit").click
+ end
+
+ def fill_post_content(content)
+ find(".d-editor-input").fill_in(with: content)
+ end
+
+ def save_post_edit
+ find(".reviewable-action.save-edit").click
+ end
+
private
def reviewable_by_id(id)
diff --git a/spec/system/viewing_reviewable_spec.rb b/spec/system/viewing_reviewable_spec.rb
index 64a326647f5..804edf8a3ad 100644
--- a/spec/system/viewing_reviewable_spec.rb
+++ b/spec/system/viewing_reviewable_spec.rb
@@ -12,6 +12,7 @@ describe "Viewing reviewable item", type: :system do
describe "when user is part of the groups list of the `reviewable_ui_refresh` site setting" do
before do
SiteSetting.reviewable_ui_refresh = group.name
+ SiteSetting.reviewable_old_moderator_actions = false
group.add(admin)
sign_in(admin)
end
@@ -118,6 +119,23 @@ describe "Viewing reviewable item", type: :system do
end
end
+ describe "when the reviewable item is a queued post" do
+ fab!(:reviewable_queued_post)
+
+ it "allows to edit post when old moderator actions are enabled" do
+ SiteSetting.reviewable_old_moderator_actions = true
+ refreshed_review_page.visit_reviewable(reviewable_queued_post)
+
+ expect(page).to have_text("hello world post contents.")
+ refreshed_review_page.click_edit_post_button
+ refreshed_review_page.fill_post_content("Hello world from system spec!")
+ refreshed_review_page.save_post_edit
+
+ expect(page).to have_text("Hello world from system spec!")
+ expect(page).not_to have_text("hello world post contents.")
+ end
+ end
+
describe "when the reviewable item is a user" do
fab!(:user)
let(:rejection_reason_modal) { PageObjects::Modals::RejectReasonReviewable.new }