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

This commit is contained in:
Mark VanLandingham
2019-10-30 14:03:08 -05:00
committed by Robin Ward
parent e7eeb7c47f
commit ba4b557114
32 changed files with 68 additions and 32 deletions

View File

@ -1,7 +1,8 @@
import ModalFunctionality from "discourse/mixins/modal-functionality"; import ModalFunctionality from "discourse/mixins/modal-functionality";
import { popupAjaxError } from "discourse/lib/ajax-error"; 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, reason: null,
message: null, message: null,
postEdit: null, postEdit: null,

View File

@ -1,7 +1,8 @@
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import computed from "ember-addons/ember-computed-decorators"; 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"], queryParams: ["period"],
period: "monthly", period: "monthly",

View File

@ -1,5 +1,6 @@
import computed from "ember-addons/ember-computed-decorators"; import computed from "ember-addons/ember-computed-decorators";
import { categoryLinkHTML } from "discourse/helpers/category-link"; import { categoryLinkHTML } from "discourse/helpers/category-link";
import Mixin from '@ember/object/mixin';
const CUSTOM_TYPES = [ const CUSTOM_TYPES = [
"bool", "bool",
@ -19,7 +20,7 @@ const CUSTOM_TYPES = [
const AUTO_REFRESH_ON_SAVE = ["logo", "logo_small", "large_icon"]; const AUTO_REFRESH_ON_SAVE = ["logo", "logo_small", "large_icon"];
export default Ember.Mixin.create({ export default Mixin.create({
classNameBindings: [":row", ":setting", "overridden", "typeClass"], classNameBindings: [":row", ":setting", "overridden", "typeClass"],
content: Ember.computed.alias("setting"), content: Ember.computed.alias("setting"),
validationMessage: null, validationMessage: null,

View File

@ -1,6 +1,7 @@
import computed from "ember-addons/ember-computed-decorators"; 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") @computed("value", "default")
overridden(val, defaultVal) { overridden(val, defaultVal) {
if (val === null) val = ""; if (val === null) val = "";

View File

@ -12,6 +12,7 @@ var define, requirejs;
inject: Ember.inject.controller inject: Ember.inject.controller
}, },
"@ember/object": { default: Ember.Object }, "@ember/object": { default: Ember.Object },
"@ember/object/mixin": { default: Ember.Mixin },
"@ember/object/proxy": { default: Ember.ObjectProxy }, "@ember/object/proxy": { default: Ember.ObjectProxy },
"@ember/routing/route": { default: Ember.Route }, "@ember/routing/route": { default: Ember.Route },
"@ember/runloop": { "@ember/runloop": {

View File

@ -1,4 +1,5 @@
import EmberObjectProxy from "@ember/object/proxy"; import EmberObjectProxy from "@ember/object/proxy";
import Mixin from "@ember/object/mixin";
/* global BufferedProxy: true */ /* global BufferedProxy: true */
export function bufferedProperty(property) { export function bufferedProperty(property) {
@ -21,7 +22,7 @@ export function bufferedProperty(property) {
// It's a good idea to null out fields when declaring objects // It's a good idea to null out fields when declaring objects
mixin.property = null; mixin.property = null;
return Ember.Mixin.create(mixin); return Mixin.create(mixin);
} }
export default bufferedProperty("content"); export default bufferedProperty("content");

View File

@ -1,7 +1,8 @@
import { NotificationLevels } from "discourse/lib/notification-levels"; import { NotificationLevels } from "discourse/lib/notification-levels";
import { on } from "ember-addons/ember-computed-decorators"; 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, bulkSelectEnabled: false,
selected: null, selected: null,

View File

@ -1,6 +1,7 @@
import { propertyEqual, setting } from "discourse/lib/computed"; 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"), isCurrentUser: propertyEqual("model.id", "currentUser.id"),
showEmailOnProfile: setting("moderators_view_emails"), showEmailOnProfile: setting("moderators_view_emails"),
canStaffCheckEmails: Ember.computed.and( canStaffCheckEmails: Ember.computed.and(

View File

@ -4,8 +4,9 @@ import { schedule } from "@ember/runloop";
import { wantsNewWindow } from "discourse/lib/intercept-click"; import { wantsNewWindow } from "discourse/lib/intercept-click";
import afterTransition from "discourse/lib/after-transition"; import afterTransition from "discourse/lib/after-transition";
import DiscourseURL from "discourse/lib/url"; 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} elementId: null, //click detection added for data-{elementId}
triggeringLinkClass: null, //the <a> classname where this card should appear 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. _showCallback: null, //username, $target - load up data for when show is called, should call this._positionCard($target) when it's done.

View File

@ -1,6 +1,7 @@
import Mixin from '@ember/object/mixin';
// Include this mixin if you want to be notified when the dom should be // Include this mixin if you want to be notified when the dom should be
// cleaned (usually on route change.) // cleaned (usually on route change.)
export default Ember.Mixin.create({ export default Mixin.create({
_initializeChooser: Ember.on("didInsertElement", function() { _initializeChooser: Ember.on("didInsertElement", function() {
this.appEvents.on("dom:clean", this, "cleanUp"); this.appEvents.on("dom:clean", this, "cleanUp");
}), }),

View File

@ -1,4 +1,6 @@
import Mixin from '@ember/object/mixin';
import { debounce } from "@ember/runloop"; import { debounce } from "@ember/runloop";
const helper = { const helper = {
offset() { offset() {
const mainOffset = $("#main").offset(); const mainOffset = $("#main").offset();
@ -7,7 +9,7 @@ const helper = {
} }
}; };
export default Ember.Mixin.create({ export default Mixin.create({
queueDockCheck: null, queueDockCheck: null,
init() { init() {

View File

@ -1,8 +1,9 @@
import computed from "ember-addons/ember-computed-decorators"; import computed from "ember-addons/ember-computed-decorators";
import UserBadge from "discourse/models/user-badge"; import UserBadge from "discourse/models/user-badge";
import { convertIconClass } from "discourse-common/lib/icon-library"; 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.[]") @computed("allBadges.[]", "userBadges.[]")
grantableBadges(allBadges, userBadges) { grantableBadges(allBadges, userBadges) {
const granted = userBadges.reduce((map, badge) => { const granted = userBadges.reduce((map, badge) => {

View File

@ -1,9 +1,10 @@
import Eyeline from "discourse/lib/eyeline"; import Eyeline from "discourse/lib/eyeline";
import Scrolling from "discourse/mixins/scrolling"; import Scrolling from "discourse/mixins/scrolling";
import { on } from "ember-addons/ember-computed-decorators"; 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. // 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() { scrolled() {
const eyeline = this.eyeline; const eyeline = this.eyeline;
return eyeline && eyeline.update(); return eyeline && eyeline.update();

View File

@ -1,8 +1,9 @@
import { debounce } from "@ember/runloop"; import { debounce } from "@ember/runloop";
import Mixin from '@ember/object/mixin';
// Small buffer so that very tiny scrolls don't trigger mobile header switch // Small buffer so that very tiny scrolls don't trigger mobile header switch
const MOBILE_SCROLL_TOLERANCE = 5; const MOBILE_SCROLL_TOLERANCE = 5;
export default Ember.Mixin.create({ export default Mixin.create({
_lastScroll: null, _lastScroll: null,
_bottomHit: 0, _bottomHit: 0,

View File

@ -1,6 +1,7 @@
import showModal from "discourse/lib/show-modal"; 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) { flash(text, messageClass) {
this.appEvents.trigger("modal-body:flash", { text, messageClass }); this.appEvents.trigger("modal-body:flash", { text, messageClass });
}, },

View File

@ -1,7 +1,8 @@
import InputValidation from "discourse/models/input-validation"; import InputValidation from "discourse/models/input-validation";
import { default as computed } from "ember-addons/ember-computed-decorators"; 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() @computed()
nameInstructions() { nameInstructions() {
return I18n.t( return I18n.t(

View File

@ -1,7 +1,8 @@
// This mixin allows a route to open the composer // This mixin allows a route to open the composer
import Composer from "discourse/models/composer"; import Composer from "discourse/models/composer";
import Mixin from '@ember/object/mixin';
export default Ember.Mixin.create({ export default Mixin.create({
openComposer(controller) { openComposer(controller) {
let categoryId = controller.get("category.id"); let categoryId = controller.get("category.id");
if ( if (

View File

@ -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 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. 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_DISTANCE_THRESHOLD = 50;
export const SWIPE_VELOCITY_THRESHOLD = 0.12; export const SWIPE_VELOCITY_THRESHOLD = 0.12;
export const MINIMUM_SWIPE_DISTANCE = 5; export const MINIMUM_SWIPE_DISTANCE = 5;
export default Ember.Mixin.create({ export default Mixin.create({
//velocity is pixels per ms //velocity is pixels per ms
_panState: null, _panState: null,

View File

@ -1,7 +1,8 @@
import InputValidation from "discourse/models/input-validation"; import InputValidation from "discourse/models/input-validation";
import { default as computed } from "ember-addons/ember-computed-decorators"; 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, rejectedPasswords: null,
init() { init() {

View File

@ -1,6 +1,7 @@
import { default as computed } from "ember-addons/ember-computed-decorators"; 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, saved: false,
@computed("model.isSaving") @computed("model.isSaving")

View File

@ -1,6 +1,7 @@
import { scheduleOnce } from "@ember/runloop"; import { scheduleOnce } from "@ember/runloop";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import { deprecated } from "discourse/mixins/scroll-top"; import { deprecated } from "discourse/mixins/scroll-top";
import Mixin from '@ember/object/mixin';
const context = { const context = {
_scrollTop() { _scrollTop() {
@ -18,7 +19,7 @@ function scrollTop() {
scheduleOnce("afterRender", context, context._scrollTop); scheduleOnce("afterRender", context, context._scrollTop);
} }
export default Ember.Mixin.create({ export default Mixin.create({
didInsertElement() { didInsertElement() {
deprecated( deprecated(
"The `ScrollTop` mixin is deprecated. Replace it with a `{{d-section}}` component" "The `ScrollTop` mixin is deprecated. Replace it with a `{{d-section}}` component"

View File

@ -1,5 +1,6 @@
import { scheduleOnce } from "@ember/runloop"; import { scheduleOnce } from "@ember/runloop";
import debounce from "discourse/lib/debounce"; 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 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. // Begin watching for scroll events. By default they will be called at max every 100ms.
// call with {debounce: N} for a diff time // call with {debounce: N} for a diff time
bindScrolling(opts) { bindScrolling(opts) {

View File

@ -45,7 +45,9 @@
``` ```
**/ **/
const Singleton = Ember.Mixin.create({ import Mixin from '@ember/object/mixin';
const Singleton = Mixin.create({
current() { current() {
if (!this._current) { if (!this._current) {
this._current = this.createCurrent(); this._current = this.createCurrent();

View File

@ -2,9 +2,11 @@ import {
displayErrorForUpload, displayErrorForUpload,
validateUploadedFiles validateUploadedFiles
} from "discourse/lib/utilities"; } from "discourse/lib/utilities";
import getUrl from "discourse-common/lib/get-url";
export default Ember.Mixin.create({ import getUrl from "discourse-common/lib/get-url";
import Mixin from '@ember/object/mixin';
export default Mixin.create({
uploading: false, uploading: false,
uploadProgress: 0, uploadProgress: 0,

View File

@ -4,8 +4,9 @@ import {
on, on,
default as computed default as computed
} from "ember-addons/ember-computed-decorators"; } from "ember-addons/ember-computed-decorators";
import Mixin from '@ember/object/mixin';
export default Ember.Mixin.create({ export default Mixin.create({
@on("init") @on("init")
_createUserFields() { _createUserFields() {
if (!this.site) { if (!this.site) {

View File

@ -2,8 +2,9 @@ import InputValidation from "discourse/models/input-validation";
import debounce from "discourse/lib/debounce"; import debounce from "discourse/lib/debounce";
import { setting } from "discourse/lib/computed"; import { setting } from "discourse/lib/computed";
import { default as computed } from "ember-addons/ember-computed-decorators"; 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, uniqueUsernameValidation: null,
maxUsernameLength: setting("max_username_length"), maxUsernameLength: setting("max_username_length"),

View File

@ -1,7 +1,8 @@
import { CLOSE_STATUS_TYPE } from "discourse/controllers/edit-topic-timer"; import { CLOSE_STATUS_TYPE } from "discourse/controllers/edit-topic-timer";
import { timeframeDetails } from "select-kit/components/future-date-input-selector"; 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) { _computeIconsForValue(value) {
let { icon } = this._updateAt(value); let { icon } = this._updateAt(value);

View File

@ -1,8 +1,9 @@
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import { schedule } from "@ember/runloop"; import { schedule } from "@ember/runloop";
import { on } from "ember-addons/ember-computed-decorators"; import { on } from "ember-addons/ember-computed-decorators";
import Mixin from '@ember/object/mixin';
export default Ember.Mixin.create({ export default Mixin.create({
init() { init() {
this._super(...arguments); this._super(...arguments);

View File

@ -1,10 +1,11 @@
import { throttle } from "@ember/runloop"; import { throttle } from "@ember/runloop";
import { schedule } from "@ember/runloop"; import { schedule } from "@ember/runloop";
import { on } from "ember-addons/ember-computed-decorators"; import { on } from "ember-addons/ember-computed-decorators";
import Mixin from '@ember/object/mixin';
const { bind } = Ember.run; const { bind } = Ember.run;
export default Ember.Mixin.create({ export default Mixin.create({
@on("init") @on("init")
_initKeys() { _initKeys() {
this.keys = { this.keys = {

View File

@ -1,3 +1,5 @@
import Mixin from '@ember/object/mixin';
let _appendContentCallbacks = {}; let _appendContentCallbacks = {};
function appendContent(pluginApiIdentifiers, contentFunction) { function appendContent(pluginApiIdentifiers, contentFunction) {
if (Ember.isNone(_appendContentCallbacks[pluginApiIdentifiers])) { if (Ember.isNone(_appendContentCallbacks[pluginApiIdentifiers])) {
@ -167,7 +169,7 @@ export function clearCallbacks() {
} }
const EMPTY_ARRAY = Object.freeze([]); const EMPTY_ARRAY = Object.freeze([]);
export default Ember.Mixin.create({ export default Mixin.create({
concatenatedProperties: ["pluginApiIdentifiers"], concatenatedProperties: ["pluginApiIdentifiers"],
pluginApiIdentifiers: EMPTY_ARRAY pluginApiIdentifiers: EMPTY_ARRAY
}); });

View File

@ -1,8 +1,9 @@
const { run, get } = Ember; const { run, get } = Ember;
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import Mixin from '@ember/object/mixin';
export default Ember.Mixin.create({ export default Mixin.create({
willDestroyElement() { willDestroyElement() {
this._super(...arguments); this._super(...arguments);

View File

@ -1,6 +1,7 @@
import Mixin from '@ember/object/mixin';
const { get, isNone, guidFor } = Ember; const { get, isNone, guidFor } = Ember;
export default Ember.Mixin.create({ export default Mixin.create({
valueForContentItem(content) { valueForContentItem(content) {
switch (typeof content) { switch (typeof content) {
case "string": case "string":