DEV: Ember upgrade (#155)

This commit is contained in:
Keegan George
2023-01-23 10:30:48 -08:00
committed by GitHub
parent 91d2cfb952
commit bdc2f27a2a
33 changed files with 772 additions and 757 deletions
@@ -0,0 +1,19 @@
{{#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}}
@@ -1,5 +0,0 @@
import Component from "@ember/component";
export default Component.extend({
classNames: ["channel-info"],
});
@@ -0,0 +1,78 @@
<div class="channel-details">
<div class="channel-header">
<div class="pull-right">
<DButton
@icon="pencil-alt"
@title="chat_integration.edit_channel"
@label="chat_integration.edit_channel"
@action={{action @editChannel @channel}}
/>
<DButton
@icon="rocket"
@title="chat_integration.test_channel"
@label="chat_integration.test_channel"
@action={{action @test @channel}}
@class="btn-chat-test"
/>
<DButton
@icon="trash-alt"
@title="chat_integration.delete_channel"
@label="chat_integration.delete_channel"
@action={{action this.deleteChannel @channel}}
@class="cancel delete-channel"
/>
</div>
<span class="channel-title">
{{#if @channel.error_key}}
<DButton
@class="delete btn-danger"
@icon="exclamation-triangle"
@action={{action @showError @channel}}
/>
{{/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={{action @editRuleWithChannel rule @channel}}
@refresh={{@refresh}}
/>
{{/each}}
</tbody>
</table>
</div>
<div class="channel-footer">
<div class="pull-right">
<DButton
@class=""
@icon="plus"
@title="chat_integration.create_rule"
@label="chat_integration.create_rule"
@action={{action @createRule @channel}}
/>
</div>
</div>
</div>
@@ -1,27 +1,23 @@
import Component from "@ember/component";
import Component from "@glimmer/component";
import { popupAjaxError } from "discourse/lib/ajax-error";
import I18n from "I18n";
import { inject as service } from "@ember/service";
import { action } from "@ember/object";
export default Component.extend({
dialog: service(),
classNames: ["channel-details"],
export default class ChannelDetails extends Component {
@service dialog;
@service siteSettings;
actions: {
deleteChannel(channel) {
this.dialog.deleteConfirm({
message: I18n.t("chat_integration.channel_delete_confirm"),
didConfirm: () => {
return channel
.destroyRecord()
.then(() => this.refresh())
.catch(popupAjaxError);
},
});
},
editRule(rule) {
this.editRuleWithChannel(rule, this.get("channel"));
},
},
});
@action
deleteChannel(channel) {
this.dialog.deleteConfirm({
message: I18n.t("chat_integration.channel_delete_confirm"),
didConfirm: () => {
return channel
.destroyRecord()
.then(() => this.args.refresh())
.catch(popupAjaxError);
},
});
}
}
@@ -0,0 +1,42 @@
<tr class="input">
<td class="label">
<label for="param-{{@param.key}}">
{{i18n
(concat
"chat_integration.provider."
@model.channel.provider
".param."
@param.key
".title"
)
}}
</label>
</td>
<td>
<Input
name={{concat "param-" @param.key}}
@value={{this.inputValue}}
{{on "change" this.updateValue}}
/>
<InputTip @validation={{this.validate}} />
</td>
</tr>
<tr class="chat-instructions">
<td></td>
<td>
<label>
{{i18n
(concat
"chat_integration.provider."
@model.channel.provider
".param."
@param.key
".help"
)
}}
</label>
</td>
</tr>
@@ -0,0 +1,51 @@
import Component from "@glimmer/component";
import EmberObject, { action } from "@ember/object";
import { tracked } from "@glimmer/tracking";
import I18n from "I18n";
export default class ChannelParamRow extends Component {
@tracked inputValue = this.args.model.channel.data[this.args.param.key] || "";
get validate() {
const parameter = this.args.param;
const regString = parameter.regex;
const regex = new RegExp(regString);
if (this.inputValue === "") {
// Fail silently if field blank
this.args.isValidParams(false);
return EmberObject.create({
failed: true,
});
} else if (!regString) {
// Pass silently if no regex available for provider
this.args.isValidParams(true);
return EmberObject.create({
ok: true,
});
} else if (regex.test(this.inputValue)) {
// Test against regex
this.args.isValidParams(true);
return EmberObject.create({
ok: true,
reason: I18n.t(
"chat_integration.edit_channel_modal.channel_validation.ok"
),
});
} else {
// Failed regex
this.args.isValidParams(false);
return EmberObject.create({
failed: true,
reason: I18n.t(
"chat_integration.edit_channel_modal.channel_validation.fail"
),
});
}
}
@action
updateValue(event) {
this.args.model.channel.data[this.args.param.key] = event.target.value;
}
}
@@ -0,0 +1,47 @@
<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
@class="edit"
@icon="pencil-alt"
@title="chat_integration.rule_table.edit_rule"
@action={{@edit}}
@actionParam={{@rule}}
/>
<DButton
@class="delete"
@icon="far-trash-alt"
@title="chat_integration.rule_table.delete_rule"
@action={{action this.delete}}
@actionParam={{@rule}}
/>
</td>
</tr>
+22 -26
View File
@@ -1,31 +1,27 @@
import Component from "@ember/component";
import { action } from "@ember/object";
import Component from "@glimmer/component";
import { popupAjaxError } from "discourse/lib/ajax-error";
import computed from "discourse-common/utils/decorators";
import { inject as service } from "@ember/service";
export default class RuleRow extends Component {
@service siteSettings;
export default Component.extend({
tagName: "tr",
get isCategory() {
return this.args.rule.type === "normal";
}
@computed("rule.type")
isCategory(type) {
return type === "normal";
},
get isMessage() {
return this.args.rule.type === "group_message";
}
@computed("rule.type")
isMessage(type) {
return type === "group_message";
},
get isMention() {
return this.args.rule.type === "group_mention";
}
@computed("rule.type")
isMention(type) {
return type === "group_mention";
},
actions: {
delete(rule) {
rule
.destroyRecord()
.then(() => this.refresh())
.catch(popupAjaxError);
},
},
});
@action
delete(rule) {
rule
.destroyRecord()
.then(() => this.args.refresh())
.catch(popupAjaxError);
}
}