mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 01:24:48 +08:00
c34f8b65cb
As of #23867 this is now a real package, so updating the imports to use the real package name, rather than relying on the alias. The name change in the package name is because `I18n` is not a valid name as NPM packages must be all lowercase. This commit also introduces an eslint rule to prevent importing from the old I18n path. For themes/plugins, the old 'i18n' name remains functional.
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import { computed } from "@ember/object";
|
|
import { gte, reads } from "@ember/object/computed";
|
|
import { setting } from "discourse/lib/computed";
|
|
import DiscourseURL from "discourse/lib/url";
|
|
import I18n from "discourse-i18n";
|
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
|
|
|
export default ComboBoxComponent.extend({
|
|
pluginApiIdentifiers: ["group-dropdown"],
|
|
classNames: ["group-dropdown"],
|
|
content: reads("groupsWithShortcut"),
|
|
valueProperty: null,
|
|
nameProperty: null,
|
|
hasManyGroups: gte("content.length", 10),
|
|
enableGroupDirectory: setting("enable_group_directory"),
|
|
|
|
selectKitOptions: {
|
|
caretDownIcon: "caret-right",
|
|
caretUpIcon: "caret-down",
|
|
filterable: "hasManyGroups",
|
|
},
|
|
|
|
groupsWithShortcut: computed("groups.[]", function () {
|
|
const shortcuts = [];
|
|
|
|
if (this.enableGroupDirectory || this.get("currentUser.staff")) {
|
|
shortcuts.push(I18n.t("groups.index.all"));
|
|
}
|
|
|
|
return shortcuts.concat(this.groups);
|
|
}),
|
|
|
|
actions: {
|
|
onChange(groupName) {
|
|
if ((this.groups || []).includes(groupName)) {
|
|
DiscourseURL.routeToUrl(`/g/${groupName}`);
|
|
} else {
|
|
DiscourseURL.routeToUrl(`/g`);
|
|
}
|
|
},
|
|
},
|
|
});
|