DEV: apply coding standards (#43)
This commit is contained in:
parent
ebb190d5e6
commit
9327e705cf
104
.eslintrc
104
.eslintrc
|
@ -1,105 +1,3 @@
|
||||||
{
|
{
|
||||||
"env": {
|
"extends": "eslint-config-discourse"
|
||||||
"jasmine": true,
|
|
||||||
"node": true,
|
|
||||||
"mocha": true,
|
|
||||||
"browser": true,
|
|
||||||
"builtin": true
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 7,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"globals": {
|
|
||||||
"Ember":true,
|
|
||||||
"jQuery":true,
|
|
||||||
"$":true,
|
|
||||||
"RSVP":true,
|
|
||||||
"Discourse":true,
|
|
||||||
"PreloadStore":true,
|
|
||||||
"Handlebars":true,
|
|
||||||
"I18n":true,
|
|
||||||
"bootbox":true,
|
|
||||||
"module":true,
|
|
||||||
"moduleFor":true,
|
|
||||||
"moduleForComponent":true,
|
|
||||||
"Pretender":true,
|
|
||||||
"sandbox":true,
|
|
||||||
"controllerFor":true,
|
|
||||||
"test":true,
|
|
||||||
"ok":true,
|
|
||||||
"not":true,
|
|
||||||
"expect":true,
|
|
||||||
"equal":true,
|
|
||||||
"visit":true,
|
|
||||||
"andThen":true,
|
|
||||||
"click":true,
|
|
||||||
"currentPath":true,
|
|
||||||
"currentRouteName":true,
|
|
||||||
"currentURL":true,
|
|
||||||
"fillIn":true,
|
|
||||||
"keyEvent":true,
|
|
||||||
"triggerEvent":true,
|
|
||||||
"count":true,
|
|
||||||
"exists":true,
|
|
||||||
"visible":true,
|
|
||||||
"invisible":true,
|
|
||||||
"asyncRender":true,
|
|
||||||
"selectKit":true,
|
|
||||||
"asyncTestDiscourse":true,
|
|
||||||
"fixture":true,
|
|
||||||
"find":true,
|
|
||||||
"sinon":true,
|
|
||||||
"moment":true,
|
|
||||||
"start":true,
|
|
||||||
"_":true,
|
|
||||||
"alert":true,
|
|
||||||
"containsInstance":true,
|
|
||||||
"deepEqual":true,
|
|
||||||
"notEqual":true,
|
|
||||||
"define":true,
|
|
||||||
"require":true,
|
|
||||||
"requirejs":true,
|
|
||||||
"hasModule":true,
|
|
||||||
"Blob":true,
|
|
||||||
"File":true},
|
|
||||||
"rules": {
|
|
||||||
"block-scoped-var": 2,
|
|
||||||
"dot-notation": 0,
|
|
||||||
"eqeqeq": [
|
|
||||||
2,
|
|
||||||
"allow-null"
|
|
||||||
],
|
|
||||||
"guard-for-in": 2,
|
|
||||||
"no-bitwise": 2,
|
|
||||||
"no-caller": 2,
|
|
||||||
"no-cond-assign": 0,
|
|
||||||
"no-debugger": 2,
|
|
||||||
"no-empty": 0,
|
|
||||||
"no-eval": 2,
|
|
||||||
"no-extend-native": 2,
|
|
||||||
"no-extra-parens": 0,
|
|
||||||
"no-irregular-whitespace": 2,
|
|
||||||
"no-iterator": 2,
|
|
||||||
"no-loop-func": 2,
|
|
||||||
"no-multi-str": 2,
|
|
||||||
"no-new": 2,
|
|
||||||
"no-plusplus": 0,
|
|
||||||
"no-proto": 2,
|
|
||||||
"no-script-url": 2,
|
|
||||||
"no-sequences": 2,
|
|
||||||
"no-shadow": 2,
|
|
||||||
"no-undef": 2,
|
|
||||||
"no-unused-vars": 2,
|
|
||||||
"no-with": 2,
|
|
||||||
"no-this-before-super": 2,
|
|
||||||
"semi": 2,
|
|
||||||
"strict": 0,
|
|
||||||
"valid-typeof": 2,
|
|
||||||
"wrap-iife": [
|
|
||||||
2,
|
|
||||||
"inside"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"parser": "babel-eslint"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,3 +3,6 @@ auto_generated/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
.rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml
|
.rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml
|
||||||
|
node_modules
|
||||||
|
yarn-error.log
|
||||||
|
.rubocop-https---raw-githubusercontent-com-discourse-*
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
module.exports = {
|
||||||
|
plugins: ["ember-template-lint-plugin-discourse"],
|
||||||
|
extends: "discourse:recommended",
|
||||||
|
};
|
|
@ -2,8 +2,8 @@ export default {
|
||||||
resource: "admin.adminPlugins",
|
resource: "admin.adminPlugins",
|
||||||
path: "/plugins",
|
path: "/plugins",
|
||||||
map() {
|
map() {
|
||||||
this.route("chat", function() {
|
this.route("chat", function () {
|
||||||
this.route("provider", { path: "/:provider" });
|
this.route("provider", { path: "/:provider" });
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNames: ["channel-info"]
|
classNames: ["channel-info"],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
classNames: ["channel-details"],
|
classNames: ["channel-details"],
|
||||||
|
@ -9,7 +10,7 @@ export default Ember.Component.extend({
|
||||||
I18n.t("chat_integration.channel_delete_confirm"),
|
I18n.t("chat_integration.channel_delete_confirm"),
|
||||||
I18n.t("no_value"),
|
I18n.t("no_value"),
|
||||||
I18n.t("yes_value"),
|
I18n.t("yes_value"),
|
||||||
result => {
|
(result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
channel
|
channel
|
||||||
.destroyRecord()
|
.destroyRecord()
|
||||||
|
@ -22,6 +23,6 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
editRule(rule) {
|
editRule(rule) {
|
||||||
this.editRuleWithChannel(rule, this.get("channel"));
|
this.editRuleWithChannel(rule, this.get("channel"));
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,6 +25,6 @@ export default Ember.Component.extend({
|
||||||
.destroyRecord()
|
.destroyRecord()
|
||||||
.then(() => this.refresh())
|
.then(() => this.refresh())
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default Ember.Controller.extend({
|
||||||
anyErrors(channels) {
|
anyErrors(channels) {
|
||||||
let anyErrors = false;
|
let anyErrors = false;
|
||||||
|
|
||||||
channels.forEach(channel => {
|
channels.forEach((channel) => {
|
||||||
if (channel.error_key) {
|
if (channel.error_key) {
|
||||||
anyErrors = true;
|
anyErrors = true;
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,14 @@ export default Ember.Controller.extend({
|
||||||
const model = {
|
const model = {
|
||||||
channel: this.store.createRecord("channel", {
|
channel: this.store.createRecord("channel", {
|
||||||
provider: this.get("model.provider.id"),
|
provider: this.get("model.provider.id"),
|
||||||
data: {}
|
data: {},
|
||||||
}),
|
}),
|
||||||
provider: this.get("model.provider")
|
provider: this.get("model.provider"),
|
||||||
};
|
};
|
||||||
|
|
||||||
showModal("admin-plugins-chat-edit-channel", {
|
showModal("admin-plugins-chat-edit-channel", {
|
||||||
model,
|
model,
|
||||||
admin: true
|
admin: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -40,12 +40,12 @@ export default Ember.Controller.extend({
|
||||||
|
|
||||||
const model = {
|
const model = {
|
||||||
channel,
|
channel,
|
||||||
provider: this.get("model.provider")
|
provider: this.get("model.provider"),
|
||||||
};
|
};
|
||||||
|
|
||||||
showModal("admin-plugins-chat-edit-channel", {
|
showModal("admin-plugins-chat-edit-channel", {
|
||||||
model,
|
model,
|
||||||
admin: true
|
admin: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ export default Ember.Controller.extend({
|
||||||
this.set("modalShowing", true);
|
this.set("modalShowing", true);
|
||||||
showModal("admin-plugins-chat-test", {
|
showModal("admin-plugins-chat-test", {
|
||||||
model: { channel },
|
model: { channel },
|
||||||
admin: true
|
admin: true,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -63,11 +63,11 @@ export default Ember.Controller.extend({
|
||||||
const model = {
|
const model = {
|
||||||
rule: this.store.createRecord("rule", {
|
rule: this.store.createRecord("rule", {
|
||||||
channel_id: channel.id,
|
channel_id: channel.id,
|
||||||
channel
|
channel,
|
||||||
}),
|
}),
|
||||||
channel,
|
channel,
|
||||||
provider: this.get("model.provider"),
|
provider: this.get("model.provider"),
|
||||||
groups: this.get("model.groups")
|
groups: this.get("model.groups"),
|
||||||
};
|
};
|
||||||
|
|
||||||
showModal("admin-plugins-chat-edit-rule", { model, admin: true });
|
showModal("admin-plugins-chat-edit-rule", { model, admin: true });
|
||||||
|
@ -80,7 +80,7 @@ export default Ember.Controller.extend({
|
||||||
rule,
|
rule,
|
||||||
channel,
|
channel,
|
||||||
provider: this.get("model.provider"),
|
provider: this.get("model.provider"),
|
||||||
groups: this.get("model.groups")
|
groups: this.get("model.groups"),
|
||||||
};
|
};
|
||||||
|
|
||||||
showModal("admin-plugins-chat-edit-rule", { model, admin: true });
|
showModal("admin-plugins-chat-edit-rule", { model, admin: true });
|
||||||
|
@ -91,8 +91,8 @@ export default Ember.Controller.extend({
|
||||||
|
|
||||||
showModal("admin-plugins-chat-channel-error", {
|
showModal("admin-plugins-chat-channel-error", {
|
||||||
model: channel,
|
model: channel,
|
||||||
admin: true
|
admin: true,
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
|
import I18n from "I18n";
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import InputValidation from "discourse/models/input-validation";
|
import InputValidation from "discourse/models/input-validation";
|
||||||
import {
|
import {
|
||||||
default as computed,
|
default as computed,
|
||||||
observes,
|
observes,
|
||||||
on
|
on,
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Ember.Controller.extend(ModalFunctionality, {
|
export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
@on("init")
|
@on("init")
|
||||||
setupKeydown() {
|
setupKeydown() {
|
||||||
Ember.run.schedule("afterRender", () => {
|
Ember.run.schedule("afterRender", () => {
|
||||||
$("#chat-integration-edit-channel-modal").keydown(e => {
|
$("#chat-integration-edit-channel-modal").keydown((e) => {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
this.send("save");
|
this.send("save");
|
||||||
}
|
}
|
||||||
|
@ -24,7 +25,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
setupValidations() {
|
setupValidations() {
|
||||||
if (this.get("model.provider")) {
|
if (this.get("model.provider")) {
|
||||||
const theKeys = this.get("model.provider.channel_parameters").map(
|
const theKeys = this.get("model.provider.channel_parameters").map(
|
||||||
param => param["key"]
|
(param) => param["key"]
|
||||||
);
|
);
|
||||||
Ember.defineProperty(
|
Ember.defineProperty(
|
||||||
this,
|
this,
|
||||||
|
@ -49,12 +50,12 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
if (val === "") {
|
if (val === "") {
|
||||||
// Fail silently if field blank
|
// Fail silently if field blank
|
||||||
return InputValidation.create({
|
return InputValidation.create({
|
||||||
failed: true
|
failed: true,
|
||||||
});
|
});
|
||||||
} else if (!regString) {
|
} else if (!regString) {
|
||||||
// Pass silently if no regex available for provider
|
// Pass silently if no regex available for provider
|
||||||
return InputValidation.create({
|
return InputValidation.create({
|
||||||
ok: true
|
ok: true,
|
||||||
});
|
});
|
||||||
} else if (regex.test(val)) {
|
} else if (regex.test(val)) {
|
||||||
// Test against regex
|
// Test against regex
|
||||||
|
@ -62,7 +63,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
ok: true,
|
ok: true,
|
||||||
reason: I18n.t(
|
reason: I18n.t(
|
||||||
"chat_integration.edit_channel_modal.channel_validation.ok"
|
"chat_integration.edit_channel_modal.channel_validation.ok"
|
||||||
)
|
),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Failed regex
|
// Failed regex
|
||||||
|
@ -70,7 +71,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
failed: true,
|
failed: true,
|
||||||
reason: I18n.t(
|
reason: I18n.t(
|
||||||
"chat_integration.edit_channel_modal.channel_validation.fail"
|
"chat_integration.edit_channel_modal.channel_validation.fail"
|
||||||
)
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -79,7 +80,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
const response = {};
|
const response = {};
|
||||||
const parameters = this.get("model.provider.channel_parameters");
|
const parameters = this.get("model.provider.channel_parameters");
|
||||||
|
|
||||||
parameters.forEach(parameter => {
|
parameters.forEach((parameter) => {
|
||||||
response[parameter.key] = this.validate(parameter);
|
response[parameter.key] = this.validate(parameter);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -92,7 +93,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
|
|
||||||
let invalid = false;
|
let invalid = false;
|
||||||
|
|
||||||
Object.keys(paramValidation).forEach(key => {
|
Object.keys(paramValidation).forEach((key) => {
|
||||||
if (!paramValidation[key]) {
|
if (!paramValidation[key]) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +120,6 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
this.send("closeModal");
|
this.send("closeModal");
|
||||||
})
|
})
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
@on("init")
|
@on("init")
|
||||||
setupKeydown() {
|
setupKeydown() {
|
||||||
Ember.run.schedule("afterRender", () => {
|
Ember.run.schedule("afterRender", () => {
|
||||||
$("#chat-integration-edit-channel-modal").keydown(e => {
|
$("#chat-integration-edit-channel-modal").keydown((e) => {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
this.send("save");
|
this.send("save");
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,6 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
.save()
|
.save()
|
||||||
.then(() => this.send("closeModal"))
|
.then(() => this.send("closeModal"))
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import I18n from "I18n";
|
||||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
@ -7,7 +8,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
@on("init")
|
@on("init")
|
||||||
setupKeydown() {
|
setupKeydown() {
|
||||||
Ember.run.schedule("afterRender", () => {
|
Ember.run.schedule("afterRender", () => {
|
||||||
$("#chat_integration_test_modal").keydown(e => {
|
$("#chat_integration_test_modal").keydown((e) => {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
this.send("send");
|
this.send("send");
|
||||||
}
|
}
|
||||||
|
@ -28,15 +29,15 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
||||||
ajax("/admin/plugins/chat/test", {
|
ajax("/admin/plugins/chat/test", {
|
||||||
data: {
|
data: {
|
||||||
channel_id: this.get("model.channel.id"),
|
channel_id: this.get("model.channel.id"),
|
||||||
topic_id: this.get("model.topic_id")
|
topic_id: this.get("model.topic_id"),
|
||||||
},
|
},
|
||||||
type: "POST"
|
type: "POST",
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.set("loading", false);
|
this.set("loading", false);
|
||||||
this.flash(I18n.t("chat_integration.test_modal.success"), "success");
|
this.flash(I18n.t("chat_integration.test_modal.success"), "success");
|
||||||
})
|
})
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,5 +7,5 @@ export default RestModel.extend({
|
||||||
|
|
||||||
createProperties() {
|
createProperties() {
|
||||||
return this.getProperties(["provider", "data"]);
|
return this.getProperties(["provider", "data"]);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
import I18n from "I18n";
|
||||||
import RestModel from "discourse/models/rest";
|
import RestModel from "discourse/models/rest";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import {
|
import {
|
||||||
default as computed,
|
default as computed,
|
||||||
observes
|
observes,
|
||||||
} from "discourse-common/utils/decorators";
|
} from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default RestModel.extend({
|
export default RestModel.extend({
|
||||||
|
@ -14,7 +15,7 @@ export default RestModel.extend({
|
||||||
available.push({
|
available.push({
|
||||||
id: "thread",
|
id: "thread",
|
||||||
name: I18n.t("chat_integration.filter.thread"),
|
name: I18n.t("chat_integration.filter.thread"),
|
||||||
icon: "chevron-right"
|
icon: "chevron-right",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,17 +23,17 @@ export default RestModel.extend({
|
||||||
{
|
{
|
||||||
id: "watch",
|
id: "watch",
|
||||||
name: I18n.t("chat_integration.filter.watch"),
|
name: I18n.t("chat_integration.filter.watch"),
|
||||||
icon: "exclamation-circle"
|
icon: "exclamation-circle",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "follow",
|
id: "follow",
|
||||||
name: I18n.t("chat_integration.filter.follow"),
|
name: I18n.t("chat_integration.filter.follow"),
|
||||||
icon: "circle"
|
icon: "circle",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "mute",
|
id: "mute",
|
||||||
name: I18n.t("chat_integration.filter.mute"),
|
name: I18n.t("chat_integration.filter.mute"),
|
||||||
icon: "times-circle"
|
icon: "times-circle",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -43,9 +44,12 @@ export default RestModel.extend({
|
||||||
{ id: "normal", name: I18n.t("chat_integration.type.normal") },
|
{ id: "normal", name: I18n.t("chat_integration.type.normal") },
|
||||||
{
|
{
|
||||||
id: "group_message",
|
id: "group_message",
|
||||||
name: I18n.t("chat_integration.type.group_message")
|
name: I18n.t("chat_integration.type.group_message"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "group_mention",
|
||||||
|
name: I18n.t("chat_integration.type.group_mention"),
|
||||||
},
|
},
|
||||||
{ id: "group_mention", name: I18n.t("chat_integration.type.group_mention") }
|
|
||||||
],
|
],
|
||||||
|
|
||||||
category_id: null,
|
category_id: null,
|
||||||
|
@ -86,7 +90,7 @@ export default RestModel.extend({
|
||||||
"category_id",
|
"category_id",
|
||||||
"group_id",
|
"group_id",
|
||||||
"tags",
|
"tags",
|
||||||
"filter"
|
"filter",
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -97,7 +101,7 @@ export default RestModel.extend({
|
||||||
"category_id",
|
"category_id",
|
||||||
"group_id",
|
"group_id",
|
||||||
"tags",
|
"tags",
|
||||||
"filter"
|
"filter",
|
||||||
]);
|
]);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,5 +8,5 @@ export default DiscourseRoute.extend({
|
||||||
model.get("firstObject").name
|
model.get("firstObject").name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,14 +9,14 @@ export default DiscourseRoute.extend({
|
||||||
"id",
|
"id",
|
||||||
params.provider
|
params.provider
|
||||||
),
|
),
|
||||||
groups: Group.findAll().then(groups => {
|
groups: Group.findAll().then((groups) => {
|
||||||
return groups.filter(g => !g.get("automatic"));
|
return groups.filter((g) => !g.get("automatic"));
|
||||||
})
|
}),
|
||||||
}).then(value => {
|
}).then((value) => {
|
||||||
value.channels.forEach(channel => {
|
value.channels.forEach((channel) => {
|
||||||
channel.set(
|
channel.set(
|
||||||
"rules",
|
"rules",
|
||||||
channel.rules.map(rule => {
|
channel.rules.map((rule) => {
|
||||||
rule = this.store.createRecord("rule", rule);
|
rule = this.store.createRecord("rule", rule);
|
||||||
rule.set("channel", channel);
|
rule.set("channel", channel);
|
||||||
return rule;
|
return rule;
|
||||||
|
@ -44,6 +44,6 @@ export default DiscourseRoute.extend({
|
||||||
|
|
||||||
refreshProvider() {
|
refreshProvider() {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,8 +8,8 @@ export default DiscourseRoute.extend({
|
||||||
actions: {
|
actions: {
|
||||||
showSettings() {
|
showSettings() {
|
||||||
this.transitionTo("adminSiteSettingsCategory", "plugins", {
|
this.transitionTo("adminSiteSettingsCategory", "plugins", {
|
||||||
queryParams: { filter: "chat_integration" }
|
queryParams: { filter: "chat_integration" },
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
export default function() {
|
export default function () {
|
||||||
this.route("transcript", { path: "/chat-transcript/:secret" });
|
this.route("transcript", { path: "/chat-transcript/:secret" });
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,10 @@ export default DiscourseRoute.extend({
|
||||||
if (this.currentUser) {
|
if (this.currentUser) {
|
||||||
const secret = params.secret;
|
const secret = params.secret;
|
||||||
|
|
||||||
this.replaceWith("discovery.latest").then(e => {
|
this.replaceWith("discovery.latest").then((e) => {
|
||||||
if (this.controllerFor("navigation/default").get("canCreateTopic")) {
|
if (this.controllerFor("navigation/default").get("canCreateTopic")) {
|
||||||
Ember.run.next(() => {
|
Ember.run.next(() => {
|
||||||
ajax(`chat-transcript/${secret}`).then(result => {
|
ajax(`chat-transcript/${secret}`).then((result) => {
|
||||||
e.send(
|
e.send(
|
||||||
"createNewTopicViaParams",
|
"createNewTopicViaParams",
|
||||||
null,
|
null,
|
||||||
|
@ -27,5 +27,5 @@ export default DiscourseRoute.extend({
|
||||||
this.session.set("shouldRedirectToUrl", window.location.href);
|
this.session.set("shouldRedirectToUrl", window.location.href);
|
||||||
this.replaceWith("login");
|
this.replaceWith("login");
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
"author": "Discourse",
|
"author": "Discourse",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^8.2",
|
"eslint-config-discourse": "latest"
|
||||||
"eslint": "^4.19",
|
|
||||||
"prettier": "1.14.3"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,15 @@ acceptance("Chat Integration", {
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
|
|
||||||
pretend(server) {
|
pretend(server) {
|
||||||
const response = object => {
|
const response = (object) => {
|
||||||
return [200, { "Content-Type": "text/html; charset=utf-8" }, object];
|
return [200, { "Content-Type": "text/html; charset=utf-8" }, object];
|
||||||
};
|
};
|
||||||
|
|
||||||
const jsonResponse = object => {
|
const jsonResponse = (object) => {
|
||||||
return [
|
return [
|
||||||
200,
|
200,
|
||||||
{ "Content-Type": "application/json; charset=utf-8" },
|
{ "Content-Type": "application/json; charset=utf-8" },
|
||||||
object
|
object,
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ acceptance("Chat Integration", {
|
||||||
{
|
{
|
||||||
name: "dummy",
|
name: "dummy",
|
||||||
id: "dummy",
|
id: "dummy",
|
||||||
channel_parameters: [{ key: "somekey", regex: "^\\S+$" }]
|
channel_parameters: [{ key: "somekey", regex: "^\\S+$" }],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ acceptance("Chat Integration", {
|
||||||
type: "normal",
|
type: "normal",
|
||||||
tags: [],
|
tags: [],
|
||||||
filter: "watch",
|
filter: "watch",
|
||||||
error_key: null
|
error_key: null,
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -82,25 +82,22 @@ acceptance("Chat Integration", {
|
||||||
server.get("/groups/search.json", () => {
|
server.get("/groups/search.json", () => {
|
||||||
return jsonResponse([]);
|
return jsonResponse([]);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Rules load successfully", async assert => {
|
test("Rules load successfully", async (assert) => {
|
||||||
await visit("/admin/plugins/chat");
|
await visit("/admin/plugins/chat");
|
||||||
|
|
||||||
assert.ok(exists("#admin-plugin-chat table"), "it shows the table of rules");
|
assert.ok(exists("#admin-plugin-chat table"), "it shows the table of rules");
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find("#admin-plugin-chat table tr td")
|
find("#admin-plugin-chat table tr td").eq(0).text().trim(),
|
||||||
.eq(0)
|
|
||||||
.text()
|
|
||||||
.trim(),
|
|
||||||
"All posts and replies",
|
"All posts and replies",
|
||||||
"rule displayed"
|
"rule displayed"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Create channel works", async assert => {
|
test("Create channel works", async (assert) => {
|
||||||
await visit("/admin/plugins/chat");
|
await visit("/admin/plugins/chat");
|
||||||
await click("#create-channel");
|
await click("#create-channel");
|
||||||
|
|
||||||
|
@ -128,7 +125,7 @@ test("Create channel works", async assert => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Edit channel works", async assert => {
|
test("Edit channel works", async (assert) => {
|
||||||
await visit("/admin/plugins/chat");
|
await visit("/admin/plugins/chat");
|
||||||
await click(".channel-header button:first");
|
await click(".channel-header button:first");
|
||||||
|
|
||||||
|
@ -161,7 +158,7 @@ test("Edit channel works", async assert => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Create rule works", async assert => {
|
test("Create rule works", async (assert) => {
|
||||||
await visit("/admin/plugins/chat");
|
await visit("/admin/plugins/chat");
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
|
@ -182,7 +179,7 @@ test("Create rule works", async assert => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Edit rule works", async assert => {
|
test("Edit rule works", async (assert) => {
|
||||||
await visit("/admin/plugins/chat");
|
await visit("/admin/plugins/chat");
|
||||||
|
|
||||||
assert.ok(exists(".edit:first"), "edit button is displayed");
|
assert.ok(exists(".edit:first"), "edit button is displayed");
|
||||||
|
@ -203,7 +200,7 @@ test("Edit rule works", async assert => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Delete channel works", async assert => {
|
test("Delete channel works", async (assert) => {
|
||||||
await visit("/admin/plugins/chat");
|
await visit("/admin/plugins/chat");
|
||||||
|
|
||||||
assert.ok(exists(".channel-header button:last"), "delete button exists");
|
assert.ok(exists(".channel-header button:last"), "delete button exists");
|
||||||
|
@ -215,14 +212,14 @@ test("Delete channel works", async assert => {
|
||||||
assert.ok(exists("div.bootbox") === false, "modal has closed");
|
assert.ok(exists("div.bootbox") === false, "modal has closed");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Delete rule works", async assert => {
|
test("Delete rule works", async (assert) => {
|
||||||
await visit("/admin/plugins/chat");
|
await visit("/admin/plugins/chat");
|
||||||
|
|
||||||
assert.ok(exists(".delete:first"));
|
assert.ok(exists(".delete:first"));
|
||||||
await click(".delete:first");
|
await click(".delete:first");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test channel works", async assert => {
|
test("Test channel works", async (assert) => {
|
||||||
await visit("/admin/plugins/chat");
|
await visit("/admin/plugins/chat");
|
||||||
|
|
||||||
await click(".btn-chat-test");
|
await click(".btn-chat-test");
|
||||||
|
|
Loading…
Reference in New Issue