Skip to content

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

DEV: add value transformer to allow bulk select in nav controls (#31800)

Krisef48e761042e
diff --git a/app/assets/javascripts/discourse/app/components/d-navigation.hbs b/app/assets/javascripts/discourse/app/components/d-navigation.hbs
index 688b83648b8..e9722541f30 100644
--- a/app/assets/javascripts/discourse/app/components/d-navigation.hbs
+++ b/app/assets/javascripts/discourse/app/components/d-navigation.hbs
@@ -27,7 +27,7 @@
{{/unless}}
<div class="navigation-controls">
- {{#if (and this.notCategoriesRoute this.site.mobileView @canBulkSelect)}}
+ {{#if this.showBulkSelectInNavControls}}
<BulkSelectToggle @bulkSelectHelper={{@bulkSelectHelper}} />
{{/if}}
diff --git a/app/assets/javascripts/discourse/app/components/d-navigation.js b/app/assets/javascripts/discourse/app/components/d-navigation.js
index dcafa17c4b8..0c572be82a0 100644
--- a/app/assets/javascripts/discourse/app/components/d-navigation.js
+++ b/app/assets/javascripts/discourse/app/components/d-navigation.js
@@ -9,12 +9,14 @@ import { setting } from "discourse/lib/computed";
import discourseComputed from "discourse/lib/decorators";
import { filterTypeForMode } from "discourse/lib/filter-mode";
import { NotificationLevels } from "discourse/lib/notification-levels";
+import { applyValueTransformer } from "discourse/lib/transformer";
import NavItem from "discourse/models/nav-item";
@tagName("")
export default class DNavigation extends Component {
@service router;
@service dialog;
+ @service site;
@tracked filterMode;
@@ -24,6 +26,20 @@ export default class DNavigation extends Component {
return this.site.desktopView ? "topic.create" : "";
}
+ get showBulkSelectInNavControls() {
+ const enableOnDesktop = applyValueTransformer(
+ "bulk-select-in-nav-controls",
+ false,
+ { site: this.site }
+ );
+
+ return (
+ (this.site.mobileView || enableOnDesktop) &&
+ this.notCategoriesRoute &&
+ this.canBulkSelect
+ );
+ }
+
@dependentKeyCompat
get filterType() {
return filterTypeForMode(this.filterMode);
diff --git a/app/assets/javascripts/discourse/app/lib/transformer/registry.js b/app/assets/javascripts/discourse/app/lib/transformer/registry.js
index 0d892f896c4..759868396c5 100644
--- a/app/assets/javascripts/discourse/app/lib/transformer/registry.js
+++ b/app/assets/javascripts/discourse/app/lib/transformer/registry.js
@@ -11,6 +11,7 @@ export const BEHAVIOR_TRANSFORMERS = Object.freeze([
export const VALUE_TRANSFORMERS = Object.freeze([
// use only lowercase names
"admin-reports-show-query-params",
+ "bulk-select-in-nav-controls",
"category-available-views",
"category-description-text",
"category-display-name",