Files
discourse-chat-integration/assets/javascripts/admin/controllers/admin-plugins-chat-integration-provider.js
T

105 lines
2.2 KiB
JavaScript
Raw Normal View History

import showModal from "discourse/lib/show-modal";
2020-02-19 11:56:45 -05:00
import computed from "discourse-common/utils/decorators";
export default Ember.Controller.extend({
2017-08-21 16:46:43 +01:00
modalShowing: false,
@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
actions: {
2017-10-03 17:42:07 +08:00
createChannel() {
this.set("modalShowing", true);
2017-10-03 17:42:07 +08:00
const model = {
channel: this.store.createRecord("channel", {
provider: this.get("model.provider.id"),
2020-09-04 13:23:28 +02:00
data: {},
}),
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", {
model,
2020-09-04 13:23:28 +02:00
admin: true,
});
2017-08-21 16:46:43 +01:00
},
2017-10-03 17:42:07 +08:00
editChannel(channel) {
this.set("modalShowing", true);
2017-10-03 17:42:07 +08:00
const model = {
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", {
model,
2020-09-04 13:23:28 +02:00
admin: true,
});
2017-08-21 16:46:43 +01:00
},
2017-10-03 17:42:07 +08:00
testChannel(channel) {
this.set("modalShowing", true);
2021-08-26 08:52:53 -05:00
showModal("admin-plugins-chat-integration-test", {
model: { channel },
2020-09-04 13:23:28 +02:00
admin: true,
});
},
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
}),
channel,
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
},
editRuleWithChannel(rule, channel) {
this.set("modalShowing", true);
2017-10-03 17:42:07 +08:00
const model = {
rule,
channel,
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
},
showError(channel) {
this.set("modalShowing", true);
2021-08-26 08:52:53 -05:00
showModal("admin-plugins-chat-integration-channel-error", {
model: channel,
2020-09-04 13:23:28 +02:00
admin: true,
});
2020-09-04 13:23:28 +02:00
},
},
2017-10-03 17:42:07 +08:00
});