2020-05-12 14:24:33 -04:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2018-09-12 11:16:18 -04:00
|
|
|
import Group from "discourse/models/group";
|
2017-06-28 10:12:37 -04:00
|
|
|
|
2020-05-12 14:24:33 -04:00
|
|
|
export default DiscourseRoute.extend({
|
2017-08-02 06:33:50 -04:00
|
|
|
model(params) {
|
2017-06-29 15:19:40 -04:00
|
|
|
return Ember.RSVP.hash({
|
2018-09-12 11:16:18 -04:00
|
|
|
channels: this.store.findAll("channel", { provider: params.provider }),
|
|
|
|
provider: this.modelFor("admin-plugins-chat").findBy(
|
|
|
|
"id",
|
|
|
|
params.provider
|
|
|
|
),
|
2020-09-04 07:23:28 -04:00
|
|
|
groups: Group.findAll().then((groups) => {
|
|
|
|
return groups.filter((g) => !g.get("automatic"));
|
|
|
|
}),
|
|
|
|
}).then((value) => {
|
|
|
|
value.channels.forEach((channel) => {
|
2018-09-12 11:16:18 -04:00
|
|
|
channel.set(
|
|
|
|
"rules",
|
2020-09-04 07:23:28 -04:00
|
|
|
channel.rules.map((rule) => {
|
2018-09-12 11:16:18 -04:00
|
|
|
rule = this.store.createRecord("rule", rule);
|
2020-06-15 11:45:25 -04:00
|
|
|
rule.set("channel", channel);
|
2018-09-12 11:16:18 -04:00
|
|
|
return rule;
|
|
|
|
})
|
|
|
|
);
|
2017-07-18 11:17:03 -04:00
|
|
|
});
|
2017-10-03 05:42:07 -04:00
|
|
|
|
2017-07-18 11:17:03 -04:00
|
|
|
return value;
|
2017-06-29 15:19:40 -04:00
|
|
|
});
|
2017-06-28 10:12:37 -04:00
|
|
|
},
|
|
|
|
|
2017-10-03 05:42:07 -04:00
|
|
|
serialize(model) {
|
2018-09-12 11:16:18 -04:00
|
|
|
return { provider: model["provider"].get("id") };
|
2017-06-29 07:56:48 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2017-10-03 05:42:07 -04:00
|
|
|
closeModal() {
|
2018-09-12 11:16:18 -04:00
|
|
|
if (this.get("controller.modalShowing")) {
|
2017-06-29 07:56:48 -04:00
|
|
|
this.refresh();
|
2018-09-12 11:16:18 -04:00
|
|
|
this.set("controller.modalShowing", false);
|
2017-06-29 07:56:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true; // Continue bubbling up, so the modal actually closes
|
|
|
|
},
|
|
|
|
|
2019-03-20 06:57:07 -04:00
|
|
|
refreshProvider() {
|
2017-06-29 15:19:40 -04:00
|
|
|
this.refresh();
|
2020-09-04 07:23:28 -04:00
|
|
|
},
|
|
|
|
},
|
2017-06-28 10:12:37 -04:00
|
|
|
});
|