mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 21:52:43 +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,5 +1,6 @@
|
|||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import { isBlank } from "@ember/utils";
|
||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
@ -15,8 +16,8 @@ export default Controller.extend({
|
|||||||
|
|
||||||
@discourseComputed("model.description", "model.username", "userMode")
|
@discourseComputed("model.description", "model.username", "userMode")
|
||||||
saveDisabled(description, username, userMode) {
|
saveDisabled(description, username, userMode) {
|
||||||
if (Ember.isBlank(description)) return true;
|
if (isBlank(description)) return true;
|
||||||
if (userMode === "single" && Ember.isBlank(username)) return true;
|
if (userMode === "single" && isBlank(username)) return true;
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Controller from "@ember/controller";
|
import Controller from "@ember/controller";
|
||||||
|
import { A } from "@ember/array";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
@ -7,7 +8,7 @@ export default Controller.extend(ModalFunctionality, {
|
|||||||
@observes("model")
|
@observes("model")
|
||||||
modelChanged() {
|
modelChanged() {
|
||||||
const model = this.model;
|
const model = this.model;
|
||||||
const copy = Ember.A();
|
const copy = A();
|
||||||
const store = this.store;
|
const store = this.store;
|
||||||
|
|
||||||
if (model) {
|
if (model) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { warn } from "@ember/debug";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { alias, oneWay } from "@ember/object/computed";
|
import { alias, oneWay } from "@ember/object/computed";
|
||||||
import { categoryLinkHTML } from "discourse/helpers/category-link";
|
import { categoryLinkHTML } from "discourse/helpers/category-link";
|
||||||
@ -137,7 +138,7 @@ export default Mixin.create({
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
_save() {
|
_save() {
|
||||||
Ember.warn("You should define a `_save` method", {
|
warn("You should define a `_save` method", {
|
||||||
id: "discourse.setting-component.missing-save"
|
id: "discourse.setting-component.missing-save"
|
||||||
});
|
});
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { A } from "@ember/array";
|
||||||
|
import ArrayProxy from "@ember/array/proxy";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { not } from "@ember/object/computed";
|
import { not } from "@ember/object/computed";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
@ -33,7 +35,7 @@ const ColorScheme = EmberObject.extend({
|
|||||||
const newScheme = ColorScheme.create({
|
const newScheme = ColorScheme.create({
|
||||||
name: this.name,
|
name: this.name,
|
||||||
can_edit: true,
|
can_edit: true,
|
||||||
colors: Ember.A()
|
colors: A()
|
||||||
});
|
});
|
||||||
this.colors.forEach(c => {
|
this.colors.forEach(c => {
|
||||||
newScheme.colors.pushObject(
|
newScheme.colors.pushObject(
|
||||||
@ -111,7 +113,7 @@ const ColorScheme = EmberObject.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const ColorSchemes = Ember.ArrayProxy.extend({});
|
const ColorSchemes = ArrayProxy.extend({});
|
||||||
|
|
||||||
ColorScheme.reopenClass({
|
ColorScheme.reopenClass({
|
||||||
findAll() {
|
findAll() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { get } from "@ember/object";
|
import { get } from "@ember/object";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isBlank, isEmpty } from "@ember/utils";
|
||||||
import { or, gt } from "@ember/object/computed";
|
import { or, gt } from "@ember/object/computed";
|
||||||
import RestModel from "discourse/models/rest";
|
import RestModel from "discourse/models/rest";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
@ -153,7 +153,7 @@ const Theme = RestModel.extend({
|
|||||||
@discourseComputed("theme_fields.[]")
|
@discourseComputed("theme_fields.[]")
|
||||||
editedFields(fields) {
|
editedFields(fields) {
|
||||||
return fields.filter(
|
return fields.filter(
|
||||||
field => !Ember.isBlank(field.value) && field.type_id !== SETTINGS_TYPE_ID
|
field => !isBlank(field.value) && field.type_id !== SETTINGS_TYPE_ID
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -12,7 +12,8 @@ var define, requirejs;
|
|||||||
jquery: { default: $ },
|
jquery: { default: $ },
|
||||||
"@ember/array": {
|
"@ember/array": {
|
||||||
default: Ember.Array,
|
default: Ember.Array,
|
||||||
A: Ember.A
|
A: Ember.A,
|
||||||
|
isArray: Ember.isArray
|
||||||
},
|
},
|
||||||
"@ember/array/proxy": {
|
"@ember/array/proxy": {
|
||||||
default: Ember.ArrayProxy
|
default: Ember.ArrayProxy
|
||||||
@ -99,10 +100,10 @@ var define, requirejs;
|
|||||||
inject: Ember.inject.service
|
inject: Ember.inject.service
|
||||||
},
|
},
|
||||||
"@ember/utils": {
|
"@ember/utils": {
|
||||||
isPresent: Ember.isPresent,
|
|
||||||
isBlank: Ember.isBlank,
|
isBlank: Ember.isBlank,
|
||||||
isEmpty: Ember.isEmpty,
|
isEmpty: Ember.isEmpty,
|
||||||
isNone: Ember.isNone
|
isNone: Ember.isNone,
|
||||||
|
isPresent: Ember.isPresent
|
||||||
},
|
},
|
||||||
rsvp: {
|
rsvp: {
|
||||||
default: Ember.RSVP,
|
default: Ember.RSVP,
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
/*global Mousetrap:true*/
|
/*global Mousetrap:true*/
|
||||||
|
import Application from "@ember/application";
|
||||||
|
import EmberObject, { computed } from "@ember/object";
|
||||||
import { buildResolver } from "discourse-common/resolver";
|
import { buildResolver } from "discourse-common/resolver";
|
||||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||||
import { computed } from "@ember/object";
|
|
||||||
import FocusEvent from "discourse-common/mixins/focus-event";
|
import FocusEvent from "discourse-common/mixins/focus-event";
|
||||||
import EmberObject from "@ember/object";
|
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
|
||||||
const _pluginCallbacks = [];
|
const _pluginCallbacks = [];
|
||||||
|
|
||||||
const Discourse = Ember.Application.extend(FocusEvent, {
|
const Discourse = Application.extend(FocusEvent, {
|
||||||
rootElement: "#main",
|
rootElement: "#main",
|
||||||
_docTitle: document.title,
|
_docTitle: document.title,
|
||||||
RAW_TEMPLATES: {},
|
RAW_TEMPLATES: {},
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
import { TextArea } from "@ember/component";
|
||||||
import { scheduleOnce } from "@ember/runloop";
|
import { scheduleOnce } from "@ember/runloop";
|
||||||
import { on, observes } from "discourse-common/utils/decorators";
|
import { on, observes } from "discourse-common/utils/decorators";
|
||||||
import autosize from "discourse/lib/autosize";
|
import autosize from "discourse/lib/autosize";
|
||||||
|
|
||||||
export default Ember.TextArea.extend({
|
export default TextArea.extend({
|
||||||
@on("didInsertElement")
|
@on("didInsertElement")
|
||||||
_startWatching() {
|
_startWatching() {
|
||||||
scheduleOnce("afterRender", () => {
|
scheduleOnce("afterRender", () => {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import { TextField } from "@ember/component";
|
||||||
import { on } from "discourse-common/utils/decorators";
|
import { on } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Ember.TextField.extend({
|
export default TextField.extend({
|
||||||
@on("init")
|
@on("init")
|
||||||
_init() {
|
_init() {
|
||||||
// Chrome autocomplete is buggy per:
|
// Chrome autocomplete is buggy per:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import { TextField } from "@ember/component";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Ember.TextField.extend({
|
export default TextField.extend({
|
||||||
classNameBindings: ["invalid"],
|
classNameBindings: ["invalid"],
|
||||||
|
|
||||||
@discourseComputed("number")
|
@discourseComputed("number")
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import { TextField } from "@ember/component";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { siteDir, isRTL, isLTR } from "discourse/lib/text-direction";
|
import { siteDir, isRTL, isLTR } from "discourse/lib/text-direction";
|
||||||
|
|
||||||
export default Ember.TextField.extend({
|
export default TextField.extend({
|
||||||
attributeBindings: [
|
attributeBindings: [
|
||||||
"autocorrect",
|
"autocorrect",
|
||||||
"autocapitalize",
|
"autocapitalize",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { A } from "@ember/array";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { notEmpty, or, not } from "@ember/object/computed";
|
import { notEmpty, or, not } from "@ember/object/computed";
|
||||||
import Controller, { inject as controller } from "@ember/controller";
|
import Controller, { inject as controller } from "@ember/controller";
|
||||||
@ -31,7 +32,7 @@ export default Controller.extend(
|
|||||||
accountChallenge: 0,
|
accountChallenge: 0,
|
||||||
accountHoneypot: 0,
|
accountHoneypot: 0,
|
||||||
formSubmitted: false,
|
formSubmitted: false,
|
||||||
rejectedEmails: Ember.A([]),
|
rejectedEmails: A(),
|
||||||
prefilledUsername: null,
|
prefilledUsername: null,
|
||||||
userFields: null,
|
userFields: null,
|
||||||
isDeveloper: false,
|
isDeveloper: false,
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
export default Ember.ArrayProxy.extend({
|
import ArrayProxy from "@ember/array/proxy";
|
||||||
|
|
||||||
|
export default ArrayProxy.extend({
|
||||||
render(topic, renderIcon) {
|
render(topic, renderIcon) {
|
||||||
const renderIconIf = (conditionProp, name, key) => {
|
const renderIconIf = (conditionProp, name, key) => {
|
||||||
if (!topic.get(conditionProp)) {
|
if (!topic.get(conditionProp)) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { computed } from "@ember/object";
|
||||||
import addonFmt from "ember-addons/fmt";
|
import addonFmt from "ember-addons/fmt";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -10,7 +11,7 @@ import addonFmt from "ember-addons/fmt";
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
export function propertyEqual(p1, p2) {
|
export function propertyEqual(p1, p2) {
|
||||||
return Ember.computed(p1, p2, function() {
|
return computed(p1, p2, function() {
|
||||||
return this.get(p1) === this.get(p2);
|
return this.get(p1) === this.get(p2);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -24,19 +25,19 @@ export function propertyEqual(p1, p2) {
|
|||||||
@return {Function} discourseComputedProperty function
|
@return {Function} discourseComputedProperty function
|
||||||
**/
|
**/
|
||||||
export function propertyNotEqual(p1, p2) {
|
export function propertyNotEqual(p1, p2) {
|
||||||
return Ember.computed(p1, p2, function() {
|
return computed(p1, p2, function() {
|
||||||
return this.get(p1) !== this.get(p2);
|
return this.get(p1) !== this.get(p2);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function propertyGreaterThan(p1, p2) {
|
export function propertyGreaterThan(p1, p2) {
|
||||||
return Ember.computed(p1, p2, function() {
|
return computed(p1, p2, function() {
|
||||||
return this.get(p1) > this.get(p2);
|
return this.get(p1) > this.get(p2);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function propertyLessThan(p1, p2) {
|
export function propertyLessThan(p1, p2) {
|
||||||
return Ember.computed(p1, p2, function() {
|
return computed(p1, p2, function() {
|
||||||
return this.get(p1) < this.get(p2);
|
return this.get(p1) < this.get(p2);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -51,7 +52,7 @@ export function propertyLessThan(p1, p2) {
|
|||||||
**/
|
**/
|
||||||
export function i18n(...args) {
|
export function i18n(...args) {
|
||||||
const format = args.pop();
|
const format = args.pop();
|
||||||
return Ember.computed(...args, function() {
|
return computed(...args, function() {
|
||||||
return I18n.t(addonFmt(format, ...args.map(a => this.get(a))));
|
return I18n.t(addonFmt(format, ...args.map(a => this.get(a))));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -67,7 +68,7 @@ export function i18n(...args) {
|
|||||||
**/
|
**/
|
||||||
export function fmt(...args) {
|
export function fmt(...args) {
|
||||||
const format = args.pop();
|
const format = args.pop();
|
||||||
return Ember.computed(...args, function() {
|
return computed(...args, function() {
|
||||||
return addonFmt(format, ...args.map(a => this.get(a)));
|
return addonFmt(format, ...args.map(a => this.get(a)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -83,7 +84,7 @@ export function fmt(...args) {
|
|||||||
**/
|
**/
|
||||||
export function url(...args) {
|
export function url(...args) {
|
||||||
const format = args.pop();
|
const format = args.pop();
|
||||||
return Ember.computed(...args, function() {
|
return computed(...args, function() {
|
||||||
return Discourse.getURL(addonFmt(format, ...args.map(a => this.get(a))));
|
return Discourse.getURL(addonFmt(format, ...args.map(a => this.get(a))));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,7 +100,7 @@ export function url(...args) {
|
|||||||
export function endWith() {
|
export function endWith() {
|
||||||
const args = Array.prototype.slice.call(arguments, 0);
|
const args = Array.prototype.slice.call(arguments, 0);
|
||||||
const substring = args.pop();
|
const substring = args.pop();
|
||||||
return Ember.computed(...args, function() {
|
return computed(...args, function() {
|
||||||
return args
|
return args
|
||||||
.map(a => this.get(a))
|
.map(a => this.get(a))
|
||||||
.every(s => {
|
.every(s => {
|
||||||
@ -118,7 +119,7 @@ export function endWith() {
|
|||||||
@param {String} name of site setting
|
@param {String} name of site setting
|
||||||
**/
|
**/
|
||||||
export function setting(name) {
|
export function setting(name) {
|
||||||
return Ember.computed(function() {
|
return computed(function() {
|
||||||
return Discourse.SiteSettings[name];
|
return Discourse.SiteSettings[name];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import EmberArray from "@ember/array";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
@ -5,7 +6,7 @@ export function Placeholder(viewName) {
|
|||||||
this.viewName = viewName;
|
this.viewName = viewName;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EmberObject.extend(Ember.Array, {
|
export default EmberObject.extend(EmberArray, {
|
||||||
posts: null,
|
posts: null,
|
||||||
_appendingIds: null,
|
_appendingIds: null,
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import EmberRouter from "@ember/routing/router";
|
||||||
import { defaultHomepage } from "discourse/lib/utilities";
|
import { defaultHomepage } from "discourse/lib/utilities";
|
||||||
import { rewritePath } from "discourse/lib/url";
|
import { rewritePath } from "discourse/lib/url";
|
||||||
import ENV from "discourse-common/config/environment";
|
import ENV from "discourse-common/config/environment";
|
||||||
@ -5,7 +6,7 @@ import Site from "discourse/models/site";
|
|||||||
|
|
||||||
const rootURL = Discourse.BaseUri;
|
const rootURL = Discourse.BaseUri;
|
||||||
|
|
||||||
const BareRouter = Ember.Router.extend({
|
const BareRouter = EmberRouter.extend({
|
||||||
rootURL,
|
rootURL,
|
||||||
location: ENV.environment === "test" ? "none" : "discourse-location",
|
location: ENV.environment === "test" ? "none" : "discourse-location",
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { warn } from "@ember/debug";
|
||||||
import {
|
import {
|
||||||
displayErrorForUpload,
|
displayErrorForUpload,
|
||||||
validateUploadedFiles
|
validateUploadedFiles
|
||||||
@ -11,7 +12,7 @@ export default Mixin.create({
|
|||||||
uploadProgress: 0,
|
uploadProgress: 0,
|
||||||
|
|
||||||
uploadDone() {
|
uploadDone() {
|
||||||
Ember.warn("You should implement `uploadDone`", {
|
warn("You should implement `uploadDone`", {
|
||||||
id: "discourse.upload.missing-upload-done"
|
id: "discourse.upload.missing-upload-done"
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
import ArrayProxy from "@ember/array/proxy";
|
||||||
import PreloadStore from "preload-store";
|
import PreloadStore from "preload-store";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import Topic from "discourse/models/topic";
|
import Topic from "discourse/models/topic";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import Site from "discourse/models/site";
|
import Site from "discourse/models/site";
|
||||||
|
|
||||||
const CategoryList = Ember.ArrayProxy.extend({
|
const CategoryList = ArrayProxy.extend({
|
||||||
init() {
|
init() {
|
||||||
this.set("content", []);
|
this.set("content", []);
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { warn } from "@ember/debug";
|
||||||
import { equal } from "@ember/object/computed";
|
import { equal } from "@ember/object/computed";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
@ -24,7 +25,7 @@ const RestModel = EmberObject.extend({
|
|||||||
const payload = this.__munge(res.payload || res.responseJson);
|
const payload = this.__munge(res.payload || res.responseJson);
|
||||||
|
|
||||||
if (payload.success === "OK") {
|
if (payload.success === "OK") {
|
||||||
Ember.warn("An update call should return the updated attributes", {
|
warn("An update call should return the updated attributes", {
|
||||||
id: "discourse.rest-model.update-attributes"
|
id: "discourse.rest-model.update-attributes"
|
||||||
});
|
});
|
||||||
res = props;
|
res = props;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import ArrayProxy from "@ember/array/proxy";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
|
|
||||||
export default Ember.ArrayProxy.extend({
|
export default ArrayProxy.extend({
|
||||||
loading: false,
|
loading: false,
|
||||||
loadingMore: false,
|
loadingMore: false,
|
||||||
totalRows: 0,
|
totalRows: 0,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { A } from "@ember/array";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { url } from "discourse/lib/computed";
|
import { url } from "discourse/lib/computed";
|
||||||
@ -70,7 +71,7 @@ export default RestModel.extend({
|
|||||||
this.set("noContentHelp", result.no_results_help);
|
this.set("noContentHelp", result.no_results_help);
|
||||||
}
|
}
|
||||||
if (result && result.drafts) {
|
if (result && result.drafts) {
|
||||||
const copy = Ember.A();
|
const copy = A();
|
||||||
result.drafts.forEach(draft => {
|
result.drafts.forEach(draft => {
|
||||||
let draftData = JSON.parse(draft.data);
|
let draftData = JSON.parse(draft.data);
|
||||||
draft.post_number = draftData.postId || null;
|
draft.post_number = draftData.postId || null;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { A } from "@ember/array";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { url } from "discourse/lib/computed";
|
import { url } from "discourse/lib/computed";
|
||||||
import RestModel from "discourse/models/rest";
|
import RestModel from "discourse/models/rest";
|
||||||
@ -104,7 +105,7 @@ export default RestModel.extend({
|
|||||||
this.set("noContentHelp", result.no_results_help);
|
this.set("noContentHelp", result.no_results_help);
|
||||||
}
|
}
|
||||||
if (result && result.user_actions) {
|
if (result && result.user_actions) {
|
||||||
const copy = Ember.A();
|
const copy = A();
|
||||||
result.user_actions.forEach(action => {
|
result.user_actions.forEach(action => {
|
||||||
action.title = emojiUnescape(
|
action.title = emojiUnescape(
|
||||||
Handlebars.Utils.escapeExpression(action.title)
|
Handlebars.Utils.escapeExpression(action.title)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { A } from "@ember/array";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { gt, equal, or } from "@ember/object/computed";
|
import { gt, equal, or } from "@ember/object/computed";
|
||||||
import EmberObject, { computed } from "@ember/object";
|
import EmberObject, { computed } from "@ember/object";
|
||||||
@ -884,7 +885,7 @@ User.reopenClass(Singleton, {
|
|||||||
responses.set("count", responses.get("count") + stat.get("count"));
|
responses.set("count", responses.get("count") + stat.get("count"));
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = Ember.A();
|
const result = A();
|
||||||
result.pushObjects(stats.rejectBy("isResponse"));
|
result.pushObjects(stats.rejectBy("isResponse"));
|
||||||
|
|
||||||
let insertAt = 0;
|
let insertAt = 0;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import Application from "@ember/application";
|
||||||
import { mapRoutes } from "discourse/mapping-router";
|
import { mapRoutes } from "discourse/mapping-router";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -10,8 +11,9 @@ export default {
|
|||||||
|
|
||||||
// HACK to fix: https://github.com/emberjs/ember.js/issues/10310
|
// HACK to fix: https://github.com/emberjs/ember.js/issues/10310
|
||||||
const originalBuildInstance =
|
const originalBuildInstance =
|
||||||
originalBuildInstance || Ember.Application.prototype.buildInstance;
|
originalBuildInstance || Application.prototype.buildInstance;
|
||||||
Ember.Application.prototype.buildInstance = function() {
|
|
||||||
|
Application.prototype.buildInstance = function() {
|
||||||
this.buildRegistry();
|
this.buildRegistry();
|
||||||
return originalBuildInstance.apply(this);
|
return originalBuildInstance.apply(this);
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
import Evented from "@ember/object/evented";
|
||||||
import Service from "@ember/service";
|
import Service from "@ember/service";
|
||||||
|
|
||||||
export default Service.extend(Ember.Evented, {
|
export default Service.extend(Evented, {
|
||||||
_events: {},
|
_events: {},
|
||||||
|
|
||||||
on() {
|
on() {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import SelectKitComponent from "select-kit/components/select-kit";
|
import SelectKitComponent from "select-kit/components/select-kit";
|
||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
import { makeArray } from "discourse-common/lib/helpers";
|
|
||||||
import { isPresent } from "@ember/utils";
|
import { isPresent } from "@ember/utils";
|
||||||
|
import { makeArray } from "discourse-common/lib/helpers";
|
||||||
|
|
||||||
export default SelectKitComponent.extend({
|
export default SelectKitComponent.extend({
|
||||||
pluginApiIdentifiers: ["multi-select"],
|
pluginApiIdentifiers: ["multi-select"],
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { computed, default as EmberObject } from "@ember/object";
|
import { computed, guidFor, default as EmberObject } from "@ember/object";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
import { makeArray } from "discourse-common/lib/helpers";
|
import { makeArray } from "discourse-common/lib/helpers";
|
||||||
@ -76,7 +76,7 @@ export default Component.extend(
|
|||||||
this.set(
|
this.set(
|
||||||
"selectKit",
|
"selectKit",
|
||||||
EmberObject.create({
|
EmberObject.create({
|
||||||
uniqueID: Ember.guidFor(this),
|
uniqueID: guidFor(this),
|
||||||
valueProperty: this.valueProperty,
|
valueProperty: this.valueProperty,
|
||||||
nameProperty: this.nameProperty,
|
nameProperty: this.nameProperty,
|
||||||
options: EmberObject.create(),
|
options: EmberObject.create(),
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
import EmberRouter from "@ember/routing/router";
|
||||||
import getUrl from "discourse-common/lib/get-url";
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
import ENV from "discourse-common/config/environment";
|
import ENV from "discourse-common/config/environment";
|
||||||
|
|
||||||
const Router = Ember.Router.extend({
|
const Router = EmberRouter.extend({
|
||||||
rootURL: getUrl("/wizard/"),
|
rootURL: getUrl("/wizard/"),
|
||||||
location: ENV.environment === "test" ? "none" : "history"
|
location: ENV.environment === "test" ? "none" : "history"
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
import Application from "@ember/application";
|
||||||
import { buildResolver } from "discourse-common/resolver";
|
import { buildResolver } from "discourse-common/resolver";
|
||||||
|
|
||||||
export default Ember.Application.extend({
|
export default Application.extend({
|
||||||
rootElement: "#wizard-main",
|
rootElement: "#wizard-main",
|
||||||
Resolver: buildResolver("wizard"),
|
Resolver: buildResolver("wizard"),
|
||||||
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
|
import EmberObject from "@ember/object";
|
||||||
import { isEmpty } from "@ember/utils";
|
import { isEmpty } from "@ember/utils";
|
||||||
import { schedule } from "@ember/runloop";
|
import { schedule } from "@ember/runloop";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { notEmpty } from "@ember/object/computed";
|
||||||
|
import { Promise } from "rsvp";
|
||||||
/* global Pikaday:true */
|
/* global Pikaday:true */
|
||||||
import { propertyNotEqual } from "discourse/lib/computed";
|
import { propertyNotEqual } from "discourse/lib/computed";
|
||||||
import loadScript from "discourse/lib/load-script";
|
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 { cookAsync } from "discourse/lib/text";
|
||||||
import discourseDebounce from "discourse/lib/debounce";
|
import discourseDebounce from "discourse/lib/debounce";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
timeFormat: "HH:mm:ss",
|
timeFormat: "HH:mm:ss",
|
||||||
@ -24,9 +26,9 @@ export default Component.extend({
|
|||||||
isValid: true,
|
isValid: true,
|
||||||
timezone: null,
|
timezone: null,
|
||||||
fromSelected: null,
|
fromSelected: null,
|
||||||
fromFilled: Ember.computed.notEmpty("date"),
|
fromFilled: notEmpty("date"),
|
||||||
toSelected: null,
|
toSelected: null,
|
||||||
toFilled: Ember.computed.notEmpty("toDate"),
|
toFilled: notEmpty("toDate"),
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
@ -113,7 +115,7 @@ export default Component.extend({
|
|||||||
format = "LL";
|
format = "LL";
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ember.Object.create({
|
return EmberObject.create({
|
||||||
date: dateTime.format(this.dateFormat),
|
date: dateTime.format(this.dateFormat),
|
||||||
time,
|
time,
|
||||||
dateTime,
|
dateTime,
|
||||||
@ -146,7 +148,7 @@ export default Component.extend({
|
|||||||
format = "LL";
|
format = "LL";
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ember.Object.create({
|
return EmberObject.create({
|
||||||
date: dateTime.format(this.dateFormat),
|
date: dateTime.format(this.dateFormat),
|
||||||
time,
|
time,
|
||||||
dateTime,
|
dateTime,
|
||||||
@ -157,7 +159,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
@computed("recurring", "timezones", "timezone", "format")
|
@computed("recurring", "timezones", "timezone", "format")
|
||||||
options(recurring, timezones, timezone, format) {
|
options(recurring, timezones, timezone, format) {
|
||||||
return Ember.Object.create({
|
return EmberObject.create({
|
||||||
recurring,
|
recurring,
|
||||||
timezones,
|
timezones,
|
||||||
timezone,
|
timezone,
|
||||||
@ -171,7 +173,7 @@ export default Component.extend({
|
|||||||
"options.{recurring,timezones,timezone,format}"
|
"options.{recurring,timezones,timezone,format}"
|
||||||
)
|
)
|
||||||
computedConfig(fromConfig, toConfig, options) {
|
computedConfig(fromConfig, toConfig, options) {
|
||||||
return Ember.Object.create({
|
return EmberObject.create({
|
||||||
from: fromConfig,
|
from: fromConfig,
|
||||||
to: toConfig,
|
to: toConfig,
|
||||||
options
|
options
|
||||||
@ -372,7 +374,7 @@ export default Component.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_setupPicker() {
|
_setupPicker() {
|
||||||
return new Ember.RSVP.Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
loadScript("/javascripts/pikaday.js").then(() => {
|
loadScript("/javascripts/pikaday.js").then(() => {
|
||||||
const options = {
|
const options = {
|
||||||
field: this.$(`.fake-input`)[0],
|
field: this.$(`.fake-input`)[0],
|
||||||
|
@ -2,6 +2,8 @@ import { once } from "@ember/runloop";
|
|||||||
import { debounce } from "@ember/runloop";
|
import { debounce } from "@ember/runloop";
|
||||||
import { cancel } from "@ember/runloop";
|
import { cancel } from "@ember/runloop";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { equal, gt } from "@ember/object/computed";
|
||||||
|
import { Promise } from "rsvp";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import computed, { observes, on } from "discourse-common/utils/decorators";
|
import computed, { observes, on } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
@ -22,6 +24,9 @@ export default Component.extend({
|
|||||||
presenceUsers: null,
|
presenceUsers: null,
|
||||||
channel: null,
|
channel: null,
|
||||||
|
|
||||||
|
isReply: equal("action", "reply"),
|
||||||
|
shouldDisplay: gt("users.length", 0),
|
||||||
|
|
||||||
@on("didInsertElement")
|
@on("didInsertElement")
|
||||||
composerOpened() {
|
composerOpened() {
|
||||||
this._lastPublish = new Date();
|
this._lastPublish = new Date();
|
||||||
@ -113,7 +118,7 @@ export default Component.extend({
|
|||||||
|
|
||||||
// Don't publish presence if disabled
|
// Don't publish presence if disabled
|
||||||
if (this.currentUser.hide_profile_and_presence) {
|
if (this.currentUser.hide_profile_and_presence) {
|
||||||
return Ember.RSVP.Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ajax("/presence/publish", { type: "POST", data });
|
return ajax("/presence/publish", { type: "POST", data });
|
||||||
@ -122,8 +127,5 @@ export default Component.extend({
|
|||||||
@computed("presenceUsers", "currentUser.id")
|
@computed("presenceUsers", "currentUser.id")
|
||||||
users(users, currentUserId) {
|
users(users, currentUserId) {
|
||||||
return (users || []).filter(user => user.id !== 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 { debounce } from "@ember/runloop";
|
||||||
import { cancel } from "@ember/runloop";
|
import { cancel } from "@ember/runloop";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { gt } from "@ember/object/computed";
|
||||||
import computed, { on } from "discourse-common/utils/decorators";
|
import computed, { on } from "discourse-common/utils/decorators";
|
||||||
import {
|
import {
|
||||||
keepAliveDuration,
|
keepAliveDuration,
|
||||||
@ -13,6 +14,8 @@ export default Component.extend({
|
|||||||
topicId: null,
|
topicId: null,
|
||||||
presenceUsers: null,
|
presenceUsers: null,
|
||||||
|
|
||||||
|
shouldDisplay: gt("users.length", 0),
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
if (!this.isDestroyed) this.set("presenceUsers", []);
|
if (!this.isDestroyed) this.set("presenceUsers", []);
|
||||||
},
|
},
|
||||||
@ -53,7 +56,5 @@ export default Component.extend({
|
|||||||
user =>
|
user =>
|
||||||
user.id !== currentUser.id && !ignoredUsers.includes(user.username)
|
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 { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
import { getRegister } from "discourse-common/lib/get-owner";
|
import { getRegister } from "discourse-common/lib/get-owner";
|
||||||
@ -44,7 +45,7 @@ function initializePolls(api) {
|
|||||||
if (existing) {
|
if (existing) {
|
||||||
this._polls[p.name].setProperties(p);
|
this._polls[p.name].setProperties(p);
|
||||||
} else {
|
} else {
|
||||||
this._polls[p.name] = Ember.Object.create(p);
|
this._polls[p.name] = EmberObject.create(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.set("pollsObject", this._polls);
|
this.set("pollsObject", this._polls);
|
||||||
@ -78,8 +79,8 @@ function initializePolls(api) {
|
|||||||
if (quotedId) {
|
if (quotedId) {
|
||||||
const quotedPost = post.quoted[quotedId];
|
const quotedPost = post.quoted[quotedId];
|
||||||
if (quotedPost) {
|
if (quotedPost) {
|
||||||
post = Ember.Object.create(quotedPost);
|
post = EmberObject.create(quotedPost);
|
||||||
poll = Ember.Object.create(
|
poll = EmberObject.create(
|
||||||
quotedPost.polls.find(p => p.name === pollName)
|
quotedPost.polls.find(p => p.name === pollName)
|
||||||
);
|
);
|
||||||
vote = quotedPost.polls_votes || {};
|
vote = quotedPost.polls_votes || {};
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
|
import EmberObject from "@ember/object";
|
||||||
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
||||||
|
|
||||||
moduleForWidget("discourse-poll-standard-results");
|
moduleForWidget("discourse-poll-standard-results");
|
||||||
|
|
||||||
const template = `{{mount-widget
|
const template = `{{mount-widget
|
||||||
@ -11,7 +13,7 @@ widgetTest("options in descending order", {
|
|||||||
beforeEach() {
|
beforeEach() {
|
||||||
this.set(
|
this.set(
|
||||||
"poll",
|
"poll",
|
||||||
Ember.Object.create({
|
EmberObject.create({
|
||||||
options: [{ votes: 5 }, { votes: 4 }],
|
options: [{ votes: 5 }, { votes: 4 }],
|
||||||
voters: 9
|
voters: 9
|
||||||
})
|
})
|
||||||
@ -30,7 +32,7 @@ widgetTest("options in ascending order", {
|
|||||||
beforeEach() {
|
beforeEach() {
|
||||||
this.set(
|
this.set(
|
||||||
"poll",
|
"poll",
|
||||||
Ember.Object.create({
|
EmberObject.create({
|
||||||
options: [{ votes: 4 }, { votes: 5 }],
|
options: [{ votes: 4 }, { votes: 5 }],
|
||||||
voters: 9
|
voters: 9
|
||||||
})
|
})
|
||||||
@ -50,7 +52,7 @@ widgetTest("multiple options in descending order", {
|
|||||||
this.set("isMultiple", true);
|
this.set("isMultiple", true);
|
||||||
this.set(
|
this.set(
|
||||||
"poll",
|
"poll",
|
||||||
Ember.Object.create({
|
EmberObject.create({
|
||||||
type: "multiple",
|
type: "multiple",
|
||||||
options: [
|
options: [
|
||||||
{ votes: 5, html: "a" },
|
{ votes: 5, html: "a" },
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import ArrayProxy from "@ember/array/proxy";
|
||||||
import Post from "discourse/models/post";
|
import Post from "discourse/models/post";
|
||||||
import createStore from "helpers/create-store";
|
import createStore from "helpers/create-store";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
@ -863,7 +864,7 @@ QUnit.test("postsWithPlaceholders", async assert => {
|
|||||||
const postsWithPlaceholders = postStream.get("postsWithPlaceholders");
|
const postsWithPlaceholders = postStream.get("postsWithPlaceholders");
|
||||||
const store = postStream.store;
|
const store = postStream.store;
|
||||||
|
|
||||||
const testProxy = Ember.ArrayProxy.create({ content: postsWithPlaceholders });
|
const testProxy = ArrayProxy.create({ content: postsWithPlaceholders });
|
||||||
|
|
||||||
const p1 = store.createRecord("post", { id: 1, post_number: 1 });
|
const p1 = store.createRecord("post", { id: 1, post_number: 1 });
|
||||||
const p2 = store.createRecord("post", { id: 2, post_number: 2 });
|
const p2 = store.createRecord("post", { id: 2, post_number: 2 });
|
||||||
|
Reference in New Issue
Block a user