UX: create category doesn't always need a dropdown (#24610)

This commit is contained in:
Kris 2023-11-28 16:28:07 -05:00 committed by GitHub
parent 2d2fd15636
commit 9576f3ec97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 14 deletions

View File

@ -22,10 +22,24 @@
{{/if}} {{/if}}
{{#if this.showCategoryAdmin}} {{#if this.showCategoryAdmin}}
<CategoriesAdminDropdown {{#if this.fixedCategoryPositions}}
@onChange={{action "selectCategoryAdminDropdownAction"}} <CategoriesAdminDropdown
@options={{hash triggerOnChangeOnTab=false}} @onChange={{action "selectCategoryAdminDropdownAction"}}
/> @options={{hash triggerOnChangeOnTab=false}}
/>
{{else}}
<DButton
@action={{this.createCategory}}
@icon="plus"
@label={{if
this.site.mobileView
"categories.category"
"category.create"
}}
class="btn-default"
id="create-category"
/>
{{/if}}
{{/if}} {{/if}}
{{#if (and this.category this.showCategoryEdit)}} {{#if (and this.category this.showCategoryEdit)}}

View File

@ -4,6 +4,7 @@ import { action } from "@ember/object";
import { dependentKeyCompat } from "@ember/object/compat"; import { dependentKeyCompat } from "@ember/object/compat";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
import { setting } from "discourse/lib/computed";
import { filterTypeForMode } from "discourse/lib/filter-mode"; import { filterTypeForMode } from "discourse/lib/filter-mode";
import { NotificationLevels } from "discourse/lib/notification-levels"; import { NotificationLevels } from "discourse/lib/notification-levels";
import NavItem from "discourse/models/nav-item"; import NavItem from "discourse/models/nav-item";
@ -14,6 +15,7 @@ export default Component.extend({
dialog: service(), dialog: service(),
tagName: "", tagName: "",
filterMode: tracked(), filterMode: tracked(),
fixedCategoryPositions: setting("fixed_category_positions"),
@dependentKeyCompat @dependentKeyCompat
get filterType() { get filterType() {

View File

@ -1,12 +1,10 @@
import { computed } from "@ember/object"; import { computed } from "@ember/object";
import { setting } from "discourse/lib/computed";
import I18n from "discourse-i18n"; import I18n from "discourse-i18n";
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box"; import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box";
export default DropdownSelectBoxComponent.extend({ export default DropdownSelectBoxComponent.extend({
pluginApiIdentifiers: ["categories-admin-dropdown"], pluginApiIdentifiers: ["categories-admin-dropdown"],
classNames: ["categories-admin-dropdown"], classNames: ["categories-admin-dropdown"],
fixedCategoryPositions: setting("fixed_category_positions"),
selectKitOptions: { selectKitOptions: {
icons: ["wrench", "caret-down"], icons: ["wrench", "caret-down"],
@ -26,14 +24,12 @@ export default DropdownSelectBoxComponent.extend({
}, },
]; ];
if (this.fixedCategoryPositions) { items.push({
items.push({ id: "reorder",
id: "reorder", name: I18n.t("categories.reorder.title"),
name: I18n.t("categories.reorder.title"), description: I18n.t("categories.reorder.title_long"),
description: I18n.t("categories.reorder.title_long"), icon: "random",
icon: "random", });
});
}
return items; return items;
}), }),