From cd077ef93bf96550eb13ea110adc87edf4455c1e Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Wed, 23 Oct 2024 16:16:19 +1100 Subject: [PATCH] FIX: visual regression for new features (#29359) Bug introduced in this PR https://github.com/discourse/discourse/pull/29244 When the experiment toggle button was introduced, new features did not look right when the toggle button was not available. In addition, the plugin name can be an empty string. In that case, information about new features should be displayed. --- .../components/dashboard-new-feature-item.gjs | 16 ++++++++-------- .../stylesheets/common/admin/dashboard.scss | 5 +++++ lib/discourse_updates.rb | 2 +- spec/lib/discourse_updates_spec.rb | 4 +++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/admin/addon/components/dashboard-new-feature-item.gjs b/app/assets/javascripts/admin/addon/components/dashboard-new-feature-item.gjs index f1cecfe88eb..97ff49bd755 100644 --- a/app/assets/javascripts/admin/addon/components/dashboard-new-feature-item.gjs +++ b/app/assets/javascripts/admin/addon/components/dashboard-new-feature-item.gjs @@ -85,15 +85,15 @@ export default class DiscourseNewFeatureItem extends Component { {{/if}} -
- {{#if @item.screenshot_url}} - {{@item.title}} - {{/if}} + {{#if @item.screenshot_url}} + {{@item.title}} + {{/if}} +
diff --git a/app/assets/stylesheets/common/admin/dashboard.scss b/app/assets/stylesheets/common/admin/dashboard.scss index b80236a39da..da85e9d87ee 100644 --- a/app/assets/stylesheets/common/admin/dashboard.scss +++ b/app/assets/stylesheets/common/admin/dashboard.scss @@ -662,6 +662,7 @@ .admin-new-feature-item__body { display: flex; justify-content: space-between; + margin-bottom: 1em; .d-toggle-switch { margin-left: 1em; align-items: flex-start; @@ -670,6 +671,10 @@ margin-top: 0; } } + +.admin-new-feature-item__screenshot { + margin-bottom: 1em; +} .admin-new-feature-item__tooltip-header { font-weight: bold; } diff --git a/lib/discourse_updates.rb b/lib/discourse_updates.rb index c3e0fbf265e..3ddae519197 100644 --- a/lib/discourse_updates.rb +++ b/lib/discourse_updates.rb @@ -165,7 +165,7 @@ module DiscourseUpdates Discourse.has_needed_version?(current_version, item["discourse_version"]) valid_plugin_name = - item["plugin_name"].nil? || Discourse.plugins_by_name[item["plugin_name"]].present? + item["plugin_name"].blank? || Discourse.plugins_by_name[item["plugin_name"]].present? valid_version && valid_plugin_name rescue StandardError diff --git a/spec/lib/discourse_updates_spec.rb b/spec/lib/discourse_updates_spec.rb index 162ab900f3c..c53b362f461 100644 --- a/spec/lib/discourse_updates_spec.rb +++ b/spec/lib/discourse_updates_spec.rb @@ -291,6 +291,7 @@ RSpec.describe DiscourseUpdates do "created_at" => 2.days.ago, "plugin_name" => "discourse-ai", }, + { "emoji" => "🙈", "title" => "Whistles", "created_at" => 3.days.ago, "plugin_name" => "" }, { "emoji" => "🙈", "title" => "Confetti", @@ -303,8 +304,9 @@ RSpec.describe DiscourseUpdates do DiscourseUpdates.last_installed_version = "2.7.0.beta2" result = DiscourseUpdates.new_features - expect(result.length).to eq(1) + expect(result.length).to eq(2) expect(result[0]["title"]).to eq("Bells") + expect(result[1]["title"]).to eq("Whistles") end end