Skip to content

A platform for community discussion. Free, open, simple.

DEV: Remove Ember.Mixin to import @ember/object/mixin (#8269)

Mark VanLandinghamba4b557114d7
diff --git a/app/assets/javascripts/admin/mixins/penalty-controller.js.es6 b/app/assets/javascripts/admin/mixins/penalty-controller.js.es6
index b38e249da37..e418887da26 100644
--- a/app/assets/javascripts/admin/mixins/penalty-controller.js.es6
+++ b/app/assets/javascripts/admin/mixins/penalty-controller.js.es6
@@ -1,7 +1,8 @@
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { popupAjaxError } from "discourse/lib/ajax-error";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create(ModalFunctionality, {
+export default Mixin.create(ModalFunctionality, {
reason: null,
message: null,
postEdit: null,
diff --git a/app/assets/javascripts/admin/mixins/period-computation.js.es6 b/app/assets/javascripts/admin/mixins/period-computation.js.es6
index 4323532e845..01d903f3737 100644
--- a/app/assets/javascripts/admin/mixins/period-computation.js.es6
+++ b/app/assets/javascripts/admin/mixins/period-computation.js.es6
@@ -1,7 +1,8 @@
import DiscourseURL from "discourse/lib/url";
import computed from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
queryParams: ["period"],
period: "monthly",
diff --git a/app/assets/javascripts/admin/mixins/setting-component.js.es6 b/app/assets/javascripts/admin/mixins/setting-component.js.es6
index c25efa99db9..28d3e1525d1 100644
--- a/app/assets/javascripts/admin/mixins/setting-component.js.es6
+++ b/app/assets/javascripts/admin/mixins/setting-component.js.es6
@@ -1,5 +1,6 @@
import computed from "ember-addons/ember-computed-decorators";
import { categoryLinkHTML } from "discourse/helpers/category-link";
+import Mixin from '@ember/object/mixin';
const CUSTOM_TYPES = [
"bool",
@@ -19,7 +20,7 @@ const CUSTOM_TYPES = [
const AUTO_REFRESH_ON_SAVE = ["logo", "logo_small", "large_icon"];
-export default Ember.Mixin.create({
+export default Mixin.create({
classNameBindings: [":row", ":setting", "overridden", "typeClass"],
content: Ember.computed.alias("setting"),
validationMessage: null,
diff --git a/app/assets/javascripts/admin/mixins/setting-object.js.es6 b/app/assets/javascripts/admin/mixins/setting-object.js.es6
index ef047af7327..ec91a5ad018 100644
--- a/app/assets/javascripts/admin/mixins/setting-object.js.es6
+++ b/app/assets/javascripts/admin/mixins/setting-object.js.es6
@@ -1,6 +1,7 @@
import computed from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
@computed("value", "default")
overridden(val, defaultVal) {
if (val === null) val = "";
diff --git a/app/assets/javascripts/discourse-loader.js b/app/assets/javascripts/discourse-loader.js
index 68128b1f6a6..cb83e8aa4ec 100644
--- a/app/assets/javascripts/discourse-loader.js
+++ b/app/assets/javascripts/discourse-loader.js
@@ -12,6 +12,7 @@ var define, requirejs;
inject: Ember.inject.controller
},
"@ember/object": { default: Ember.Object },
+ "@ember/object/mixin": { default: Ember.Mixin },
"@ember/object/proxy": { default: Ember.ObjectProxy },
"@ember/routing/route": { default: Ember.Route },
"@ember/runloop": {
diff --git a/app/assets/javascripts/discourse/mixins/buffered-content.js.es6 b/app/assets/javascripts/discourse/mixins/buffered-content.js.es6
index 99364df7a9c..08723e1486a 100644
--- a/app/assets/javascripts/discourse/mixins/buffered-content.js.es6
+++ b/app/assets/javascripts/discourse/mixins/buffered-content.js.es6
@@ -1,4 +1,5 @@
import EmberObjectProxy from "@ember/object/proxy";
+import Mixin from "@ember/object/mixin";
/* global BufferedProxy: true */
export function bufferedProperty(property) {
@@ -21,7 +22,7 @@ export function bufferedProperty(property) {
// It's a good idea to null out fields when declaring objects
mixin.property = null;
- return Ember.Mixin.create(mixin);
+ return Mixin.create(mixin);
}
export default bufferedProperty("content");
diff --git a/app/assets/javascripts/discourse/mixins/bulk-topic-selection.js.es6 b/app/assets/javascripts/discourse/mixins/bulk-topic-selection.js.es6
index 411dfb6688a..b03bf1f86fa 100644
--- a/app/assets/javascripts/discourse/mixins/bulk-topic-selection.js.es6
+++ b/app/assets/javascripts/discourse/mixins/bulk-topic-selection.js.es6
@@ -1,7 +1,8 @@
import { NotificationLevels } from "discourse/lib/notification-levels";
import { on } from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
bulkSelectEnabled: false,
selected: null,
diff --git a/app/assets/javascripts/discourse/mixins/can-check-emails.js.es6 b/app/assets/javascripts/discourse/mixins/can-check-emails.js.es6
index a7eb59fe7b6..f3af56a3ec9 100644
--- a/app/assets/javascripts/discourse/mixins/can-check-emails.js.es6
+++ b/app/assets/javascripts/discourse/mixins/can-check-emails.js.es6
@@ -1,6 +1,7 @@
import { propertyEqual, setting } from "discourse/lib/computed";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
isCurrentUser: propertyEqual("model.id", "currentUser.id"),
showEmailOnProfile: setting("moderators_view_emails"),
canStaffCheckEmails: Ember.computed.and(
diff --git a/app/assets/javascripts/discourse/mixins/card-contents-base.js.es6 b/app/assets/javascripts/discourse/mixins/card-contents-base.js.es6
index 69bafea2fb9..dae6c1edc1f 100644
--- a/app/assets/javascripts/discourse/mixins/card-contents-base.js.es6
+++ b/app/assets/javascripts/discourse/mixins/card-contents-base.js.es6
@@ -4,8 +4,9 @@ import { schedule } from "@ember/runloop";
import { wantsNewWindow } from "discourse/lib/intercept-click";
import afterTransition from "discourse/lib/after-transition";
import DiscourseURL from "discourse/lib/url";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
elementId: null, //click detection added for data-{elementId}
triggeringLinkClass: null, //the <a> classname where this card should appear
_showCallback: null, //username, $target - load up data for when show is called, should call this._positionCard($target) when it's done.
diff --git a/app/assets/javascripts/discourse/mixins/cleans-up.js.es6 b/app/assets/javascripts/discourse/mixins/cleans-up.js.es6
index 8392aacf27e..2d229620b32 100644
--- a/app/assets/javascripts/discourse/mixins/cleans-up.js.es6
+++ b/app/assets/javascripts/discourse/mixins/cleans-up.js.es6
@@ -1,6 +1,7 @@
+import Mixin from '@ember/object/mixin';
// Include this mixin if you want to be notified when the dom should be
// cleaned (usually on route change.)
-export default Ember.Mixin.create({
+export default Mixin.create({
_initializeChooser: Ember.on("didInsertElement", function() {
this.appEvents.on("dom:clean", this, "cleanUp");
}),
diff --git a/app/assets/javascripts/discourse/mixins/docking.js.es6 b/app/assets/javascripts/discourse/mixins/docking.js.es6
index 18a5ae5bf64..6bc0250d0c2 100644
--- a/app/assets/javascripts/discourse/mixins/docking.js.es6
+++ b/app/assets/javascripts/discourse/mixins/docking.js.es6
@@ -1,4 +1,6 @@
+import Mixin from '@ember/object/mixin';
import { debounce } from "@ember/runloop";
+
const helper = {
offset() {
const mainOffset = $("#main").offset();
@@ -7,7 +9,7 @@ const helper = {
}
};
-export default Ember.Mixin.create({
+export default Mixin.create({
queueDockCheck: null,
init() {
diff --git a/app/assets/javascripts/discourse/mixins/grant-badge-controller.js.es6 b/app/assets/javascripts/discourse/mixins/grant-badge-controller.js.es6
index cc0d82fd879..f13b88dc542 100644
--- a/app/assets/javascripts/discourse/mixins/grant-badge-controller.js.es6
+++ b/app/assets/javascripts/discourse/mixins/grant-badge-controller.js.es6
@@ -1,8 +1,9 @@
import computed from "ember-addons/ember-computed-decorators";
import UserBadge from "discourse/models/user-badge";
import { convertIconClass } from "discourse-common/lib/icon-library";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
@computed("allBadges.[]", "userBadges.[]")
grantableBadges(allBadges, userBadges) {
const granted = userBadges.reduce((map, badge) => {
diff --git a/app/assets/javascripts/discourse/mixins/load-more.js.es6 b/app/assets/javascripts/discourse/mixins/load-more.js.es6
index caf86100ea5..9872914aecc 100644
--- a/app/assets/javascripts/discourse/mixins/load-more.js.es6
+++ b/app/assets/javascripts/discourse/mixins/load-more.js.es6
@@ -1,9 +1,10 @@
import Eyeline from "discourse/lib/eyeline";
import Scrolling from "discourse/mixins/scrolling";
import { on } from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
// Provides the ability to load more items for a view which is scrolled to the bottom.
-export default Ember.Mixin.create(Scrolling, {
+export default Mixin.create(Scrolling, {
scrolled() {
const eyeline = this.eyeline;
return eyeline && eyeline.update();
diff --git a/app/assets/javascripts/discourse/mixins/mobile-scroll-direction.js.es6 b/app/assets/javascripts/discourse/mixins/mobile-scroll-direction.js.es6
index edd93096f02..96534bcda85 100644
--- a/app/assets/javascripts/discourse/mixins/mobile-scroll-direction.js.es6
+++ b/app/assets/javascripts/discourse/mixins/mobile-scroll-direction.js.es6
@@ -1,8 +1,9 @@
import { debounce } from "@ember/runloop";
+import Mixin from '@ember/object/mixin';
// Small buffer so that very tiny scrolls don't trigger mobile header switch
const MOBILE_SCROLL_TOLERANCE = 5;
-export default Ember.Mixin.create({
+export default Mixin.create({
_lastScroll: null,
_bottomHit: 0,
diff --git a/app/assets/javascripts/discourse/mixins/modal-functionality.js.es6 b/app/assets/javascripts/discourse/mixins/modal-functionality.js.es6
index cb4ba7717f1..0f8e860234a 100644
--- a/app/assets/javascripts/discourse/mixins/modal-functionality.js.es6
+++ b/app/assets/javascripts/discourse/mixins/modal-functionality.js.es6
@@ -1,6 +1,7 @@
import showModal from "discourse/lib/show-modal";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
flash(text, messageClass) {
this.appEvents.trigger("modal-body:flash", { text, messageClass });
},
diff --git a/app/assets/javascripts/discourse/mixins/name-validation.js.es6 b/app/assets/javascripts/discourse/mixins/name-validation.js.es6
index 5b505c13598..45bf59750a1 100644
--- a/app/assets/javascripts/discourse/mixins/name-validation.js.es6
+++ b/app/assets/javascripts/discourse/mixins/name-validation.js.es6
@@ -1,7 +1,8 @@
import InputValidation from "discourse/models/input-validation";
import { default as computed } from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
@computed()
nameInstructions() {
return I18n.t(
diff --git a/app/assets/javascripts/discourse/mixins/open-composer.js.es6 b/app/assets/javascripts/discourse/mixins/open-composer.js.es6
index 29a4aca2434..4bd5100cf51 100644
--- a/app/assets/javascripts/discourse/mixins/open-composer.js.es6
+++ b/app/assets/javascripts/discourse/mixins/open-composer.js.es6
@@ -1,7 +1,8 @@
// This mixin allows a route to open the composer
import Composer from "discourse/models/composer";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
openComposer(controller) {
let categoryId = controller.get("category.id");
if (
diff --git a/app/assets/javascripts/discourse/mixins/pan-events.js.es6 b/app/assets/javascripts/discourse/mixins/pan-events.js.es6
index 1608d72fea1..4fa81a71175 100644
--- a/app/assets/javascripts/discourse/mixins/pan-events.js.es6
+++ b/app/assets/javascripts/discourse/mixins/pan-events.js.es6
@@ -1,3 +1,4 @@
+import Mixin from '@ember/object/mixin';
/**
Pan events is a mixin that allows components to detect and respond to swipe gestures
It fires callbacks for panStart, panEnd, panMove with the pan state, and the original event.
@@ -6,7 +7,7 @@ export const SWIPE_VELOCITY = 40;
export const SWIPE_DISTANCE_THRESHOLD = 50;
export const SWIPE_VELOCITY_THRESHOLD = 0.12;
export const MINIMUM_SWIPE_DISTANCE = 5;
-export default Ember.Mixin.create({
+export default Mixin.create({
//velocity is pixels per ms
_panState: null,
diff --git a/app/assets/javascripts/discourse/mixins/password-validation.js.es6 b/app/assets/javascripts/discourse/mixins/password-validation.js.es6
index 50a98e87908..fdd27bb6403 100644
--- a/app/assets/javascripts/discourse/mixins/password-validation.js.es6
+++ b/app/assets/javascripts/discourse/mixins/password-validation.js.es6
@@ -1,7 +1,8 @@
import InputValidation from "discourse/models/input-validation";
import { default as computed } from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
rejectedPasswords: null,
init() {
diff --git a/app/assets/javascripts/discourse/mixins/preferences-tab-controller.js.es6 b/app/assets/javascripts/discourse/mixins/preferences-tab-controller.js.es6
index 080c81fe9fa..0c602e83c55 100644
--- a/app/assets/javascripts/discourse/mixins/preferences-tab-controller.js.es6
+++ b/app/assets/javascripts/discourse/mixins/preferences-tab-controller.js.es6
@@ -1,6 +1,7 @@
import { default as computed } from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
saved: false,
@computed("model.isSaving")
diff --git a/app/assets/javascripts/discourse/mixins/scroll-top.js.es6 b/app/assets/javascripts/discourse/mixins/scroll-top.js.es6
index f666e9be5a9..4fd5aa19645 100644
--- a/app/assets/javascripts/discourse/mixins/scroll-top.js.es6
+++ b/app/assets/javascripts/discourse/mixins/scroll-top.js.es6
@@ -1,6 +1,7 @@
import { scheduleOnce } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url";
import { deprecated } from "discourse/mixins/scroll-top";
+import Mixin from '@ember/object/mixin';
const context = {
_scrollTop() {
@@ -18,7 +19,7 @@ function scrollTop() {
scheduleOnce("afterRender", context, context._scrollTop);
}
-export default Ember.Mixin.create({
+export default Mixin.create({
didInsertElement() {
deprecated(
"The `ScrollTop` mixin is deprecated. Replace it with a `{{d-section}}` component"
diff --git a/app/assets/javascripts/discourse/mixins/scrolling.js.es6 b/app/assets/javascripts/discourse/mixins/scrolling.js.es6
index f51474c0b20..f26d332d169 100644
--- a/app/assets/javascripts/discourse/mixins/scrolling.js.es6
+++ b/app/assets/javascripts/discourse/mixins/scrolling.js.es6
@@ -1,5 +1,6 @@
import { scheduleOnce } from "@ember/runloop";
import debounce from "discourse/lib/debounce";
+import Mixin from '@ember/object/mixin';
/**
This object provides the DOM methods we need for our Mixin to bind to scrolling
@@ -24,7 +25,7 @@ const ScrollingDOMMethods = {
}
};
-const Scrolling = Ember.Mixin.create({
+const Scrolling = Mixin.create({
// Begin watching for scroll events. By default they will be called at max every 100ms.
// call with {debounce: N} for a diff time
bindScrolling(opts) {
diff --git a/app/assets/javascripts/discourse/mixins/singleton.js.es6 b/app/assets/javascripts/discourse/mixins/singleton.js.es6
index b67c529fdf6..ad6625c7ad3 100644
--- a/app/assets/javascripts/discourse/mixins/singleton.js.es6
+++ b/app/assets/javascripts/discourse/mixins/singleton.js.es6
@@ -45,7 +45,9 @@
```
**/
-const Singleton = Ember.Mixin.create({
+import Mixin from '@ember/object/mixin';
+
+const Singleton = Mixin.create({
current() {
if (!this._current) {
this._current = this.createCurrent();
diff --git a/app/assets/javascripts/discourse/mixins/upload.js.es6 b/app/assets/javascripts/discourse/mixins/upload.js.es6
index d12a1ef00ad..655b1374257 100644
--- a/app/assets/javascripts/discourse/mixins/upload.js.es6
+++ b/app/assets/javascripts/discourse/mixins/upload.js.es6
@@ -2,9 +2,11 @@ import {
displayErrorForUpload,
validateUploadedFiles
} from "discourse/lib/utilities";
+
import getUrl from "discourse-common/lib/get-url";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
uploading: false,
uploadProgress: 0,
diff --git a/app/assets/javascripts/discourse/mixins/user-fields-validation.js.es6 b/app/assets/javascripts/discourse/mixins/user-fields-validation.js.es6
index c5345d4ee9d..73580d0e2c5 100644
--- a/app/assets/javascripts/discourse/mixins/user-fields-validation.js.es6
+++ b/app/assets/javascripts/discourse/mixins/user-fields-validation.js.es6
@@ -4,8 +4,9 @@ import {
on,
default as computed
} from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
@on("init")
_createUserFields() {
if (!this.site) {
diff --git a/app/assets/javascripts/discourse/mixins/username-validation.js.es6 b/app/assets/javascripts/discourse/mixins/username-validation.js.es6
index 892f587b85a..c445c608931 100644
--- a/app/assets/javascripts/discourse/mixins/username-validation.js.es6
+++ b/app/assets/javascripts/discourse/mixins/username-validation.js.es6
@@ -2,8 +2,9 @@ import InputValidation from "discourse/models/input-validation";
import debounce from "discourse/lib/debounce";
import { setting } from "discourse/lib/computed";
import { default as computed } from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
uniqueUsernameValidation: null,
maxUsernameLength: setting("max_username_length"),
diff --git a/app/assets/javascripts/select-kit/components/future-date-input-selector/mixin.js.es6 b/app/assets/javascripts/select-kit/components/future-date-input-selector/mixin.js.es6
index d40b2398e7d..07fcbee139c 100644
--- a/app/assets/javascripts/select-kit/components/future-date-input-selector/mixin.js.es6
+++ b/app/assets/javascripts/select-kit/components/future-date-input-selector/mixin.js.es6
@@ -1,7 +1,8 @@
import { CLOSE_STATUS_TYPE } from "discourse/controllers/edit-topic-timer";
import { timeframeDetails } from "select-kit/components/future-date-input-selector";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
_computeIconsForValue(value) {
let { icon } = this._updateAt(value);
diff --git a/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6 b/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6
index 62522d9edd3..fa01f8f84ca 100644
--- a/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6
+++ b/app/assets/javascripts/select-kit/mixins/dom-helpers.js.es6
@@ -1,8 +1,9 @@
import { next } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import { on } from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
init() {
this._super(...arguments);
diff --git a/app/assets/javascripts/select-kit/mixins/events.js.es6 b/app/assets/javascripts/select-kit/mixins/events.js.es6
index f985da16166..231814263aa 100644
--- a/app/assets/javascripts/select-kit/mixins/events.js.es6
+++ b/app/assets/javascripts/select-kit/mixins/events.js.es6
@@ -1,10 +1,11 @@
import { throttle } from "@ember/runloop";
import { schedule } from "@ember/runloop";
import { on } from "ember-addons/ember-computed-decorators";
+import Mixin from '@ember/object/mixin';
const { bind } = Ember.run;
-export default Ember.Mixin.create({
+export default Mixin.create({
@on("init")
_initKeys() {
this.keys = {
diff --git a/app/assets/javascripts/select-kit/mixins/plugin-api.js.es6 b/app/assets/javascripts/select-kit/mixins/plugin-api.js.es6
index fd8c9ae9f68..546c6df6446 100644
--- a/app/assets/javascripts/select-kit/mixins/plugin-api.js.es6
+++ b/app/assets/javascripts/select-kit/mixins/plugin-api.js.es6
@@ -1,3 +1,5 @@
+import Mixin from '@ember/object/mixin';
+
let _appendContentCallbacks = {};
function appendContent(pluginApiIdentifiers, contentFunction) {
if (Ember.isNone(_appendContentCallbacks[pluginApiIdentifiers])) {
@@ -167,7 +169,7 @@ export function clearCallbacks() {
}
const EMPTY_ARRAY = Object.freeze([]);
-export default Ember.Mixin.create({
+export default Mixin.create({
concatenatedProperties: ["pluginApiIdentifiers"],
pluginApiIdentifiers: EMPTY_ARRAY
});
diff --git a/app/assets/javascripts/select-kit/mixins/tags.js.es6 b/app/assets/javascripts/select-kit/mixins/tags.js.es6
index 39644bfa5f1..20a849a410a 100644
--- a/app/assets/javascripts/select-kit/mixins/tags.js.es6
+++ b/app/assets/javascripts/select-kit/mixins/tags.js.es6
@@ -1,8 +1,9 @@
const { run, get } = Ember;
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
+import Mixin from '@ember/object/mixin';
-export default Ember.Mixin.create({
+export default Mixin.create({
willDestroyElement() {
this._super(...arguments);
diff --git a/app/assets/javascripts/select-kit/mixins/utils.js.es6 b/app/assets/javascripts/select-kit/mixins/utils.js.es6
index 3bbf7e8d8e5..1d5c88adcf6 100644
--- a/app/assets/javascripts/select-kit/mixins/utils.js.es6
+++ b/app/assets/javascripts/select-kit/mixins/utils.js.es6
@@ -1,6 +1,7 @@
+import Mixin from '@ember/object/mixin';
const { get, isNone, guidFor } = Ember;
-export default Ember.Mixin.create({
+export default Mixin.create({
valueForContentItem(content) {
switch (typeof content) {
case "string":