From 25ebfd599840f386c21c6ffc1b7f0d1f9d790f2f Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 18 Feb 2020 23:41:15 +0100 Subject: [PATCH] DEV: allows to import isPresent (#8993) --- app/assets/javascripts/discourse-loader.js | 1 + app/assets/javascripts/discourse/controllers/topic.js.es6 | 4 ++-- .../javascripts/select-kit/components/multi-select.js.es6 | 3 ++- .../javascripts/select-kit/components/select-kit.js.es6 | 8 ++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/discourse-loader.js b/app/assets/javascripts/discourse-loader.js index 9e7780d9109..ab01553c1c9 100644 --- a/app/assets/javascripts/discourse-loader.js +++ b/app/assets/javascripts/discourse-loader.js @@ -80,6 +80,7 @@ var define, requirejs; inject: Ember.inject.service }, "@ember/utils": { + isPresent: Ember.isPresent, isEmpty: Ember.isEmpty, isNone: Ember.isNone }, diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 25f515420b5..ec53fe427de 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -1,4 +1,4 @@ -import { isEmpty } from "@ember/utils"; +import { isPresent, isEmpty } from "@ember/utils"; import { or, and, not, alias } from "@ember/object/computed"; import EmberObject from "@ember/object"; import { next } from "@ember/runloop"; @@ -1299,7 +1299,7 @@ export default Controller.extend(bufferedProperty("model"), { data => { const topic = this.model; - if (Ember.isPresent(data.notification_level_change)) { + if (isPresent(data.notification_level_change)) { topic.set( "details.notification_level", data.notification_level_change diff --git a/app/assets/javascripts/select-kit/components/multi-select.js.es6 b/app/assets/javascripts/select-kit/components/multi-select.js.es6 index 42cb8e52295..0557dc93e5a 100644 --- a/app/assets/javascripts/select-kit/components/multi-select.js.es6 +++ b/app/assets/javascripts/select-kit/components/multi-select.js.es6 @@ -2,6 +2,7 @@ import deprecated from "discourse-common/lib/deprecated"; import SelectKitComponent from "select-kit/components/select-kit"; import { computed } from "@ember/object"; import { makeArray } from "discourse-common/lib/helpers"; +import { isPresent } from "@ember/utils"; export default SelectKitComponent.extend({ pluginApiIdentifiers: ["multi-select"], @@ -41,7 +42,7 @@ export default SelectKitComponent.extend({ }, select(value, item) { - if (!Ember.isPresent(value)) { + if (!isPresent(value)) { if (!this.validateSelect(this.selectKit.highlighted)) { return; } diff --git a/app/assets/javascripts/select-kit/components/select-kit.js.es6 b/app/assets/javascripts/select-kit/components/select-kit.js.es6 index 9eaa205aed8..2a081a22500 100644 --- a/app/assets/javascripts/select-kit/components/select-kit.js.es6 +++ b/app/assets/javascripts/select-kit/components/select-kit.js.es6 @@ -6,7 +6,7 @@ import { get } from "@ember/object"; import UtilsMixin from "select-kit/mixins/utils"; import PluginApiMixin from "select-kit/mixins/plugin-api"; import Mixin from "@ember/object/mixin"; -import { isEmpty, isNone } from "@ember/utils"; +import { isPresent, isEmpty, isNone } from "@ember/utils"; import { next, debounce, @@ -422,8 +422,8 @@ export default Component.extend( } if (this.singleSelect) { - value = Ember.isPresent(value.firstObject) ? value.firstObject : null; - items = Ember.isPresent(items.firstObject) ? items.firstObject : null; + value = isPresent(value.firstObject) ? value.firstObject : null; + items = isPresent(items.firstObject) ? items.firstObject : null; } this._boundaryActionHandler("onChange", value, items); @@ -704,7 +704,7 @@ export default Component.extend( }, select(value, item) { - if (!Ember.isPresent(value)) { + if (!isPresent(value)) { if (!this.validateSelect(this.selectKit.highlighted)) { return; }