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:
Isaac Janzen 2022-06-17 07:18:36 -05:00 committed by GitHub
parent 45b6e7eb4f
commit 780232c902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 32 additions and 22 deletions

View File

@ -1,4 +1,5 @@
import { observes } from "discourse-common/utils/decorators";
import { schedule, throttle } from "@ember/runloop";
export default Ember.Component.extend({
@observes("hideSchema")
@ -8,7 +9,7 @@ export default Ember.Component.extend({
@observes("everEditing")
_onInsertEditor() {
Ember.run.schedule("afterRender", this, () => this._bindControls());
schedule("afterRender", this, () => this._bindControls());
},
_bindControls() {
@ -49,7 +50,7 @@ export default Ember.Component.extend({
const throttledMousemove = ((event) => {
event.preventDefault();
Ember.run.throttle(this, mousemove, event, 20);
throttle(this, mousemove, event, 20);
}).bind(this);
const mouseup = (() => {

View File

@ -1,10 +1,11 @@
import { on } from "discourse-common/utils/decorators";
import { reads } from "@ember/object/computed";
export default Ember.Component.extend({
classNameBindings: [":schema-table", "open"],
tagName: "li",
open: Ember.computed.reads("table.open"),
open: reads("table.open"),
@on("didInsertElement")
_bindClicks() {

View File

@ -5,6 +5,8 @@ import getURL from "discourse-common/lib/get-url";
import Badge from "discourse/models/badge";
import { default as computed } from "discourse-common/utils/decorators";
import { capitalize } from "@ember/string";
import { alias, mapBy, notEmpty, reads } from "@ember/object/computed";
import { schedule } from "@ember/runloop";
function randomIdShort() {
return "xxxxxxxx".replace(/[xy]/g, () => {
@ -29,13 +31,13 @@ function transformedRelTable(table, modelClass) {
const QueryResultComponent = Ember.Component.extend({
layoutName: "explorer-query-result",
rows: Ember.computed.alias("content.rows"),
columns: Ember.computed.alias("content.columns"),
params: Ember.computed.alias("content.params"),
explainText: Ember.computed.alias("content.explain"),
hasExplain: Ember.computed.notEmpty("content.explain"),
chartDatasetName: Ember.computed.reads("columnDispNames.1"),
chartValues: Ember.computed.mapBy("content.rows", "1"),
rows: alias("content.rows"),
columns: alias("content.columns"),
params: alias("content.params"),
explainText: alias("content.explain"),
hasExplain: notEmpty("content.explain"),
chartDatasetName: reads("columnDispNames.1"),
chartValues: mapBy("content.rows", "1"),
showChart: false,
@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")
duration(contentDuration) {
@ -241,7 +243,7 @@ const QueryResultComponent = Ember.Component.extend({
document.body.appendChild(form);
form.submit();
Ember.run.schedule("afterRender", () => document.body.removeChild(form));
schedule("afterRender", () => document.body.removeChild(form));
});
},

View File

@ -1,5 +1,6 @@
import { default as computed, on } from "discourse-common/utils/decorators";
import getURL from "discourse-common/lib/get-url";
import { bind } from "@ember/runloop";
export default Ember.Component.extend({
classNames: ["share-report"],
@ -38,8 +39,8 @@ export default Ember.Component.extend({
@on("init")
_setupHandlers() {
this._boundMouseDownHandler = Ember.run.bind(this, this._mouseDownHandler);
this._boundKeydownHandler = Ember.run.bind(this, this._keydownHandler);
this._boundMouseDownHandler = bind(this, this._mouseDownHandler);
this._boundKeydownHandler = bind(this, this._keydownHandler);
},
didInsertElement() {

View File

@ -9,6 +9,7 @@ import {
import I18n from "I18n";
import { Promise } from "rsvp";
import bootbox from "bootbox";
import { not, reads, sort } from "@ember/object/computed";
const NoQuery = Query.create({ name: "No queries", fake: true, group_ids: [] });
@ -21,9 +22,9 @@ export default Ember.Controller.extend({
loading: false,
explain: false,
saveDisabled: Ember.computed.not("selectedItem.dirty"),
runDisabled: Ember.computed.reads("selectedItem.dirty"),
results: Ember.computed.reads("selectedItem.results"),
saveDisabled: not("selectedItem.dirty"),
runDisabled: reads("selectedItem.dirty"),
results: reads("selectedItem.results"),
asc: null,
order: null,
@ -31,7 +32,7 @@ export default Ember.Controller.extend({
everEditing: false,
showRecentQueries: true,
sortBy: ["last_run_at:desc"],
sortedQueries: Ember.computed.sort("model", "sortBy"),
sortedQueries: sort("model", "sortBy"),
@computed("params")
parsedParams(params) {

View File

@ -1,3 +1,5 @@
import { alias } from "@ember/object/computed";
export default Ember.Controller.extend({
queries: Ember.computed.alias("model.queries"),
queries: alias("model.queries"),
});

View File

@ -6,13 +6,14 @@ import Bookmark, {
} from "discourse/models/bookmark";
import { openBookmarkModal } from "discourse/controllers/bookmark";
import discourseComputed from "discourse-common/utils/decorators";
import { alias, gt } from "@ember/object/computed";
export default Ember.Controller.extend({
showResults: false,
explain: false,
loading: false,
results: Ember.computed.alias("model.results"),
hasParams: Ember.computed.gt("model.param_info.length", 0),
results: alias("model.results"),
hasParams: gt("model.param_info.length", 0),
actions: {
run() {

View File

@ -5,6 +5,7 @@ import {
} from "discourse-common/utils/decorators";
import getURL from "discourse-common/lib/get-url";
import RestModel from "discourse/models/rest";
import { reads } from "@ember/object/computed";
const Query = RestModel.extend({
dirty: false,
@ -33,7 +34,7 @@ const Query = RestModel.extend({
this.set("dirty", false);
},
hasParams: Ember.computed.reads("param_info.length"),
hasParams: reads("param_info.length"),
resetParams() {
const newParams = {};