mirror of
https://github.com/discourse/discourse.git
synced 2025-04-10 10:02:25 +08:00
REFACTOR: Ember.makeArray
was removed from the public API
This commit is contained in:
parent
90f934a660
commit
89f602f66b
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { debounce } from "@ember/runloop";
|
import { debounce } from "@ember/runloop";
|
||||||
import { schedule } from "@ember/runloop";
|
import { schedule } from "@ember/runloop";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
@ -49,10 +50,10 @@ export default Component.extend({
|
|||||||
if (!chartCanvas) return;
|
if (!chartCanvas) return;
|
||||||
|
|
||||||
const context = chartCanvas.getContext("2d");
|
const context = chartCanvas.getContext("2d");
|
||||||
const chartData = Ember.makeArray(
|
const chartData = makeArray(
|
||||||
model.get("chartData") || model.get("data")
|
model.get("chartData") || model.get("data")
|
||||||
);
|
);
|
||||||
const prevChartData = Ember.makeArray(
|
const prevChartData = makeArray(
|
||||||
model.get("prevChartData") || model.get("prev_data")
|
model.get("prevChartData") || model.get("prev_data")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { debounce } from "@ember/runloop";
|
import { debounce } from "@ember/runloop";
|
||||||
import { schedule } from "@ember/runloop";
|
import { schedule } from "@ember/runloop";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
@ -52,7 +53,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
const context = chartCanvas.getContext("2d");
|
const context = chartCanvas.getContext("2d");
|
||||||
|
|
||||||
const chartData = Ember.makeArray(
|
const chartData = makeArray(
|
||||||
model.get("chartData") || model.get("data")
|
model.get("chartData") || model.get("data")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { alias } from "@ember/object/computed";
|
import { alias } from "@ember/object/computed";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
@ -91,7 +92,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
@computed("sortLabel", "sortDirection", "model.data.[]")
|
@computed("sortLabel", "sortDirection", "model.data.[]")
|
||||||
sortedData(sortLabel, sortDirection, data) {
|
sortedData(sortLabel, sortDirection, data) {
|
||||||
data = Ember.makeArray(data);
|
data = makeArray(data);
|
||||||
|
|
||||||
if (sortLabel) {
|
if (sortLabel) {
|
||||||
const compare = (label, direction) => {
|
const compare = (label, direction) => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { alias, or, and, reads, equal, notEmpty } from "@ember/object/computed";
|
import { alias, or, and, reads, equal, notEmpty } from "@ember/object/computed";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import { next } from "@ember/runloop";
|
import { next } from "@ember/runloop";
|
||||||
@ -108,7 +109,7 @@ export default Component.extend({
|
|||||||
displayedModes(currentMode, reportModes, forcedModes) {
|
displayedModes(currentMode, reportModes, forcedModes) {
|
||||||
const modes = forcedModes ? forcedModes.split(",") : reportModes;
|
const modes = forcedModes ? forcedModes.split(",") : reportModes;
|
||||||
|
|
||||||
return Ember.makeArray(modes).map(mode => {
|
return makeArray(modes).map(mode => {
|
||||||
const base = `btn-default mode-btn ${mode}`;
|
const base = `btn-default mode-btn ${mode}`;
|
||||||
const cssClass = currentMode === mode ? `${base} is-current` : base;
|
const cssClass = currentMode === mode ? `${base} is-current` : base;
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { empty, alias } from "@ember/object/computed";
|
import { empty, alias } from "@ember/object/computed";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { on } from "ember-addons/ember-computed-decorators";
|
import { on } from "ember-addons/ember-computed-decorators";
|
||||||
@ -31,7 +32,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
@computed("choices.[]", "collection.[]")
|
@computed("choices.[]", "collection.[]")
|
||||||
filteredChoices(choices, collection) {
|
filteredChoices(choices, collection) {
|
||||||
return Ember.makeArray(choices).filter(i => collection.indexOf(i) < 0);
|
return makeArray(choices).filter(i => collection.indexOf(i) < 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
keyDown(event) {
|
keyDown(event) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { empty, notEmpty, match } from "@ember/object/computed";
|
import { empty, notEmpty, match } from "@ember/object/computed";
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||||
@ -126,8 +127,8 @@ export default Controller.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.get("parentController.model.content").forEach(theme => {
|
this.get("parentController.model.content").forEach(theme => {
|
||||||
const children = Ember.makeArray(theme.get("childThemes"));
|
const children = makeArray(theme.get("childThemes"));
|
||||||
const rawChildren = Ember.makeArray(theme.get("child_themes"));
|
const rawChildren = makeArray(theme.get("child_themes"));
|
||||||
const index = children ? children.indexOf(model) : -1;
|
const index = children ? children.indexOf(model) : -1;
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
children.splice(index, 1);
|
children.splice(index, 1);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { inject } from "@ember/controller";
|
import { inject } from "@ember/controller";
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
import { setting } from "discourse/lib/computed";
|
import { setting } from "discourse/lib/computed";
|
||||||
@ -8,7 +9,7 @@ import PeriodComputationMixin from "admin/mixins/period-computation";
|
|||||||
|
|
||||||
function staticReport(reportType) {
|
function staticReport(reportType) {
|
||||||
return Ember.computed("reports.[]", function() {
|
return Ember.computed("reports.[]", function() {
|
||||||
return Ember.makeArray(this.reports).find(
|
return makeArray(this.reports).find(
|
||||||
report => report.type === reportType
|
report => report.type === reportType
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -95,7 +96,7 @@ export default Controller.extend(PeriodComputationMixin, {
|
|||||||
this.setProperties({
|
this.setProperties({
|
||||||
dashboardFetchedAt: new Date(),
|
dashboardFetchedAt: new Date(),
|
||||||
model: adminDashboardModel,
|
model: adminDashboardModel,
|
||||||
reports: Ember.makeArray(adminDashboardModel.reports).map(x =>
|
reports: makeArray(adminDashboardModel.reports).map(x =>
|
||||||
Report.create(x)
|
Report.create(x)
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import { escapeExpression } from "discourse/lib/utilities";
|
import { escapeExpression } from "discourse/lib/utilities";
|
||||||
@ -137,7 +138,7 @@ const Report = Discourse.Model.extend({
|
|||||||
|
|
||||||
@computed("data", "currentTotal")
|
@computed("data", "currentTotal")
|
||||||
currentAverage(data, total) {
|
currentAverage(data, total) {
|
||||||
return Ember.makeArray(data).length === 0
|
return makeArray(data).length === 0
|
||||||
? 0
|
? 0
|
||||||
: parseFloat((total / parseFloat(data.length)).toFixed(1));
|
: parseFloat((total / parseFloat(data.length)).toFixed(1));
|
||||||
},
|
},
|
||||||
|
@ -3,6 +3,13 @@ import toMarkdown from "discourse/lib/to-markdown";
|
|||||||
|
|
||||||
const homepageSelector = "meta[name=discourse_current_homepage]";
|
const homepageSelector = "meta[name=discourse_current_homepage]";
|
||||||
|
|
||||||
|
export function makeArray(obj) {
|
||||||
|
if (obj === null || obj === undefined) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return Array.isArray(obj) ? obj : [obj];
|
||||||
|
}
|
||||||
|
|
||||||
export function translateSize(size) {
|
export function translateSize(size) {
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case "tiny":
|
case "tiny":
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { createWidget } from "discourse/widgets/widget";
|
import { createWidget } from "discourse/widgets/widget";
|
||||||
import { h } from "virtual-dom";
|
import { h } from "virtual-dom";
|
||||||
import { avatarFor, avatarImg } from "discourse/widgets/post";
|
import { avatarFor, avatarImg } from "discourse/widgets/post";
|
||||||
@ -146,7 +147,7 @@ export default createWidget("private-message-map", {
|
|||||||
if (
|
if (
|
||||||
!this.state.isEditing &&
|
!this.state.isEditing &&
|
||||||
this.site.mobileView &&
|
this.site.mobileView &&
|
||||||
Ember.makeArray(participants[0]).length > 4
|
makeArray(participants[0]).length > 4
|
||||||
) {
|
) {
|
||||||
hideNamesClass = ".hide-names";
|
hideNamesClass = ".hide-names";
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ export default MultiSelectComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
computeValues() {
|
computeValues() {
|
||||||
return Ember.makeArray(this.categories).map(c => c.id);
|
return makeArray(this.categories).map(c => c.id);
|
||||||
},
|
},
|
||||||
|
|
||||||
mutateValues(values) {
|
mutateValues(values) {
|
||||||
@ -43,7 +44,7 @@ export default MultiSelectComponent.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
computeContent() {
|
computeContent() {
|
||||||
const blacklist = Ember.makeArray(this.blacklist);
|
const blacklist = makeArray(this.blacklist);
|
||||||
return Category.list().filter(category => {
|
return Category.list().filter(category => {
|
||||||
return (
|
return (
|
||||||
this.categories.includes(category) || !blacklist.includes(category)
|
this.categories.includes(category) || !blacklist.includes(category)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import ComboBox from "select-kit/components/combo-box";
|
import ComboBox from "select-kit/components/combo-box";
|
||||||
import TagsMixin from "select-kit/mixins/tags";
|
import TagsMixin from "select-kit/mixins/tags";
|
||||||
@ -5,7 +6,7 @@ import { default as computed } from "ember-addons/ember-computed-decorators";
|
|||||||
import renderTag from "discourse/lib/render-tag";
|
import renderTag from "discourse/lib/render-tag";
|
||||||
import { escapeExpression } from "discourse/lib/utilities";
|
import { escapeExpression } from "discourse/lib/utilities";
|
||||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||||
const { get, isEmpty, run, makeArray } = Ember;
|
const { get, isEmpty, run } = Ember;
|
||||||
|
|
||||||
export default ComboBox.extend(TagsMixin, {
|
export default ComboBox.extend(TagsMixin, {
|
||||||
allowContentReplacement: true,
|
allowContentReplacement: true,
|
||||||
@ -226,7 +227,7 @@ export default ComboBox.extend(TagsMixin, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
destroyTags(tags) {
|
destroyTags(tags) {
|
||||||
tags = Ember.makeArray(tags).map(c => get(c, "value"));
|
tags = makeArray(tags).map(c => get(c, "value"));
|
||||||
|
|
||||||
// work around usage with buffered proxy
|
// work around usage with buffered proxy
|
||||||
// it does not listen on array changes, similar hack already on select
|
// it does not listen on array changes, similar hack already on select
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { on } from "ember-addons/ember-computed-decorators";
|
import { on } from "ember-addons/ember-computed-decorators";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";
|
import SelectKitHeaderComponent from "select-kit/components/select-kit/select-kit-header";
|
||||||
@ -39,14 +40,14 @@ export default SelectKitHeaderComponent.extend({
|
|||||||
|
|
||||||
@computed("computedContent.selection.[]")
|
@computed("computedContent.selection.[]")
|
||||||
names(selection) {
|
names(selection) {
|
||||||
return Ember.makeArray(selection)
|
return makeArray(selection)
|
||||||
.map(s => s.name)
|
.map(s => s.name)
|
||||||
.join(",");
|
.join(",");
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("computedContent.selection.[]")
|
@computed("computedContent.selection.[]")
|
||||||
values(selection) {
|
values(selection) {
|
||||||
return Ember.makeArray(selection)
|
return makeArray(selection)
|
||||||
.map(s => s.value)
|
.map(s => s.value)
|
||||||
.join(",");
|
.join(",");
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ import MultiSelectComponent from "select-kit/components/multi-select";
|
|||||||
import TagsMixin from "select-kit/mixins/tags";
|
import TagsMixin from "select-kit/mixins/tags";
|
||||||
import renderTag from "discourse/lib/render-tag";
|
import renderTag from "discourse/lib/render-tag";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import computed from "ember-addons/ember-computed-decorators";
|
||||||
const { get, run, makeArray } = Ember;
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
|
const { get, run } = Ember;
|
||||||
|
|
||||||
export default MultiSelectComponent.extend(TagsMixin, {
|
export default MultiSelectComponent.extend(TagsMixin, {
|
||||||
pluginApiIdentifiers: ["tag-chooser"],
|
pluginApiIdentifiers: ["tag-chooser"],
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import ComboBoxComponent from "select-kit/components/combo-box";
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import TagsMixin from "select-kit/mixins/tags";
|
import TagsMixin from "select-kit/mixins/tags";
|
||||||
@ -123,7 +124,7 @@ export default ComboBoxComponent.extend(TagsMixin, {
|
|||||||
if (this.siteSettings.tags_sort_alphabetically && topTags) {
|
if (this.siteSettings.tags_sort_alphabetically && topTags) {
|
||||||
return shortcuts.concat(topTags.sort());
|
return shortcuts.concat(topTags.sort());
|
||||||
} else {
|
} else {
|
||||||
return shortcuts.concat(Ember.makeArray(topTags));
|
return shortcuts.concat(makeArray(topTags));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { makeArray } from "discourse/lib/utilities";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { throttle } from "@ember/runloop";
|
import { throttle } from "@ember/runloop";
|
||||||
import { schedule } from "@ember/runloop";
|
import { schedule } from "@ember/runloop";
|
||||||
@ -293,7 +294,7 @@ export default Mixin.create({
|
|||||||
|
|
||||||
if (!this.highlightedSelection.length) {
|
if (!this.highlightedSelection.length) {
|
||||||
// try to highlight the last non locked item from the current selection
|
// try to highlight the last non locked item from the current selection
|
||||||
Ember.makeArray(this.selection)
|
makeArray(this.selection)
|
||||||
.slice()
|
.slice()
|
||||||
.reverse()
|
.reverse()
|
||||||
.some(selection => {
|
.some(selection => {
|
||||||
@ -311,7 +312,7 @@ export default Mixin.create({
|
|||||||
},
|
},
|
||||||
|
|
||||||
didPressSelectAll() {
|
didPressSelectAll() {
|
||||||
this.highlightSelection(Ember.makeArray(this.selection));
|
this.highlightSelection(makeArray(this.selection));
|
||||||
},
|
},
|
||||||
|
|
||||||
didClickOutside(event) {
|
didClickOutside(event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user