DEV: Remove the last (defunct) use of Ember.View (#8976)

This codepath has been deprecated 3 years ago in c5687100b0.

Ember.View has been removed in Ember 2.0.
This commit is contained in:
Jarek Radosz 2020-03-02 20:23:46 +01:00 committed by GitHub
parent f9cc3dc4b7
commit 76a06dfa03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,4 @@
import { next } from "@ember/runloop";
import deprecated from "discourse-common/lib/deprecated";
import { setOwner, getOwner } from "@ember/application";
export default class Connector {
@ -16,44 +15,18 @@ export default class Connector {
next(() => {
const mounted = widget._findView();
if (opts.templateName) {
deprecated(
`Using a 'templateName' for a connector is deprecated. Use 'component' instead [${opts.templateName}]`
);
}
const container = getOwner ? getOwner(mounted) : mounted.container;
let view;
if (opts.component) {
const connector = widget.register.lookupFactory(
"component:connector-container"
);
view = connector.create({
const view = connector.create({
layoutName: `components/${opts.component}`,
model: widget.findAncestorModel()
});
}
if (opts.templateName) {
let context;
if (opts.context === "model") {
const model = widget.findAncestorModel();
context = model;
}
setOwner(view, getOwner(mounted));
view = Ember.View.create({
container: container || widget.register,
templateName: opts.templateName,
context
});
}
if (view) {
if (setOwner) {
setOwner(view, getOwner(mounted));
}
mounted._connected.push(view);
view.renderer.appendTo(view, $elem[0]);
}