diff --git a/assets/javascripts/admin/components/channel-details.js.es6 b/assets/javascripts/admin/components/channel-details.js.es6 index 2b352fa..3e43a66 100644 --- a/assets/javascripts/admin/components/channel-details.js.es6 +++ b/assets/javascripts/admin/components/channel-details.js.es6 @@ -2,12 +2,9 @@ import { popupAjaxError } from "discourse/lib/ajax-error"; export default Ember.Component.extend({ classNames: ["channel-details"], - actions: { - refresh: function() { - this.sendAction("refresh"); - }, - delete(channel) { + actions: { + deleteChannel(channel) { bootbox.confirm( I18n.t("chat_integration.channel_delete_confirm"), I18n.t("no_value"), @@ -16,33 +13,15 @@ export default Ember.Component.extend({ if (result) { channel .destroyRecord() - .then(() => { - this.send("refresh"); - }) + .then(() => this.refresh()) .catch(popupAjaxError); } } ); }, - edit(channel) { - this.sendAction("edit", channel); - }, - - test(channel) { - this.sendAction("test", channel); - }, - - createRule(channel) { - this.sendAction("createRule", channel); - }, - editRule(rule) { - this.sendAction("editRule", rule, this.get("channel")); - }, - - showError(channel) { - this.sendAction("showError", channel); + this.editRuleWithChannel(rule, this.get("channel")); } } }); diff --git a/assets/javascripts/admin/components/rule-row.js.es6 b/assets/javascripts/admin/components/rule-row.js.es6 index 140d69b..7256f84 100644 --- a/assets/javascripts/admin/components/rule-row.js.es6 +++ b/assets/javascripts/admin/components/rule-row.js.es6 @@ -20,21 +20,11 @@ export default Ember.Component.extend({ }, actions: { - edit() { - this.sendAction("edit", this.get("rule")); - }, - delete(rule) { rule .destroyRecord() - .then(() => { - this.send("refresh"); - }) + .then(() => this.refresh()) .catch(popupAjaxError); - }, - - refresh() { - this.sendAction("refresh"); } } }); diff --git a/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 b/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 index 7c0a591..9ff22ee 100644 --- a/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 +++ b/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6 @@ -30,7 +30,7 @@ export default Ember.Controller.extend({ }; showModal("admin-plugins-chat-edit-channel", { - model: model, + model, admin: true }); }, @@ -39,12 +39,12 @@ export default Ember.Controller.extend({ this.set("modalShowing", true); const model = { - channel: channel, + channel, provider: this.get("model.provider") }; showModal("admin-plugins-chat-edit-channel", { - model: model, + model, admin: true }); }, @@ -52,7 +52,7 @@ export default Ember.Controller.extend({ testChannel(channel) { this.set("modalShowing", true); showModal("admin-plugins-chat-test", { - model: { channel: channel }, + model: { channel }, admin: true }); }, @@ -62,24 +62,25 @@ export default Ember.Controller.extend({ const model = { rule: this.store.createRecord("rule", { channel_id: channel.id }), - channel: channel, + channel, provider: this.get("model.provider"), groups: this.get("model.groups") }; - showModal("admin-plugins-chat-edit-rule", { model: model, admin: true }); + showModal("admin-plugins-chat-edit-rule", { model, admin: true }); }, - editRule(rule, channel) { + + editRuleWithChannel(rule, channel) { this.set("modalShowing", true); const model = { - rule: rule, - channel: channel, + rule, + channel, provider: this.get("model.provider"), groups: this.get("model.groups") }; - showModal("admin-plugins-chat-edit-rule", { model: model, admin: true }); + showModal("admin-plugins-chat-edit-rule", { model, admin: true }); }, showError(channel) { diff --git a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-rule.js.es6 b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-rule.js.es6 index 6d14632..2441e56 100644 --- a/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-rule.js.es6 +++ b/assets/javascripts/admin/controllers/modals/admin-plugins-chat-edit-rule.js.es6 @@ -25,18 +25,12 @@ export default Ember.Controller.extend(ModalFunctionality, { }, actions: { - cancel() { - this.send("closeModal"); - }, - - save() { + save(rule) { if (this.get("saveDisabled")) return; - this.get("model.rule") + rule .save() - .then(() => { - this.send("closeModal"); - }) + .then(() => this.send("closeModal")) .catch(popupAjaxError); } } diff --git a/assets/javascripts/admin/routes/admin-plugins-chat-provider.js.es6 b/assets/javascripts/admin/routes/admin-plugins-chat-provider.js.es6 index 69bdd0f..149f29e 100644 --- a/assets/javascripts/admin/routes/admin-plugins-chat-provider.js.es6 +++ b/assets/javascripts/admin/routes/admin-plugins-chat-provider.js.es6 @@ -41,7 +41,7 @@ export default Discourse.Route.extend({ return true; // Continue bubbling up, so the modal actually closes }, - refresh() { + refreshProvider() { this.refresh(); } } diff --git a/assets/javascripts/admin/templates/modal/admin-plugins-chat-edit-rule.hbs b/assets/javascripts/admin/templates/modal/admin-plugins-chat-edit-rule.hbs index c1726e8..d29bc15 100644 --- a/assets/javascripts/admin/templates/modal/admin-plugins-chat-edit-rule.hbs +++ b/assets/javascripts/admin/templates/modal/admin-plugins-chat-edit-rule.hbs @@ -97,14 +97,15 @@
diff --git a/assets/javascripts/admin/templates/modal/admin-plugins-chat-test.hbs b/assets/javascripts/admin/templates/modal/admin-plugins-chat-test.hbs index c936cf4..16da474 100644 --- a/assets/javascripts/admin/templates/modal/admin-plugins-chat-test.hbs +++ b/assets/javascripts/admin/templates/modal/admin-plugins-chat-test.hbs @@ -15,16 +15,18 @@ diff --git a/assets/javascripts/discourse/templates/admin/plugins-chat-provider.hbs b/assets/javascripts/discourse/templates/admin/plugins-chat-provider.hbs index d1aad35..ad27031 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-chat-provider.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-chat-provider.hbs @@ -7,24 +7,24 @@ {{#each model.channels as |channel|}} {{channel-details - channel=channel - provider=model.provider - store=store - refresh='refresh' - edit='editChannel' - test='testChannel' - createRule='createRule' - editRule='editRule' - showError='showError'}} + channel=channel + provider=model.provider + refresh=(route-action "refreshProvider") + editChannel=(action "editChannel") + test=(action "testChannel") + createRule=(action "createRule") + editRuleWithChannel=(action "editRuleWithChannel") + showError=(action "showError")}} {{/each}} diff --git a/assets/javascripts/discourse/templates/admin/plugins-chat.hbs b/assets/javascripts/discourse/templates/admin/plugins-chat.hbs index 7b0036a..3c7539f 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-chat.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-chat.hbs @@ -3,16 +3,20 @@