DEV: Fix imports (#132)
This commit is contained in:
		
							parent
							
								
									c788b7bf1f
								
							
						
					
					
						commit
						7e2a490b67
					
				| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
{}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,24 +1,27 @@
 | 
			
		|||
import Component from "@ember/component";
 | 
			
		||||
import { inject as service } from "@ember/service";
 | 
			
		||||
import { alias, or } from "@ember/object/computed";
 | 
			
		||||
import discourseComputed from "discourse-common/utils/decorators";
 | 
			
		||||
 | 
			
		||||
export default Ember.Component.extend({
 | 
			
		||||
  router: Ember.inject.service(),
 | 
			
		||||
export default Component.extend({
 | 
			
		||||
  router: service(),
 | 
			
		||||
 | 
			
		||||
  currentCategoryId: Ember.computed.or(
 | 
			
		||||
  currentCategoryId: or(
 | 
			
		||||
    "router.currentRoute.attributes.category.id",
 | 
			
		||||
    "router.currentRoute.parent.attributes.category_id"
 | 
			
		||||
  ),
 | 
			
		||||
 | 
			
		||||
  currentCategorySlug: Ember.computed.or(
 | 
			
		||||
  currentCategorySlug: or(
 | 
			
		||||
    "router.currentRoute.attributes.category.slug",
 | 
			
		||||
    "router.currentRoute.parent.attributes.category.slug"
 | 
			
		||||
  ),
 | 
			
		||||
 | 
			
		||||
  // Server needs to compute this in case hidden tags are being used.
 | 
			
		||||
  topicTagsDisableAds: Ember.computed.alias(
 | 
			
		||||
  topicTagsDisableAds: alias(
 | 
			
		||||
    "router.currentRoute.parent.attributes.tags_disable_ads"
 | 
			
		||||
  ),
 | 
			
		||||
 | 
			
		||||
  isRestrictedCategory: Ember.computed.or(
 | 
			
		||||
  isRestrictedCategory: or(
 | 
			
		||||
    "router.currentRoute.attributes.category.read_restricted",
 | 
			
		||||
    "router.currentRoute.parent.attributes.category.read_restricted"
 | 
			
		||||
  ),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,9 @@
 | 
			
		|||
import EmberObject from "@ember/object";
 | 
			
		||||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
 | 
			
		||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
 | 
			
		||||
import { isBlank } from "@ember/utils";
 | 
			
		||||
 | 
			
		||||
const adConfig = Ember.Object.create({
 | 
			
		||||
const adConfig = EmberObject.create({
 | 
			
		||||
  "google-adsense": {
 | 
			
		||||
    settingPrefix: "adsense", // settings follow naming convention
 | 
			
		||||
    enabledSetting: "adsense_publisher_code",
 | 
			
		||||
| 
						 | 
				
			
			@ -82,7 +84,7 @@ export default AdComponent.extend({
 | 
			
		|||
 | 
			
		||||
      if (
 | 
			
		||||
        Object.keys(houseAds.creatives).length > 0 &&
 | 
			
		||||
        !Ember.isBlank(adsForSlot) &&
 | 
			
		||||
        !isBlank(adsForSlot) &&
 | 
			
		||||
        (!postNumber ||
 | 
			
		||||
          this.isNthPost(parseInt(houseAds.settings.after_nth_post, 10)))
 | 
			
		||||
      ) {
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +99,7 @@ export default AdComponent.extend({
 | 
			
		|||
 | 
			
		||||
      if (
 | 
			
		||||
        ((config.enabledSetting &&
 | 
			
		||||
          !Ember.isBlank(this.siteSettings[config.enabledSetting])) ||
 | 
			
		||||
          !isBlank(this.siteSettings[config.enabledSetting])) ||
 | 
			
		||||
          config.enabledSetting === false) &&
 | 
			
		||||
        (!postNumber ||
 | 
			
		||||
          !config.nthPost ||
 | 
			
		||||
| 
						 | 
				
			
			@ -123,7 +125,7 @@ export default AdComponent.extend({
 | 
			
		|||
        if (
 | 
			
		||||
          name !== false &&
 | 
			
		||||
          this.siteSettings[name] !== false &&
 | 
			
		||||
          !Ember.isBlank(this.siteSettings[name])
 | 
			
		||||
          !isBlank(this.siteSettings[name])
 | 
			
		||||
        ) {
 | 
			
		||||
          types.push(adNetwork);
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,9 @@
 | 
			
		|||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
 | 
			
		||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
 | 
			
		||||
import loadScript from "discourse/lib/load-script";
 | 
			
		||||
import RSVP from "rsvp";
 | 
			
		||||
import { scheduleOnce } from "@ember/runloop";
 | 
			
		||||
import { isTesting } from "discourse-common/config/environment";
 | 
			
		||||
 | 
			
		||||
let _loaded = false,
 | 
			
		||||
  _promise = null,
 | 
			
		||||
| 
						 | 
				
			
			@ -8,7 +11,7 @@ let _loaded = false,
 | 
			
		|||
 | 
			
		||||
function loadAdbutler(adserverHostname) {
 | 
			
		||||
  if (_loaded) {
 | 
			
		||||
    return Ember.RSVP.resolve();
 | 
			
		||||
    return RSVP.resolve();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (_promise) {
 | 
			
		||||
| 
						 | 
				
			
			@ -71,7 +74,7 @@ export default AdComponent.extend({
 | 
			
		|||
  },
 | 
			
		||||
 | 
			
		||||
  _triggerAds() {
 | 
			
		||||
    if (Ember.testing) {
 | 
			
		||||
    if (isTesting()) {
 | 
			
		||||
      return; // Don't load external JS during tests
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +108,7 @@ export default AdComponent.extend({
 | 
			
		|||
 | 
			
		||||
  didInsertElement() {
 | 
			
		||||
    this._super();
 | 
			
		||||
    Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
 | 
			
		||||
    scheduleOnce("afterRender", this, this._triggerAds);
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  @observes("listLoading")
 | 
			
		||||
| 
						 | 
				
			
			@ -114,7 +117,7 @@ export default AdComponent.extend({
 | 
			
		|||
      return;
 | 
			
		||||
    } // already requested that this ad unit be populated
 | 
			
		||||
    if (!this.get("listLoading")) {
 | 
			
		||||
      Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
 | 
			
		||||
      scheduleOnce("afterRender", this, this._triggerAds);
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,11 @@
 | 
			
		|||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
 | 
			
		||||
import discourseComputed from "discourse-common/utils/decorators";
 | 
			
		||||
import { and } from "@ember/object/computed";
 | 
			
		||||
 | 
			
		||||
export default AdComponent.extend({
 | 
			
		||||
  classNames: ["amazon-product-links"],
 | 
			
		||||
 | 
			
		||||
  showAd: Ember.computed.and(
 | 
			
		||||
  showAd: and(
 | 
			
		||||
    "showToTrustLevel",
 | 
			
		||||
    "showToGroups",
 | 
			
		||||
    "showAfterPost",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,9 @@
 | 
			
		|||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
 | 
			
		||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
 | 
			
		||||
import loadScript from "discourse/lib/load-script";
 | 
			
		||||
import RSVP from "rsvp";
 | 
			
		||||
import { scheduleOnce } from "@ember/runloop";
 | 
			
		||||
import { isTesting } from "discourse-common/config/environment";
 | 
			
		||||
 | 
			
		||||
let _loaded = false,
 | 
			
		||||
  _promise = null,
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +41,7 @@ function parseAdHeight(value) {
 | 
			
		|||
 | 
			
		||||
function loadAdsense() {
 | 
			
		||||
  if (_loaded) {
 | 
			
		||||
    return Ember.RSVP.resolve();
 | 
			
		||||
    return RSVP.resolve();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (_promise) {
 | 
			
		||||
| 
						 | 
				
			
			@ -138,7 +141,7 @@ export default AdComponent.extend({
 | 
			
		|||
  },
 | 
			
		||||
 | 
			
		||||
  _triggerAds() {
 | 
			
		||||
    if (Ember.testing) {
 | 
			
		||||
    if (isTesting()) {
 | 
			
		||||
      return; // Don't load external JS during tests
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +166,7 @@ export default AdComponent.extend({
 | 
			
		|||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
 | 
			
		||||
    scheduleOnce("afterRender", this, this._triggerAds);
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  @observes("listLoading")
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +175,7 @@ export default AdComponent.extend({
 | 
			
		|||
      return;
 | 
			
		||||
    } // already requested that this ad unit be populated
 | 
			
		||||
    if (!this.get("listLoading")) {
 | 
			
		||||
      Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
 | 
			
		||||
      scheduleOnce("afterRender", this, this._triggerAds);
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,9 @@
 | 
			
		|||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
 | 
			
		||||
import discourseComputed, { on } from "discourse-common/utils/decorators";
 | 
			
		||||
import loadScript from "discourse/lib/load-script";
 | 
			
		||||
import { alias } from "@ember/object/computed";
 | 
			
		||||
import RSVP from "rsvp";
 | 
			
		||||
import { isTesting } from "discourse-common/config/environment";
 | 
			
		||||
 | 
			
		||||
let _loaded = false,
 | 
			
		||||
  _promise = null,
 | 
			
		||||
| 
						 | 
				
			
			@ -200,7 +203,7 @@ function loadGoogle() {
 | 
			
		|||
   */
 | 
			
		||||
 | 
			
		||||
  if (_loaded) {
 | 
			
		||||
    return Ember.RSVP.resolve();
 | 
			
		||||
    return RSVP.resolve();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (_promise) {
 | 
			
		||||
| 
						 | 
				
			
			@ -240,8 +243,8 @@ export default AdComponent.extend({
 | 
			
		|||
  loadedGoogletag: false,
 | 
			
		||||
  refreshOnChange: null,
 | 
			
		||||
  lastAdRefresh: null,
 | 
			
		||||
  width: Ember.computed.alias("size.width"),
 | 
			
		||||
  height: Ember.computed.alias("size.height"),
 | 
			
		||||
  width: alias("size.width"),
 | 
			
		||||
  height: alias("size.height"),
 | 
			
		||||
 | 
			
		||||
  @discourseComputed
 | 
			
		||||
  size() {
 | 
			
		||||
| 
						 | 
				
			
			@ -372,7 +375,7 @@ export default AdComponent.extend({
 | 
			
		|||
 | 
			
		||||
  @on("didInsertElement")
 | 
			
		||||
  _initGoogleDFP() {
 | 
			
		||||
    if (Ember.testing) {
 | 
			
		||||
    if (isTesting()) {
 | 
			
		||||
      return; // Don't load external JS during tests
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
 | 
			
		||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
 | 
			
		||||
import { isBlank } from "@ember/utils";
 | 
			
		||||
 | 
			
		||||
const adIndex = {
 | 
			
		||||
  topic_list_top: null,
 | 
			
		||||
| 
						 | 
				
			
			@ -60,10 +61,7 @@ export default AdComponent.extend({
 | 
			
		|||
 | 
			
		||||
    const adsForSlot = houseAds.settings[placement];
 | 
			
		||||
 | 
			
		||||
    if (
 | 
			
		||||
      Object.keys(houseAds.creatives).length > 0 &&
 | 
			
		||||
      !Ember.isBlank(adsForSlot)
 | 
			
		||||
    ) {
 | 
			
		||||
    if (Object.keys(houseAds.creatives).length > 0 && !isBlank(adsForSlot)) {
 | 
			
		||||
      return adsForSlot.split("|");
 | 
			
		||||
    } else {
 | 
			
		||||
      return [];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
 | 
			
		||||
import { mapBy } from "@ember/object/computed";
 | 
			
		||||
 | 
			
		||||
export default HouseAdsSetting.extend({
 | 
			
		||||
  classNames: "house-ads-setting house-ads-list-setting",
 | 
			
		||||
  adNames: Ember.computed.mapBy("allAds", "name"),
 | 
			
		||||
  adNames: mapBy("allAds", "name"),
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,10 @@
 | 
			
		|||
import Component from "@ember/component";
 | 
			
		||||
import { ajax } from "discourse/lib/ajax";
 | 
			
		||||
import { popupAjaxError } from "discourse/lib/ajax-error";
 | 
			
		||||
import { i18n, propertyNotEqual } from "discourse/lib/computed";
 | 
			
		||||
import I18n from "I18n";
 | 
			
		||||
 | 
			
		||||
export default Ember.Component.extend({
 | 
			
		||||
export default Component.extend({
 | 
			
		||||
  classNames: "house-ads-setting",
 | 
			
		||||
  adValue: "",
 | 
			
		||||
  saving: false,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,8 @@
 | 
			
		|||
export default Ember.Controller.extend({
 | 
			
		||||
  adminPluginsHouseAds: Ember.inject.controller("adminPlugins.houseAds"),
 | 
			
		||||
  houseAds: Ember.computed.alias("adminPluginsHouseAds.model"),
 | 
			
		||||
  adSettings: Ember.computed.alias("adminPluginsHouseAds.houseAdsSettings"),
 | 
			
		||||
import Controller, { inject as controller } from "@ember/controller";
 | 
			
		||||
import { alias } from "@ember/object/computed";
 | 
			
		||||
 | 
			
		||||
export default Controller.extend({
 | 
			
		||||
  adminPluginsHouseAds: controller("adminPlugins.houseAds"),
 | 
			
		||||
  houseAds: alias("adminPluginsHouseAds.model"),
 | 
			
		||||
  adSettings: alias("adminPluginsHouseAds.houseAdsSettings"),
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,17 +3,20 @@ import { ajax } from "discourse/lib/ajax";
 | 
			
		|||
import { popupAjaxError } from "discourse/lib/ajax-error";
 | 
			
		||||
import { propertyNotEqual } from "discourse/lib/computed";
 | 
			
		||||
import { bufferedProperty } from "discourse/mixins/buffered-content";
 | 
			
		||||
import bootbox from "bootbox";
 | 
			
		||||
import Controller, { inject as controller } from "@ember/controller";
 | 
			
		||||
import { not, or } from "@ember/object/computed";
 | 
			
		||||
 | 
			
		||||
export default Ember.Controller.extend(bufferedProperty("model"), {
 | 
			
		||||
  adminPluginsHouseAds: Ember.inject.controller("adminPlugins.houseAds"),
 | 
			
		||||
export default Controller.extend(bufferedProperty("model"), {
 | 
			
		||||
  adminPluginsHouseAds: controller("adminPlugins.houseAds"),
 | 
			
		||||
 | 
			
		||||
  saving: false,
 | 
			
		||||
  savingStatus: "",
 | 
			
		||||
 | 
			
		||||
  nameDirty: propertyNotEqual("buffered.name", "model.name"),
 | 
			
		||||
  htmlDirty: propertyNotEqual("buffered.html", "model.html"),
 | 
			
		||||
  dirty: Ember.computed.or("nameDirty", "htmlDirty"),
 | 
			
		||||
  disableSave: Ember.computed.not("dirty"),
 | 
			
		||||
  dirty: or("nameDirty", "htmlDirty"),
 | 
			
		||||
  disableSave: not("dirty"),
 | 
			
		||||
 | 
			
		||||
  actions: {
 | 
			
		||||
    save() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,3 +1,5 @@
 | 
			
		|||
export default Ember.Controller.extend({
 | 
			
		||||
import Controller from "@ember/controller";
 | 
			
		||||
 | 
			
		||||
export default Controller.extend({
 | 
			
		||||
  loadingAds: true,
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,11 @@
 | 
			
		|||
import DiscourseRoute from "discourse/routes/discourse";
 | 
			
		||||
import EmberObject from "@ember/object";
 | 
			
		||||
import I18n from "I18n";
 | 
			
		||||
 | 
			
		||||
export default DiscourseRoute.extend({
 | 
			
		||||
  model(params) {
 | 
			
		||||
    if (params.ad_id === "new") {
 | 
			
		||||
      return Ember.Object.create({
 | 
			
		||||
      return EmberObject.create({
 | 
			
		||||
        name: I18n.t("admin.adplugin.house_ads.new_name"),
 | 
			
		||||
        html: "",
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,13 +1,14 @@
 | 
			
		|||
import { ajax } from "discourse/lib/ajax";
 | 
			
		||||
import DiscourseRoute from "discourse/routes/discourse";
 | 
			
		||||
import EmberObject from "@ember/object";
 | 
			
		||||
 | 
			
		||||
export default DiscourseRoute.extend({
 | 
			
		||||
  settings: null,
 | 
			
		||||
 | 
			
		||||
  model() {
 | 
			
		||||
    return ajax("/admin/plugins/pluginad/house_creatives.json").then((data) => {
 | 
			
		||||
      this.set("settings", Ember.Object.create(data.settings));
 | 
			
		||||
      return data.house_ads.map((ad) => Ember.Object.create(ad));
 | 
			
		||||
      this.set("settings", EmberObject.create(data.settings));
 | 
			
		||||
      return data.house_ads.map((ad) => EmberObject.create(ad));
 | 
			
		||||
    });
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,6 @@
 | 
			
		|||
  "author": "Discourse",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "eslint-config-discourse": "^1.1.8"
 | 
			
		||||
    "eslint-config-discourse": "^2.0.0"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -498,10 +498,10 @@ escape-string-regexp@^1.0.5:
 | 
			
		|||
  resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
 | 
			
		||||
  integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
 | 
			
		||||
 | 
			
		||||
eslint-config-discourse@^1.1.8:
 | 
			
		||||
  version "1.1.8"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-1.1.8.tgz#c297831876811ea08203aa348d1ba2a963b2ae78"
 | 
			
		||||
  integrity sha512-ZSQfhliiO5Cfa7WcKoMkN4wW/1rBJpecpMJpfjiFsElfgPj4EV4Pzksi5CvFnRbJDoZh6DYYrQfO+tW062VOUA==
 | 
			
		||||
eslint-config-discourse@^2.0.0:
 | 
			
		||||
  version "2.0.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-2.0.0.tgz#811ab2cf4e32c1f0d41bd57d9736d578fe80b741"
 | 
			
		||||
  integrity sha512-enjsLU++iibJXM64YM6Y/yUM5580wKtkti9fQdrJDFkfLJnvv8/f2j7QmNbX//MoqWfIQfY2RkHH6VTfRUg4Mw==
 | 
			
		||||
  dependencies:
 | 
			
		||||
    babel-eslint "^10.1.0"
 | 
			
		||||
    ember-template-lint "^2.11.0"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue