mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 21:55:25 +08:00
DEV: Clean up Ember imports (#8979)
Includes: * Import `computed` helpers * Import `@ember/application` * Import `isBlank` from `@ember/utils` * Import `A` from `@ember/array` * Import `EmberArray` from `@ember/array` * Import `ArrayProxy` from `@ember/array/proxy` * Import `warn` from `@ember/debug` * Import `EmberObject` from `@ember/object` * Import `Application` from `@ember/application` * Import `EmberRouter` from `@ember/routing/router` * Import `isPresent` from `@ember/utils` * Import `computed` from `@ember/object` * Import `guidFor` from `@ember/object` * Import `isArray` from `@ember/array` * Import `TextField` from `@ember/component` * Import `TextArea` from `@ember/component` * Import `Promise` from `rsvp` * Import `Evented` from `@ember/object/evented` * Replace deprecated `ember-addons/ember-computed-decorators` imports
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
import EmberObject from "@ember/object";
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import Component from "@ember/component";
|
||||
import { notEmpty } from "@ember/object/computed";
|
||||
import { Promise } from "rsvp";
|
||||
/* global Pikaday:true */
|
||||
import { propertyNotEqual } from "discourse/lib/computed";
|
||||
import loadScript from "discourse/lib/load-script";
|
||||
import computed from "discourse-common/utils/decorators";
|
||||
import computed, { observes } from "discourse-common/utils/decorators";
|
||||
import { cookAsync } from "discourse/lib/text";
|
||||
import discourseDebounce from "discourse/lib/debounce";
|
||||
import { observes } from "discourse-common/utils/decorators";
|
||||
|
||||
export default Component.extend({
|
||||
timeFormat: "HH:mm:ss",
|
||||
@ -24,9 +26,9 @@ export default Component.extend({
|
||||
isValid: true,
|
||||
timezone: null,
|
||||
fromSelected: null,
|
||||
fromFilled: Ember.computed.notEmpty("date"),
|
||||
fromFilled: notEmpty("date"),
|
||||
toSelected: null,
|
||||
toFilled: Ember.computed.notEmpty("toDate"),
|
||||
toFilled: notEmpty("toDate"),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
@ -113,7 +115,7 @@ export default Component.extend({
|
||||
format = "LL";
|
||||
}
|
||||
|
||||
return Ember.Object.create({
|
||||
return EmberObject.create({
|
||||
date: dateTime.format(this.dateFormat),
|
||||
time,
|
||||
dateTime,
|
||||
@ -146,7 +148,7 @@ export default Component.extend({
|
||||
format = "LL";
|
||||
}
|
||||
|
||||
return Ember.Object.create({
|
||||
return EmberObject.create({
|
||||
date: dateTime.format(this.dateFormat),
|
||||
time,
|
||||
dateTime,
|
||||
@ -157,7 +159,7 @@ export default Component.extend({
|
||||
|
||||
@computed("recurring", "timezones", "timezone", "format")
|
||||
options(recurring, timezones, timezone, format) {
|
||||
return Ember.Object.create({
|
||||
return EmberObject.create({
|
||||
recurring,
|
||||
timezones,
|
||||
timezone,
|
||||
@ -171,7 +173,7 @@ export default Component.extend({
|
||||
"options.{recurring,timezones,timezone,format}"
|
||||
)
|
||||
computedConfig(fromConfig, toConfig, options) {
|
||||
return Ember.Object.create({
|
||||
return EmberObject.create({
|
||||
from: fromConfig,
|
||||
to: toConfig,
|
||||
options
|
||||
@ -372,7 +374,7 @@ export default Component.extend({
|
||||
},
|
||||
|
||||
_setupPicker() {
|
||||
return new Ember.RSVP.Promise(resolve => {
|
||||
return new Promise(resolve => {
|
||||
loadScript("/javascripts/pikaday.js").then(() => {
|
||||
const options = {
|
||||
field: this.$(`.fake-input`)[0],
|
||||
|
@ -2,6 +2,8 @@ import { once } from "@ember/runloop";
|
||||
import { debounce } from "@ember/runloop";
|
||||
import { cancel } from "@ember/runloop";
|
||||
import Component from "@ember/component";
|
||||
import { equal, gt } from "@ember/object/computed";
|
||||
import { Promise } from "rsvp";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import computed, { observes, on } from "discourse-common/utils/decorators";
|
||||
|
||||
@ -22,6 +24,9 @@ export default Component.extend({
|
||||
presenceUsers: null,
|
||||
channel: null,
|
||||
|
||||
isReply: equal("action", "reply"),
|
||||
shouldDisplay: gt("users.length", 0),
|
||||
|
||||
@on("didInsertElement")
|
||||
composerOpened() {
|
||||
this._lastPublish = new Date();
|
||||
@ -113,7 +118,7 @@ export default Component.extend({
|
||||
|
||||
// Don't publish presence if disabled
|
||||
if (this.currentUser.hide_profile_and_presence) {
|
||||
return Ember.RSVP.Promise.resolve();
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return ajax("/presence/publish", { type: "POST", data });
|
||||
@ -122,8 +127,5 @@ export default Component.extend({
|
||||
@computed("presenceUsers", "currentUser.id")
|
||||
users(users, currentUserId) {
|
||||
return (users || []).filter(user => user.id !== currentUserId);
|
||||
},
|
||||
|
||||
isReply: Ember.computed.equal("action", "reply"),
|
||||
shouldDisplay: Ember.computed.gt("users.length", 0)
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { debounce } from "@ember/runloop";
|
||||
import { cancel } from "@ember/runloop";
|
||||
import Component from "@ember/component";
|
||||
import { gt } from "@ember/object/computed";
|
||||
import computed, { on } from "discourse-common/utils/decorators";
|
||||
import {
|
||||
keepAliveDuration,
|
||||
@ -13,6 +14,8 @@ export default Component.extend({
|
||||
topicId: null,
|
||||
presenceUsers: null,
|
||||
|
||||
shouldDisplay: gt("users.length", 0),
|
||||
|
||||
clear() {
|
||||
if (!this.isDestroyed) this.set("presenceUsers", []);
|
||||
},
|
||||
@ -53,7 +56,5 @@ export default Component.extend({
|
||||
user =>
|
||||
user.id !== currentUser.id && !ignoredUsers.includes(user.username)
|
||||
);
|
||||
},
|
||||
|
||||
shouldDisplay: Ember.computed.gt("users.length", 0)
|
||||
}
|
||||
});
|
||||
|
@ -1,3 +1,4 @@
|
||||
import EmberObject from "@ember/object";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import { observes } from "discourse-common/utils/decorators";
|
||||
import { getRegister } from "discourse-common/lib/get-owner";
|
||||
@ -44,7 +45,7 @@ function initializePolls(api) {
|
||||
if (existing) {
|
||||
this._polls[p.name].setProperties(p);
|
||||
} else {
|
||||
this._polls[p.name] = Ember.Object.create(p);
|
||||
this._polls[p.name] = EmberObject.create(p);
|
||||
}
|
||||
});
|
||||
this.set("pollsObject", this._polls);
|
||||
@ -78,8 +79,8 @@ function initializePolls(api) {
|
||||
if (quotedId) {
|
||||
const quotedPost = post.quoted[quotedId];
|
||||
if (quotedPost) {
|
||||
post = Ember.Object.create(quotedPost);
|
||||
poll = Ember.Object.create(
|
||||
post = EmberObject.create(quotedPost);
|
||||
poll = EmberObject.create(
|
||||
quotedPost.polls.find(p => p.name === pollName)
|
||||
);
|
||||
vote = quotedPost.polls_votes || {};
|
||||
|
@ -1,4 +1,6 @@
|
||||
import EmberObject from "@ember/object";
|
||||
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
||||
|
||||
moduleForWidget("discourse-poll-standard-results");
|
||||
|
||||
const template = `{{mount-widget
|
||||
@ -11,7 +13,7 @@ widgetTest("options in descending order", {
|
||||
beforeEach() {
|
||||
this.set(
|
||||
"poll",
|
||||
Ember.Object.create({
|
||||
EmberObject.create({
|
||||
options: [{ votes: 5 }, { votes: 4 }],
|
||||
voters: 9
|
||||
})
|
||||
@ -30,7 +32,7 @@ widgetTest("options in ascending order", {
|
||||
beforeEach() {
|
||||
this.set(
|
||||
"poll",
|
||||
Ember.Object.create({
|
||||
EmberObject.create({
|
||||
options: [{ votes: 4 }, { votes: 5 }],
|
||||
voters: 9
|
||||
})
|
||||
@ -50,7 +52,7 @@ widgetTest("multiple options in descending order", {
|
||||
this.set("isMultiple", true);
|
||||
this.set(
|
||||
"poll",
|
||||
Ember.Object.create({
|
||||
EmberObject.create({
|
||||
type: "multiple",
|
||||
options: [
|
||||
{ votes: 5, html: "a" },
|
||||
|
Reference in New Issue
Block a user