Migrate `this.container` to `getOwner(this)`

This commit is contained in:
Robin Ward 2016-11-04 11:32:12 -04:00
parent 24ad68e765
commit 70fb2431a1
35 changed files with 154 additions and 74 deletions

View File

@ -1,6 +1,8 @@
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
router: function() {
return this.container.lookup('router:main');
return getOwner(this).lookup('router:main');
}.property(),
active: function() {

View File

@ -0,0 +1,3 @@
export default function deprecated(msg) {
console.warn(`DEPRECATION: ${msg}`);
}

View File

@ -0,0 +1,32 @@
import deprecated from 'discourse-common/lib/deprecated';
export function getOwner(obj) {
if (Ember.getOwner) {
return Ember.getOwner(obj) || Discourse.__container__;
}
return obj.container;
}
// `this.container` is deprecated, but we can still build a container-like
// object for components to use
export function getRegister(obj) {
const owner = getOwner(obj);
const register = {
lookup: (...args) => owner.lookup(...args),
lookupFactory: (...args) => {
return owner.lookupFactory ? owner.lookupFactory(...args) : owner._lookupFactory(...args);
},
deprecateContainer(target) {
Object.defineProperty(target, 'container', {
get() {
deprecated("Use `this.register` or `getOwner` instead of `this.container`");
return register;
}
});
}
};
return register;
}

View File

@ -1,4 +1,5 @@
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
@computed('placeholderKey')
@ -17,7 +18,7 @@ export default Ember.Component.extend({
var self = this;
var selectedBadges;
var template = this.container.lookup('template:badge-selector-autocomplete.raw');
var template = getOwner(this).lookup('template:badge-selector-autocomplete.raw');
self.$('input').autocomplete({
allowAny: false,
items: _.isArray(this.get('badgeNames')) ? this.get('badgeNames') : [this.get('badgeNames')],

View File

@ -1,6 +1,7 @@
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
import Category from 'discourse/models/category';
import { on, observes } from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
@observes('categories')
@ -12,7 +13,7 @@ export default Ember.Component.extend({
@on('didInsertElement')
_initializeAutocomplete(opts) {
const self = this,
template = this.container.lookup('template:category-selector-autocomplete.raw'),
template = getOwner(this).lookup('template:category-selector-autocomplete.raw'),
regexp = new RegExp(`href=['\"]${Discourse.getURL('/c/')}([^'\"]+)`);
this.$('input').autocomplete({

View File

@ -6,7 +6,7 @@ import { linkSeenTagHashtags, fetchUnseenTagHashtags } from 'discourse/lib/link-
import { load } from 'pretty-text/oneboxer';
import { ajax } from 'discourse/lib/ajax';
import InputValidation from 'discourse/models/input-validation';
import { getOwner } from 'discourse-common/lib/get-owner';
import { tinyAvatar,
displayErrorForUpload,
getUploadMarkdown,
@ -62,7 +62,7 @@ export default Ember.Component.extend({
@on('didInsertElement')
_composerEditorInit() {
const topicId = this.get('topic.id');
const template = this.container.lookup('template:user-selector-autocomplete.raw');
const template = getOwner(this).lookup('template:user-selector-autocomplete.raw');
const $input = this.$('.d-editor-input');
$input.autocomplete({
template,

View File

@ -1,11 +1,12 @@
import computed from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
classNameBindings: [':composer-popup', ':hidden', 'message.extraClass'],
@computed('message.templateName')
defaultLayout(templateName) {
return this.container.lookup(`template:composer/${templateName}`);
return getOwner(this).lookup(`template:composer/${templateName}`);
},
didInsertElement() {

View File

@ -10,6 +10,8 @@ import { cook } from 'discourse/lib/text';
import { translations } from 'pretty-text/emoji/data';
import { emojiSearch } from 'pretty-text/emoji';
import { emojiUrlFor } from 'discourse/lib/text';
import { getRegister } from 'discourse-common/lib/get-owner';
import deprecated from 'discourse-common/lib/deprecated';
// Our head can be a static string or a function that returns a string
// based on input (like for numbered lists).
@ -182,7 +184,7 @@ export function addToolbarCallback(func) {
}
export function onToolbarCreate(func) {
console.warn('`onToolbarCreate` is deprecated, use the plugin api instead.');
deprecated('`onToolbarCreate` is deprecated, use the plugin api instead.');
addToolbarCallback(func);
};
@ -205,15 +207,18 @@ export default Ember.Component.extend({
this.set('ready', true);
},
init() {
this._super();
this.register = getRegister(this);
},
didInsertElement() {
this._super();
const container = this.get('container'),
$editorInput = this.$('.d-editor-input');
this._applyEmojiAutocomplete(container, $editorInput);
this._applyCategoryHashtagAutocomplete(container, $editorInput);
const $editorInput = this.$('.d-editor-input');
this._applyEmojiAutocomplete($editorInput);
this._applyCategoryHashtagAutocomplete($editorInput);
Ember.run.scheduleOnce('afterRender', this, this._readyNow);
@ -287,8 +292,8 @@ export default Ember.Component.extend({
}
},
_applyCategoryHashtagAutocomplete(container) {
const template = container.lookup('template:category-tag-autocomplete.raw');
_applyCategoryHashtagAutocomplete() {
const template = this.register.lookup('template:category-tag-autocomplete.raw');
const siteSettings = this.siteSettings;
this.$('.d-editor-input').autocomplete({
@ -310,10 +315,11 @@ export default Ember.Component.extend({
});
},
_applyEmojiAutocomplete(container, $editorInput) {
_applyEmojiAutocomplete($editorInput) {
if (!this.siteSettings.enable_emoji) { return; }
const template = container.lookup('template:emoji-selector-autocomplete.raw');
const register = this.register;
const template = this.register.lookup('template:emoji-selector-autocomplete.raw');
const self = this;
$editorInput.autocomplete({
@ -329,7 +335,7 @@ export default Ember.Component.extend({
} else {
showSelector({
appendTo: self.$(),
container,
register,
onSelect: title => {
// Remove the previously type characters when a new emoji is selected from the selector.
let selected = self._getSelected();
@ -614,7 +620,7 @@ export default Ember.Component.extend({
emoji() {
showSelector({
appendTo: this.$(),
container: this.container,
register: this.register,
onSelect: title => this._addText(this._getSelected(), `:${title}:`)
});
}

View File

@ -1,4 +1,5 @@
import { on, observes, default as computed } from 'ember-addons/ember-computed-decorators';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
@computed('placeholderKey')
@ -18,7 +19,7 @@ export default Ember.Component.extend({
var selectedGroups;
var groupNames = this.get('groupNames');
var template = this.container.lookup('template:group-selector-autocomplete.raw');
var template = getOwner(this).lookup('template:group-selector-autocomplete.raw');
self.$('input').autocomplete({
allowAny: false,
items: _.isArray(groupNames) ? groupNames : (Ember.isEmpty(groupNames)) ? [] : [groupNames],

View File

@ -1,3 +1,5 @@
import deprecated from 'discourse-common/lib/deprecated';
export function needsSecondRowIf() {
Ember.warn("DEPRECATION: `needsSecondRowIf` is deprecated. Use widget hooks on `header-second-row`");
deprecated("`needsSecondRowIf` is deprecated. Use widget hooks on `header-second-row`");
}

View File

@ -2,6 +2,7 @@ import { keyDirty } from 'discourse/widgets/widget';
import { diff, patch } from 'virtual-dom';
import { WidgetClickHook } from 'discourse/widgets/hooks';
import { renderedKey, queryRegistry } from 'discourse/widgets/widget';
import { getRegister } from 'discourse-common/lib/get-owner';
const _cleanCallbacks = {};
export function addWidgetCleanCallback(widgetName, fn) {
@ -24,12 +25,15 @@ export default Ember.Component.extend({
(this.get('delegated') || []).forEach(m => this.set(m, m));
this._widgetClass = queryRegistry(name) || this.container.lookupFactory(`widget:${name}`);
this.register = getRegister(this);
this._widgetClass = queryRegistry(name) || this.register.lookupFactory(`widget:${name}`);
if (!this._widgetClass) {
console.error(`Error: Could not find widget: ${name}`);
}
this._childEvents = [];
this._connected = [];
this._dispatched = [];
@ -97,13 +101,14 @@ export default Ember.Component.extend({
rerenderWidget() {
Ember.run.cancel(this._timeout);
if (this._rootNode) {
if (!this._widgetClass) { return; }
const t0 = new Date().getTime();
const args = this.get('args') || this.buildArgs();
const opts = { model: this.get('model') };
const newTree = new this._widgetClass(args, this.container, opts);
const newTree = new this._widgetClass(args, this.register, opts);
newTree._emberView = this;
const patches = diff(this._tree || this._rootNode, newTree);

View File

@ -1,6 +1,7 @@
/* You might be looking for navigation-item. */
import computed from "ember-addons/ember-computed-decorators";
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
tagName: 'li',
@ -8,7 +9,7 @@ export default Ember.Component.extend({
@computed()
router() {
return this.container.lookup('router:main');
return getOwner(this).lookup('router:main');
},
@computed("path")

View File

@ -1,5 +1,6 @@
import computed from 'ember-addons/ember-computed-decorators';
import { bufferedRender } from 'discourse-common/lib/buffered-render';
import { getOwner } from 'discourse-common/lib/get-owner';
export function showEntrance(e) {
let target = $(e.target);
@ -11,7 +12,7 @@ export function showEntrance(e) {
target = target.end();
}
}
this.container.lookup('controller:application').send("showTopicEntrance", {topic: this.get('topic'), position: target.offset()});
getOwner(this).lookup('controller:application').send("showTopicEntrance", {topic: this.get('topic'), position: target.offset()});
return false;
}
}
@ -30,7 +31,7 @@ export default Ember.Component.extend(bufferedRender({
},
buildBuffer(buffer) {
const template = Discourse.__container__.lookup('template:list/topic-list-item.raw');
const template = getOwner(this).lookup('template:list/topic-list-item.raw');
if (template) {
buffer.push(template(this));
}

View File

@ -1,6 +1,7 @@
import { observes } from 'ember-addons/ember-computed-decorators';
import TextField from 'discourse/components/text-field';
import userSearch from 'discourse/lib/user-search';
import { getOwner } from 'discourse-common/lib/get-owner';
export default TextField.extend({
@observes('usernames')
@ -30,7 +31,7 @@ export default TextField.extend({
}
this.$().val(this.get('usernames')).autocomplete({
template: this.container.lookup('template:user-selector-autocomplete.raw'),
template: getOwner(this).lookup('template:user-selector-autocomplete.raw'),
disabled: this.get('disabled'),
single: this.get('single'),
allowAny: this.get('allowAny'),

View File

@ -6,6 +6,7 @@ import { default as computed, observes } from 'ember-addons/ember-computed-decor
import { relativeAge } from 'discourse/lib/formatter';
import { escapeExpression } from 'discourse/lib/utilities';
import InputValidation from 'discourse/models/input-validation';
import { getOwner } from 'discourse-common/lib/get-owner';
function loadDraft(store, opts) {
opts = opts || {};
@ -85,8 +86,8 @@ export default Ember.Controller.extend({
},
showToolbar: Em.computed({
get(){
const keyValueStore = this.container.lookup('key-value-store:main');
get() {
const keyValueStore = getOwner(this).lookup('key-value-store:main');
const storedVal = keyValueStore.get("toolbar-enabled");
if (this._toolbarEnabled === undefined && storedVal === undefined) {
// iPhone 6 is 375, anything narrower and toolbar should
@ -97,7 +98,7 @@ export default Ember.Controller.extend({
return this._toolbarEnabled || storedVal === "true";
},
set(key, val){
const keyValueStore = this.container.lookup('key-value-store:main');
const keyValueStore = getOwner(this).lookup('key-value-store:main');
this._toolbarEnabled = val;
keyValueStore.set({key: "toolbar-enabled", value: val ? "true" : "false"});
return val;

View File

@ -1,6 +1,7 @@
import { addFlagProperty as realAddFlagProperty } from 'discourse/components/site-header';
import deprecated from 'discourse-common/lib/deprecated';
export function addFlagProperty(prop) {
Ember.warn("importing `addFlagProperty` is deprecated. Use the PluginAPI instead");
deprecated("importing `addFlagProperty` is deprecated. Use the PluginAPI instead");
realAddFlagProperty(prop);
}

View File

@ -151,7 +151,7 @@ function render(page, offset, options) {
};
$('.emoji-modal', options.appendTo).remove();
const template = options.container.lookup('template:emoji-toolbar.raw');
const template = options.register.lookup('template:emoji-toolbar.raw');
options.appendTo.append(template(model));
bindEvents(page, offset, options);

View File

@ -1,3 +1,5 @@
import deprecated from 'discourse-common/lib/deprecated';
let mobileForced = false;
// An object that is responsible for logic related to mobile devices.
@ -67,10 +69,9 @@ export function resetMobile() {
mobileForced = false;
}
// Backwards compatibiltity, deprecated
Object.defineProperty(Discourse, 'Mobile', {
get: function() {
Ember.warn("DEPRECATION: `Discourse.Mobile` is deprecated, use `this.site.mobileView` instead");
get() {
deprecated("`Discourse.Mobile` is deprecated, use `this.site.mobileView` instead");
return Mobile;
}
});

View File

@ -1,3 +1,5 @@
import deprecated from 'discourse-common/lib/deprecated';
const PageTracker = Ember.Object.extend(Ember.Evented);
let _pageTracker = PageTracker.create();
@ -42,7 +44,7 @@ export function onPageChange(fn) {
// backwards compatibility
const BackwardsCompat = {
current() {
console.warn(`Using PageTracker.current() is deprecated. Your plugin should use the PluginAPI`);
deprecated(`Using PageTracker.current() is deprecated. Your plugin should use the PluginAPI`);
return _pageTracker;
}
};

View File

@ -332,7 +332,8 @@ const DiscourseURL = Ember.Object.extend({
const transition = router.handleURL(path);
transition._discourse_intercepted = true;
transition.promise.then(() => jumpToElement(elementId));
const promise = transition.promise || transition;
promise.then(() => jumpToElement(elementId));
}
}).create();

View File

@ -1,6 +1,7 @@
import { ajax } from 'discourse/lib/ajax';
import RestModel from 'discourse/models/rest';
import ResultSet from 'discourse/models/result-set';
import { getRegister } from 'discourse-common/lib/get-owner';
let _identityMap;
@ -41,6 +42,11 @@ export default Ember.Object.extend({
_plurals: {'post-reply': 'post-replies',
'post-reply-history': 'post_reply_histories'},
init() {
this._super();
this.register = getRegister(this);
},
pluralize(thing) {
return this._plurals[thing] || thing + "s";
},
@ -196,11 +202,11 @@ export default Ember.Object.extend({
obj.__state = obj.id ? "created" : "new";
// TODO: Have injections be automatic
obj.topicTrackingState = this.container.lookup('topic-tracking-state:main');
obj.keyValueStore = this.container.lookup('key-value-store:main');
obj.siteSettings = this.container.lookup('site-settings:main');
obj.topicTrackingState = this.register.lookup('topic-tracking-state:main');
obj.keyValueStore = this.register.lookup('key-value-store:main');
obj.siteSettings = this.register.lookup('site-settings:main');
const klass = this.container.lookupFactory('model:' + type) || RestModel;
const klass = this.register.lookupFactory('model:' + type) || RestModel;
const model = klass.create(obj);
storeMap(type, obj.id, model);
@ -208,7 +214,7 @@ export default Ember.Object.extend({
},
adapterFor(type) {
return this.container.lookup('adapter:' + type) || this.container.lookup('adapter:rest');
return this.register.lookup('adapter:' + type) || this.register.lookup('adapter:rest');
},
_lookupSubType(subType, type, id, root) {
@ -287,7 +293,7 @@ export default Ember.Object.extend({
if (existing) {
delete obj.id;
const klass = this.container.lookupFactory('model:' + type) || RestModel;
const klass = this.register.lookupFactory('model:' + type) || RestModel;
existing.setProperties(klass.munge(obj));
obj.id = id;
return existing;

View File

@ -10,7 +10,10 @@ export default {
// HACK to fix: https://github.com/emberjs/ember.js/issues/10310
const originalBuildInstance = originalBuildInstance || Ember.Application.prototype.buildInstance;
Ember.Application.prototype.buildInstance = function() {
this.registry = this.buildRegistry();
const registry = this.buildRegistry();
if (Ember.VERSION[0] === "1") {
this.registry = registry;
}
return originalBuildInstance.apply(this);
};
}

View File

@ -6,6 +6,7 @@ import OpenComposer from "discourse/mixins/open-composer";
import Category from 'discourse/models/category';
import mobile from 'discourse/lib/mobile';
import { findAll } from 'discourse/models/login-method';
import { getOwner } from 'discourse-common/lib/get-owner';
function unlessReadOnly(method, message) {
return function() {
@ -40,7 +41,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
// Ember doesn't provider a router `willTransition` event so let's make one
willTransition() {
var router = this.container.lookup('router:main');
var router = getOwner(this).lookup('router:main');
Ember.run.once(router, router.trigger, 'willTransition');
return this._super();
},
@ -150,7 +151,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
changeBulkTemplate(w) {
const controllerName = w.replace('modal/', ''),
factory = this.container.lookupFactory('controller:' + controllerName);
factory = getOwner(this).lookupFactory('controller:' + controllerName);
this.render(w, {into: 'modal/topic-bulk-actions', outlet: 'bulkOutlet', controller: factory ? controllerName : 'topic-bulk-actions'});
},
@ -200,7 +201,7 @@ const ApplicationRoute = Discourse.Route.extend(OpenComposer, {
_autoLogin(modal, modalClass, notAuto) {
const methods = findAll(this.siteSettings,
this.container.lookup('capabilities:main'),
getOwner(this).lookup('capabilities:main'),
this.site.isMobileDevice);
if (!this.siteSettings.enable_local_logins && methods.length === 1) {

View File

@ -3,6 +3,7 @@ import { translateResults, getSearchKey, isValidSearchTerm } from "discourse/lib
import Composer from 'discourse/models/composer';
import PreloadStore from 'preload-store';
import { getTransient, setTransient } from 'discourse/lib/page-tracker';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Discourse.Route.extend({
queryParams: { q: {}, expanded: false, context_id: {}, context: {}, skip_context: {} },
@ -52,7 +53,7 @@ export default Discourse.Route.extend({
category = match[1];
}
}
this.container.lookup('controller:composer').open({action: Composer.CREATE_TOPIC, draftKey: Composer.CREATE_TOPIC, topicCategory: category});
getOwner(this).lookup('controller:composer').open({action: Composer.CREATE_TOPIC, draftKey: Composer.CREATE_TOPIC, topicCategory: category});
}
}

View File

@ -56,8 +56,10 @@ export default Discourse.Route.extend({
ignoreIfChanged: true
});
}
}).catch(function(e) {
Ember.warn('Could not view topic', e);
}).catch(e => {
if (!Ember.testing) {
console.log('Could not view topic', e);
}
});
}

View File

@ -17,7 +17,7 @@
<div class='control'>
{{#if site.mobileView}}
<a href class='toggle-toolbar' {{action "toggleToolbar" bubbles=false}}></a>
<a href class='toggle-toolbar' {{action "toggleToolbar" bubbles=false}}></a>
{{/if}}
<a href class='toggler' {{action "toggle" bubbles=false}} title={{i18n 'composer.toggler'}}></a>

View File

@ -21,7 +21,7 @@ export default class Connector {
}
const view = Ember.View.create({
container: widget.container,
container: widget.register,
templateName: opts.templateName,
context
});

View File

@ -8,7 +8,8 @@ class DecoratorHelper {
this.widget = widget;
this.attrs = attrs;
this.state = state;
this.container = widget.container;
this.register = widget.register;
this.register.deprecateContainer(this);
}
/**

View File

@ -63,7 +63,7 @@ export default createWidget('hamburger-menu', {
},
lookupCount(type) {
const tts = this.container.lookup('topic-tracking-state:main');
const tts = this.register.lookup('topic-tracking-state:main');
return tts ? tts.lookupCount(type) : 0;
},

View File

@ -190,7 +190,7 @@ export default createWidget('header', {
updateHighlight() {
if (!this.state.searchVisible) {
const service = this.container.lookup('search-service:main');
const service = this.register.lookup('search-service:main');
service.set('highlightTerm', '');
}
},
@ -208,7 +208,7 @@ export default createWidget('header', {
toggleSearchMenu() {
if (this.site.mobileView) {
const searchService = this.container.lookup('search-service:main');
const searchService = this.register.lookup('search-service:main');
const context = searchService.get('searchContext');
var params = "";
@ -240,7 +240,7 @@ export default createWidget('header', {
state.contextEnabled = false;
const currentPath = this.container.lookup('controller:application').get('currentPath');
const currentPath = this.register.lookup('controller:application').get('currentPath');
const blacklist = [ /^discovery\.categories/ ];
const whitelist = [ /^topic\./ ];
const check = function(regex) { return !!currentPath.match(regex); };
@ -249,7 +249,7 @@ export default createWidget('header', {
// If we're viewing a topic, only intercept search if there are cloaked posts
if (showSearch && currentPath.match(/^topic\./)) {
showSearch = ($('.topic-post .cooked, .small-action:not(.time-gap)').length <
this.container.lookup('controller:topic').get('model.postStream.stream.length'));
this.register.lookup('controller:topic').get('model.postStream.stream.length'));
}
if (state.searchVisible) {

View File

@ -10,7 +10,7 @@ export default createWidget('link', {
href(attrs) {
const route = attrs.route;
if (route) {
const router = this.container.lookup('router:main');
const router = this.register.lookup('router:main');
if (router && router.router) {
const params = [route];
if (attrs.model) {

View File

@ -30,7 +30,7 @@ createWidget('search-context', {
tagName: 'div.search-context',
html(attrs) {
const service = this.container.lookup('search-service:main');
const service = this.register.lookup('search-service:main');
const ctx = service.get('searchContext');
const result = [];

View File

@ -134,7 +134,7 @@ export default createWidget('search-menu', {
searchService() {
if (!this._searchService) {
this._searchService = this.container.lookup('search-service:main');
this._searchService = this.register.lookup('search-service:main');
}
return this._searchService;
},

View File

@ -127,12 +127,14 @@ export function createWidget(name, opts) {
}
export default class Widget {
constructor(attrs, container, opts) {
constructor(attrs, register, opts) {
opts = opts || {};
this.attrs = attrs || {};
this.mergeState = opts.state;
this.container = container;
this.model = opts.model;
this.register = register;
register.deprecateContainer(this);
this.key = this.buildKey ? this.buildKey(attrs) : null;
@ -146,13 +148,13 @@ export default class Widget {
}
}
this.site = container.lookup('site:main');
this.siteSettings = container.lookup('site-settings:main');
this.currentUser = container.lookup('current-user:main');
this.capabilities = container.lookup('capabilities:main');
this.store = container.lookup('store:main');
this.appEvents = container.lookup('app-events:main');
this.keyValueStore = container.lookup('key-value-store:main');
this.site = register.lookup('site:main');
this.siteSettings = register.lookup('site-settings:main');
this.currentUser = register.lookup('current-user:main');
this.capabilities = register.lookup('capabilities:main');
this.store = register.lookup('store:main');
this.appEvents = register.lookup('app-events:main');
this.keyValueStore = register.lookup('key-value-store:main');
if (this.name) {
const custom = _customSettings[this.name];
@ -223,15 +225,15 @@ export default class Widget {
let WidgetClass = _registry[widgetName];
if (!WidgetClass) {
if (!this.container) {
console.error("couldn't find container");
if (!this.register) {
console.error("couldn't find register");
return;
}
WidgetClass = this.container.lookupFactory(`widget:${widgetName}`);
WidgetClass = this.register.lookupFactory(`widget:${widgetName}`);
}
if (WidgetClass) {
const result = new WidgetClass(attrs, this.container, opts);
const result = new WidgetClass(attrs, this.register, opts);
result.parentWidget = this;
return result;
} else {

View File

@ -1,6 +1,7 @@
import getUrl from 'discourse-common/lib/get-url';
import computed from 'ember-addons/ember-computed-decorators';
import { getToken } from 'wizard/lib/ajax';
import { getOwner } from 'discourse-common/lib/get-owner';
export default Ember.Component.extend({
classNames: ['wizard-image-row'],
@ -9,7 +10,7 @@ export default Ember.Component.extend({
@computed('field.id')
previewComponent(id) {
const componentName = `image-preview-${Ember.String.dasherize(id)}`;
const exists = this.container.lookup(`component:${componentName}`);
const exists = getOwner(this).lookup(`component:${componentName}`);
return exists ? componentName : 'wizard-image-preview';
},