From 3da6759860e209ce0862c47ad75710182b4b4e0d Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Tue, 18 Jul 2023 09:41:38 +0800 Subject: [PATCH] FEATURE: Add admin dashboard warning for `legacy` navigation menu (#22655) Why this change? The `legacy` navigation menu option for the `navigation_menu` site setting will be removed shortly after the release of Discourse 3.1 in the first beta release of Discourse 3.2. Therefore, we're adding an admin dashboard warning to give sites on the `legacy` navigation menu a heads up. --- app/models/admin_dashboard_data.rb | 9 ++++++++- config/locales/server.en.yml | 1 + spec/models/admin_dashboard_data_spec.rb | 12 ++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/models/admin_dashboard_data.rb b/app/models/admin_dashboard_data.rb index a57b4d7c1b4..1e3c3c75356 100644 --- a/app/models/admin_dashboard_data.rb +++ b/app/models/admin_dashboard_data.rb @@ -207,7 +207,8 @@ class AdminDashboardData :unreachable_themes, :watched_words_check, :google_analytics_version_check, - :translation_overrides_check + :translation_overrides_check, + :legacy_navigation_menu_check register_default_scheduled_problem_checks @@ -367,6 +368,12 @@ class AdminDashboardData end end + def legacy_navigation_menu_check + if SiteSetting.navigation_menu == "legacy" + I18n.t("dashboard.legacy_navigation_menu_deprecated", base_path: Discourse.base_path) + end + end + def image_magick_check if SiteSetting.create_thumbnails && !system("command -v convert >/dev/null;") I18n.t("dashboard.image_magick_warning") diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index ce6f1bb5e8f..7e3831a69a3 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1491,6 +1491,7 @@ en: unreachable_themes: "We were unable to check for updates on the following themes:" watched_word_regexp_error: "The regular expression for '%{action}' watched words is invalid. Please check your Watched Word settings, or disable the 'watched words regular expressions' site setting." v3_analytics_deprecated: "Your Discourse is currently using Google Analytics 3, which will no longer be supported after July 2023. Upgrade to Google Analytics 4 now to continue receiving valuable insights and analytics for your website's performance." + legacy_navigation_menu_deprecated: "Your Discourse is currently using the 'legacy' navigation menu which will be removed in the first beta release of Discourse 3.2. Migrate to the new 'sidebar' navigation menu by updating your navigation menu site setting." site_settings: allow_bulk_invite: "Allow bulk invites by uploading a CSV file" diff --git a/spec/models/admin_dashboard_data_spec.rb b/spec/models/admin_dashboard_data_spec.rb index 4f93c786fd3..fec93548322 100644 --- a/spec/models/admin_dashboard_data_spec.rb +++ b/spec/models/admin_dashboard_data_spec.rb @@ -45,6 +45,18 @@ RSpec.describe AdminDashboardData do expect(problems.map(&:to_s)).to include("a problem was found") end end + + describe "when `navigation_menu` site setting is `legacy`" do + it "should include the right problem message" do + SiteSetting.set(:navigation_menu, "legacy") + + problem = AdminDashboardData.fetch_problems.last + + expect(problem.message).to include( + I18n.t("dashboard.legacy_navigation_menu_deprecated", base_path: Discourse.base_path), + ) + end + end end describe "adding scheduled checks" do