DEV: Remove use of run-loop-and-computed-dot-access (#178)
Context: https://deprecations.emberjs.com/v3.x/#toc_deprecated-run-loop-and-computed-dot-access
This commit is contained in:
parent
45b6e7eb4f
commit
780232c902
|
@ -1,4 +1,5 @@
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
|
import { schedule, throttle } from "@ember/runloop";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
@observes("hideSchema")
|
@observes("hideSchema")
|
||||||
|
@ -8,7 +9,7 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
@observes("everEditing")
|
@observes("everEditing")
|
||||||
_onInsertEditor() {
|
_onInsertEditor() {
|
||||||
Ember.run.schedule("afterRender", this, () => this._bindControls());
|
schedule("afterRender", this, () => this._bindControls());
|
||||||
},
|
},
|
||||||
|
|
||||||
_bindControls() {
|
_bindControls() {
|
||||||
|
@ -49,7 +50,7 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
const throttledMousemove = ((event) => {
|
const throttledMousemove = ((event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
Ember.run.throttle(this, mousemove, event, 20);
|
throttle(this, mousemove, event, 20);
|
||||||
}).bind(this);
|
}).bind(this);
|
||||||
|
|
||||||
const mouseup = (() => {
|
const mouseup = (() => {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import { on } from "discourse-common/utils/decorators";
|
import { on } from "discourse-common/utils/decorators";
|
||||||
|
import { reads } from "@ember/object/computed";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNameBindings: [":schema-table", "open"],
|
classNameBindings: [":schema-table", "open"],
|
||||||
tagName: "li",
|
tagName: "li",
|
||||||
|
|
||||||
open: Ember.computed.reads("table.open"),
|
open: reads("table.open"),
|
||||||
|
|
||||||
@on("didInsertElement")
|
@on("didInsertElement")
|
||||||
_bindClicks() {
|
_bindClicks() {
|
||||||
|
|
|
@ -5,6 +5,8 @@ import getURL from "discourse-common/lib/get-url";
|
||||||
import Badge from "discourse/models/badge";
|
import Badge from "discourse/models/badge";
|
||||||
import { default as computed } from "discourse-common/utils/decorators";
|
import { default as computed } from "discourse-common/utils/decorators";
|
||||||
import { capitalize } from "@ember/string";
|
import { capitalize } from "@ember/string";
|
||||||
|
import { alias, mapBy, notEmpty, reads } from "@ember/object/computed";
|
||||||
|
import { schedule } from "@ember/runloop";
|
||||||
|
|
||||||
function randomIdShort() {
|
function randomIdShort() {
|
||||||
return "xxxxxxxx".replace(/[xy]/g, () => {
|
return "xxxxxxxx".replace(/[xy]/g, () => {
|
||||||
|
@ -29,13 +31,13 @@ function transformedRelTable(table, modelClass) {
|
||||||
const QueryResultComponent = Ember.Component.extend({
|
const QueryResultComponent = Ember.Component.extend({
|
||||||
layoutName: "explorer-query-result",
|
layoutName: "explorer-query-result",
|
||||||
|
|
||||||
rows: Ember.computed.alias("content.rows"),
|
rows: alias("content.rows"),
|
||||||
columns: Ember.computed.alias("content.columns"),
|
columns: alias("content.columns"),
|
||||||
params: Ember.computed.alias("content.params"),
|
params: alias("content.params"),
|
||||||
explainText: Ember.computed.alias("content.explain"),
|
explainText: alias("content.explain"),
|
||||||
hasExplain: Ember.computed.notEmpty("content.explain"),
|
hasExplain: notEmpty("content.explain"),
|
||||||
chartDatasetName: Ember.computed.reads("columnDispNames.1"),
|
chartDatasetName: reads("columnDispNames.1"),
|
||||||
chartValues: Ember.computed.mapBy("content.rows", "1"),
|
chartValues: mapBy("content.rows", "1"),
|
||||||
showChart: false,
|
showChart: false,
|
||||||
|
|
||||||
@computed("content.result_count")
|
@computed("content.result_count")
|
||||||
|
@ -47,7 +49,7 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
colCount: Ember.computed.reads("content.columns.length"),
|
colCount: reads("content.columns.length"),
|
||||||
|
|
||||||
@computed("content.duration")
|
@computed("content.duration")
|
||||||
duration(contentDuration) {
|
duration(contentDuration) {
|
||||||
|
@ -241,7 +243,7 @@ const QueryResultComponent = Ember.Component.extend({
|
||||||
|
|
||||||
document.body.appendChild(form);
|
document.body.appendChild(form);
|
||||||
form.submit();
|
form.submit();
|
||||||
Ember.run.schedule("afterRender", () => document.body.removeChild(form));
|
schedule("afterRender", () => document.body.removeChild(form));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { default as computed, on } from "discourse-common/utils/decorators";
|
import { default as computed, on } from "discourse-common/utils/decorators";
|
||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
|
import { bind } from "@ember/runloop";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNames: ["share-report"],
|
classNames: ["share-report"],
|
||||||
|
@ -38,8 +39,8 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
@on("init")
|
@on("init")
|
||||||
_setupHandlers() {
|
_setupHandlers() {
|
||||||
this._boundMouseDownHandler = Ember.run.bind(this, this._mouseDownHandler);
|
this._boundMouseDownHandler = bind(this, this._mouseDownHandler);
|
||||||
this._boundKeydownHandler = Ember.run.bind(this, this._keydownHandler);
|
this._boundKeydownHandler = bind(this, this._keydownHandler);
|
||||||
},
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import bootbox from "bootbox";
|
import bootbox from "bootbox";
|
||||||
|
import { not, reads, sort } from "@ember/object/computed";
|
||||||
|
|
||||||
const NoQuery = Query.create({ name: "No queries", fake: true, group_ids: [] });
|
const NoQuery = Query.create({ name: "No queries", fake: true, group_ids: [] });
|
||||||
|
|
||||||
|
@ -21,9 +22,9 @@ export default Ember.Controller.extend({
|
||||||
loading: false,
|
loading: false,
|
||||||
explain: false,
|
explain: false,
|
||||||
|
|
||||||
saveDisabled: Ember.computed.not("selectedItem.dirty"),
|
saveDisabled: not("selectedItem.dirty"),
|
||||||
runDisabled: Ember.computed.reads("selectedItem.dirty"),
|
runDisabled: reads("selectedItem.dirty"),
|
||||||
results: Ember.computed.reads("selectedItem.results"),
|
results: reads("selectedItem.results"),
|
||||||
|
|
||||||
asc: null,
|
asc: null,
|
||||||
order: null,
|
order: null,
|
||||||
|
@ -31,7 +32,7 @@ export default Ember.Controller.extend({
|
||||||
everEditing: false,
|
everEditing: false,
|
||||||
showRecentQueries: true,
|
showRecentQueries: true,
|
||||||
sortBy: ["last_run_at:desc"],
|
sortBy: ["last_run_at:desc"],
|
||||||
sortedQueries: Ember.computed.sort("model", "sortBy"),
|
sortedQueries: sort("model", "sortBy"),
|
||||||
|
|
||||||
@computed("params")
|
@computed("params")
|
||||||
parsedParams(params) {
|
parsedParams(params) {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { alias } from "@ember/object/computed";
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
queries: Ember.computed.alias("model.queries"),
|
queries: alias("model.queries"),
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,13 +6,14 @@ import Bookmark, {
|
||||||
} from "discourse/models/bookmark";
|
} from "discourse/models/bookmark";
|
||||||
import { openBookmarkModal } from "discourse/controllers/bookmark";
|
import { openBookmarkModal } from "discourse/controllers/bookmark";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
import { alias, gt } from "@ember/object/computed";
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
showResults: false,
|
showResults: false,
|
||||||
explain: false,
|
explain: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
results: Ember.computed.alias("model.results"),
|
results: alias("model.results"),
|
||||||
hasParams: Ember.computed.gt("model.param_info.length", 0),
|
hasParams: gt("model.param_info.length", 0),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
run() {
|
run() {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
import RestModel from "discourse/models/rest";
|
import RestModel from "discourse/models/rest";
|
||||||
|
import { reads } from "@ember/object/computed";
|
||||||
|
|
||||||
const Query = RestModel.extend({
|
const Query = RestModel.extend({
|
||||||
dirty: false,
|
dirty: false,
|
||||||
|
@ -33,7 +34,7 @@ const Query = RestModel.extend({
|
||||||
this.set("dirty", false);
|
this.set("dirty", false);
|
||||||
},
|
},
|
||||||
|
|
||||||
hasParams: Ember.computed.reads("param_info.length"),
|
hasParams: reads("param_info.length"),
|
||||||
|
|
||||||
resetParams() {
|
resetParams() {
|
||||||
const newParams = {};
|
const newParams = {};
|
||||||
|
|
Loading…
Reference in New Issue