Skip to content

A platform for community discussion. Free, open, simple.

DEV: Import `makeArray` from `discourse-common` instead using `Ember` global (#8977)

Jarek Radosz9f8a27a132c4
diff --git a/app/assets/javascripts/select-kit/components/multi-select.js.es6 b/app/assets/javascripts/select-kit/components/multi-select.js.es6
index 0557dc93e5a..a37eff583f2 100644
--- a/app/assets/javascripts/select-kit/components/multi-select.js.es6
+++ b/app/assets/javascripts/select-kit/components/multi-select.js.es6
@@ -81,7 +81,7 @@ export default SelectKitComponent.extend({
},
selectedContent: computed("value.[]", "content.[]", function() {
- const value = Ember.makeArray(this.value).map(v =>
+ const value = makeArray(this.value).map(v =>
this.selectKit.options.castInteger && this._isNumeric(v) ? Number(v) : v
);
diff --git a/app/assets/javascripts/select-kit/components/multi-select/multi-select-header.js.es6 b/app/assets/javascripts/select-kit/components/multi-select/multi-select-header.js.es6
index b9c500dc07a..83972945422 100644
--- a/app/assets/javascripts/select-kit/components/multi-select/multi-select-header.js.es6
+++ b/app/assets/javascripts/select-kit/components/multi-select/multi-select-header.js.es6
@@ -1,5 +1,6 @@
import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";
import { computed } from "@ember/object";
+import { makeArray } from "discourse-common/lib/helpers";
export default SelectKitHeaderComponent.extend({
classNames: ["multi-select-header"],
@@ -7,11 +8,11 @@ export default SelectKitHeaderComponent.extend({
"select-kit/templates/components/multi-select/multi-select-header",
selectedNames: computed("selectedContent", function() {
- return Ember.makeArray(this.selectedContent).map(c => this.getName(c));
+ return makeArray(this.selectedContent).map(c => this.getName(c));
}),
selectedValue: computed("selectedContent", function() {
- return Ember.makeArray(this.selectedContent)
+ return makeArray(this.selectedContent)
.map(c => {
if (this.getName(c) !== this.getName(this.selectKit.noneItem)) {
return this.getValue(c);
diff --git a/app/assets/javascripts/select-kit/components/select-kit.js.es6 b/app/assets/javascripts/select-kit/components/select-kit.js.es6
index 2a081a22500..3159d596a94 100644
--- a/app/assets/javascripts/select-kit/components/select-kit.js.es6
+++ b/app/assets/javascripts/select-kit/components/select-kit.js.es6
@@ -318,7 +318,7 @@ export default Component.extend(
validateSelect() {
this.clearErrors();
- const selection = Ember.makeArray(this.value);
+ const selection = makeArray(this.value);
const maximum = this.selectKit.options.maximum;
if (maximum && selection.length >= maximum) {
diff --git a/app/assets/javascripts/select-kit/components/user-chooser.js.es6 b/app/assets/javascripts/select-kit/components/user-chooser.js.es6
index ae8d75c5ec0..2342c89b97e 100644
--- a/app/assets/javascripts/select-kit/components/user-chooser.js.es6
+++ b/app/assets/javascripts/select-kit/components/user-chooser.js.es6
@@ -28,7 +28,7 @@ export default MultiSelectComponent.extend({
},
content: computed("value.[]", function() {
- return Ember.makeArray(this.value).map(x => this.defaultItem(x, x));
+ return makeArray(this.value).map(x => this.defaultItem(x, x));
}),
excludedUsers: computed(
diff --git a/app/assets/javascripts/select-kit/mixins/plugin-api.js.es6 b/app/assets/javascripts/select-kit/mixins/plugin-api.js.es6
index 6ff04393f27..370f301b152 100644
--- a/app/assets/javascripts/select-kit/mixins/plugin-api.js.es6
+++ b/app/assets/javascripts/select-kit/mixins/plugin-api.js.es6
@@ -1,5 +1,6 @@
import Mixin from "@ember/object/mixin";
import { isNone } from "@ember/utils";
+import { makeArray } from "discourse-common/lib/helpers";
let _appendContentCallbacks = {};
function appendContent(pluginApiIdentifiers, contentFunction) {
@@ -109,10 +110,10 @@ export function applyContentPluginApiCallbacks(
) {
identifiers.forEach(key => {
(_prependContentCallbacks[key] || []).forEach(c => {
- content = Ember.makeArray(c(selectKit, content)).concat(content);
+ content = makeArray(c(selectKit, content)).concat(content);
});
(_appendContentCallbacks[key] || []).forEach(c => {
- content = content.concat(Ember.makeArray(c(selectKit, content)));
+ content = content.concat(makeArray(c(selectKit, content)));
});
const filterCallbacks = _filterContentCallbacks[key] || [];
if (filterCallbacks.length) {