2022-03-06 21:18:46 +01:00
|
|
|
import Controller from "@ember/controller";
|
2018-08-20 12:05:59 +01:00
|
|
|
import showModal from "discourse/lib/show-modal";
|
2020-02-19 11:56:45 -05:00
|
|
|
import computed from "discourse-common/utils/decorators";
|
2017-06-28 15:12:37 +01:00
|
|
|
|
2022-03-06 21:18:46 +01:00
|
|
|
export default Controller.extend({
|
2017-08-21 16:46:43 +01:00
|
|
|
modalShowing: false,
|
2017-07-18 16:17:03 +01:00
|
|
|
|
2018-08-20 12:05:59 +01:00
|
|
|
@computed("model.channels")
|
2017-10-03 17:42:07 +08:00
|
|
|
anyErrors(channels) {
|
|
|
|
|
let anyErrors = false;
|
|
|
|
|
|
2020-09-04 13:23:28 +02:00
|
|
|
channels.forEach((channel) => {
|
2017-10-03 17:42:07 +08:00
|
|
|
if (channel.error_key) {
|
2017-07-04 19:37:56 +01:00
|
|
|
anyErrors = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-10-03 17:42:07 +08:00
|
|
|
|
2017-07-04 19:37:56 +01:00
|
|
|
return anyErrors;
|
2017-10-03 17:42:07 +08:00
|
|
|
},
|
2017-07-04 19:37:56 +01:00
|
|
|
|
2018-08-20 12:05:59 +01:00
|
|
|
actions: {
|
2017-10-03 17:42:07 +08:00
|
|
|
createChannel() {
|
2018-08-20 12:05:59 +01:00
|
|
|
this.set("modalShowing", true);
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
const model = {
|
2018-08-20 12:05:59 +01:00
|
|
|
channel: this.store.createRecord("channel", {
|
|
|
|
|
provider: this.get("model.provider.id"),
|
2020-09-04 13:23:28 +02:00
|
|
|
data: {},
|
2018-08-20 12:05:59 +01:00
|
|
|
}),
|
2020-09-04 13:23:28 +02:00
|
|
|
provider: this.get("model.provider"),
|
2017-10-03 17:42:07 +08:00
|
|
|
};
|
|
|
|
|
|
2021-08-26 08:52:53 -05:00
|
|
|
showModal("admin-plugins-chat-integration-edit-channel", {
|
2019-03-20 11:57:07 +01:00
|
|
|
model,
|
2020-09-04 13:23:28 +02:00
|
|
|
admin: true,
|
2018-08-20 12:05:59 +01:00
|
|
|
});
|
2017-08-21 16:46:43 +01:00
|
|
|
},
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
editChannel(channel) {
|
2018-08-20 12:05:59 +01:00
|
|
|
this.set("modalShowing", true);
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
const model = {
|
2019-03-20 11:57:07 +01:00
|
|
|
channel,
|
2020-09-04 13:23:28 +02:00
|
|
|
provider: this.get("model.provider"),
|
2017-10-03 17:42:07 +08:00
|
|
|
};
|
|
|
|
|
|
2021-08-26 08:52:53 -05:00
|
|
|
showModal("admin-plugins-chat-integration-edit-channel", {
|
2019-03-20 11:57:07 +01:00
|
|
|
model,
|
2020-09-04 13:23:28 +02:00
|
|
|
admin: true,
|
2018-08-20 12:05:59 +01:00
|
|
|
});
|
2017-08-21 16:46:43 +01:00
|
|
|
},
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
testChannel(channel) {
|
2018-08-20 12:05:59 +01:00
|
|
|
this.set("modalShowing", true);
|
2021-08-26 08:52:53 -05:00
|
|
|
showModal("admin-plugins-chat-integration-test", {
|
2019-03-20 11:57:07 +01:00
|
|
|
model: { channel },
|
2020-09-04 13:23:28 +02:00
|
|
|
admin: true,
|
2018-08-20 12:05:59 +01:00
|
|
|
});
|
2017-07-18 16:17:03 +01:00
|
|
|
},
|
2017-06-29 12:56:48 +01:00
|
|
|
|
2018-08-20 12:05:59 +01:00
|
|
|
createRule(channel) {
|
|
|
|
|
this.set("modalShowing", true);
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
const model = {
|
2020-07-16 12:41:05 +01:00
|
|
|
rule: this.store.createRecord("rule", {
|
|
|
|
|
channel_id: channel.id,
|
2020-09-04 13:23:28 +02:00
|
|
|
channel,
|
2020-07-16 12:41:05 +01:00
|
|
|
}),
|
2019-03-20 11:57:07 +01:00
|
|
|
channel,
|
2018-08-20 12:05:59 +01:00
|
|
|
provider: this.get("model.provider"),
|
2020-09-04 13:23:28 +02:00
|
|
|
groups: this.get("model.groups"),
|
2017-10-03 17:42:07 +08:00
|
|
|
};
|
|
|
|
|
|
2021-08-26 08:52:53 -05:00
|
|
|
showModal("admin-plugins-chat-integration-edit-rule", {
|
|
|
|
|
model,
|
|
|
|
|
admin: true,
|
|
|
|
|
});
|
2017-07-31 17:09:21 +01:00
|
|
|
},
|
2019-03-20 11:57:07 +01:00
|
|
|
|
|
|
|
|
editRuleWithChannel(rule, channel) {
|
2018-08-20 12:05:59 +01:00
|
|
|
this.set("modalShowing", true);
|
2017-10-03 17:42:07 +08:00
|
|
|
|
|
|
|
|
const model = {
|
2019-03-20 11:57:07 +01:00
|
|
|
rule,
|
|
|
|
|
channel,
|
2018-08-20 12:05:59 +01:00
|
|
|
provider: this.get("model.provider"),
|
2020-09-04 13:23:28 +02:00
|
|
|
groups: this.get("model.groups"),
|
2017-10-03 17:42:07 +08:00
|
|
|
};
|
|
|
|
|
|
2021-08-26 08:52:53 -05:00
|
|
|
showModal("admin-plugins-chat-integration-edit-rule", {
|
|
|
|
|
model,
|
|
|
|
|
admin: true,
|
|
|
|
|
});
|
2017-07-31 17:09:21 +01:00
|
|
|
},
|
2018-08-20 12:05:59 +01:00
|
|
|
|
|
|
|
|
showError(channel) {
|
|
|
|
|
this.set("modalShowing", true);
|
|
|
|
|
|
2021-08-26 08:52:53 -05:00
|
|
|
showModal("admin-plugins-chat-integration-channel-error", {
|
2018-08-20 12:05:59 +01:00
|
|
|
model: channel,
|
2020-09-04 13:23:28 +02:00
|
|
|
admin: true,
|
2018-08-20 12:05:59 +01:00
|
|
|
});
|
2020-09-04 13:23:28 +02:00
|
|
|
},
|
|
|
|
|
},
|
2017-10-03 17:42:07 +08:00
|
|
|
});
|