mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 03:19:10 +00:00
FIX: register customOptions as select kit filter (#14933)
* FIX: register customOptions as select kit filter We are allowing plugins to define custom filters which are added to CUSTOM_USER_SEARCH_OPTIONS const. However, we need to have static placeholder for custom filters, so those props will be passed, and we can use it later. * fix
This commit is contained in:
parent
cc1b45f58b
commit
9ce29ad013
@ -4,6 +4,7 @@ import userSearch, {
|
||||
} from "discourse/lib/user-search";
|
||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||
import { computed } from "@ember/object";
|
||||
import { isPresent } from "@ember/utils";
|
||||
import { makeArray } from "discourse-common/lib/helpers";
|
||||
|
||||
export const CUSTOM_USER_SEARCH_OPTIONS = [];
|
||||
@ -27,6 +28,7 @@ export default MultiSelectComponent.extend({
|
||||
allowEmails: false,
|
||||
groupMembersOf: undefined,
|
||||
excludeCurrentUser: false,
|
||||
customSearchOptions: undefined,
|
||||
},
|
||||
|
||||
content: computed("value.[]", function () {
|
||||
@ -66,15 +68,18 @@ export default MultiSelectComponent.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
let customUserSearchOptions = CUSTOM_USER_SEARCH_OPTIONS.reduce(
|
||||
(obj, option) => {
|
||||
return {
|
||||
...obj,
|
||||
[option]: options[option],
|
||||
};
|
||||
},
|
||||
{}
|
||||
);
|
||||
let customUserSearchOptions = {};
|
||||
if (options.customSearchOptions && isPresent(CUSTOM_USER_SEARCH_OPTIONS)) {
|
||||
customUserSearchOptions = CUSTOM_USER_SEARCH_OPTIONS.reduce(
|
||||
(obj, option) => {
|
||||
return {
|
||||
...obj,
|
||||
[option]: options.customSearchOptions[option],
|
||||
};
|
||||
},
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
return userSearch({
|
||||
term: filter,
|
||||
|
Loading…
x
Reference in New Issue
Block a user