A platform for community discussion. Free, open, simple.
UX: reset review queue tab, don't look up insights every toggle (#39271)
Kris92521f46c34e
diff --git a/frontend/discourse/app/components/reviewable/item.gjs b/frontend/discourse/app/components/reviewable/item.gjsindex 610e736607d..fd61969da64 100644--- a/frontend/discourse/app/components/reviewable/item.gjs+++ b/frontend/discourse/app/components/reviewable/item.gjs@@ -38,7 +38,7 @@ import Category from "discourse/models/category";import Composer from "discourse/models/composer";import { PENDING } from "discourse/models/reviewable";import Topic from "discourse/models/topic";-import { eq } from "discourse/truth-helpers";+import { eq, not } from "discourse/truth-helpers";import { i18n } from "discourse-i18n";let _components = {};@@ -101,13 +101,16 @@ export default class ReviewableItem extends Component {@tracked disabled = false;@tracked activeTab = "timeline";+ @tracked insightsOpened = false;updating = null;editing = false;_updates = null;+ _previousReviewableId = null;constructor() {super(...arguments);+ this._previousReviewableId = this.reviewable?.id;this.messageBus.subscribe("/reviewable_claimed", this._updateClaimedBy);this.messageBus.subscribe("/reviewable_action", this._updateStatus);}@@ -118,6 +121,15 @@ export default class ReviewableItem extends Component {this.messageBus.unsubscribe("/reviewable_action", this._updateStatus);}+ didUpdateAttrs() {+ super.didUpdateAttrs(...arguments);+ if (this.reviewable?.id !== this._previousReviewableId) {+ this._previousReviewableId = this.reviewable?.id;+ this.activeTab = "timeline";+ this.insightsOpened = false;+ }+ }+@computed("reviewable.claimed_by.automatic")get autoClaimed() {return this.reviewable?.claimed_by?.automatic;@@ -610,6 +622,9 @@ export default class ReviewableItem extends Component {switchTab(tabName, event) {event.preventDefault();this.activeTab = tabName;+ if (tabName === "insights") {+ this.insightsOpened = true;+ }}@action@@ -832,9 +847,12 @@ export default class ReviewableItem extends Component {</HorizontalOverflowNav></div>- {{#if (eq this.activeTab "insights")}}- <ReviewableInsights @reviewable={{this.reviewable}} />- {{else if (eq this.activeTab "timeline")}}+ {{#if this.insightsOpened}}+ <div hidden={{not (eq this.activeTab "insights")}}>+ <ReviewableInsights @reviewable={{this.reviewable}} />+ </div>+ {{/if}}+ {{#if (eq this.activeTab "timeline")}}<ReviewableTimeline@reviewable={{this.reviewable}}@historyEvents={{this.reviewable.reviewable_histories}}diff --git a/spec/system/viewing_reviewable_spec.rb b/spec/system/viewing_reviewable_spec.rbindex e0c31263f9a..fcb544a197e 100644--- a/spec/system/viewing_reviewable_spec.rb+++ b/spec/system/viewing_reviewable_spec.rb@@ -252,6 +252,30 @@ describe "Viewing reviewable item" doexpect(review_page).to have_account_in_modal(other_user.username)end+ it "shows correct IP when navigating between reviewables" do+ other_reviewable =+ Fabricate(+ :reviewable_flagged_post,+ target_created_by: Fabricate(:user, ip_address: "2.125.160.216"),+ )++ Resolv::DNS+ .any_instance+ .stubs(:getname)+ .with("2.125.160.216")+ .returns("ip-2-125-160-216.example.com")++ review_page.visit_reviewable(reviewable_flagged_post)+ review_page.click_insights_tab++ expect(review_page).to have_ip_hostname("ip-81-2-69-142.example.com")++ review_page.visit_reviewable(other_reviewable)+ review_page.click_insights_tab++ expect(review_page).to have_ip_hostname("ip-2-125-160-216.example.com")+ end+context "when category moderator" dofab!(:category)fab!(:trust_level_1_user, :trust_level_1)