Skip to content

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

DEV: clean up review queue button classes (#32685)

Kris6551bd815519
diff --git a/app/assets/javascripts/discourse/app/components/reviewable-bundled-action.gjs b/app/assets/javascripts/discourse/app/components/reviewable-bundled-action.gjs
index 44c305e3dfe..6c04915241f 100644
--- a/app/assets/javascripts/discourse/app/components/reviewable-bundled-action.gjs
+++ b/app/assets/javascripts/discourse/app/components/reviewable-bundled-action.gjs
@@ -26,6 +26,20 @@ export default class ReviewableBundledAction extends Component {
return `${vertical}-${horizontal}`;
}
+ get buttonClass() {
+ const buttonIdentifier = dasherize(
+ this.first.button_class || this.first.id
+ );
+
+ if (buttonIdentifier === "reject-post") {
+ return "btn-danger";
+ } else if (buttonIdentifier === "approve-post") {
+ return "btn-success";
+ } else {
+ return "btn-default";
+ }
+ }
+
@action
perform(id) {
if (id) {
@@ -47,6 +61,8 @@ export default class ReviewableBundledAction extends Component {
disabled=@reviewableUpdating
placement=this.placement
+ customStyle=true
+ btnCustomClasses=this.buttonClass
}}
class={{concatClass
"reviewable-action-dropdown"
@@ -61,9 +77,10 @@ export default class ReviewableBundledAction extends Component {
@translatedLabel={{this.first.label}}
@disabled={{@reviewableUpdating}}
class={{concatClass
- "btn-default reviewable-action"
+ "reviewable-action"
(dasherize this.first.id)
this.first.button_class
+ this.buttonClass
}}
/>
{{/if}}
diff --git a/app/assets/stylesheets/common/base/reviewables.scss b/app/assets/stylesheets/common/base/reviewables.scss
index 79eb2a10eaf..8ede4338a0d 100644
--- a/app/assets/stylesheets/common/base/reviewables.scss
+++ b/app/assets/stylesheets/common/base/reviewables.scss
@@ -464,18 +464,6 @@
white-space: nowrap;
}
- .approve-post,
- .approve-post > summary {
- background-color: var(--success);
- color: var(--secondary);
- }
-
- .reject-post,
- .reject-post > summary {
- background-color: var(--danger);
- color: var(--secondary);
- }
-
.reviewable-action,
.reviewable-action-dropdown {
margin-right: 0.5em;
diff --git a/app/assets/stylesheets/common/components/buttons.scss b/app/assets/stylesheets/common/components/buttons.scss
index 16e520d1cf4..b08113a73f4 100644
--- a/app/assets/stylesheets/common/components/buttons.scss
+++ b/app/assets/stylesheets/common/components/buttons.scss
@@ -185,6 +185,16 @@
);
}
+.btn-success {
+ @include btn(
+ $text-color: var(--secondary),
+ $bg-color: var(--success),
+ $icon-color: var(--success-low),
+ $hover-bg-color: var(--success-hover),
+ $hover-icon-color: var(--success-low)
+ );
+}
+
// ✘ and ✔ buttons
// --------------------------------------------------
.btn.cancel {
diff --git a/spec/system/reviewables_spec.rb b/spec/system/reviewables_spec.rb
index 1a253d580c2..ea399257983 100644
--- a/spec/system/reviewables_spec.rb
+++ b/spec/system/reviewables_spec.rb
@@ -91,6 +91,16 @@ describe "Reviewables", type: :system do
expect(review_page).to have_no_post_body_collapsed
expect(review_page).to have_no_post_body_toggle
end
+
+ it "should apply correct button classes to actions" do
+ visit("/review")
+
+ expect(page).to have_css(".approve-post.btn-success")
+ expect(page).to have_css(".reject-post .btn-danger")
+
+ expect(page).to have_no_css(".approve-post.btn-default")
+ expect(page).to have_no_css(".reject-post .btn-default")
+ end
end
describe "when there is a queued post reviewable with a long post" do