A platform for community discussion. Free, open, simple.
FIX: remove admin_sidebar_enabled_groups setting (#31693)
Krzysztof Kotlarek54771b594982
diff --git a/app/assets/javascripts/admin/addon/controllers/admin.js b/app/assets/javascripts/admin/addon/controllers/admin.jsindex 02e21d55224..aece8c720a6 100644--- a/app/assets/javascripts/admin/addon/controllers/admin.js+++ b/app/assets/javascripts/admin/addon/controllers/admin.js@@ -7,11 +7,6 @@ export default class AdminController extends Controller {@service router;@service currentUser;- @discourseComputed("currentUser.use_admin_sidebar")- showAdminSidebar() {- return this.currentUser.use_admin_sidebar;- }-@discourseComputed("siteSettings.enable_group_directory")showGroups(enableGroupDirectory) {return !enableGroupDirectory;diff --git a/app/assets/javascripts/admin/addon/routes/admin.js b/app/assets/javascripts/admin/addon/routes/admin.jsindex 9d22347fe63..deca02b04fc 100644--- a/app/assets/javascripts/admin/addon/routes/admin.js+++ b/app/assets/javascripts/admin/addon/routes/admin.js@@ -50,10 +50,8 @@ export default class AdminRoute extends DiscourseRoute {});}- if (this.adminSidebarStateManager.currentUserUsingAdminSidebar) {- if (!transition?.to.name.startsWith("admin")) {- this.adminSidebarStateManager.stopForcingAdminSidebar();- }+ if (!transition?.to.name.startsWith("admin")) {+ this.adminSidebarStateManager.stopForcingAdminSidebar();}}diff --git a/app/assets/javascripts/admin/addon/services/admin-plugin-nav-manager.js b/app/assets/javascripts/admin/addon/services/admin-plugin-nav-manager.jsindex 28bd9b38efd..ea6b5c19343 100644--- a/app/assets/javascripts/admin/addon/services/admin-plugin-nav-manager.js+++ b/app/assets/javascripts/admin/addon/services/admin-plugin-nav-manager.js@@ -12,10 +12,6 @@ export default class AdminPluginNavManager extends Service {// This will be removed when all plugins follow the new "show route" pattern.@tracked viewingPluginsList = false;- get currentUserUsingAdminSidebar() {- return this.currentUser?.use_admin_sidebar;- }-get currentConfigNav() {const configNav = configNavForPlugin(this.currentPlugin.id);const settingsNav = {diff --git a/app/assets/javascripts/admin/addon/services/admin-sidebar-state-manager.js b/app/assets/javascripts/admin/addon/services/admin-sidebar-state-manager.jsindex 64cc77968f6..ed77fcca27e 100644--- a/app/assets/javascripts/admin/addon/services/admin-sidebar-state-manager.js+++ b/app/assets/javascripts/admin/addon/services/admin-sidebar-state-manager.js@@ -5,10 +5,7 @@ import { ADMIN_PANEL, MAIN_PANEL } from "discourse/lib/sidebar/panels";export default class AdminSidebarStateManager extends Service {@service sidebarState;- @service currentUser;- @alias("sidebarState.currentUserUsingAdminSidebar")- currentUserUsingAdminSidebar;@alias("sidebarState.isForcingAdminSidebar") isForcingAdminSidebar;keywords = {};@@ -48,11 +45,6 @@ export default class AdminSidebarStateManager extends Service {const isAdminSidebarActive =this.sidebarState.currentPanel?.key === ADMIN_PANEL;- if (!this.currentUserUsingAdminSidebar) {- this.isForcingAdminSidebar = false;- return false;- }-if (!opts.onlyIfAlreadyActive) {return this.#forceAdminSidebar();}diff --git a/app/assets/javascripts/admin/addon/templates/admin.hbs b/app/assets/javascripts/admin/addon/templates/admin.hbsindex 400399cc04d..0c2000916c7 100644--- a/app/assets/javascripts/admin/addon/templates/admin.hbs+++ b/app/assets/javascripts/admin/addon/templates/admin.hbs@@ -4,45 +4,6 @@<div class="row"><div class="full-width">- {{#unless this.showAdminSidebar}}- <div class="admin-main-nav">- <ul class="nav nav-pills">- <NavItem @route="admin.dashboard" @label="admin.dashboard.title" />- {{#if this.currentUser.admin}}- <NavItem- @route="adminSiteSettings"- @label="admin.site_settings.nav_title"- />- {{/if}}- <NavItem @route="adminUsers" @label="admin.users.title" />- {{#if this.showGroups}}- <NavItem @route="groups" @label="admin.groups.title" />- {{/if}}- {{#if this.showBadges}}- <NavItem @route="adminBadges" @label="admin.badges.title" />- {{/if}}- {{#if this.currentUser.admin}}- <NavItem @route="adminEmail" @label="admin.email.title" />- {{/if}}- <NavItem @route="adminLogs" @label="admin.logs.nav_title" />- <NavItem- @route="adminCustomizeThemes"- @routeParam="themes"- @label="admin.customize.title"- />- {{#if this.currentUser.admin}}- <NavItem @route="adminApiKeys" @label="admin.api_keys.title" />- <NavItem @route="adminWebHooks" @label="admin.web_hooks.title" />- {{#if this.siteSettings.enable_backups}}- <NavItem @route="admin.backups" @label="admin.backups.title" />- {{/if}}- <NavItem @route="adminPlugins" @label="admin.plugins.title" />- {{/if}}- <PluginOutlet @name="admin-menu" />- </ul>- </div>- {{/unless}}-<div class="boxed white admin-content"><div class="admin-contents {{this.adminContentsClassName}}">{{outlet}}diff --git a/app/assets/javascripts/admin/addon/templates/customize.hbs b/app/assets/javascripts/admin/addon/templates/customize.hbsindex d10e5b7de2a..de20dd22a3e 100644--- a/app/assets/javascripts/admin/addon/templates/customize.hbs+++ b/app/assets/javascripts/admin/addon/templates/customize.hbs@@ -1,63 +1,3 @@-{{#unless this.currentUser.use_admin_sidebar}}- <AdminNav>- {{#if this.currentUser.admin}}- <NavItem- @route="adminCustomizeThemes"- @routeParam="themes"- @label="admin.customize.theme.title"- class="admin-customize-themes"- />- <NavItem- @route="adminCustomize.colors"- @label="admin.customize.colors.title"- class="admin-customize-colors"- />- <NavItem- @route="adminSiteText"- @label="admin.site_text.title"- class="admin-customize-site-text"- />- <NavItem- @route="adminCustomizeEmailStyle"- @label="admin.customize.email_style.title"- class="admin-customize-email-styles"- />- <NavItem- @route="adminUserFields"- @label="admin.user_fields.title"- class="admin-customize-user-fields"- />- <NavItem- @route="adminEmojis"- @label="admin.emoji.title"- class="admin-customize-emojis"- />- <NavItem- @route="adminPermalinks"- @label="admin.permalink.title"- class="admin-customize-permalinks"- />- <NavItem- @route="adminEmbedding"- @label="admin.embedding.title"- class="admin-customize-embedding"- />- {{#if this.siteSettings.experimental_form_templates}}- <NavItem- @route="adminCustomizeFormTemplates"- @label="admin.form_templates.nav_title"- class="admin-customize-form-templates"- />- {{/if}}- {{/if}}- <NavItem- @route="adminWatchedWords"- @label="admin.watched_words.title"- class="admin-customize-watched-words"- />- </AdminNav>-{{/unless}}-<div class="admin-config-page">{{outlet}}</div>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/controllers/application.js b/app/assets/javascripts/discourse/app/controllers/application.jsindex 298c0bebcdc..19f9a3904ea 100644--- a/app/assets/javascripts/discourse/app/controllers/application.js+++ b/app/assets/javascripts/discourse/app/controllers/application.js@@ -95,10 +95,7 @@ export default class ApplicationController extends Controller {}// Always show sidebar for admin if user can see the admin sidbar- if (- this.sidebarState.isForcingAdminSidebar &&- this.sidebarState.currentUserUsingAdminSidebar- ) {+ if (this.sidebarState.isForcingAdminSidebar) {return true;}diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.js b/app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.jsindex 66ee82e7014..2b34d3e735e 100644--- a/app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.js+++ b/app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.js@@ -326,9 +326,6 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {const store = getOwnerWithFallback(this).lookup("service:store");const router = getOwnerWithFallback(this).lookup("service:router");const session = getOwnerWithFallback(this).lookup("service:session");- if (!currentUser.use_admin_sidebar) {- return [];- }this.adminSidebarStateManager = getOwnerWithFallback(this).lookup("service:admin-sidebar-state-manager"diff --git a/app/assets/javascripts/discourse/app/services/sidebar-state.js b/app/assets/javascripts/discourse/app/services/sidebar-state.jsindex 219de35d08a..bf1e8180978 100644--- a/app/assets/javascripts/discourse/app/services/sidebar-state.js+++ b/app/assets/javascripts/discourse/app/services/sidebar-state.js@@ -132,13 +132,9 @@ export default class SidebarState extends Service {return this.currentPanelKey === MAIN_PANEL;}- get currentUserUsingAdminSidebar() {- return this.currentUser?.use_admin_sidebar;- }-get adminSidebarAllowedWithLegacyNavigationMenu() {return (- this.currentUserUsingAdminSidebar &&+ this.currentUser?.staff &&this.siteSettings.navigation_menu === "header dropdown");}diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.jsindex 208c61f5057..5c7b779d378 100644--- a/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-sidebar-section-test.js@@ -11,7 +11,6 @@ acceptance("Admin Sidebar - Sections", function (needs) {needs.user({admin: true,groups: [AUTO_GROUPS.admins],- use_admin_sidebar: true,});needs.hooks.beforeEach(() => {@@ -131,7 +130,6 @@ acceptance("Admin Sidebar - Sections - Plugin API", function (needs) {needs.user({admin: true,groups: [AUTO_GROUPS.admins],- use_admin_sidebar: true,});needs.hooks.beforeEach(() => {@@ -254,7 +252,6 @@ acceptance(needs.user({admin: true,groups: [AUTO_GROUPS.admins],- use_admin_sidebar: true,});needs.hooks.beforeEach(() => {diff --git a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.jsindex d41d766cbfe..9b647c58263 100644--- a/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/admin-site-settings-test.js@@ -109,12 +109,12 @@ acceptance("Admin - Site Settings", function (needs) {assert.dom(".row.setting").exists({ count: 1 });// navigate away to the "Dashboard" page- await click(".nav.nav-pills li:nth-child(1) a");+ await click(".sidebar-section-link-wrapper:nth-child(1) a");assert.dom(".row.setting").exists({ count: 0 });// navigate back to the "Settings" page, the title filter// has been removed from navigation- await click(".nav.nav-pills li:nth-child(2) a");+ await click(".sidebar-section-link-wrapper:nth-child(5) a");assert.dom(".row.setting").exists({ count: 4 });});@@ -184,7 +184,7 @@ acceptance("Admin - Site Settings", function (needs) {await click("button.ok");assert.strictEqual(- pretender.handledRequests[pretender.handledRequests.length - 1]+ pretender.handledRequests.find((request) => request.method === "PUT").requestBody,"blocked_onebox_domains=proper.com");diff --git a/app/models/problem_check.rb b/app/models/problem_check.rbindex 5fbe3c38ee4..4235ea0759c 100644--- a/app/models/problem_check.rb+++ b/app/models/problem_check.rb@@ -61,7 +61,6 @@ class ProblemCheck# Note: This list must come after the `config_accessor` declarations.#CORE_PROBLEM_CHECKS = [- ProblemCheck::AdminSidebarDeprecation,ProblemCheck::BadFaviconUrl,ProblemCheck::EmailPollingErroredRecently,ProblemCheck::FacebookConfig,diff --git a/app/serializers/current_user_serializer.rb b/app/serializers/current_user_serializer.rbindex 87130115bd6..7d339597c12 100644--- a/app/serializers/current_user_serializer.rb+++ b/app/serializers/current_user_serializer.rb@@ -72,7 +72,6 @@ class CurrentUserSerializer < BasicUserSerializer:sidebar_category_ids,:sidebar_sections,:new_new_view_enabled?,- :use_admin_sidebar,:use_experimental_admin_search,:can_view_raw_email,:login_method,@@ -134,18 +133,10 @@ class CurrentUserSerializer < BasicUserSerializerscope.can_send_private_messages?end- def use_admin_sidebar- object.staff? && object.in_any_groups?(SiteSetting.admin_sidebar_enabled_groups_map)- end-def use_experimental_admin_searchobject.staff? && object.in_any_groups?(SiteSetting.experimental_admin_search_enabled_groups_map)end- def include_use_admin_sidebar?- object.staff?- end-def has_unseen_featuresDiscourseUpdates.has_unseen_features?(object.id)enddiff --git a/app/services/problem_check/admin_sidebar_deprecation.rb b/app/services/problem_check/admin_sidebar_deprecation.rbdeleted file mode 100644index 019ea60b909..00000000000--- a/app/services/problem_check/admin_sidebar_deprecation.rb+++ /dev/null@@ -1,14 +0,0 @@-# frozen_string_literal: true--class ProblemCheck::AdminSidebarDeprecation < ProblemCheck::ProblemCheck- self.priority = "low"-- def call- if SiteSetting.admin_sidebar_enabled_groups.present? &&- SiteSetting.admin_sidebar_enabled_groups != "-1"- return no_problem- end-- problem- end-enddiff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex f41758b1c1a..5269d3d4164 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2753,7 +2753,6 @@ en:glimmer_post_menu_mode: "Control whether the new 'glimmer' post menu implementation is used. 'auto' will enable automatically once all your themes and plugins are ready. This implementation is under active development, and is not intended for production use. Do not develop themes/plugins against it until the implementation is finalized and announced."glimmer_post_menu_groups: "Enable the new 'glimmer' post menu implementation in 'auto' mode for the specified user groups. This implementation is under active development, and is not intended for production use. Do not develop themes/plugins against it until the implementation is finalized and announced."experimental_form_templates: "Enable the form templates feature. Manage the templates at <a href='%{base_path}/admin/customize/form-templates'>Customize / Templates</a>."- admin_sidebar_enabled_groups: "Enable sidebar navigation for the admin UI for the specified groups, which replaces the top-level admin navigation buttons."lazy_load_categories_groups: "Lazy load category information only for users of these groups. This improves performance on sites with many categories."experimental_auto_grid_images: "Automatically wraps images in [grid] tags when 3 or more images are uploaded in the composer."page_loading_indicator: "Configure the loading indicator which appears during page navigations within Discourse. 'Spinner' is a full page indicator. 'Slider' shows a narrow bar at the top of the screen."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex db6a48789a8..6c71cb2fb43 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -2672,13 +2672,6 @@ navigation:- "top"- "bottom"area: "navigation"- admin_sidebar_enabled_groups:- type: group_list- list_type: compact- default: "1|2"- allow_any: false- refresh: true- area: "group_permissions|navigation"embedding:embed_by_username:diff --git a/db/migrate/20250307034117_remove_old_admin_sidebar_enabled_groups_site_settings.rb b/db/migrate/20250307034117_remove_old_admin_sidebar_enabled_groups_site_settings.rbnew file mode 100644index 00000000000..512767fb806--- /dev/null+++ b/db/migrate/20250307034117_remove_old_admin_sidebar_enabled_groups_site_settings.rb@@ -0,0 +1,10 @@+# frozen_string_literal: true+class RemoveOldAdminSidebarEnabledGroupsSiteSettings < ActiveRecord::Migration[7.2]+ def up+ execute "DELETE FROM site_settings WHERE name = 'admin_sidebar_enabled_groups'"+ end++ def down+ raise ActiveRecord::IrreversibleMigration+ end+enddiff --git a/docs/CHANGELOG-JAVASCRIPT-PLUGIN-API.md b/docs/CHANGELOG-JAVASCRIPT-PLUGIN-API.mdindex 41734b82fb1..2d58186a20a 100644--- a/docs/CHANGELOG-JAVASCRIPT-PLUGIN-API.md+++ b/docs/CHANGELOG-JAVASCRIPT-PLUGIN-API.md@@ -109,7 +109,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [1.24.0] - 2024-01-08-- Added `addAdminSidebarSectionLink` which is used to add a link to a specific admin sidebar section, as a replacement for the `admin-menu` plugin outlet. This only has an effect if the `admin_sidebar_enabled_groups` site setting is in use, which enables the new admin nav sidebar.+- Added `addAdminSidebarSectionLink` which is used to add a link to a specific admin sidebar section, as a replacement for the `admin-menu` plugin outlet.## [1.23.0] - 2024-01-03diff --git a/plugins/chat/spec/system/admin_sidebar_navigation_spec.rb b/plugins/chat/spec/system/admin_sidebar_navigation_spec.rbindex b15bca51d2a..8f38fb9298a 100644--- a/plugins/chat/spec/system/admin_sidebar_navigation_spec.rb+++ b/plugins/chat/spec/system/admin_sidebar_navigation_spec.rb@@ -7,7 +7,6 @@ describe "Admin Revamp | Sidebar Navigation | Plugin Links", type: :system dobefore dochat_system_bootstrap- SiteSetting.admin_sidebar_enabled_groups = Group::AUTO_GROUPS[:admins]sign_in(admin)enddiff --git a/plugins/footnote/spec/system/admin_sidebar_navigation_spec.rb b/plugins/footnote/spec/system/admin_sidebar_navigation_spec.rbindex 30e67dc169c..65e02bc8a90 100644--- a/plugins/footnote/spec/system/admin_sidebar_navigation_spec.rb+++ b/plugins/footnote/spec/system/admin_sidebar_navigation_spec.rb@@ -7,7 +7,6 @@ RSpec.describe "Admin | Sidebar Navigation", type: :system dobefore doSiteSetting.navigation_menu = "sidebar"- SiteSetting.admin_sidebar_enabled_groups = [Group::AUTO_GROUPS[:admins]]sign_in(admin)enddiff --git a/spec/services/problem_check/admin_sidebar_deprecation_spec.rb b/spec/services/problem_check/admin_sidebar_deprecation_spec.rbdeleted file mode 100644index aa684df7de1..00000000000--- a/spec/services/problem_check/admin_sidebar_deprecation_spec.rb+++ /dev/null@@ -1,35 +0,0 @@-# frozen_string_literal: true--RSpec.describe ProblemCheck::AdminSidebarDeprecation do- subject(:check) { described_class.new }-- describe ".call" do- before { SiteSetting.stubs(admin_sidebar_enabled_groups: configured) }-- context "when sidebar is enabled for some group" do- let(:configured) { "1" }-- it { expect(check).to be_chill_about_it }- end-- context "when sidebar is not enabled for any group" do- let(:configured) { "" }-- it do- expect(check).to have_a_problem.with_priority("low").with_message(- "The old admin layout is deprecated in favour of the new <a href='https://meta.discourse.org/t/-/289281'>sidebar layout</a> and will be removed in the next release. You can <a href='/admin/config/navigation?filter=admin%20sidebar'>configure</a> the new sidebar layout now to opt in before that.",- )- end- end-- context "when sidebar is set to -1 from the initial migration" do- let(:configured) { "-1" }-- it do- expect(check).to have_a_problem.with_priority("low").with_message(- "The old admin layout is deprecated in favour of the new <a href='https://meta.discourse.org/t/-/289281'>sidebar layout</a> and will be removed in the next release. You can <a href='/admin/config/navigation?filter=admin%20sidebar'>configure</a> the new sidebar layout now to opt in before that.",- )- end- end- end-enddiff --git a/spec/system/admin_dashboard_new_features_spec.rb b/spec/system/admin_dashboard_new_features_spec.rbindex a2e2e6014c1..5ce282f474b 100644--- a/spec/system/admin_dashboard_new_features_spec.rb+++ b/spec/system/admin_dashboard_new_features_spec.rb@@ -7,10 +7,6 @@ describe "Admin New Features Page", type: :system dobefore doSiteSetting.navigation_menu = "sidebar"- SiteSetting.admin_sidebar_enabled_groups = [- Group::AUTO_GROUPS[:admins],- Group::AUTO_GROUPS[:moderators],- ]sign_in(admin)enddiff --git a/spec/system/admin_sidebar_navigation_spec.rb b/spec/system/admin_sidebar_navigation_spec.rbindex 5bb89039ef3..2dd5e08f0e3 100644--- a/spec/system/admin_sidebar_navigation_spec.rb+++ b/spec/system/admin_sidebar_navigation_spec.rb@@ -12,10 +12,6 @@ describe "Admin | Sidebar Navigation", type: :system dobefore doSiteSetting.navigation_menu = "sidebar"- SiteSetting.admin_sidebar_enabled_groups = [- Group::AUTO_GROUPS[:admins],- Group::AUTO_GROUPS[:moderators],- ]sign_in(admin)end@@ -82,17 +78,6 @@ describe "Admin | Sidebar Navigation", type: :system doendend- context "when the setting is disabled" do- before { SiteSetting.admin_sidebar_enabled_groups = "" }-- it "does not show the admin sidebar" do- visit("/latest")- sidebar.click_link_in_section("community", "admin")- expect(page).to have_current_path("/admin")- expect(sidebar).to have_no_section("admin-root")- end- end-it "allows links to be filtered" dovisit("/admin")sidebar.toggle_all_sectionsdiff --git a/spec/system/navigation_menu_state_integration_spec.rb b/spec/system/navigation_menu_state_integration_spec.rbindex 47aa3a175dc..1d1cfb200a6 100644--- a/spec/system/navigation_menu_state_integration_spec.rb+++ b/spec/system/navigation_menu_state_integration_spec.rb@@ -58,15 +58,6 @@ describe "Navigation menu states", type: :system dovisit "/admin/reports"expect(sidebar_navigation).to be_visibleend-- context "when the user is not in admin_sidebar_enabled_groups" do- before { SiteSetting.admin_sidebar_enabled_groups = "" }-- it "does not show the sidebar" do- visit "/admin"- expect(sidebar_navigation).to be_not_visible- end- endendend@@ -108,21 +99,6 @@ describe "Navigation menu states", type: :system dovisit "/admin"expect(header_dropdown).to be_not_visibleend-- context "when the user is not in admin_sidebar_enabled_groups" do- before { SiteSetting.admin_sidebar_enabled_groups = "" }-- it "shows the MAIN_PANEL of the sidebar" do- visit "/admin"- expect(sidebar_navigation).to have_no_section("admin-root")- expect(sidebar_navigation).to have_section("community")- end-- it "does show the sidebar toggle" do- visit "/admin"- expect(page).to have_css(sidebar_navigation.header_toggle_css)- end- endendendend