mirror of
https://github.com/discourse/discourse.git
synced 2025-06-24 19:01:33 +08:00
DEV: [gjs-codemod] Convert automation/styleguide/other to gjs
Co-authored-by: Jarek Radosz <jarek@cvx.dev>
This commit is contained in:
@ -3,7 +3,7 @@ import I18n, { i18n } from "discourse-i18n";
|
||||
import DaBooleanField from "./fields/da-boolean-field";
|
||||
import DaCategoriesField from "./fields/da-categories-field";
|
||||
import DaCategoryField from "./fields/da-category-field";
|
||||
import DaCategoryNotificationlevelField from "./fields/da-category-notification-level-field";
|
||||
import DaCategoryNotificationLevelField from "./fields/da-category-notification-level-field";
|
||||
import DaChoicesField from "./fields/da-choices-field";
|
||||
import DaCustomField from "./fields/da-custom-field";
|
||||
import DaCustomFields from "./fields/da-custom-fields";
|
||||
@ -44,7 +44,7 @@ const FIELD_COMPONENTS = {
|
||||
group: DaGroupField,
|
||||
groups: DaGroupsField,
|
||||
choices: DaChoicesField,
|
||||
category_notification_level: DaCategoryNotificationlevelField,
|
||||
category_notification_level: DaCategoryNotificationLevelField,
|
||||
email_group_user: DaEmailGroupUserField,
|
||||
custom_field: DaCustomField,
|
||||
custom_fields: DaCustomFields,
|
||||
|
@ -3,7 +3,7 @@ import BaseField from "./da-base-field";
|
||||
import DAFieldDescription from "./da-field-description";
|
||||
import DAFieldLabel from "./da-field-label";
|
||||
|
||||
export default class CategoryNotficationLevelField extends BaseField {
|
||||
export default class CategoryNotificationLevelField extends BaseField {
|
||||
<template>
|
||||
<section class="field category-notification-level-field">
|
||||
<div class="control-group">
|
||||
|
@ -0,0 +1,10 @@
|
||||
import htmlSafe from "discourse/helpers/html-safe";
|
||||
|
||||
const FormError = <template>
|
||||
{{#if @error}}
|
||||
<div class="alert alert-error form-errors">
|
||||
{{htmlSafe @error}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>;
|
||||
export default FormError;
|
@ -0,0 +1,22 @@
|
||||
import { Input } from "@ember/component";
|
||||
import { on } from "@ember/modifier";
|
||||
import { i18n } from "discourse-i18n";
|
||||
|
||||
const TopicTrigger = <template>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{{i18n "discourse_automation.triggerables.topic.topic_id.label"}}
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
<Input
|
||||
@value={{this.metadata.topic_id}}
|
||||
{{on
|
||||
"input"
|
||||
(action (mut this.metadata.topic_id) value="target.value")
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>;
|
||||
export default TopicTrigger;
|
@ -1,5 +0,0 @@
|
||||
{{#if @error}}
|
||||
<div class="alert alert-error form-errors">
|
||||
{{html-safe @error}}
|
||||
</div>
|
||||
{{/if}}
|
@ -1,12 +0,0 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{{i18n "discourse_automation.triggerables.topic.topic_id.label"}}
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
<Input
|
||||
@value={{this.metadata.topic_id}}
|
||||
{{on "input" (action (mut this.metadata.topic_id) value="target.value")}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
@ -1,189 +1,228 @@
|
||||
<div class="admin-detail discourse-automation-edit discourse-automation-form">
|
||||
<BackButton
|
||||
@label="discourse_automation.back"
|
||||
@route="adminPlugins.show.automation.index"
|
||||
class="discourse-automation-back"
|
||||
/>
|
||||
<AdminConfigAreaCard @heading="discourse_automation.select_script">
|
||||
<:content>
|
||||
<form class="form-horizontal">
|
||||
<FormError @error={{this.error}} />
|
||||
import { Input } from "@ember/component";
|
||||
import { fn, hash } from "@ember/helper";
|
||||
import { on } from "@ember/modifier";
|
||||
import RouteTemplate from "ember-route-template";
|
||||
import { and } from "truth-helpers";
|
||||
import BackButton from "discourse/components/back-button";
|
||||
import DButton from "discourse/components/d-button";
|
||||
import TextField from "discourse/components/text-field";
|
||||
import withEventValue from "discourse/helpers/with-event-value";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import AdminConfigAreaCard from "admin/components/admin-config-area-card";
|
||||
import ComboBox from "select-kit/components/combo-box";
|
||||
import AutomationField from "discourse/plugins/automation/admin/components/automation-field";
|
||||
import FormError from "discourse/plugins/automation/admin/components/form-error";
|
||||
|
||||
<section class="form-section edit">
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{{i18n "discourse_automation.models.automation.name.label"}}
|
||||
</label>
|
||||
export default RouteTemplate(
|
||||
<template>
|
||||
<div
|
||||
class="admin-detail discourse-automation-edit discourse-automation-form"
|
||||
>
|
||||
<BackButton
|
||||
@label="discourse_automation.back"
|
||||
@route="adminPlugins.show.automation.index"
|
||||
class="discourse-automation-back"
|
||||
/>
|
||||
<AdminConfigAreaCard @heading="discourse_automation.select_script">
|
||||
<:content>
|
||||
<form class="form-horizontal">
|
||||
<FormError @error={{@controller.error}} />
|
||||
|
||||
<div class="controls">
|
||||
<TextField
|
||||
@value={{this.automationForm.name}}
|
||||
@type="text"
|
||||
@autofocus={{true}}
|
||||
@name="automation-name"
|
||||
class="input-large"
|
||||
@input={{with-event-value (fn (mut this.automationForm.name))}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<section class="form-section edit">
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{{i18n "discourse_automation.models.automation.name.label"}}
|
||||
</label>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{{i18n "discourse_automation.models.script.name.label"}}
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
<ComboBox
|
||||
@value={{this.automationForm.script}}
|
||||
@content={{this.model.scriptables}}
|
||||
@onChange={{this.onChangeScript}}
|
||||
@options={{hash filterable=true}}
|
||||
class="scriptables"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="trigger-section form-section edit">
|
||||
<h2 class="title">
|
||||
{{i18n
|
||||
"discourse_automation.edit_automation.trigger_section.title"
|
||||
}}
|
||||
</h2>
|
||||
|
||||
<div class="control-group">
|
||||
{{#if this.model.automation.script.forced_triggerable}}
|
||||
<div class="alert alert-warning">
|
||||
{{i18n
|
||||
"discourse_automation.edit_automation.trigger_section.forced"
|
||||
}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<label class="control-label">
|
||||
{{i18n "discourse_automation.models.trigger.name.label"}}
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
<ComboBox
|
||||
@value={{this.automationForm.trigger}}
|
||||
@content={{this.model.triggerables}}
|
||||
@onChange={{this.onChangeTrigger}}
|
||||
@options={{hash
|
||||
filterable=true
|
||||
none="discourse_automation.select_trigger"
|
||||
disabled=this.model.automation.script.forced_triggerable
|
||||
}}
|
||||
class="triggerables"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if this.automationForm.trigger}}
|
||||
{{#if this.model.automation.trigger.doc}}
|
||||
<div class="alert alert-info">
|
||||
<p>{{this.model.automation.trigger.doc}}</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if
|
||||
(and
|
||||
this.model.automation.enabled
|
||||
this.model.automation.trigger.settings.manual_trigger
|
||||
)
|
||||
}}
|
||||
<div class="alert alert-info next-trigger">
|
||||
|
||||
{{#if this.nextPendingAutomationAtFormatted}}
|
||||
<p>
|
||||
{{i18n
|
||||
"discourse_automation.edit_automation.trigger_section.next_pending_automation"
|
||||
date=this.nextPendingAutomationAtFormatted
|
||||
<div class="controls">
|
||||
<TextField
|
||||
@value={{@controller.automationForm.name}}
|
||||
@type="text"
|
||||
@autofocus={{true}}
|
||||
@name="automation-name"
|
||||
class="input-large"
|
||||
@input={{withEventValue
|
||||
(fn (mut @controller.automationForm.name))
|
||||
}}
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
<DButton
|
||||
@label="discourse_automation.edit_automation.trigger_section.trigger_now"
|
||||
@isLoading={{this.isTriggeringAutomation}}
|
||||
@action={{fn
|
||||
this.onManualAutomationTrigger
|
||||
this.model.automation.id
|
||||
}}
|
||||
class="btn-primary trigger-now-btn"
|
||||
/>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#each this.triggerFields as |field|}}
|
||||
<AutomationField
|
||||
@automation={{this.automation}}
|
||||
@field={{field}}
|
||||
@saveAutomation={{fn this.saveAutomation this.automation}}
|
||||
/>
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
</section>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
{{i18n "discourse_automation.models.script.name.label"}}
|
||||
</label>
|
||||
|
||||
{{#if this.automationForm.trigger}}
|
||||
{{#if this.scriptFields}}
|
||||
<section class="fields-section form-section edit">
|
||||
<div class="controls">
|
||||
<ComboBox
|
||||
@value={{@controller.automationForm.script}}
|
||||
@content={{@controller.model.scriptables}}
|
||||
@onChange={{@controller.onChangeScript}}
|
||||
@options={{hash filterable=true}}
|
||||
class="scriptables"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="trigger-section form-section edit">
|
||||
<h2 class="title">
|
||||
{{i18n
|
||||
"discourse_automation.edit_automation.fields_section.title"
|
||||
"discourse_automation.edit_automation.trigger_section.title"
|
||||
}}
|
||||
</h2>
|
||||
|
||||
{{#if this.model.automation.script.with_trigger_doc}}
|
||||
<div class="alert alert-info">
|
||||
<p>{{this.model.automation.script.with_trigger_doc}}</p>
|
||||
<div class="control-group">
|
||||
{{#if @controller.model.automation.script.forced_triggerable}}
|
||||
<div class="alert alert-warning">
|
||||
{{i18n
|
||||
"discourse_automation.edit_automation.trigger_section.forced"
|
||||
}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<label class="control-label">
|
||||
{{i18n "discourse_automation.models.trigger.name.label"}}
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
<ComboBox
|
||||
@value={{@controller.automationForm.trigger}}
|
||||
@content={{@controller.model.triggerables}}
|
||||
@onChange={{@controller.onChangeTrigger}}
|
||||
@options={{hash
|
||||
filterable=true
|
||||
none="discourse_automation.select_trigger"
|
||||
disabled=@controller.model.automation.script.forced_triggerable
|
||||
}}
|
||||
class="triggerables"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if @controller.automationForm.trigger}}
|
||||
{{#if @controller.model.automation.trigger.doc}}
|
||||
<div class="alert alert-info">
|
||||
<p>{{@controller.model.automation.trigger.doc}}</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if
|
||||
(and
|
||||
@controller.model.automation.enabled
|
||||
@controller.model.automation.trigger.settings.manual_trigger
|
||||
)
|
||||
}}
|
||||
<div class="alert alert-info next-trigger">
|
||||
|
||||
{{#if @controller.nextPendingAutomationAtFormatted}}
|
||||
<p>
|
||||
{{i18n
|
||||
"discourse_automation.edit_automation.trigger_section.next_pending_automation"
|
||||
date=@controller.nextPendingAutomationAtFormatted
|
||||
}}
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
<DButton
|
||||
@label="discourse_automation.edit_automation.trigger_section.trigger_now"
|
||||
@isLoading={{@controller.isTriggeringAutomation}}
|
||||
@action={{fn
|
||||
@controller.onManualAutomationTrigger
|
||||
@controller.model.automation.id
|
||||
}}
|
||||
class="btn-primary trigger-now-btn"
|
||||
/>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#each @controller.triggerFields as |field|}}
|
||||
<AutomationField
|
||||
@automation={{@controller.automation}}
|
||||
@field={{field}}
|
||||
@saveAutomation={{fn
|
||||
@controller.saveAutomation
|
||||
@controller.automation
|
||||
}}
|
||||
/>
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
</section>
|
||||
|
||||
{{#if @controller.automationForm.trigger}}
|
||||
{{#if @controller.scriptFields}}
|
||||
<section class="fields-section form-section edit">
|
||||
<h2 class="title">
|
||||
{{i18n
|
||||
"discourse_automation.edit_automation.fields_section.title"
|
||||
}}
|
||||
</h2>
|
||||
|
||||
{{#if @controller.model.automation.script.with_trigger_doc}}
|
||||
<div class="alert alert-info">
|
||||
<p
|
||||
>{{@controller.model.automation.script.with_trigger_doc}}</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
{{#each @controller.scriptFields as |field|}}
|
||||
<AutomationField
|
||||
@automation={{@controller.automation}}
|
||||
@field={{field}}
|
||||
@saveAutomation={{fn
|
||||
@controller.saveAutomation
|
||||
@controller.automation
|
||||
}}
|
||||
/>
|
||||
{{/each}}
|
||||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{#if @controller.automationForm.trigger}}
|
||||
<div
|
||||
class="control-group automation-enabled alert
|
||||
{{if
|
||||
@controller.automationForm.enabled
|
||||
'alert-info'
|
||||
'alert-warning'
|
||||
}}"
|
||||
>
|
||||
<span>{{i18n
|
||||
"discourse_automation.models.automation.enabled.label"
|
||||
}}</span>
|
||||
<Input
|
||||
@type="checkbox"
|
||||
@checked={{@controller.automationForm.enabled}}
|
||||
{{on
|
||||
"click"
|
||||
(action
|
||||
(mut @controller.automationForm.enabled)
|
||||
value="target.checked"
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
{{#each this.scriptFields as |field|}}
|
||||
<AutomationField
|
||||
@automation={{this.automation}}
|
||||
@field={{field}}
|
||||
@saveAutomation={{fn this.saveAutomation this.automation}}
|
||||
/>
|
||||
{{/each}}
|
||||
<DButton
|
||||
@isLoading={{@controller.isUpdatingAutomation}}
|
||||
@label="discourse_automation.update"
|
||||
@type="submit"
|
||||
@action={{fn
|
||||
@controller.saveAutomation
|
||||
@controller.automation
|
||||
true
|
||||
}}
|
||||
class="btn-primary update-automation"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.automationForm.trigger}}
|
||||
<div
|
||||
class="control-group automation-enabled alert
|
||||
{{if this.automationForm.enabled 'alert-info' 'alert-warning'}}"
|
||||
>
|
||||
<span>{{i18n
|
||||
"discourse_automation.models.automation.enabled.label"
|
||||
}}</span>
|
||||
<Input
|
||||
@type="checkbox"
|
||||
@checked={{this.automationForm.enabled}}
|
||||
{{on
|
||||
"click"
|
||||
(action
|
||||
(mut this.automationForm.enabled) value="target.checked"
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group">
|
||||
<DButton
|
||||
@isLoading={{this.isUpdatingAutomation}}
|
||||
@label="discourse_automation.update"
|
||||
@type="submit"
|
||||
@action={{fn this.saveAutomation this.automation true}}
|
||||
class="btn-primary update-automation"
|
||||
/>
|
||||
</div>
|
||||
{{/if}}
|
||||
</form>
|
||||
</:content>
|
||||
</AdminConfigAreaCard>
|
||||
</div>
|
||||
{{/if}}
|
||||
</form>
|
||||
</:content>
|
||||
</AdminConfigAreaCard>
|
||||
</div>
|
||||
</template>
|
||||
);
|
||||
|
@ -1 +1,6 @@
|
||||
<AutomationList @model={{this.model}} />
|
||||
import RouteTemplate from "ember-route-template";
|
||||
import AutomationList from "discourse/plugins/automation/admin/components/automation-list";
|
||||
|
||||
export default RouteTemplate(
|
||||
<template><AutomationList @model={{@controller.model}} /></template>
|
||||
);
|
||||
|
@ -1,27 +1,41 @@
|
||||
<div class="admin-detail discourse-automation-new discourse-automation-form">
|
||||
<BackButton
|
||||
@label="discourse_automation.back"
|
||||
@route="adminPlugins.show.automation.index"
|
||||
class="discourse-automation-back"
|
||||
/>
|
||||
<AdminConfigAreaCard @heading="discourse_automation.select_script">
|
||||
<:content>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={{i18n "discourse_automation.filter_placeholder"}}
|
||||
{{on "input" this.updateFilterText}}
|
||||
class="admin-section-landing__header-filter"
|
||||
/>
|
||||
import { fn } from "@ember/helper";
|
||||
import { on } from "@ember/modifier";
|
||||
import RouteTemplate from "ember-route-template";
|
||||
import BackButton from "discourse/components/back-button";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import AdminConfigAreaCard from "admin/components/admin-config-area-card";
|
||||
import AdminSectionLandingItem from "admin/components/admin-section-landing-item";
|
||||
|
||||
<div class="admin-section-landing__wrapper">
|
||||
{{#each this.scriptableContent as |script|}}
|
||||
<AdminSectionLandingItem
|
||||
{{on "click" (fn this.selectScriptToEdit script)}}
|
||||
@titleLabelTranslated={{script.name}}
|
||||
@descriptionLabelTranslated={{script.description}}
|
||||
export default RouteTemplate(
|
||||
<template>
|
||||
<div
|
||||
class="admin-detail discourse-automation-new discourse-automation-form"
|
||||
>
|
||||
<BackButton
|
||||
@label="discourse_automation.back"
|
||||
@route="adminPlugins.show.automation.index"
|
||||
class="discourse-automation-back"
|
||||
/>
|
||||
<AdminConfigAreaCard @heading="discourse_automation.select_script">
|
||||
<:content>
|
||||
<input
|
||||
type="text"
|
||||
placeholder={{i18n "discourse_automation.filter_placeholder"}}
|
||||
{{on "input" @controller.updateFilterText}}
|
||||
class="admin-section-landing__header-filter"
|
||||
/>
|
||||
{{/each}}
|
||||
</div>
|
||||
</:content>
|
||||
</AdminConfigAreaCard>
|
||||
</div>
|
||||
|
||||
<div class="admin-section-landing__wrapper">
|
||||
{{#each @controller.scriptableContent as |script|}}
|
||||
<AdminSectionLandingItem
|
||||
{{on "click" (fn @controller.selectScriptToEdit script)}}
|
||||
@titleLabelTranslated={{script.name}}
|
||||
@descriptionLabelTranslated={{script.description}}
|
||||
/>
|
||||
{{/each}}
|
||||
</div>
|
||||
</:content>
|
||||
</AdminConfigAreaCard>
|
||||
</div>
|
||||
</template>
|
||||
);
|
||||
|
Reference in New Issue
Block a user