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 this.showCategoryAdmin}}
<CategoriesAdminDropdown
@onChange={{action "selectCategoryAdminDropdownAction"}}
@options={{hash triggerOnChangeOnTab=false}}
/>
{{#if this.fixedCategoryPositions}}
<CategoriesAdminDropdown
@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 (and this.category this.showCategoryEdit)}}

View File

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

View File

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