mirror of
https://github.com/discourse/discourse-chat-integration.git
synced 2025-07-08 14:42:44 +00:00
DEV: Update linting config and run gjs-codemod (#258)
This commit is contained in:
parent
464400f7c8
commit
a47382b3fd
@ -1,3 +1,4 @@
|
||||
< 3.5.0.beta5-dev: d9103b11fcaa7ac201829dac824c6ea23f0495dd
|
||||
< 3.5.0.beta1-dev: 29ad813cd04812786780e1706cbc043810dea7d8
|
||||
< 3.4.0.beta2-dev: 5b8d8343329e1cd9668189b6cb6fdfd676f4a28d
|
||||
< 3.4.0.beta1-dev: e19808d4ad3f7d16cd9b93f315ca586f694e6288
|
||||
|
44
Gemfile.lock
44
Gemfile.lock
@ -20,30 +20,31 @@ GEM
|
||||
securerandom (>= 0.3)
|
||||
tzinfo (~> 2.0, >= 2.0.5)
|
||||
uri (>= 0.13.1)
|
||||
ast (2.4.2)
|
||||
base64 (0.2.0)
|
||||
benchmark (0.4.0)
|
||||
bigdecimal (3.1.9)
|
||||
ast (2.4.3)
|
||||
base64 (0.3.0)
|
||||
benchmark (0.4.1)
|
||||
bigdecimal (3.2.0)
|
||||
concurrent-ruby (1.3.5)
|
||||
connection_pool (2.5.0)
|
||||
drb (2.2.1)
|
||||
connection_pool (2.5.3)
|
||||
drb (2.2.3)
|
||||
i18n (1.14.7)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json (2.10.2)
|
||||
language_server-protocol (3.17.0.4)
|
||||
json (2.12.2)
|
||||
language_server-protocol (3.17.0.5)
|
||||
lint_roller (1.1.0)
|
||||
logger (1.6.6)
|
||||
logger (1.7.0)
|
||||
minitest (5.25.5)
|
||||
parallel (1.26.3)
|
||||
parser (3.3.7.1)
|
||||
parallel (1.27.0)
|
||||
parser (3.3.8.0)
|
||||
ast (~> 2.4.1)
|
||||
racc
|
||||
prettier_print (1.2.1)
|
||||
prism (1.4.0)
|
||||
racc (1.8.1)
|
||||
rack (3.1.12)
|
||||
rack (3.1.15)
|
||||
rainbow (3.1.1)
|
||||
regexp_parser (2.10.0)
|
||||
rubocop (1.74.0)
|
||||
rubocop (1.75.8)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (~> 3.17.0.2)
|
||||
lint_roller (~> 1.1.0)
|
||||
@ -51,11 +52,12 @@ GEM
|
||||
parser (>= 3.3.0.2)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 2.9.3, < 3.0)
|
||||
rubocop-ast (>= 1.38.0, < 2.0)
|
||||
rubocop-ast (>= 1.44.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 2.4.0, < 4.0)
|
||||
rubocop-ast (1.38.1)
|
||||
parser (>= 3.3.1.0)
|
||||
rubocop-ast (1.44.1)
|
||||
parser (>= 3.3.7.2)
|
||||
prism (~> 1.4)
|
||||
rubocop-capybara (2.22.1)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
@ -71,13 +73,13 @@ GEM
|
||||
rubocop-factory_bot (2.27.1)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-rails (2.30.3)
|
||||
rubocop-rails (2.32.0)
|
||||
activesupport (>= 4.2.0)
|
||||
lint_roller (~> 1.1)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.72.1, < 2.0)
|
||||
rubocop-ast (>= 1.38.0, < 2.0)
|
||||
rubocop-rspec (3.5.0)
|
||||
rubocop (>= 1.75.0, < 2.0)
|
||||
rubocop-ast (>= 1.44.0, < 2.0)
|
||||
rubocop-rspec (3.6.0)
|
||||
lint_roller (~> 1.1)
|
||||
rubocop (~> 1.72, >= 1.72.1)
|
||||
rubocop-rspec_rails (2.31.0)
|
||||
@ -104,4 +106,4 @@ DEPENDENCIES
|
||||
translations-manager!
|
||||
|
||||
BUNDLED WITH
|
||||
2.6.6
|
||||
2.6.9
|
||||
|
26
admin/assets/javascripts/admin/components/channel-data.gjs
Normal file
26
admin/assets/javascripts/admin/components/channel-data.gjs
Normal file
@ -0,0 +1,26 @@
|
||||
import { concat, get } from "@ember/helper";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
const ChannelData = <template>
|
||||
{{#each @provider.channel_parameters as |param|}}
|
||||
{{#unless param.hidden}}
|
||||
<div class="channel-info">
|
||||
<span class="field-name">
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider."
|
||||
@channel.provider
|
||||
".param."
|
||||
param.key
|
||||
".title"
|
||||
)
|
||||
}}:
|
||||
</span>
|
||||
<span class="field-value">{{get @channel.data param.key}}</span>
|
||||
<br />
|
||||
</div>
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
</template>;
|
||||
|
||||
export default ChannelData;
|
@ -1,19 +0,0 @@
|
||||
{{#each @provider.channel_parameters as |param|}}
|
||||
{{#unless param.hidden}}
|
||||
<div class="channel-info">
|
||||
<span class="field-name">
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider."
|
||||
@channel.provider
|
||||
".param."
|
||||
param.key
|
||||
".title"
|
||||
)
|
||||
}}:
|
||||
</span>
|
||||
<span class="field-value">{{get @channel.data param.key}}</span>
|
||||
<br />
|
||||
</div>
|
||||
{{/unless}}
|
||||
{{/each}}
|
107
admin/assets/javascripts/admin/components/channel-details.gjs
Normal file
107
admin/assets/javascripts/admin/components/channel-details.gjs
Normal file
@ -0,0 +1,107 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { fn } from "@ember/helper";
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import ChannelData from "./channel-data";
|
||||
import RuleRow from "./rule-row";
|
||||
|
||||
export default class ChannelDetails extends Component {
|
||||
@service dialog;
|
||||
@service siteSettings;
|
||||
|
||||
@action
|
||||
deleteChannel(channel) {
|
||||
this.dialog.deleteConfirm({
|
||||
message: i18n("chat_integration.channel_delete_confirm"),
|
||||
didConfirm: () => {
|
||||
return channel
|
||||
.destroyRecord()
|
||||
.then(() => this.args.refresh())
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="channel-details">
|
||||
<div class="channel-header">
|
||||
<div class="pull-right">
|
||||
<DButton
|
||||
@icon="pencil"
|
||||
@title="chat_integration.edit_channel"
|
||||
@label="chat_integration.edit_channel"
|
||||
@action={{fn @editChannel @channel}}
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@icon="rocket"
|
||||
@title="chat_integration.test_channel"
|
||||
@label="chat_integration.test_channel"
|
||||
@action={{fn @test @channel}}
|
||||
class="btn-chat-test"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@icon="trash-can"
|
||||
@title="chat_integration.delete_channel"
|
||||
@label="chat_integration.delete_channel"
|
||||
@action={{fn this.deleteChannel @channel}}
|
||||
class="cancel delete-channel"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<span class="channel-title">
|
||||
{{#if @channel.error_key}}
|
||||
<DButton
|
||||
@icon="triangle-exclamation"
|
||||
@action={{fn @showError @channel}}
|
||||
class="delete btn-danger"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
<ChannelData @provider={{@provider}} @channel={{@channel}} />
|
||||
</span>
|
||||
</div>
|
||||
<div class="channel-body">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{i18n "chat_integration.rule_table.filter"}}</th>
|
||||
<th>{{i18n "chat_integration.rule_table.category"}}</th>
|
||||
|
||||
{{#if this.siteSettings.tagging_enabled}}
|
||||
<th>{{i18n "chat_integration.rule_table.tags"}}</th>
|
||||
{{/if}}
|
||||
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{{#each @channel.rules as |rule|}}
|
||||
<RuleRow
|
||||
@rule={{rule}}
|
||||
@edit={{fn @editRuleWithChannel rule @channel}}
|
||||
@refresh={{@refresh}}
|
||||
/>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="channel-footer">
|
||||
<div class="pull-right">
|
||||
<DButton
|
||||
@icon="plus"
|
||||
@title="chat_integration.create_rule"
|
||||
@label="chat_integration.create_rule"
|
||||
@action={{fn @createRule @channel}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
<div class="channel-details">
|
||||
<div class="channel-header">
|
||||
<div class="pull-right">
|
||||
<DButton
|
||||
@icon="pencil"
|
||||
@title="chat_integration.edit_channel"
|
||||
@label="chat_integration.edit_channel"
|
||||
@action={{fn @editChannel @channel}}
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@icon="rocket"
|
||||
@title="chat_integration.test_channel"
|
||||
@label="chat_integration.test_channel"
|
||||
@action={{fn @test @channel}}
|
||||
class="btn-chat-test"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@icon="trash-can"
|
||||
@title="chat_integration.delete_channel"
|
||||
@label="chat_integration.delete_channel"
|
||||
@action={{fn this.deleteChannel @channel}}
|
||||
class="cancel delete-channel"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<span class="channel-title">
|
||||
{{#if @channel.error_key}}
|
||||
<DButton
|
||||
@icon="triangle-exclamation"
|
||||
@action={{fn @showError @channel}}
|
||||
class="delete btn-danger"
|
||||
/>
|
||||
{{/if}}
|
||||
|
||||
<ChannelData @provider={{@provider}} @channel={{@channel}} />
|
||||
</span>
|
||||
</div>
|
||||
<div class="channel-body">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{i18n "chat_integration.rule_table.filter"}}</th>
|
||||
<th>{{i18n "chat_integration.rule_table.category"}}</th>
|
||||
|
||||
{{#if this.siteSettings.tagging_enabled}}
|
||||
<th>{{i18n "chat_integration.rule_table.tags"}}</th>
|
||||
{{/if}}
|
||||
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{{#each @channel.rules as |rule|}}
|
||||
<RuleRow
|
||||
@rule={{rule}}
|
||||
@edit={{fn @editRuleWithChannel rule @channel}}
|
||||
@refresh={{@refresh}}
|
||||
/>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="channel-footer">
|
||||
<div class="pull-right">
|
||||
<DButton
|
||||
@icon="plus"
|
||||
@title="chat_integration.create_rule"
|
||||
@label="chat_integration.create_rule"
|
||||
@action={{fn @createRule @channel}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -1,23 +0,0 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export default class ChannelDetails extends Component {
|
||||
@service dialog;
|
||||
@service siteSettings;
|
||||
|
||||
@action
|
||||
deleteChannel(channel) {
|
||||
this.dialog.deleteConfirm({
|
||||
message: i18n("chat_integration.channel_delete_confirm"),
|
||||
didConfirm: () => {
|
||||
return channel
|
||||
.destroyRecord()
|
||||
.then(() => this.args.refresh())
|
||||
.catch(popupAjaxError);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { concat, get } from "@ember/helper";
|
||||
import { on } from "@ember/modifier";
|
||||
import { action } from "@ember/object";
|
||||
import InputTip from "discourse/components/input-tip";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export default class ChannelParamRow extends Component {
|
||||
get validation() {
|
||||
const value = this.args.channel.get(`data.${this.args.param.key}`);
|
||||
|
||||
if (!value?.trim()) {
|
||||
return { failed: true };
|
||||
} else if (!this.args.param.regex) {
|
||||
return { ok: true };
|
||||
} else if (new RegExp(this.args.param.regex).test(value)) {
|
||||
return {
|
||||
ok: true,
|
||||
reason: i18n(
|
||||
"chat_integration.edit_channel_modal.channel_validation.ok"
|
||||
),
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
failed: true,
|
||||
reason: i18n(
|
||||
"chat_integration.edit_channel_modal.channel_validation.fail"
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
updateValue(event) {
|
||||
this.args.channel.set(`data.${this.args.param.key}`, event.target.value);
|
||||
}
|
||||
|
||||
<template>
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="param-{{@param.key}}">
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider."
|
||||
@channel.provider
|
||||
".param."
|
||||
@param.key
|
||||
".title"
|
||||
)
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
{{on "input" this.updateValue}}
|
||||
value={{get @channel.data @param.key}}
|
||||
type="text"
|
||||
name="param-{{@param.key}}"
|
||||
/>
|
||||
|
||||
<InputTip @validation={{this.validation}} />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider."
|
||||
@channel.provider
|
||||
".param."
|
||||
@param.key
|
||||
".help"
|
||||
)
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="param-{{@param.key}}">
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider."
|
||||
@channel.provider
|
||||
".param."
|
||||
@param.key
|
||||
".title"
|
||||
)
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
{{on "input" this.updateValue}}
|
||||
value={{get @channel.data @param.key}}
|
||||
type="text"
|
||||
name="param-{{@param.key}}"
|
||||
/>
|
||||
|
||||
<InputTip @validation={{this.validation}} />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider."
|
||||
@channel.provider
|
||||
".param."
|
||||
@param.key
|
||||
".help"
|
||||
)
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
@ -1,34 +0,0 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export default class ChannelParamRow extends Component {
|
||||
get validation() {
|
||||
const value = this.args.channel.get(`data.${this.args.param.key}`);
|
||||
|
||||
if (!value?.trim()) {
|
||||
return { failed: true };
|
||||
} else if (!this.args.param.regex) {
|
||||
return { ok: true };
|
||||
} else if (new RegExp(this.args.param.regex).test(value)) {
|
||||
return {
|
||||
ok: true,
|
||||
reason: i18n(
|
||||
"chat_integration.edit_channel_modal.channel_validation.ok"
|
||||
),
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
failed: true,
|
||||
reason: i18n(
|
||||
"chat_integration.edit_channel_modal.channel_validation.fail"
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
updateValue(event) {
|
||||
this.args.channel.set(`data.${this.args.param.key}`, event.target.value);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import DModal from "discourse/components/d-modal";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
const ChannelError = <template>
|
||||
<DModal @closeModal={{@closeModal}} id="chat_integration_error_modal">
|
||||
<h4>{{i18n @model.channel.error_key}}</h4>
|
||||
<pre>{{@model.channel.error_info}}</pre>
|
||||
</DModal>
|
||||
</template>;
|
||||
|
||||
export default ChannelError;
|
@ -1,4 +0,0 @@
|
||||
<DModal @closeModal={{@closeModal}} id="chat_integration_error_modal">
|
||||
<h4>{{i18n @model.channel.error_key}}</h4>
|
||||
<pre>{{@model.channel.error_info}}</pre>
|
||||
</DModal>
|
@ -0,0 +1,97 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { concat } from "@ember/helper";
|
||||
import { on } from "@ember/modifier";
|
||||
import { action } from "@ember/object";
|
||||
import { not } from "truth-helpers";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import DModal from "discourse/components/d-modal";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import ChannelParamRow from "../channel-param-row";
|
||||
|
||||
export default class EditChannel extends Component {
|
||||
get validParams() {
|
||||
return this.args.model.provider.channel_parameters.every((param) => {
|
||||
const value = this.args.model.channel.get(`data.${param.key}`);
|
||||
|
||||
if (!value?.trim()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!param.regex) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return new RegExp(param.regex).test(value);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
async save() {
|
||||
try {
|
||||
await this.args.model.channel.save();
|
||||
this.args.closeModal();
|
||||
} catch (e) {
|
||||
popupAjaxError(e);
|
||||
}
|
||||
}
|
||||
|
||||
<template>
|
||||
<DModal
|
||||
{{on "submit" this.save}}
|
||||
@title={{i18n "chat_integration.edit_channel_modal.title"}}
|
||||
@closeModal={{@closeModal}}
|
||||
@tagName="form"
|
||||
id="chat-integration-edit-channel-modal"
|
||||
>
|
||||
<:body>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="provider">
|
||||
{{i18n "chat_integration.edit_channel_modal.provider"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider."
|
||||
@model.channel.provider
|
||||
".title"
|
||||
)
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
{{#each @model.provider.channel_parameters as |param|}}
|
||||
<ChannelParamRow @param={{param}} @channel={{@model.channel}} />
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</:body>
|
||||
|
||||
<:footer>
|
||||
<DButton
|
||||
@action={{this.save}}
|
||||
@label="chat_integration.edit_channel_modal.save"
|
||||
@disabled={{not this.validParams}}
|
||||
type="submit"
|
||||
id="save-channel"
|
||||
class="btn-primary btn-large"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@action={{@closeModal}}
|
||||
@label="chat_integration.edit_channel_modal.cancel"
|
||||
class="btn-large"
|
||||
/>
|
||||
</:footer>
|
||||
</DModal>
|
||||
</template>
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
<DModal
|
||||
{{on "submit" this.save}}
|
||||
@title={{i18n "chat_integration.edit_channel_modal.title"}}
|
||||
@closeModal={{@closeModal}}
|
||||
@tagName="form"
|
||||
id="chat-integration-edit-channel-modal"
|
||||
>
|
||||
<:body>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="provider">
|
||||
{{i18n "chat_integration.edit_channel_modal.provider"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider." @model.channel.provider ".title"
|
||||
)
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
{{#each @model.provider.channel_parameters as |param|}}
|
||||
<ChannelParamRow @param={{param}} @channel={{@model.channel}} />
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</:body>
|
||||
|
||||
<:footer>
|
||||
<DButton
|
||||
@action={{this.save}}
|
||||
@label="chat_integration.edit_channel_modal.save"
|
||||
@disabled={{not this.validParams}}
|
||||
type="submit"
|
||||
id="save-channel"
|
||||
class="btn-primary btn-large"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@action={{@closeModal}}
|
||||
@label="chat_integration.edit_channel_modal.cancel"
|
||||
class="btn-large"
|
||||
/>
|
||||
</:footer>
|
||||
</DModal>
|
@ -1,31 +0,0 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default class EditChannel extends Component {
|
||||
get validParams() {
|
||||
return this.args.model.provider.channel_parameters.every((param) => {
|
||||
const value = this.args.model.channel.get(`data.${param.key}`);
|
||||
|
||||
if (!value?.trim()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!param.regex) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return new RegExp(param.regex).test(value);
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
async save() {
|
||||
try {
|
||||
await this.args.model.channel.save();
|
||||
this.args.closeModal();
|
||||
} catch (e) {
|
||||
popupAjaxError(e);
|
||||
}
|
||||
}
|
||||
}
|
240
admin/assets/javascripts/admin/components/modal/edit-rule.gjs
Normal file
240
admin/assets/javascripts/admin/components/modal/edit-rule.gjs
Normal file
@ -0,0 +1,240 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { concat, fn, hash } from "@ember/helper";
|
||||
import { on } from "@ember/modifier";
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import { eq } from "truth-helpers";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import DModal from "discourse/components/d-modal";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import CategoryChooser from "select-kit/components/category-chooser";
|
||||
import ComboBox from "select-kit/components/combo-box";
|
||||
import TagChooser from "select-kit/components/tag-chooser";
|
||||
import ChannelData from "../channel-data";
|
||||
|
||||
export default class EditRule extends Component {
|
||||
@service siteSettings;
|
||||
|
||||
@action
|
||||
async save(rule) {
|
||||
try {
|
||||
await rule.save();
|
||||
this.args.closeModal();
|
||||
} catch (e) {
|
||||
popupAjaxError(e);
|
||||
}
|
||||
}
|
||||
|
||||
<template>
|
||||
<DModal
|
||||
{{on "submit" this.save}}
|
||||
@title={{i18n "chat_integration.edit_rule_modal.title"}}
|
||||
@closeModal={{@closeModal}}
|
||||
@tagName="form"
|
||||
id="chat-integration-edit-rule_modal"
|
||||
>
|
||||
<:body>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="provider">
|
||||
{{i18n "chat_integration.edit_rule_modal.provider"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider."
|
||||
@model.channel.provider
|
||||
".title"
|
||||
)
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="channel">
|
||||
{{i18n "chat_integration.edit_rule_modal.channel"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ChannelData
|
||||
@provider={{@model.provider}}
|
||||
@channel={{@model.channel}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="filter">
|
||||
{{i18n "chat_integration.edit_rule_modal.type"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ComboBox
|
||||
@name="type"
|
||||
@content={{@model.rule.available_types}}
|
||||
@value={{@model.rule.type}}
|
||||
@onChange={{fn (mut @model.rule.type)}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n "chat_integration.edit_rule_modal.instructions.type"}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="filter">
|
||||
{{i18n "chat_integration.edit_rule_modal.filter"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ComboBox
|
||||
@name="filter"
|
||||
@content={{@model.rule.available_filters}}
|
||||
@value={{@model.rule.filter}}
|
||||
@onChange={{fn (mut @model.rule.filter)}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n
|
||||
"chat_integration.edit_rule_modal.instructions.filter"
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{#if (eq @model.rule.type "normal")}}
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="category">
|
||||
{{i18n "chat_integration.edit_rule_modal.category"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<CategoryChooser
|
||||
@name="category"
|
||||
@options={{hash none="chat_integration.all_categories"}}
|
||||
@value={{@model.rule.category_id}}
|
||||
@onChange={{fn (mut @model.rule.category_id)}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n
|
||||
"chat_integration.edit_rule_modal.instructions.category"
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="group">
|
||||
{{i18n "chat_integration.edit_rule_modal.group"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ComboBox
|
||||
@content={{@model.groups}}
|
||||
@valueProperty="id"
|
||||
@value={{@model.rule.group_id}}
|
||||
@onChange={{fn (mut @model.rule.group_id)}}
|
||||
@options={{hash none="chat_integration.choose_group"}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n
|
||||
"chat_integration.edit_rule_modal.instructions.group"
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.siteSettings.tagging_enabled}}
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="tags">
|
||||
{{i18n "chat_integration.edit_rule_modal.tags"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<TagChooser
|
||||
@placeholderKey="chat_integration.all_tags"
|
||||
@name="tags"
|
||||
@tags={{@model.rule.tags}}
|
||||
@everyTag="true"
|
||||
@onChange={{fn (mut @model.rule.tags)}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n
|
||||
"chat_integration.edit_rule_modal.instructions.tags"
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</tbody>
|
||||
</table>
|
||||
</:body>
|
||||
|
||||
<:footer>
|
||||
<DButton
|
||||
@action={{fn this.save @model.rule}}
|
||||
@label="chat_integration.edit_rule_modal.save"
|
||||
type="submit"
|
||||
id="save-rule"
|
||||
class="btn-primary btn-large"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@label="chat_integration.edit_rule_modal.cancel"
|
||||
@action={{@closeModal}}
|
||||
class="btn-large"
|
||||
/>
|
||||
</:footer>
|
||||
</DModal>
|
||||
</template>
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
<DModal
|
||||
{{on "submit" this.save}}
|
||||
@title={{i18n "chat_integration.edit_rule_modal.title"}}
|
||||
@closeModal={{@closeModal}}
|
||||
@tagName="form"
|
||||
id="chat-integration-edit-rule_modal"
|
||||
>
|
||||
<:body>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="provider">
|
||||
{{i18n "chat_integration.edit_rule_modal.provider"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
{{i18n
|
||||
(concat
|
||||
"chat_integration.provider." @model.channel.provider ".title"
|
||||
)
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="channel">
|
||||
{{i18n "chat_integration.edit_rule_modal.channel"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ChannelData
|
||||
@provider={{@model.provider}}
|
||||
@channel={{@model.channel}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="filter">
|
||||
{{i18n "chat_integration.edit_rule_modal.type"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ComboBox
|
||||
@name="type"
|
||||
@content={{@model.rule.available_types}}
|
||||
@value={{@model.rule.type}}
|
||||
@onChange={{fn (mut @model.rule.type)}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n "chat_integration.edit_rule_modal.instructions.type"}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="filter">
|
||||
{{i18n "chat_integration.edit_rule_modal.filter"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ComboBox
|
||||
@name="filter"
|
||||
@content={{@model.rule.available_filters}}
|
||||
@value={{@model.rule.filter}}
|
||||
@onChange={{fn (mut @model.rule.filter)}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n "chat_integration.edit_rule_modal.instructions.filter"}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{{#if (eq @model.rule.type "normal")}}
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="category">
|
||||
{{i18n "chat_integration.edit_rule_modal.category"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<CategoryChooser
|
||||
@name="category"
|
||||
@options={{hash none="chat_integration.all_categories"}}
|
||||
@value={{@model.rule.category_id}}
|
||||
@onChange={{fn (mut @model.rule.category_id)}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n
|
||||
"chat_integration.edit_rule_modal.instructions.category"
|
||||
}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="group">
|
||||
{{i18n "chat_integration.edit_rule_modal.group"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ComboBox
|
||||
@content={{@model.groups}}
|
||||
@valueProperty="id"
|
||||
@value={{@model.rule.group_id}}
|
||||
@onChange={{fn (mut @model.rule.group_id)}}
|
||||
@options={{hash none="chat_integration.choose_group"}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n "chat_integration.edit_rule_modal.instructions.group"}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.siteSettings.tagging_enabled}}
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="tags">
|
||||
{{i18n "chat_integration.edit_rule_modal.tags"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<TagChooser
|
||||
@placeholderKey="chat_integration.all_tags"
|
||||
@name="tags"
|
||||
@tags={{@model.rule.tags}}
|
||||
@everyTag="true"
|
||||
@onChange={{fn (mut @model.rule.tags)}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="chat-instructions">
|
||||
<td></td>
|
||||
<td>
|
||||
<label>
|
||||
{{i18n "chat_integration.edit_rule_modal.instructions.tags"}}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</tbody>
|
||||
</table>
|
||||
</:body>
|
||||
|
||||
<:footer>
|
||||
<DButton
|
||||
@action={{fn this.save @model.rule}}
|
||||
@label="chat_integration.edit_rule_modal.save"
|
||||
type="submit"
|
||||
id="save-rule"
|
||||
class="btn-primary btn-large"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@label="chat_integration.edit_rule_modal.cancel"
|
||||
@action={{@closeModal}}
|
||||
class="btn-large"
|
||||
/>
|
||||
</:footer>
|
||||
</DModal>
|
@ -1,18 +0,0 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default class EditRule extends Component {
|
||||
@service siteSettings;
|
||||
|
||||
@action
|
||||
async save(rule) {
|
||||
try {
|
||||
await rule.save();
|
||||
this.args.closeModal();
|
||||
} catch (e) {
|
||||
popupAjaxError(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { on } from "@ember/modifier";
|
||||
import { action } from "@ember/object";
|
||||
import { not } from "truth-helpers";
|
||||
import ChooseTopic from "discourse/components/choose-topic";
|
||||
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import DModal from "discourse/components/d-modal";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export default class TestIntegration extends Component {
|
||||
@tracked loading = false;
|
||||
@tracked flash;
|
||||
@tracked topicId;
|
||||
|
||||
@action
|
||||
async send() {
|
||||
this.loading = true;
|
||||
|
||||
try {
|
||||
await ajax("/admin/plugins/chat-integration/test", {
|
||||
data: {
|
||||
channel_id: this.args.model.channel.id,
|
||||
topic_id: this.topicId,
|
||||
},
|
||||
type: "POST",
|
||||
});
|
||||
|
||||
this.loading = false;
|
||||
this.flash = i18n("chat_integration.test_modal.success");
|
||||
} catch (e) {
|
||||
popupAjaxError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
newTopicSelected(topic) {
|
||||
this.topicId = topic?.id;
|
||||
}
|
||||
|
||||
<template>
|
||||
<DModal
|
||||
{{on "submit" this.send}}
|
||||
@title={{i18n "chat_integration.test_modal.title"}}
|
||||
@closeModal={{@closeModal}}
|
||||
@flash={{this.flash}}
|
||||
@flashType="success"
|
||||
@tagName="form"
|
||||
id="chat_integration_test_modal"
|
||||
>
|
||||
<:body>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="channel">
|
||||
{{i18n "chat_integration.test_modal.topic"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ChooseTopic
|
||||
@topicChangedCallback={{this.newTopicSelected}}
|
||||
@selectedTopicId={{this.topicId}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</:body>
|
||||
|
||||
<:footer>
|
||||
<ConditionalLoadingSpinner @condition={{this.loading}}>
|
||||
<DButton
|
||||
@action={{this.send}}
|
||||
@label="chat_integration.test_modal.send"
|
||||
@disabled={{not this.topicId}}
|
||||
type="submit"
|
||||
id="send-test"
|
||||
class="btn-primary btn-large"
|
||||
/>
|
||||
<DButton
|
||||
@action={{@closeModal}}
|
||||
@label="chat_integration.test_modal.close"
|
||||
class="btn-large"
|
||||
/>
|
||||
</ConditionalLoadingSpinner>
|
||||
</:footer>
|
||||
</DModal>
|
||||
</template>
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
<DModal
|
||||
{{on "submit" this.send}}
|
||||
@title={{i18n "chat_integration.test_modal.title"}}
|
||||
@closeModal={{@closeModal}}
|
||||
@flash={{this.flash}}
|
||||
@flashType="success"
|
||||
@tagName="form"
|
||||
id="chat_integration_test_modal"
|
||||
>
|
||||
<:body>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="input">
|
||||
<td class="label">
|
||||
<label for="channel">
|
||||
{{i18n "chat_integration.test_modal.topic"}}
|
||||
</label>
|
||||
</td>
|
||||
<td>
|
||||
<ChooseTopic
|
||||
@topicChangedCallback={{this.newTopicSelected}}
|
||||
@selectedTopicId={{this.topicId}}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</:body>
|
||||
|
||||
<:footer>
|
||||
<ConditionalLoadingSpinner @condition={{this.loading}}>
|
||||
<DButton
|
||||
@action={{this.send}}
|
||||
@label="chat_integration.test_modal.send"
|
||||
@disabled={{not this.topicId}}
|
||||
type="submit"
|
||||
id="send-test"
|
||||
class="btn-primary btn-large"
|
||||
/>
|
||||
<DButton
|
||||
@action={{@closeModal}}
|
||||
@label="chat_integration.test_modal.close"
|
||||
class="btn-large"
|
||||
/>
|
||||
</ConditionalLoadingSpinner>
|
||||
</:footer>
|
||||
</DModal>
|
@ -1,37 +0,0 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { action } from "@ember/object";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export default class TestIntegration extends Component {
|
||||
@tracked loading = false;
|
||||
@tracked flash;
|
||||
@tracked topicId;
|
||||
|
||||
@action
|
||||
async send() {
|
||||
this.loading = true;
|
||||
|
||||
try {
|
||||
await ajax("/admin/plugins/chat-integration/test", {
|
||||
data: {
|
||||
channel_id: this.args.model.channel.id,
|
||||
topic_id: this.topicId,
|
||||
},
|
||||
type: "POST",
|
||||
});
|
||||
|
||||
this.loading = false;
|
||||
this.flash = i18n("chat_integration.test_modal.success");
|
||||
} catch (e) {
|
||||
popupAjaxError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
newTopicSelected(topic) {
|
||||
this.topicId = topic?.id;
|
||||
}
|
||||
}
|
90
admin/assets/javascripts/admin/components/rule-row.gjs
Normal file
90
admin/assets/javascripts/admin/components/rule-row.gjs
Normal file
@ -0,0 +1,90 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { fn } from "@ember/helper";
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import categoryLink from "discourse/helpers/category-link";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export default class RuleRow extends Component {
|
||||
@service siteSettings;
|
||||
|
||||
get isCategory() {
|
||||
return this.args.rule.type === "normal";
|
||||
}
|
||||
|
||||
get isMessage() {
|
||||
return this.args.rule.type === "group_message";
|
||||
}
|
||||
|
||||
get isMention() {
|
||||
return this.args.rule.type === "group_mention";
|
||||
}
|
||||
|
||||
@action
|
||||
delete(rule) {
|
||||
rule
|
||||
.destroyRecord()
|
||||
.then(() => this.args.refresh())
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
|
||||
<template>
|
||||
<tr>
|
||||
<td>
|
||||
{{@rule.filterName}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{#if this.isCategory}}
|
||||
{{#if @rule.category}}
|
||||
{{categoryLink
|
||||
@rule.category
|
||||
allowUncategorized="true"
|
||||
link="false"
|
||||
}}
|
||||
{{else}}
|
||||
{{i18n "chat_integration.all_categories"}}
|
||||
{{/if}}
|
||||
{{else if this.isMention}}
|
||||
{{i18n
|
||||
"chat_integration.group_mention_template"
|
||||
name=@rule.group_name
|
||||
}}
|
||||
{{else if this.isMessage}}
|
||||
{{i18n
|
||||
"chat_integration.group_message_template"
|
||||
name=@rule.group_name
|
||||
}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{#if this.siteSettings.tagging_enabled}}
|
||||
{{#if @rule.tags}}
|
||||
{{@rule.tags}}
|
||||
{{else}}
|
||||
{{i18n "chat_integration.all_tags"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<DButton
|
||||
@icon="pencil"
|
||||
@title="chat_integration.rule_table.edit_rule"
|
||||
@action={{fn @edit @rule}}
|
||||
class="edit"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@icon="far-trash-can"
|
||||
@title="chat_integration.rule_table.delete_rule"
|
||||
@action={{fn this.delete @rule}}
|
||||
class="delete"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<tr>
|
||||
<td>
|
||||
{{@rule.filterName}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{#if this.isCategory}}
|
||||
{{#if @rule.category}}
|
||||
{{category-link @rule.category allowUncategorized="true" link="false"}}
|
||||
{{else}}
|
||||
{{i18n "chat_integration.all_categories"}}
|
||||
{{/if}}
|
||||
{{else if this.isMention}}
|
||||
{{i18n "chat_integration.group_mention_template" name=@rule.group_name}}
|
||||
{{else if this.isMessage}}
|
||||
{{i18n "chat_integration.group_message_template" name=@rule.group_name}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{#if this.siteSettings.tagging_enabled}}
|
||||
{{#if @rule.tags}}
|
||||
{{@rule.tags}}
|
||||
{{else}}
|
||||
{{i18n "chat_integration.all_tags"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<DButton
|
||||
@icon="pencil"
|
||||
@title="chat_integration.rule_table.edit_rule"
|
||||
@action={{fn @edit @rule}}
|
||||
class="edit"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@icon="far-trash-can"
|
||||
@title="chat_integration.rule_table.delete_rule"
|
||||
@action={{fn this.delete @rule}}
|
||||
class="delete"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
@ -1,28 +0,0 @@
|
||||
import Component from "@glimmer/component";
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default class RuleRow extends Component {
|
||||
@service siteSettings;
|
||||
|
||||
get isCategory() {
|
||||
return this.args.rule.type === "normal";
|
||||
}
|
||||
|
||||
get isMessage() {
|
||||
return this.args.rule.type === "group_message";
|
||||
}
|
||||
|
||||
get isMention() {
|
||||
return this.args.rule.type === "group_mention";
|
||||
}
|
||||
|
||||
@action
|
||||
delete(rule) {
|
||||
rule
|
||||
.destroyRecord()
|
||||
.then(() => this.args.refresh())
|
||||
.catch(popupAjaxError);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
import { fn } from "@ember/helper";
|
||||
import RouteTemplate from "ember-route-template";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import icon from "discourse/helpers/d-icon";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import ChannelDetails from "../components/channel-details";
|
||||
|
||||
export default RouteTemplate(
|
||||
<template>
|
||||
{{#if @controller.anyErrors}}
|
||||
<div class="error">
|
||||
{{icon "triangle-exclamation"}}
|
||||
<span class="error-message">
|
||||
{{i18n "chat_integration.channels_with_errors"}}
|
||||
</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#each @controller.model.channels.content as |channel|}}
|
||||
<ChannelDetails
|
||||
@channel={{channel}}
|
||||
@provider={{@controller.model.provider}}
|
||||
@refresh={{@controller.refresh}}
|
||||
@editChannel={{@controller.editChannel}}
|
||||
@test={{@controller.testChannel}}
|
||||
@createRule={{@controller.createRule}}
|
||||
@editRuleWithChannel={{@controller.editRuleWithChannel}}
|
||||
@showError={{@controller.showError}}
|
||||
/>
|
||||
{{/each}}
|
||||
|
||||
<div class="table-footer">
|
||||
<div class="pull-right">
|
||||
<DButton
|
||||
@action={{fn @controller.createChannel @controller.model.provider}}
|
||||
@label="chat_integration.create_channel"
|
||||
@icon="plus"
|
||||
id="create-channel"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
);
|
@ -1,32 +0,0 @@
|
||||
{{#if this.anyErrors}}
|
||||
<div class="error">
|
||||
{{d-icon "triangle-exclamation"}}
|
||||
<span class="error-message">
|
||||
{{i18n "chat_integration.channels_with_errors"}}
|
||||
</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#each this.model.channels.content as |channel|}}
|
||||
<ChannelDetails
|
||||
@channel={{channel}}
|
||||
@provider={{this.model.provider}}
|
||||
@refresh={{this.refresh}}
|
||||
@editChannel={{this.editChannel}}
|
||||
@test={{this.testChannel}}
|
||||
@createRule={{this.createRule}}
|
||||
@editRuleWithChannel={{this.editRuleWithChannel}}
|
||||
@showError={{this.showError}}
|
||||
/>
|
||||
{{/each}}
|
||||
|
||||
<div class="table-footer">
|
||||
<div class="pull-right">
|
||||
<DButton
|
||||
@action={{fn this.createChannel this.model.provider}}
|
||||
@label="chat_integration.create_channel"
|
||||
@icon="plus"
|
||||
id="create-channel"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,44 @@
|
||||
import { concat } from "@ember/helper";
|
||||
import RouteTemplate from "ember-route-template";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import NavItem from "discourse/components/nav-item";
|
||||
import routeAction from "discourse/helpers/route-action";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
export default RouteTemplate(
|
||||
<template>
|
||||
<div id="admin-plugin-chat">
|
||||
<div class="admin-controls">
|
||||
<div class="admin-controls-chat-providers">
|
||||
<ul class="nav nav-pills">
|
||||
{{#each @controller.model as |provider|}}
|
||||
<NavItem
|
||||
@route="adminPlugins.chat-integration.provider"
|
||||
@routeParam={{provider.name}}
|
||||
@label={{concat
|
||||
"chat_integration.provider."
|
||||
provider.name
|
||||
".title"
|
||||
}}
|
||||
/>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<DButton
|
||||
@icon="gear"
|
||||
@title="chat_integration.settings"
|
||||
@label="chat_integration.settings"
|
||||
@action={{routeAction "showSettings"}}
|
||||
class="chat-integration-settings-button"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{{#unless @controller.model.totalRows}}
|
||||
{{i18n "chat_integration.no_providers"}}
|
||||
{{/unless}}
|
||||
|
||||
{{outlet}}
|
||||
</div>
|
||||
</template>
|
||||
);
|
@ -1,33 +0,0 @@
|
||||
<div id="admin-plugin-chat">
|
||||
<div class="admin-controls">
|
||||
<div class="admin-controls-chat-providers">
|
||||
<ul class="nav nav-pills">
|
||||
{{#each this.model as |provider|}}
|
||||
<NavItem
|
||||
@route="adminPlugins.chat-integration.provider"
|
||||
@routeParam={{provider.name}}
|
||||
@label={{concat
|
||||
"chat_integration.provider."
|
||||
provider.name
|
||||
".title"
|
||||
}}
|
||||
/>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<DButton
|
||||
@icon="gear"
|
||||
@title="chat_integration.settings"
|
||||
@label="chat_integration.settings"
|
||||
@action={{route-action "showSettings"}}
|
||||
class="chat-integration-settings-button"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{{#unless this.model.totalRows}}
|
||||
{{i18n "chat_integration.no_providers"}}
|
||||
{{/unless}}
|
||||
|
||||
{{outlet}}
|
||||
</div>
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@discourse/lint-configs": "2.11.1",
|
||||
"ember-template-lint": "7.0.1",
|
||||
"eslint": "9.22.0",
|
||||
"@discourse/lint-configs": "2.23.0",
|
||||
"ember-template-lint": "7.7.0",
|
||||
"eslint": "9.28.0",
|
||||
"prettier": "3.5.3",
|
||||
"stylelint": "16.16.0"
|
||||
"stylelint": "16.20.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 22",
|
||||
|
872
pnpm-lock.yaml
generated
872
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user