Skip to content

FIX: remove sidebar filter #32485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion app/assets/javascripts/admin/addon/components/admin-search.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import didUpdate from "@ember/render-modifiers/modifiers/did-update";
import { service } from "@ember/service";
import { htmlSafe } from "@ember/template";
import { TrackedObject } from "@ember-compat/tracked-built-ins";
import { and, not } from "truth-helpers";
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
import DButton from "discourse/components/d-button";
import icon from "discourse/helpers/d-icon";
import discourseDebounce from "discourse/lib/debounce";
import { INPUT_DELAY } from "discourse/lib/environment";
import { escapeExpression } from "discourse/lib/utilities";
import autoFocus from "discourse/modifiers/auto-focus";
import { i18n } from "discourse-i18n";
import AdminSearchFilters from "admin/components/admin-search-filters";
Expand Down Expand Up @@ -62,6 +64,12 @@ export default class AdminSearch extends Component {
return !this.adminSearchDataSource.isLoaded || this.loading;
}

get noResultsDescription() {
return i18n("admin.search.no_results", {
filter: escapeExpression(this.filter),
});
}

@action
toggleFilters() {
this.showFilters = !this.showFilters;
Expand Down Expand Up @@ -91,7 +99,9 @@ export default class AdminSearch extends Component {
changeSearchTerm(event) {
this.searchResults = [];
this.filter = event.target.value;
this.runSearch();
if (this.filter.length > 0) {
this.runSearch();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to this PR but I don't think we are debouncing search at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

@action
Expand Down Expand Up @@ -219,6 +229,11 @@ export default class AdminSearch extends Component {
</a>
</div>
{{/each}}
{{#if (and (not this.searchResults) this.filter)}}
<p class="admin-search__no-results">
{{this.noResultsDescription}}
</p>
{{/if}}
</ConditionalLoadingSpinner>
</div>
</template>
Expand Down

This file was deleted.

82 changes: 0 additions & 82 deletions app/assets/javascripts/discourse/app/components/sidebar/filter.gjs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Component from "@glimmer/component";
import { service } from "@ember/service";
import BackToForum from "./back-to-forum";
import Filter from "./filter";
import FilterNoResults from "./filter-no-results";
import ToggleAllSections from "./toggle-all-sections";

export default class PanelHeader extends Component {
Expand All @@ -19,11 +17,7 @@ export default class PanelHeader extends Component {
<BackToForum />
<ToggleAllSections @sections={{@sections}} />
</div>
<div class="sidebar-panel-header__row">
<Filter />
</div>
</div>
<FilterNoResults @sections={{@sections}} />
{{/if}}
</template>
}
10 changes: 0 additions & 10 deletions app/assets/javascripts/discourse/app/lib/keyboard-shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ const DEFAULT_BINDINGS = {
"!": { postAction: "showFlags" },
"#": { handler: "goToPost", anonymous: true },
"/": { handler: "toggleSearch", anonymous: true },
"meta+/": { handler: "filterSidebar", anonymous: true },
[`${PLATFORM_KEY_MODIFIER}+/`]: { handler: "filterSidebar", anonymous: true },
"ctrl+alt+f": { handler: "toggleSearch", anonymous: true, global: true },
"=": { handler: "toggleHamburgerMenu", anonymous: true },
"?": { handler: "showHelpModal", anonymous: true },
Expand Down Expand Up @@ -495,14 +493,6 @@ export default {
composer.focusComposer(event);
},

filterSidebar() {
const filterInput = document.querySelector(".sidebar-filter__input");

if (filterInput) {
this._scrollTo(0);
}
},

fullscreenComposer() {
const composer = getOwner(this).lookup("service:composer");
if (composer.get("model")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ export const ADMIN_NAV_MAP = [
icon: "house",
moderator: true,
},
{
name: "admin_users",
route: "adminUsers",
label: "admin.config.users.title",
description: "admin.config.users.header_description",
icon: "users",
moderator: true,
},
{
name: "admin_search",
route: "adminSearch",
Expand All @@ -28,6 +20,14 @@ export const ADMIN_NAV_MAP = [
icon: "magnifying-glass",
moderator: true,
},
{
name: "admin_users",
route: "adminUsers",
label: "admin.config.users.title",
description: "admin.config.users.header_description",
icon: "users",
moderator: true,
},
{
name: "admin_groups",
route: "adminGroups",
Expand Down
19 changes: 0 additions & 19 deletions app/assets/javascripts/discourse/app/lib/sidebar/admin-sidebar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { cached } from "@glimmer/tracking";
import { warn } from "@ember/debug";
import { htmlSafe } from "@ember/template";
import { configNavForPlugin } from "discourse/lib/admin-plugin-config-nav";
import { adminRouteValid } from "discourse/lib/admin-utilities";
import { getOwnerWithFallback } from "discourse/lib/get-owner";
Expand All @@ -11,7 +10,6 @@ import BaseCustomSidebarPanel from "discourse/lib/sidebar/base-custom-sidebar-pa
import BaseCustomSidebarSection from "discourse/lib/sidebar/base-custom-sidebar-section";
import BaseCustomSidebarSectionLink from "discourse/lib/sidebar/base-custom-sidebar-section-link";
import { ADMIN_PANEL } from "discourse/lib/sidebar/panels";
import { escapeExpression } from "discourse/lib/utilities";
import I18n, { i18n } from "discourse-i18n";

let additionalAdminSidebarSectionLinks = {};
Expand Down Expand Up @@ -409,21 +407,4 @@ export default class AdminSidebarPanel extends BaseCustomSidebarPanel {
);
});
}

get filterable() {
return true;
}

filterNoResultsDescription(filter) {
const escapedFilter = escapeExpression(filter);

return htmlSafe(
i18n("sidebar.no_results.description_admin_search", {
filter: escapedFilter,
admin_search_url: getURL(
`/admin/search?filter=${encodeURIComponent(filter)}`
),
})
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ export default class BaseCustomSidebarPanel {
return false;
}

/**
* @returns {boolean} Controls whether the filter is shown
*/
get filterable() {
return false;
}

get expandActiveSection() {
return false;
}
Expand All @@ -65,17 +58,6 @@ export default class BaseCustomSidebarPanel {
return false;
}

/**
* @param {string} filter filter applied
*
* @returns {string | SafeString} Description displayed when the applied filter has no results.
* Use `htmlSafe` from `from "@ember/template` to use HTML strings.
*/
// eslint-disable-next-line no-unused-vars
filterNoResultsDescription(filter) {
return null;
}

#notImplemented() {
throw "not implemented";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { click, fillIn, triggerKeyEvent, visit } from "@ember/test-helpers";
import { click, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { AUTO_GROUPS } from "discourse/lib/constants";
import { withPluginApi } from "discourse/lib/plugin-api";
Expand Down Expand Up @@ -64,25 +64,6 @@ acceptance("Admin Sidebar - Sections", function (needs) {
.exists("advanced section is displayed");
});

test("filter sections and clear filter with ESC", async function (assert) {
await visit("/admin");
await fillIn(".sidebar-filter__input", "advanced");
assert
.dom(".sidebar-section[data-section-name='admin-plugins']")
.doesNotExist("plugins section is hidden");
assert
.dom(".sidebar-section[data-section-name='admin-advanced']")
.exists("advanced section is displayed");

await triggerKeyEvent(".sidebar-filter__input", "keydown", "Escape");
assert
.dom(".sidebar-section[data-section-name='admin-plugins']")
.exists("plugins section is displayed");
assert
.dom(".sidebar-section[data-section-name='admin-advanced']")
.exists("advanced section is displayed");
});

test("enabled plugin admin routes have links added", async function (assert) {
await visit("/admin");
await click(".sidebar-toggle-all-sections");
Expand Down
4 changes: 0 additions & 4 deletions app/assets/stylesheets/common/base/menu-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,6 @@
.badge-notification {
vertical-align: text-bottom;
}

.sidebar-filter {
width: 100%;
}
}

.search-menu .menu-panel {
Expand Down
Loading
Loading