mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 17:45:13 +08:00
d9a02d1336
This reverts commit20780a1eee
. * SECURITY: re-adds accidentally reverted commit: 03d26cd6: ensure embed_url contains valid http(s) uri * when the merge commite62a85cf
was reverted, git chose the2660c2e2
parent to land on instead of the03d26cd6
parent (which contains security fixes)
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
import I18n from "I18n";
|
|
import { reads, gte } from "@ember/object/computed";
|
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
|
import DiscourseURL from "discourse/lib/url";
|
|
import { computed } from "@ember/object";
|
|
import { setting } from "discourse/lib/computed";
|
|
|
|
export default ComboBoxComponent.extend({
|
|
pluginApiIdentifiers: ["group-dropdown"],
|
|
classNames: ["group-dropdown"],
|
|
content: reads("groupsWithShortcut"),
|
|
tagName: "li",
|
|
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").toLowerCase());
|
|
}
|
|
|
|
return shortcuts.concat(this.groups);
|
|
}),
|
|
|
|
actions: {
|
|
onChange(groupName) {
|
|
if ((this.groups || []).includes(groupName)) {
|
|
DiscourseURL.routeToUrl(`/g/${groupName}`);
|
|
} else {
|
|
DiscourseURL.routeToUrl(`/g`);
|
|
}
|
|
}
|
|
}
|
|
});
|