This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/plugin-connector.js.es6
2018-06-15 17:03:24 +02:00

29 lines
845 B
JavaScript

import { observes } from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
init() {
this._super();
const connector = this.get("connector");
this.set("layoutName", connector.templateName);
const args = this.get("args") || {};
Object.keys(args).forEach(key => this.set(key, args[key]));
const connectorClass = this.get("connector.connectorClass");
connectorClass.setupComponent.call(this, args, this);
},
@observes("args")
_argsChanged() {
const args = this.get("args") || {};
Object.keys(args).forEach(key => this.set(key, args[key]));
},
send(name, ...args) {
const connectorClass = this.get("connector.connectorClass");
const action = connectorClass.actions[name];
return action ? action.call(this, ...args) : this._super(name, ...args);
}
});