diff --git a/.template-lintrc.js b/.template-lintrc.js
index e3fc07b48d6..b5095385b21 100644
--- a/.template-lintrc.js
+++ b/.template-lintrc.js
@@ -3,6 +3,7 @@ module.exports = {
extends: "discourse:recommended",
rules: {
+ "no-action-modifiers": true,
"no-capital-arguments": false, // TODO: we extensively use `args` argument name
"no-curly-component-invocation": {
allow: [
diff --git a/app/assets/javascripts/admin/addon/components/admin-editable-field.js b/app/assets/javascripts/admin/addon/components/admin-editable-field.js
index 993a3ed6752..892a3208e86 100644
--- a/app/assets/javascripts/admin/addon/components/admin-editable-field.js
+++ b/app/assets/javascripts/admin/addon/components/admin-editable-field.js
@@ -1,4 +1,6 @@
import Component from "@ember/component";
+import { action } from "@ember/object";
+
export default Component.extend({
tagName: "",
@@ -10,12 +12,14 @@ export default Component.extend({
this.set("editing", false);
},
- actions: {
- edit() {
- this.set("buffer", this.value);
- this.toggleProperty("editing");
- },
+ @action
+ edit(event) {
+ event?.preventDefault();
+ this.set("buffer", this.value);
+ this.toggleProperty("editing");
+ },
+ actions: {
save() {
// Action has to toggle 'editing' property.
this.action(this.buffer);
diff --git a/app/assets/javascripts/admin/addon/components/admin-theme-editor.js b/app/assets/javascripts/admin/addon/components/admin-theme-editor.js
index 014055c1498..de8f0635791 100644
--- a/app/assets/javascripts/admin/addon/components/admin-theme-editor.js
+++ b/app/assets/javascripts/admin/addon/components/admin-theme-editor.js
@@ -3,6 +3,7 @@ import I18n from "I18n";
import discourseComputed from "discourse-common/utils/decorators";
import { fmt } from "discourse/lib/computed";
import { isDocumentRTL } from "discourse/lib/text-direction";
+import { action } from "@ember/object";
import { next } from "@ember/runloop";
export default Component.extend({
@@ -91,15 +92,26 @@ export default Component.extend({
return this.theme.getError(target, fieldName);
},
+ @action
+ toggleShowAdvanced(event) {
+ event?.preventDefault();
+ this.toggleProperty("showAdvanced");
+ },
+
+ @action
+ toggleAddField(event) {
+ event?.preventDefault();
+ this.toggleProperty("addingField");
+ },
+
+ @action
+ toggleMaximize(event) {
+ event?.preventDefault();
+ this.toggleProperty("maximized");
+ next(() => this.appEvents.trigger("ace:resize"));
+ },
+
actions: {
- toggleShowAdvanced() {
- this.toggleProperty("showAdvanced");
- },
-
- toggleAddField() {
- this.toggleProperty("addingField");
- },
-
cancelAddField() {
this.set("addingField", false);
},
@@ -114,11 +126,6 @@ export default Component.extend({
this.fieldAdded(this.currentTargetName, name);
},
- toggleMaximize() {
- this.toggleProperty("maximized");
- next(() => this.appEvents.trigger("ace:resize"));
- },
-
onlyOverriddenChanged(value) {
this.onlyOverriddenChanged(value);
},
diff --git a/app/assets/javascripts/admin/addon/components/ip-lookup.js b/app/assets/javascripts/admin/addon/components/ip-lookup.js
index 222e04b9ab6..02a52405645 100644
--- a/app/assets/javascripts/admin/addon/components/ip-lookup.js
+++ b/app/assets/javascripts/admin/addon/components/ip-lookup.js
@@ -1,6 +1,6 @@
import AdminUser from "admin/models/admin-user";
import Component from "@ember/component";
-import EmberObject from "@ember/object";
+import EmberObject, { action } from "@ember/object";
import I18n from "I18n";
import { ajax } from "discourse/lib/ajax";
import copyText from "discourse/lib/copy-text";
@@ -21,6 +21,12 @@ export default Component.extend({
return Math.max(visible, total);
},
+ @action
+ hide(event) {
+ event?.preventDefault();
+ this.set("show", false);
+ },
+
actions: {
lookup() {
this.set("show", true);
@@ -55,10 +61,6 @@ export default Component.extend({
}
},
- hide() {
- this.set("show", false);
- },
-
copy() {
let text = `IP: ${this.ip}\n`;
const location = this.location;
diff --git a/app/assets/javascripts/admin/addon/components/themes-list-item.js b/app/assets/javascripts/admin/addon/components/themes-list-item.js
index e2237e249ba..29158c44967 100644
--- a/app/assets/javascripts/admin/addon/components/themes-list-item.js
+++ b/app/assets/javascripts/admin/addon/components/themes-list-item.js
@@ -3,6 +3,7 @@ import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component";
import { escape } from "pretty-text/sanitizer";
import { iconHTML } from "discourse-common/lib/icon-library";
+import { action } from "@ember/object";
const MAX_COMPONENTS = 4;
@@ -59,9 +60,9 @@ export default Component.extend({
return childrenCount - MAX_COMPONENTS;
},
- actions: {
- toggleChildrenExpanded() {
- this.toggleProperty("childrenExpanded");
- },
+ @action
+ toggleChildrenExpanded(event) {
+ event?.preventDefault();
+ this.toggleProperty("childrenExpanded");
},
});
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js b/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js
index 2b380818269..5b098387ef8 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-badges/show.js
@@ -133,6 +133,12 @@ export default class AdminBadgesShowController extends Controller.extend(
this.buffered.set("image_url", null);
}
+ @action
+ showPreview(badge, explain, event) {
+ event?.preventDefault();
+ this.send("preview", badge, explain);
+ }
+
@action
save() {
if (!this.saving) {
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-email-bounced.js b/app/assets/javascripts/admin/addon/controllers/admin-email-bounced.js
index 15005495645..c7a8ec98a60 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-email-bounced.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-email-bounced.js
@@ -2,8 +2,15 @@ import AdminEmailLogsController from "admin/controllers/admin-email-logs";
import { INPUT_DELAY } from "discourse-common/config/environment";
import discourseDebounce from "discourse-common/lib/debounce";
import { observes } from "discourse-common/utils/decorators";
+import { action } from "@ember/object";
export default AdminEmailLogsController.extend({
+ @action
+ handleShowIncomingEmail(id, event) {
+ event?.preventDefault();
+ this.send("showIncomingEmail", id);
+ },
+
@observes("filter.{status,user,address,type}")
filterEmailLogs() {
discourseDebounce(this, this.loadLogs, INPUT_DELAY);
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-email-preview-digest.js b/app/assets/javascripts/admin/addon/controllers/admin-email-preview-digest.js
index 50d74d35d8e..84f85eea6d3 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-email-preview-digest.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-email-preview-digest.js
@@ -1,7 +1,7 @@
import { empty, notEmpty, or } from "@ember/object/computed";
import Controller from "@ember/controller";
import EmailPreview from "admin/models/email-preview";
-import { get } from "@ember/object";
+import { action, get } from "@ember/object";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { inject as service } from "@ember/service";
@@ -14,6 +14,12 @@ export default Controller.extend({
showSendEmailForm: notEmpty("model.html_content"),
htmlEmpty: empty("model.html_content"),
+ @action
+ toggleShowHtml(event) {
+ event?.preventDefault();
+ this.toggleProperty("showHtml");
+ },
+
actions: {
updateUsername(selected) {
this.set("username", get(selected, "firstObject"));
@@ -39,10 +45,6 @@ export default Controller.extend({
});
},
- toggleShowHtml() {
- this.toggleProperty("showHtml");
- },
-
sendEmail() {
this.set("sendingEmail", true);
this.set("sentEmail", false);
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-email-rejected.js b/app/assets/javascripts/admin/addon/controllers/admin-email-rejected.js
index 89c67f3cf95..6e4ce786568 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-email-rejected.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-email-rejected.js
@@ -3,6 +3,7 @@ import { INPUT_DELAY } from "discourse-common/config/environment";
import IncomingEmail from "admin/models/incoming-email";
import discourseDebounce from "discourse-common/lib/debounce";
import { observes } from "discourse-common/utils/decorators";
+import { action } from "@ember/object";
export default AdminEmailLogsController.extend({
@observes("filter.{status,from,to,subject,error}")
@@ -10,6 +11,12 @@ export default AdminEmailLogsController.extend({
discourseDebounce(this, this.loadLogs, IncomingEmail, INPUT_DELAY);
},
+ @action
+ handleShowIncomingEmail(id, event) {
+ event?.preventDefault();
+ this.send("showIncomingEmail", id);
+ },
+
actions: {
loadMore() {
this.loadLogs(IncomingEmail, true);
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-logs-screened-ip-addresses.js b/app/assets/javascripts/admin/addon/controllers/admin-logs-screened-ip-addresses.js
index 0e8b43f9c13..bc11ec51f46 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-logs-screened-ip-addresses.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-logs-screened-ip-addresses.js
@@ -6,6 +6,7 @@ import discourseDebounce from "discourse-common/lib/debounce";
import { exportEntity } from "discourse/lib/export-csv";
import { observes } from "discourse-common/utils/decorators";
import { outputExportResult } from "discourse/lib/export-result";
+import { action } from "@ember/object";
import { inject as service } from "@ember/service";
export default Controller.extend({
@@ -26,6 +27,15 @@ export default Controller.extend({
discourseDebounce(this, this._debouncedShow, INPUT_DELAY);
},
+ @action
+ edit(record, event) {
+ event?.preventDefault();
+ if (!record.get("editing")) {
+ this.set("savedIpAddress", record.get("ip_address"));
+ }
+ record.set("editing", true);
+ },
+
actions: {
allow(record) {
record.set("action_name", "do_nothing");
@@ -37,13 +47,6 @@ export default Controller.extend({
record.save();
},
- edit(record) {
- if (!record.get("editing")) {
- this.set("savedIpAddress", record.get("ip_address"));
- }
- record.set("editing", true);
- },
-
cancel(record) {
const savedIpAddress = this.savedIpAddress;
if (savedIpAddress && record.get("editing")) {
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-logs-staff-action-logs.js b/app/assets/javascripts/admin/addon/controllers/admin-logs-staff-action-logs.js
index 670d48c17b9..a8a297d47c4 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-logs-staff-action-logs.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-logs-staff-action-logs.js
@@ -1,5 +1,5 @@
import Controller from "@ember/controller";
-import EmberObject from "@ember/object";
+import EmberObject, { action } from "@ember/object";
import I18n from "I18n";
import discourseComputed from "discourse-common/utils/decorators";
import { exportEntity } from "discourse/lib/export-csv";
@@ -31,11 +31,13 @@ export default Controller.extend({
this.set(
"userHistoryActions",
result.extras.user_history_actions
- .map((action) => ({
- id: action.id,
- action_id: action.action_id,
- name: I18n.t("admin.logs.staff_actions.actions." + action.id),
- name_raw: action.id,
+ .map((historyAction) => ({
+ id: historyAction.id,
+ action_id: historyAction.action_id,
+ name: I18n.t(
+ "admin.logs.staff_actions.actions." + historyAction.id
+ ),
+ name_raw: historyAction.id,
}))
.sort((a, b) => a.name.localeCompare(b.name))
);
@@ -75,61 +77,74 @@ export default Controller.extend({
this.scheduleRefresh();
},
- actions: {
- filterActionIdChanged(filterActionId) {
- if (filterActionId) {
- this.changeFilters({
- action_name: filterActionId,
- action_id: this.userHistoryActions.findBy("id", filterActionId)
- .action_id,
- });
- }
- },
-
- clearFilter(key) {
- if (key === "actionFilter") {
- this.set("filterActionId", null);
- this.changeFilters({
- action_name: null,
- action_id: null,
- custom_type: null,
- });
- } else {
- this.changeFilters({ [key]: null });
- }
- },
-
- clearAllFilters() {
- this.set("filterActionId", null);
- this.resetFilters();
- },
-
- filterByAction(logItem) {
+ @action
+ filterActionIdChanged(filterActionId) {
+ if (filterActionId) {
this.changeFilters({
- action_name: logItem.get("action_name"),
- action_id: logItem.get("action"),
- custom_type: logItem.get("custom_type"),
+ action_name: filterActionId,
+ action_id: this.userHistoryActions.findBy("id", filterActionId)
+ .action_id,
});
- },
+ }
+ },
- filterByStaffUser(acting_user) {
- this.changeFilters({ acting_user: acting_user.username });
- },
+ @action
+ clearFilter(key, event) {
+ event?.preventDefault();
+ if (key === "actionFilter") {
+ this.set("filterActionId", null);
+ this.changeFilters({
+ action_name: null,
+ action_id: null,
+ custom_type: null,
+ });
+ } else {
+ this.changeFilters({ [key]: null });
+ }
+ },
- filterByTargetUser(target_user) {
- this.changeFilters({ target_user: target_user.username });
- },
+ @action
+ clearAllFilters(event) {
+ event?.preventDefault();
+ this.set("filterActionId", null);
+ this.resetFilters();
+ },
- filterBySubject(subject) {
- this.changeFilters({ subject });
- },
+ @action
+ filterByAction(logItem, event) {
+ event?.preventDefault();
+ this.changeFilters({
+ action_name: logItem.get("action_name"),
+ action_id: logItem.get("action"),
+ custom_type: logItem.get("custom_type"),
+ });
+ },
- exportStaffActionLogs() {
- exportEntity("staff_action").then(outputExportResult);
- },
+ @action
+ filterByStaffUser(acting_user, event) {
+ event?.preventDefault();
+ this.changeFilters({ acting_user: acting_user.username });
+ },
- loadMore() {
- this.model.loadMore();
- },
+ @action
+ filterByTargetUser(target_user, event) {
+ event?.preventDefault();
+ this.changeFilters({ target_user: target_user.username });
+ },
+
+ @action
+ filterBySubject(subject, event) {
+ event?.preventDefault();
+ this.changeFilters({ subject });
+ },
+
+ @action
+ exportStaffActionLogs() {
+ exportEntity("staff_action").then(outputExportResult);
+ },
+
+ @action
+ loadMore() {
+ this.model.loadMore();
},
});
diff --git a/app/assets/javascripts/admin/addon/controllers/admin-web-hooks-show-events.js b/app/assets/javascripts/admin/addon/controllers/admin-web-hooks-show-events.js
index 71990f47a34..84b7650ff16 100644
--- a/app/assets/javascripts/admin/addon/controllers/admin-web-hooks-show-events.js
+++ b/app/assets/javascripts/admin/addon/controllers/admin-web-hooks-show-events.js
@@ -1,5 +1,6 @@
import Controller from "@ember/controller";
import { ajax } from "discourse/lib/ajax";
+import { action } from "@ember/object";
import { alias } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
import { popupAjaxError } from "discourse/lib/ajax-error";
@@ -43,6 +44,23 @@ export default Controller.extend({
}
},
+ @action
+ showInserted(event) {
+ event?.preventDefault();
+ const webHookId = this.get("model.extras.web_hook_id");
+
+ ajax(`/admin/api/web_hooks/${webHookId}/events/bulk`, {
+ type: "GET",
+ data: { ids: this.incomingEventIds },
+ }).then((data) => {
+ const objects = data.map((webHookEvent) =>
+ this.store.createRecord("web-hook-event", webHookEvent)
+ );
+ this.model.unshiftObjects(objects);
+ this.set("incomingEventIds", []);
+ });
+ },
+
actions: {
loadMore() {
this.model.loadMore();
@@ -61,20 +79,5 @@ export default Controller.extend({
popupAjaxError(error);
});
},
-
- showInserted() {
- const webHookId = this.get("model.extras.web_hook_id");
-
- ajax(`/admin/api/web_hooks/${webHookId}/events/bulk`, {
- type: "GET",
- data: { ids: this.incomingEventIds },
- }).then((data) => {
- const objects = data.map((event) =>
- this.store.createRecord("web-hook-event", event)
- );
- this.model.unshiftObjects(objects);
- this.set("incomingEventIds", []);
- });
- },
},
});
diff --git a/app/assets/javascripts/admin/addon/controllers/modals/admin-uploaded-image-list.js b/app/assets/javascripts/admin/addon/controllers/modals/admin-uploaded-image-list.js
index 7ab4cb69848..8a60037a5ba 100644
--- a/app/assets/javascripts/admin/addon/controllers/modals/admin-uploaded-image-list.js
+++ b/app/assets/javascripts/admin/addon/controllers/modals/admin-uploaded-image-list.js
@@ -1,5 +1,6 @@
import { observes, on } from "discourse-common/utils/decorators";
import Controller from "@ember/controller";
+import { action } from "@ember/object";
import ModalFunctionality from "discourse/mixins/modal-functionality";
export default Controller.extend(ModalFunctionality, {
@@ -10,15 +11,17 @@ export default Controller.extend(ModalFunctionality, {
this.set("images", value && value.length ? value.split("|") : []);
},
+ @action
+ remove(url, event) {
+ event?.preventDefault();
+ this.images.removeObject(url);
+ },
+
actions: {
uploadDone({ url }) {
this.images.addObject(url);
},
- remove(url) {
- this.images.removeObject(url);
- },
-
close() {
this.save(this.images.join("|"));
this.send("closeModal");
diff --git a/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs b/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs
index 31b16af4cc0..82492beecb4 100644
--- a/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs
+++ b/app/assets/javascripts/admin/addon/templates/admin-badges/show.hbs
@@ -88,9 +88,9 @@
{{#if this.hasQuery}}
- {{i18n "admin.badges.preview.link_text"}}
+ {{i18n "admin.badges.preview.link_text"}}
|
- {{i18n "admin.badges.preview.plan_text"}}
+ {{i18n "admin.badges.preview.plan_text"}}
{{#if this.preview_loading}}
{{i18n "loading"}}
{{/if}}
diff --git a/app/assets/javascripts/admin/addon/templates/components/admin-editable-field.hbs b/app/assets/javascripts/admin/addon/templates/components/admin-editable-field.hbs
index d62cfdbd783..998174f20a9 100644
--- a/app/assets/javascripts/admin/addon/templates/components/admin-editable-field.hbs
+++ b/app/assets/javascripts/admin/addon/templates/components/admin-editable-field.hbs
@@ -3,7 +3,7 @@
{{#if this.editing}}