A platform for community discussion. Free, open, simple.
DEV: Add `CurrentUserSerializer#use_reviewable_ui_refresh` attribute (#33460)
Alan Guo Xiang Tan0ec3fd570db9
diff --git a/app/assets/javascripts/discourse/app/templates/review-show.gjs b/app/assets/javascripts/discourse/app/templates/review-show.gjsindex 1020318efee..bcdce636ad4 100644--- a/app/assets/javascripts/discourse/app/templates/review-show.gjs+++ b/app/assets/javascripts/discourse/app/templates/review-show.gjs@@ -25,42 +25,16 @@ export default RouteTemplate(return owner.hasRegistration(`component:${dasherized}`);}- /**- * Determines if the current user can use the refreshed reviewable UI.- *- * @returns {boolean} True if the current user can access the refreshed UI, false otherwise- */- get canUseRefreshUI() {- if (!this.currentUser) {- return false;- }-- const allowedGroupIds =- this.args.controller.siteSettings.reviewable_ui_refresh;- if (!allowedGroupIds) {- return false;- }-- // Convert comma-separated string to array of numbers- const groupIds = allowedGroupIds- .toString()- .split(",")- .map((id) => parseInt(id.trim(), 10))- .filter((id) => !isNaN(id));-- // Check if current user is in any of the specified groups- return this.currentUser.groups.some((userGroup) =>- groupIds.includes(userGroup.id)- );- }-/*** Determines whether to use the refreshed reviewable UI component.** @returns {boolean} True if both conditions are met: user has permission and component exists*/get shouldUseRefreshUI() {- return this.canUseRefreshUI && this.refreshedReviewableComponentExists;+ return (+ this.currentUser.use_reviewable_ui_refresh &&+ this.refreshedReviewableComponentExists+ );}<template>diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rbindex 7b58cdb6588..bc921581421 100644--- a/app/serializers/current_user_serializer.rb+++ b/app/serializers/current_user_serializer.rb@@ -78,7 +78,8 @@ class CurrentUserSerializer < BasicUserSerializer:can_see_emails,:use_glimmer_post_stream_mode_auto_mode,:can_localize_content?,- :effective_locale+ :effective_locale,+ :use_reviewable_ui_refreshdelegate :user_stat, to: :object, private: truedelegate :any_posts, :draft_count, :pending_posts_count, :read_faq?, to: :user_stat@@ -342,4 +343,12 @@ class CurrentUserSerializer < BasicUserSerializerdef include_effective_locale?SiteSetting.content_localization_enabledend++ def use_reviewable_ui_refresh+ scope.can_see_reviewable_ui_refresh?+ end++ def include_use_reviewable_ui_refresh?+ scope.can_see_review_queue?+ endenddiff --git a/spec/system/reviewables_spec.rb b/spec/system/reviewables_spec.rbindex d88677410e8..d34f3fe29af 100644--- a/spec/system/reviewables_spec.rb+++ b/spec/system/reviewables_spec.rb@@ -331,4 +331,22 @@ describe "Reviewables", type: :system doexpect(review_page).to have_no_information_about_unknown_reviewables_visibleendend++ describe "when user is part of the groups list of the `reviewable_ui_refresh` site setting" do+ fab!(:reviewable_flagged_post)+ fab!(:group)++ before do+ SiteSetting.reviewable_ui_refresh = group.name+ group.add(admin)+ end++ it "shows the new reviewable UI" do+ sign_in(admin)++ visit "/review/#{reviewable_flagged_post.id}"++ expect(page).to have_selector(".review-container")+ end+ endend