DEV: Remove usage of `{{action}}` modifiers (#18333)

This PR enables the [`no-action-modifiers`](https://github.com/ember-template-lint/ember-template-lint/blob/master/docs/rule/no-action-modifiers.md) template lint rule and removes all usages of the `{{action}}` modifier in core.

In general, instances of `{{action "x"}}` have been replaced with `{{on "click" (action "x")}}`. 

In many cases, such as for `a` elements, we also need to prevent default event handling to avoid unwanted side effects. While the `{{action}}` modifier internally calls `event.preventDefault()`, we need to handle these cases more explicitly. For this purpose, this PR also adds the [ember-event-helpers](https://github.com/buschtoens/ember-event-helpers) dependency so we can use the `prevent-default` handler. For instance:

```
<a href {{on "click" (prevent-default (action "x"))}}>Do X</a>
```

Note that `action` has not in general been refactored away as a helper yet. In general, all event handlers should be methods on the corresponding component and referenced directly (e.g. `{{on "click" this.doSomething}}`). However, the `action` helper is used extensively throughout the codebase and often references methods in the `actions` hash on controllers or routes. Thus this refactor will also be extensive and probably deserves a separate PR.

Note: This work was done to complement #17767 by minimizing the potential impact of the `action` modifier override, which uses private API and arguably should be replaced with an AST transform.

Commits:
* Enable `no-action-modifiers` template lint rule
* Replace {{action "x"}} with {{on "click" (action "x")}}
* Remove unnecessary action helper usage
* Remove ctl+click tests for user-menu
   These tests now break in Chrome when used with addEventListener. As per the comment, they can probably be safely removed.
* Prevent default event handlers to avoid unwanted side effects
   Uses `event.preventDefault()` in event handlers to prevent default event handling. This had been done automatically by the `action` modifier, but is not always desirable or necessary.
* Restore UserCardContents#showUser action to avoid regression
   By keeping the `showUser` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showUser` argument that's been passed.
* Revert EditCategoryTab#selectTab -> EditCategoryTab#select
   Avoid potential breaking change in themes / plugins
* Restore GroupCardContents#showGroup action to avoid regression
   By keeping the `showGroup` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showGroup` argument that's been passed.
* Restore SecondFactorAddTotp#showSecondFactorKey action to avoid regression
   By keeping the `showSecondFactorKey` action, we can avoid a breaking change for plugins that rely upon it, while not interfering with the `showSecondFactorKey` property that's maintained on the controller.
* Refactor away from `actions` hash in ChooseMessage component
* Modernize EmojiPicker#onCategorySelection usage
* Modernize SearchResultEntry#logClick usage
* Modernize Discovery::Categories#showInserted usage
* Modernize Preferences::Account#resendConfirmationEmail usage
* Modernize MultiSelect::SelectedCategory#onSelectedNameClick usage
* Favor fn over action in SelectedChoice component
* Modernize WizardStep event handlers
* Favor fn over action usage in buttons
* Restore Login#forgotPassword action to avoid possible regression
This commit is contained in:
Dan Gebhardt 2022-10-04 04:42:46 -04:00 committed by GitHub
parent c654bdbfa9
commit ba27ee1637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
135 changed files with 930 additions and 731 deletions

View File

@ -3,6 +3,7 @@ module.exports = {
extends: "discourse:recommended", extends: "discourse:recommended",
rules: { rules: {
"no-action-modifiers": true,
"no-capital-arguments": false, // TODO: we extensively use `args` argument name "no-capital-arguments": false, // TODO: we extensively use `args` argument name
"no-curly-component-invocation": { "no-curly-component-invocation": {
allow: [ allow: [

View File

@ -1,4 +1,6 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { action } from "@ember/object";
export default Component.extend({ export default Component.extend({
tagName: "", tagName: "",
@ -10,12 +12,14 @@ export default Component.extend({
this.set("editing", false); this.set("editing", false);
}, },
actions: { @action
edit() { edit(event) {
event?.preventDefault();
this.set("buffer", this.value); this.set("buffer", this.value);
this.toggleProperty("editing"); this.toggleProperty("editing");
}, },
actions: {
save() { save() {
// Action has to toggle 'editing' property. // Action has to toggle 'editing' property.
this.action(this.buffer); this.action(this.buffer);

View File

@ -3,6 +3,7 @@ import I18n from "I18n";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { fmt } from "discourse/lib/computed"; import { fmt } from "discourse/lib/computed";
import { isDocumentRTL } from "discourse/lib/text-direction"; import { isDocumentRTL } from "discourse/lib/text-direction";
import { action } from "@ember/object";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
export default Component.extend({ export default Component.extend({
@ -91,15 +92,26 @@ export default Component.extend({
return this.theme.getError(target, fieldName); return this.theme.getError(target, fieldName);
}, },
actions: { @action
toggleShowAdvanced() { toggleShowAdvanced(event) {
event?.preventDefault();
this.toggleProperty("showAdvanced"); this.toggleProperty("showAdvanced");
}, },
toggleAddField() { @action
toggleAddField(event) {
event?.preventDefault();
this.toggleProperty("addingField"); this.toggleProperty("addingField");
}, },
@action
toggleMaximize(event) {
event?.preventDefault();
this.toggleProperty("maximized");
next(() => this.appEvents.trigger("ace:resize"));
},
actions: {
cancelAddField() { cancelAddField() {
this.set("addingField", false); this.set("addingField", false);
}, },
@ -114,11 +126,6 @@ export default Component.extend({
this.fieldAdded(this.currentTargetName, name); this.fieldAdded(this.currentTargetName, name);
}, },
toggleMaximize() {
this.toggleProperty("maximized");
next(() => this.appEvents.trigger("ace:resize"));
},
onlyOverriddenChanged(value) { onlyOverriddenChanged(value) {
this.onlyOverriddenChanged(value); this.onlyOverriddenChanged(value);
}, },

View File

@ -1,6 +1,6 @@
import AdminUser from "admin/models/admin-user"; import AdminUser from "admin/models/admin-user";
import Component from "@ember/component"; import Component from "@ember/component";
import EmberObject from "@ember/object"; import EmberObject, { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import copyText from "discourse/lib/copy-text"; import copyText from "discourse/lib/copy-text";
@ -21,6 +21,12 @@ export default Component.extend({
return Math.max(visible, total); return Math.max(visible, total);
}, },
@action
hide(event) {
event?.preventDefault();
this.set("show", false);
},
actions: { actions: {
lookup() { lookup() {
this.set("show", true); this.set("show", true);
@ -55,10 +61,6 @@ export default Component.extend({
} }
}, },
hide() {
this.set("show", false);
},
copy() { copy() {
let text = `IP: ${this.ip}\n`; let text = `IP: ${this.ip}\n`;
const location = this.location; const location = this.location;

View File

@ -3,6 +3,7 @@ import discourseComputed from "discourse-common/utils/decorators";
import Component from "@ember/component"; import Component from "@ember/component";
import { escape } from "pretty-text/sanitizer"; import { escape } from "pretty-text/sanitizer";
import { iconHTML } from "discourse-common/lib/icon-library"; import { iconHTML } from "discourse-common/lib/icon-library";
import { action } from "@ember/object";
const MAX_COMPONENTS = 4; const MAX_COMPONENTS = 4;
@ -59,9 +60,9 @@ export default Component.extend({
return childrenCount - MAX_COMPONENTS; return childrenCount - MAX_COMPONENTS;
}, },
actions: { @action
toggleChildrenExpanded() { toggleChildrenExpanded(event) {
event?.preventDefault();
this.toggleProperty("childrenExpanded"); this.toggleProperty("childrenExpanded");
}, },
},
}); });

View File

@ -133,6 +133,12 @@ export default class AdminBadgesShowController extends Controller.extend(
this.buffered.set("image_url", null); this.buffered.set("image_url", null);
} }
@action
showPreview(badge, explain, event) {
event?.preventDefault();
this.send("preview", badge, explain);
}
@action @action
save() { save() {
if (!this.saving) { if (!this.saving) {

View File

@ -2,8 +2,15 @@ import AdminEmailLogsController from "admin/controllers/admin-email-logs";
import { INPUT_DELAY } from "discourse-common/config/environment"; import { INPUT_DELAY } from "discourse-common/config/environment";
import discourseDebounce from "discourse-common/lib/debounce"; import discourseDebounce from "discourse-common/lib/debounce";
import { observes } from "discourse-common/utils/decorators"; import { observes } from "discourse-common/utils/decorators";
import { action } from "@ember/object";
export default AdminEmailLogsController.extend({ export default AdminEmailLogsController.extend({
@action
handleShowIncomingEmail(id, event) {
event?.preventDefault();
this.send("showIncomingEmail", id);
},
@observes("filter.{status,user,address,type}") @observes("filter.{status,user,address,type}")
filterEmailLogs() { filterEmailLogs() {
discourseDebounce(this, this.loadLogs, INPUT_DELAY); discourseDebounce(this, this.loadLogs, INPUT_DELAY);

View File

@ -1,7 +1,7 @@
import { empty, notEmpty, or } from "@ember/object/computed"; import { empty, notEmpty, or } from "@ember/object/computed";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import EmailPreview from "admin/models/email-preview"; 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 { popupAjaxError } from "discourse/lib/ajax-error";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
@ -14,6 +14,12 @@ export default Controller.extend({
showSendEmailForm: notEmpty("model.html_content"), showSendEmailForm: notEmpty("model.html_content"),
htmlEmpty: empty("model.html_content"), htmlEmpty: empty("model.html_content"),
@action
toggleShowHtml(event) {
event?.preventDefault();
this.toggleProperty("showHtml");
},
actions: { actions: {
updateUsername(selected) { updateUsername(selected) {
this.set("username", get(selected, "firstObject")); this.set("username", get(selected, "firstObject"));
@ -39,10 +45,6 @@ export default Controller.extend({
}); });
}, },
toggleShowHtml() {
this.toggleProperty("showHtml");
},
sendEmail() { sendEmail() {
this.set("sendingEmail", true); this.set("sendingEmail", true);
this.set("sentEmail", false); this.set("sentEmail", false);

View File

@ -3,6 +3,7 @@ import { INPUT_DELAY } from "discourse-common/config/environment";
import IncomingEmail from "admin/models/incoming-email"; import IncomingEmail from "admin/models/incoming-email";
import discourseDebounce from "discourse-common/lib/debounce"; import discourseDebounce from "discourse-common/lib/debounce";
import { observes } from "discourse-common/utils/decorators"; import { observes } from "discourse-common/utils/decorators";
import { action } from "@ember/object";
export default AdminEmailLogsController.extend({ export default AdminEmailLogsController.extend({
@observes("filter.{status,from,to,subject,error}") @observes("filter.{status,from,to,subject,error}")
@ -10,6 +11,12 @@ export default AdminEmailLogsController.extend({
discourseDebounce(this, this.loadLogs, IncomingEmail, INPUT_DELAY); discourseDebounce(this, this.loadLogs, IncomingEmail, INPUT_DELAY);
}, },
@action
handleShowIncomingEmail(id, event) {
event?.preventDefault();
this.send("showIncomingEmail", id);
},
actions: { actions: {
loadMore() { loadMore() {
this.loadLogs(IncomingEmail, true); this.loadLogs(IncomingEmail, true);

View File

@ -6,6 +6,7 @@ import discourseDebounce from "discourse-common/lib/debounce";
import { exportEntity } from "discourse/lib/export-csv"; import { exportEntity } from "discourse/lib/export-csv";
import { observes } from "discourse-common/utils/decorators"; import { observes } from "discourse-common/utils/decorators";
import { outputExportResult } from "discourse/lib/export-result"; import { outputExportResult } from "discourse/lib/export-result";
import { action } from "@ember/object";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
export default Controller.extend({ export default Controller.extend({
@ -26,6 +27,15 @@ export default Controller.extend({
discourseDebounce(this, this._debouncedShow, INPUT_DELAY); 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: { actions: {
allow(record) { allow(record) {
record.set("action_name", "do_nothing"); record.set("action_name", "do_nothing");
@ -37,13 +47,6 @@ export default Controller.extend({
record.save(); record.save();
}, },
edit(record) {
if (!record.get("editing")) {
this.set("savedIpAddress", record.get("ip_address"));
}
record.set("editing", true);
},
cancel(record) { cancel(record) {
const savedIpAddress = this.savedIpAddress; const savedIpAddress = this.savedIpAddress;
if (savedIpAddress && record.get("editing")) { if (savedIpAddress && record.get("editing")) {

View File

@ -1,5 +1,5 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import EmberObject from "@ember/object"; import EmberObject, { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { exportEntity } from "discourse/lib/export-csv"; import { exportEntity } from "discourse/lib/export-csv";
@ -31,11 +31,13 @@ export default Controller.extend({
this.set( this.set(
"userHistoryActions", "userHistoryActions",
result.extras.user_history_actions result.extras.user_history_actions
.map((action) => ({ .map((historyAction) => ({
id: action.id, id: historyAction.id,
action_id: action.action_id, action_id: historyAction.action_id,
name: I18n.t("admin.logs.staff_actions.actions." + action.id), name: I18n.t(
name_raw: action.id, "admin.logs.staff_actions.actions." + historyAction.id
),
name_raw: historyAction.id,
})) }))
.sort((a, b) => a.name.localeCompare(b.name)) .sort((a, b) => a.name.localeCompare(b.name))
); );
@ -75,7 +77,7 @@ export default Controller.extend({
this.scheduleRefresh(); this.scheduleRefresh();
}, },
actions: { @action
filterActionIdChanged(filterActionId) { filterActionIdChanged(filterActionId) {
if (filterActionId) { if (filterActionId) {
this.changeFilters({ this.changeFilters({
@ -86,7 +88,9 @@ export default Controller.extend({
} }
}, },
clearFilter(key) { @action
clearFilter(key, event) {
event?.preventDefault();
if (key === "actionFilter") { if (key === "actionFilter") {
this.set("filterActionId", null); this.set("filterActionId", null);
this.changeFilters({ this.changeFilters({
@ -99,12 +103,16 @@ export default Controller.extend({
} }
}, },
clearAllFilters() { @action
clearAllFilters(event) {
event?.preventDefault();
this.set("filterActionId", null); this.set("filterActionId", null);
this.resetFilters(); this.resetFilters();
}, },
filterByAction(logItem) { @action
filterByAction(logItem, event) {
event?.preventDefault();
this.changeFilters({ this.changeFilters({
action_name: logItem.get("action_name"), action_name: logItem.get("action_name"),
action_id: logItem.get("action"), action_id: logItem.get("action"),
@ -112,24 +120,31 @@ export default Controller.extend({
}); });
}, },
filterByStaffUser(acting_user) { @action
filterByStaffUser(acting_user, event) {
event?.preventDefault();
this.changeFilters({ acting_user: acting_user.username }); this.changeFilters({ acting_user: acting_user.username });
}, },
filterByTargetUser(target_user) { @action
filterByTargetUser(target_user, event) {
event?.preventDefault();
this.changeFilters({ target_user: target_user.username }); this.changeFilters({ target_user: target_user.username });
}, },
filterBySubject(subject) { @action
filterBySubject(subject, event) {
event?.preventDefault();
this.changeFilters({ subject }); this.changeFilters({ subject });
}, },
@action
exportStaffActionLogs() { exportStaffActionLogs() {
exportEntity("staff_action").then(outputExportResult); exportEntity("staff_action").then(outputExportResult);
}, },
@action
loadMore() { loadMore() {
this.model.loadMore(); this.model.loadMore();
}, },
},
}); });

View File

@ -1,5 +1,6 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { action } from "@ember/object";
import { alias } from "@ember/object/computed"; import { alias } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { popupAjaxError } from "discourse/lib/ajax-error"; 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: { actions: {
loadMore() { loadMore() {
this.model.loadMore(); this.model.loadMore();
@ -61,20 +79,5 @@ export default Controller.extend({
popupAjaxError(error); 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", []);
});
},
}, },
}); });

View File

@ -1,5 +1,6 @@
import { observes, on } from "discourse-common/utils/decorators"; import { observes, on } from "discourse-common/utils/decorators";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { action } from "@ember/object";
import ModalFunctionality from "discourse/mixins/modal-functionality"; import ModalFunctionality from "discourse/mixins/modal-functionality";
export default Controller.extend(ModalFunctionality, { export default Controller.extend(ModalFunctionality, {
@ -10,15 +11,17 @@ export default Controller.extend(ModalFunctionality, {
this.set("images", value && value.length ? value.split("|") : []); this.set("images", value && value.length ? value.split("|") : []);
}, },
@action
remove(url, event) {
event?.preventDefault();
this.images.removeObject(url);
},
actions: { actions: {
uploadDone({ url }) { uploadDone({ url }) {
this.images.addObject(url); this.images.addObject(url);
}, },
remove(url) {
this.images.removeObject(url);
},
close() { close() {
this.save(this.images.join("|")); this.save(this.images.join("|"));
this.send("closeModal"); this.send("closeModal");

View File

@ -88,9 +88,9 @@
</div> </div>
{{#if this.hasQuery}} {{#if this.hasQuery}}
<a href {{action "preview" this.buffered "false"}}>{{i18n "admin.badges.preview.link_text"}}</a> <a href {{on "click" (fn this.showPreview this.buffered "false")}}>{{i18n "admin.badges.preview.link_text"}}</a>
| |
<a href {{action "preview" this.buffered "true"}}>{{i18n "admin.badges.preview.plan_text"}}</a> <a href {{on "click" (fn this.showPreview this.buffered "true")}}>{{i18n "admin.badges.preview.plan_text"}}</a>
{{#if this.preview_loading}} {{#if this.preview_loading}}
{{i18n "loading"}} {{i18n "loading"}}
{{/if}} {{/if}}

View File

@ -3,7 +3,7 @@
{{#if this.editing}} {{#if this.editing}}
<TextField @value={{this.buffer}} @autofocus="autofocus" @autocomplete="off" /> <TextField @value={{this.buffer}} @autofocus="autofocus" @autocomplete="off" />
{{else}} {{else}}
<a href {{action "edit"}} class="inline-editable-field"> <a href {{on "click" this.edit}} class="inline-editable-field">
<span>{{this.value}}</span> <span>{{this.value}}</span>
</a> </a>
{{/if}} {{/if}}
@ -11,7 +11,7 @@
<div class="controls"> <div class="controls">
{{#if this.editing}} {{#if this.editing}}
<DButton @class="btn-default" @action={{action "save"}} @label="admin.user_fields.save" /> <DButton @class="btn-default" @action={{action "save"}} @label="admin.user_fields.save" />
<a href {{action "edit"}}>{{i18n "cancel"}}</a> <a href {{on "click" this.edit}}>{{i18n "cancel"}}</a>
{{else}} {{else}}
<DButton @class="btn-default" @action={{action "edit"}} @icon="pencil-alt" /> <DButton @class="btn-default" @action={{action "edit"}} @icon="pencil-alt" />
{{/if}} {{/if}}

View File

@ -13,7 +13,7 @@
{{#if this.allowAdvanced}} {{#if this.allowAdvanced}}
<li> <li>
<a {{action "toggleShowAdvanced"}} <a {{on "click" this.toggleShowAdvanced}}
href href
title={{i18n (concat "admin.customize.theme." (if this.showAdvanced "hide_advanced" "show_advanced"))}} title={{i18n (concat "admin.customize.theme." (if this.showAdvanced "hide_advanced" "show_advanced"))}}
class="no-text"> class="no-text">
@ -52,7 +52,7 @@
<DButton @class="ok" @action={{action "addField" this.newFieldName}} @icon="check" /> <DButton @class="ok" @action={{action "addField" this.newFieldName}} @icon="check" />
<DButton @class="cancel" @action={{action "cancelAddField"}} @icon="times" /> <DButton @class="cancel" @action={{action "cancelAddField"}} @icon="times" />
{{else}} {{else}}
<a href {{action "toggleAddField" this.currentTargetName}} class="no-text"> <a href {{on "click" this.toggleAddField}} class="no-text">
{{d-icon "plus"}} {{d-icon "plus"}}
</a> </a>
{{/if}} {{/if}}
@ -61,7 +61,7 @@
<li class="spacer"></li> <li class="spacer"></li>
<li> <li>
<a href {{action "toggleMaximize"}} class="no-text"> <a href {{on "click" this.toggleMaximize}} class="no-text">
{{d-icon this.maximizeIcon}} {{d-icon this.maximizeIcon}}
</a> </a>
</li> </li>

View File

@ -3,7 +3,7 @@
{{/if}} {{/if}}
{{#if this.show}} {{#if this.show}}
<div class="location-box"> <div class="location-box">
<a href class="close pull-right" {{action "hide"}}>{{d-icon "times"}}</a> <a href class="close pull-right" {{on "click" this.hide}}>{{d-icon "times"}}</a>
{{#if this.copied}} {{#if this.copied}}
<DButton @class="btn-hover pull-right" @icon="copy" @label="ip_lookup.copied" /> <DButton @class="btn-hover pull-right" @icon="copy" @label="ip_lookup.copied" />
{{else}} {{else}}

View File

@ -31,7 +31,7 @@
<span class="components">{{html-safe this.childrenString}}</span> <span class="components">{{html-safe this.childrenString}}</span>
{{#if this.displayHasMore}} {{#if this.displayHasMore}}
<a href {{action "toggleChildrenExpanded"}} class="others-count"> <a href {{on "click" this.toggleChildrenExpanded}} class="others-count">
{{#if this.childrenExpanded}} {{#if this.childrenExpanded}}
{{i18n "admin.customize.theme.collapse"}} {{i18n "admin.customize.theme.collapse"}}
{{else}} {{else}}

View File

@ -30,7 +30,7 @@
<td class="email-address"><a href="mailto:{{l.to_address}}">{{l.to_address}}</a></td> <td class="email-address"><a href="mailto:{{l.to_address}}">{{l.to_address}}</a></td>
<td> <td>
{{#if l.has_bounce_key}} {{#if l.has_bounce_key}}
<a href {{action "showIncomingEmail" l.id}}> <a href {{on "click" (fn this.handleShowIncomingEmail l.id)}}>
{{l.email_type}} {{l.email_type}}
</a> </a>
{{else}} {{else}}
@ -39,7 +39,7 @@
</td> </td>
<td class="email-details"> <td class="email-details">
{{#if l.has_bounce_key}} {{#if l.has_bounce_key}}
<a href {{action "showIncomingEmail" l.id}} title={{i18n "admin.email.details_title"}}> <a href {{on "click" (fn this.handleShowIncomingEmail l.id)}} title={{i18n "admin.email.details_title"}}>
{{d-icon "info-circle"}} {{d-icon "info-circle"}}
</a> </a>
{{/if}} {{/if}}

View File

@ -15,11 +15,11 @@
{{#if this.showHtml}} {{#if this.showHtml}}
<span>{{i18n "admin.email.html"}}</span> <span>{{i18n "admin.email.html"}}</span>
| |
<a href {{action "toggleShowHtml"}}> <a href {{on "click" this.toggleShowHtml}}>
{{i18n "admin.email.text"}} {{i18n "admin.email.text"}}
</a> </a>
{{else}} {{else}}
<a href {{action "toggleShowHtml"}}>{{i18n "admin.email.html"}}</a> | <a href {{on "click" this.toggleShowHtml}}>{{i18n "admin.email.html"}}</a> |
<span>{{i18n "admin.email.text"}}</span> <span>{{i18n "admin.email.text"}}</span>
{{/if}} {{/if}}
</div> </div>

View File

@ -48,10 +48,10 @@
</td> </td>
<td>{{email.subject}}</td> <td>{{email.subject}}</td>
<td class="error"> <td class="error">
<a href {{action "showIncomingEmail" email.id}}>{{email.error}}</a> <a href {{on "click" (fn this.handleShowIncomingEmail email.id)}}>{{email.error}}</a>
</td> </td>
<td class="email-details"> <td class="email-details">
<a href {{action "showIncomingEmail" email.id}} title={{i18n "admin.email.details_title"}}> <a href {{on "click" (fn this.handleShowIncomingEmail email.id)}} title={{i18n "admin.email.details_title"}}>
{{d-icon "info-circle"}} {{d-icon "info-circle"}}
</a> </a>
</td> </td>

View File

@ -27,7 +27,7 @@
{{#if item.editing}} {{#if item.editing}}
<TextField @value={{item.ip_address}} @autofocus="autofocus" /> <TextField @value={{item.ip_address}} @autofocus="autofocus" />
{{else}} {{else}}
<a href {{action "edit" item}} class="inline-editable-field"> <a href {{on "click" (fn this.edit item)}} class="inline-editable-field">
{{#if item.isRange}} {{#if item.isRange}}
<strong>{{item.ip_address}}</strong> <strong>{{item.ip_address}}</strong>
{{else}} {{else}}

View File

@ -1,29 +1,29 @@
<div class="staff-action-logs-controls"> <div class="staff-action-logs-controls">
{{#if this.filtersExists}} {{#if this.filtersExists}}
<div class="staff-action-logs-filters"> <div class="staff-action-logs-filters">
<a href {{action "clearAllFilters"}} class="clear-filters filter btn"> <a href {{on "click" this.clearAllFilters}} class="clear-filters filter btn">
<span class="label">{{i18n "admin.logs.staff_actions.clear_filters"}}</span> <span class="label">{{i18n "admin.logs.staff_actions.clear_filters"}}</span>
</a> </a>
{{#if this.actionFilter}} {{#if this.actionFilter}}
<a href {{action "clearFilter" "actionFilter"}} class="filter btn"> <a href {{on "click" (fn this.clearFilter "actionFilter")}} class="filter btn">
<span class="label">{{i18n "admin.logs.action"}}</span>: {{this.actionFilter}} <span class="label">{{i18n "admin.logs.action"}}</span>: {{this.actionFilter}}
{{d-icon "times-circle"}} {{d-icon "times-circle"}}
</a> </a>
{{/if}} {{/if}}
{{#if this.filters.acting_user}} {{#if this.filters.acting_user}}
<a href {{action "clearFilter" "acting_user"}} class="filter btn"> <a href {{on "click" (fn this.clearFilter "acting_user")}} class="filter btn">
<span class="label">{{i18n "admin.logs.staff_actions.staff_user"}}</span>: {{this.filters.acting_user}} <span class="label">{{i18n "admin.logs.staff_actions.staff_user"}}</span>: {{this.filters.acting_user}}
{{d-icon "times-circle"}} {{d-icon "times-circle"}}
</a> </a>
{{/if}} {{/if}}
{{#if this.filters.target_user}} {{#if this.filters.target_user}}
<a href {{action "clearFilter" "target_user"}} class="filter btn"> <a href {{on "click" (fn this.clearFilter "target_user")}} class="filter btn">
<span class="label">{{i18n "admin.logs.staff_actions.target_user"}}</span>: {{this.filters.target_user}} <span class="label">{{i18n "admin.logs.staff_actions.target_user"}}</span>: {{this.filters.target_user}}
{{d-icon "times-circle"}} {{d-icon "times-circle"}}
</a> </a>
{{/if}} {{/if}}
{{#if this.filters.subject}} {{#if this.filters.subject}}
<a href {{action "clearFilter" "subject"}} class="filter btn"> <a href {{on "click" (fn this.clearFilter "subject")}} class="filter btn">
<span class="label">{{i18n "admin.logs.staff_actions.subject"}}</span>: {{this.filters.subject}} <span class="label">{{i18n "admin.logs.staff_actions.subject"}}</span>: {{this.filters.subject}}
{{d-icon "times-circle"}} {{d-icon "times-circle"}}
</a> </a>
@ -71,16 +71,16 @@
</div> </div>
</td> </td>
<td class="col value action"> <td class="col value action">
<a href {{action "filterByAction" item}}>{{item.actionName}}</a> <a href {{on "click" (fn this.filterByAction item)}}>{{item.actionName}}</a>
</td> </td>
<td class="col value subject"> <td class="col value subject">
<div class="subject"> <div class="subject">
{{#if item.target_user}} {{#if item.target_user}}
<LinkTo @route="adminUser" @model={{item.target_user}}>{{avatar item.target_user imageSize="tiny"}}</LinkTo> <LinkTo @route="adminUser" @model={{item.target_user}}>{{avatar item.target_user imageSize="tiny"}}</LinkTo>
<a href {{action "filterByTargetUser" item.target_user}}>{{item.target_user.username}}</a> <a href {{on "click" (fn this.filterByTargetUser item.target_user)}}>{{item.target_user.username}}</a>
{{/if}} {{/if}}
{{#if item.subject}} {{#if item.subject}}
<a href {{action "filterBySubject" item.subject}} title={{item.subject}}>{{item.subject}}</a> <a href {{on "click" (fn this.filterBySubject item.subject)}} title={{item.subject}}>{{item.subject}}</a>
{{/if}} {{/if}}
</div> </div>
</td> </td>
@ -89,10 +89,10 @@
<div> <div>
{{html-safe item.formattedDetails}} {{html-safe item.formattedDetails}}
{{#if item.useCustomModalForDetails}} {{#if item.useCustomModalForDetails}}
<a href {{action "showCustomDetailsModal" item}}>{{d-icon "info-circle"}} {{i18n "admin.logs.staff_actions.show"}}</a> <a href {{on "click" (fn this.showCustomDetailsModal item)}}>{{d-icon "info-circle"}} {{i18n "admin.logs.staff_actions.show"}}</a>
{{/if}} {{/if}}
{{#if item.useModalForDetails}} {{#if item.useModalForDetails}}
<a href {{action "showDetailsModal" item}}>{{d-icon "info-circle"}} {{i18n "admin.logs.staff_actions.show"}}</a> <a href {{on "click" (fn this.showDetailsModal item)}}>{{d-icon "info-circle"}} {{i18n "admin.logs.staff_actions.show"}}</a>
{{/if}} {{/if}}
</div> </div>
</td> </td>

View File

@ -1,7 +1,7 @@
<DModalBody @class="uploaded-image-list"> <DModalBody @class="uploaded-image-list">
<div class="selectable-avatars"> <div class="selectable-avatars">
{{#each this.images as |image|}} {{#each this.images as |image|}}
<a href class="selectable-avatar" {{action "remove" image}}> <a href class="selectable-avatar" {{on "click" (fn this.remove image)}}>
{{bound-avatar-template image "huge"}} {{bound-avatar-template image "huge"}}
</a> </a>
{{else}} {{else}}

View File

@ -21,7 +21,7 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
{{#if this.hasIncoming}} {{#if this.hasIncoming}}
<a href tabindex="0" {{action "showInserted"}} class="alert alert-info clickable"> <a href tabindex="0" {{on "click" this.showInserted}} class="alert alert-info clickable">
<CountI18n @key="admin.web_hooks.events.incoming" @count={{this.incomingCount}} /> <CountI18n @key="admin.web_hooks.events.incoming" @count={{this.incomingCount}} />
</a> </a>
{{/if}} {{/if}}

View File

@ -50,7 +50,8 @@ export default Component.extend({
}, },
@action @action
toggleShowMuted() { toggleShowMuted(event) {
event?.preventDefault();
this.toggleProperty("showMuted"); this.toggleProperty("showMuted");
}, },
}); });

View File

@ -1,3 +1,4 @@
import { action } from "@ember/object";
import { alias, equal } from "@ember/object/computed"; import { alias, equal } from "@ember/object/computed";
import discourseComputed, { observes } from "discourse-common/utils/decorators"; import discourseComputed, { observes } from "discourse-common/utils/decorators";
import Component from "@ember/component"; import Component from "@ember/component";
@ -92,11 +93,13 @@ export default Component.extend({
this.category.updatePermission(this.group_name, type); this.category.updatePermission(this.group_name, type);
}, },
actions: { @action
removeRow() { removeRow(event) {
event?.preventDefault();
this.category.removePermission(this.group_name); this.category.removePermission(this.group_name);
}, },
actions: {
setPermissionReply() { setPermissionReply() {
if (this.type <= PermissionType.CREATE_POST) { if (this.type <= PermissionType.CREATE_POST) {
this.updatePermission(PermissionType.READONLY); this.updatePermission(PermissionType.READONLY);

View File

@ -1,6 +1,6 @@
import Component from "@ember/component"; import Component from "@ember/component";
import discourseDebounce from "discourse-common/lib/debounce"; import discourseDebounce from "discourse-common/lib/debounce";
import { get } from "@ember/object"; import { action, get } from "@ember/object";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import { observes } from "discourse-common/utils/decorators"; import { observes } from "discourse-common/utils/decorators";
@ -63,12 +63,11 @@ export default Component.extend({
); );
}, },
actions: { @action
chooseMessage(message) { chooseMessage(message, event) {
event?.preventDefault();
const messageId = get(message, "id"); const messageId = get(message, "id");
this.set("selectedTopicId", messageId); this.set("selectedTopicId", messageId);
next(() => $(`#choose-message-${messageId}`).prop("checked", "true")); next(() => $(`#choose-message-${messageId}`).prop("checked", "true"));
return false;
},
}, },
}); });

View File

@ -1,5 +1,5 @@
import Component from "@ember/component"; import Component from "@ember/component";
import EmberObject from "@ember/object"; import EmberObject, { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import LinkLookup from "discourse/lib/link-lookup"; import LinkLookup from "discourse/lib/link-lookup";
import { not } from "@ember/object/computed"; import { not } from "@ember/object/computed";
@ -54,11 +54,13 @@ export default Component.extend({
this.set("messageCount", messages.get("length")); this.set("messageCount", messages.get("length"));
}, },
actions: { @action
closeMessage(message) { closeMessage(message, event) {
event?.preventDefault();
this._removeMessage(message); this._removeMessage(message);
}, },
actions: {
hideMessage(message) { hideMessage(message) {
this._removeMessage(message); this._removeMessage(message);
// kind of hacky but the visibility depends on this // kind of hacky but the visibility depends on this

View File

@ -2,6 +2,7 @@ import Component from "@ember/component";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import I18n from "I18n"; import I18n from "I18n";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { action } from "@ember/object";
import { empty } from "@ember/object/computed"; import { empty } from "@ember/object/computed";
import getURL from "discourse-common/lib/get-url"; import getURL from "discourse-common/lib/get-url";
import { propertyEqual } from "discourse/lib/computed"; import { propertyEqual } from "discourse/lib/computed";
@ -49,13 +50,12 @@ export default Component.extend({
return getURL(`/c/${slugPart}/edit/${this.tab}`); return getURL(`/c/${slugPart}/edit/${this.tab}`);
}, },
actions: { @action
select() { select(event) {
event?.preventDefault();
this.set("selectedTab", this.tab); this.set("selectedTab", this.tab);
if (!this.newCategory) { if (!this.newCategory) {
DiscourseURL.routeTo(this.fullSlug); DiscourseURL.routeTo(this.fullSlug);
} }
}, },
},
}); });

View File

@ -240,7 +240,8 @@ export default Component.extend({
}, },
@action @action
onCategorySelection(sectionName) { onCategorySelection(sectionName, event) {
event?.preventDefault();
const section = document.querySelector( const section = document.querySelector(
`.emoji-picker-emoji-area .section[data-section="${sectionName}"]` `.emoji-picker-emoji-area .section[data-section="${sectionName}"]`
); );

View File

@ -1,3 +1,4 @@
import { action } from "@ember/object";
import { alias, gt } from "@ember/object/computed"; import { alias, gt } from "@ember/object/computed";
import CardContentsBase from "discourse/mixins/card-contents-base"; import CardContentsBase from "discourse/mixins/card-contents-base";
import CleansUp from "discourse/mixins/cleans-up"; import CleansUp from "discourse/mixins/cleans-up";
@ -70,11 +71,22 @@ export default Component.extend(CardContentsBase, CleansUp, {
this._close(); this._close();
}, },
actions: { @action
close() { close(event) {
event?.preventDefault();
this._close(); this._close();
}, },
@action
handleShowGroup(group, event) {
event?.preventDefault();
// Invokes `showGroup` argument. Convert to `this.args.showGroup` when
// refactoring this to a glimmer component.
this.showGroup(group);
this._close();
},
actions: {
cancelFilter() { cancelFilter() {
const postStream = this.postStream; const postStream = this.postStream;
postStream.cancelFilter(); postStream.cancelFilter();
@ -90,8 +102,7 @@ export default Component.extend(CardContentsBase, CleansUp, {
}, },
showGroup(group) { showGroup(group) {
this.showGroup(group); this.handleShowGroup(group);
this._close();
}, },
}, },
}); });

View File

@ -53,7 +53,8 @@ export default Component.extend({
}, },
@action @action
prefillSettings(provider) { prefillSettings(provider, event) {
event?.preventDefault();
this.form.setProperties(emailProviderDefaultSettings(provider, "imap")); this.form.setProperties(emailProviderDefaultSettings(provider, "imap"));
}, },

View File

@ -1,10 +1,12 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { action } from "@ember/object";
export default Component.extend({ export default Component.extend({
classNames: ["item"], classNames: ["item"],
actions: { @action
remove() { remove(event) {
event?.preventDefault();
this.removeAction(this.member); this.removeAction(this.member);
}, },
},
}); });

View File

@ -43,7 +43,8 @@ export default Component.extend({
}, },
@action @action
prefillSettings(provider) { prefillSettings(provider, event) {
event?.preventDefault();
this.form.setProperties(emailProviderDefaultSettings(provider, "smtp")); this.form.setProperties(emailProviderDefaultSettings(provider, "smtp"));
}, },

View File

@ -1,5 +1,6 @@
import { on } from "discourse-common/utils/decorators"; import { on } from "discourse-common/utils/decorators";
import Component from "@ember/component"; import Component from "@ember/component";
import { action } from "@ember/object";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import deprecated from "discourse-common/lib/deprecated"; import deprecated from "discourse-common/lib/deprecated";
@ -56,8 +57,9 @@ export default Component.extend({
this.router.off("routeDidChange", this, this.currentRouteChanged); this.router.off("routeDidChange", this, this.currentRouteChanged);
}, },
actions: { @action
toggleExpanded() { toggleExpanded(event) {
event?.preventDefault();
this.toggleProperty("expanded"); this.toggleProperty("expanded");
next(() => { next(() => {
@ -78,5 +80,4 @@ export default Component.extend({
} }
}); });
}, },
},
}); });

View File

@ -1,5 +1,6 @@
import discourseComputed, { observes } from "discourse-common/utils/decorators"; import discourseComputed, { observes } from "discourse-common/utils/decorators";
import Component from "@ember/component"; import Component from "@ember/component";
import { action } from "@ember/object";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import FilterModeMixin from "discourse/mixins/filter-mode"; import FilterModeMixin from "discourse/mixins/filter-mode";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
@ -61,8 +62,9 @@ export default Component.extend(FilterModeMixin, {
DiscourseURL.appEvents.off("dom:clean", this, this.ensureDropClosed); DiscourseURL.appEvents.off("dom:clean", this, this.ensureDropClosed);
}, },
actions: { @action
toggleDrop() { toggleDrop(event) {
event?.preventDefault();
this.set("expanded", !this.expanded); this.set("expanded", !this.expanded);
if (this.expanded) { if (this.expanded) {
@ -89,5 +91,4 @@ export default Component.extend(FilterModeMixin, {
}); });
} }
}, },
},
}); });

View File

@ -7,7 +7,7 @@ import { classify, dasherize } from "@ember/string";
import discourseComputed, { bind } from "discourse-common/utils/decorators"; import discourseComputed, { bind } from "discourse-common/utils/decorators";
import optionalService from "discourse/lib/optional-service"; import optionalService from "discourse/lib/optional-service";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import { set } from "@ember/object"; import { action, set } from "@ember/object";
import showModal from "discourse/lib/show-modal"; import showModal from "discourse/lib/show-modal";
let _components = {}; let _components = {};
@ -121,7 +121,7 @@ export default Component.extend({
}, },
@bind @bind
_performConfirmed(action) { _performConfirmed(performableAction) {
let reviewable = this.reviewable; let reviewable = this.reviewable;
let performAction = () => { let performAction = () => {
@ -140,7 +140,7 @@ export default Component.extend({
}); });
return ajax( return ajax(
`/review/${reviewable.id}/perform/${action.id}?version=${version}`, `/review/${reviewable.id}/perform/${performableAction.id}?version=${version}`,
{ {
type: "PUT", type: "PUT",
data, data,
@ -173,13 +173,16 @@ export default Component.extend({
.finally(() => this.set("updating", false)); .finally(() => this.set("updating", false));
}; };
if (action.client_action) { if (performableAction.client_action) {
let actionMethod = this[`client${classify(action.client_action)}`]; let actionMethod =
this[`client${classify(performableAction.client_action)}`];
if (actionMethod) { if (actionMethod) {
return actionMethod.call(this, reviewable, performAction); return actionMethod.call(this, reviewable, performAction);
} else { } else {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(`No handler for ${action.client_action} found`); console.error(
`No handler for ${performableAction.client_action} found`
);
return; return;
} }
} else { } else {
@ -209,14 +212,16 @@ export default Component.extend({
} }
}, },
actions: { @action
explainReviewable(reviewable) { explainReviewable(reviewable, event) {
event?.preventDefault();
showModal("explain-reviewable", { showModal("explain-reviewable", {
title: "review.explain.title", title: "review.explain.title",
model: reviewable, model: reviewable,
}); });
}, },
actions: {
edit() { edit() {
this.set("editing", true); this.set("editing", true);
this.set("_updates", { payload: {} }); this.set("_updates", { payload: {} });
@ -259,18 +264,18 @@ export default Component.extend({
set(this._updates, fieldId, event.target.value); set(this._updates, fieldId, event.target.value);
}, },
perform(action) { perform(performableAction) {
if (this.updating) { if (this.updating) {
return; return;
} }
let msg = action.get("confirm_message"); let msg = performableAction.get("confirm_message");
let requireRejectReason = action.get("require_reject_reason"); let requireRejectReason = performableAction.get("require_reject_reason");
let customModal = action.get("custom_modal"); let customModal = performableAction.get("custom_modal");
if (msg) { if (msg) {
bootbox.confirm(msg, (answer) => { bootbox.confirm(msg, (answer) => {
if (answer) { if (answer) {
return this._performConfirmed(action); return this._performConfirmed(performableAction);
} }
}); });
} else if (requireRejectReason) { } else if (requireRejectReason) {
@ -279,7 +284,7 @@ export default Component.extend({
model: this.reviewable, model: this.reviewable,
}).setProperties({ }).setProperties({
performConfirmed: this._performConfirmed, performConfirmed: this._performConfirmed,
action, action: performableAction,
}); });
} else if (customModal) { } else if (customModal) {
showModal(customModal, { showModal(customModal, {
@ -287,10 +292,10 @@ export default Component.extend({
model: this.reviewable, model: this.reviewable,
}).setProperties({ }).setProperties({
performConfirmed: this._performConfirmed, performConfirmed: this._performConfirmed,
action, action: performableAction,
}); });
} else { } else {
return this._performConfirmed(action); return this._performConfirmed(performableAction);
} }
}, },
}, },

View File

@ -1,5 +1,6 @@
import Component from "@ember/component"; import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { action } from "@ember/object";
import { gt } from "@ember/object/computed"; import { gt } from "@ember/object/computed";
import { historyHeat } from "discourse/widgets/post-edits-indicator"; import { historyHeat } from "discourse/widgets/post-edits-indicator";
import { longDate } from "discourse/lib/formatter"; import { longDate } from "discourse/lib/formatter";
@ -18,8 +19,9 @@ export default Component.extend({
return longDate(updatedAt); return longDate(updatedAt);
}, },
actions: { @action
showEditHistory() { showEditHistory(event) {
event?.preventDefault();
let postId = this.get("reviewable.post_id"); let postId = this.get("reviewable.post_id");
this.store.find("post", postId).then((post) => { this.store.find("post", postId).then((post) => {
let historyController = showModal("history", { let historyController = showModal("history", {
@ -31,5 +33,4 @@ export default Component.extend({
historyController.set("topicController", null); historyController.set("topicController", null);
}); });
}, },
},
}); });

View File

@ -1,10 +1,11 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { action } from "@ember/object";
import showModal from "discourse/lib/show-modal"; import showModal from "discourse/lib/show-modal";
export default Component.extend({ export default Component.extend({
actions: { @action
showRawEmail() { showRawEmail(event) {
event?.preventDefault();
showModal("raw-email").set("rawEmail", this.reviewable.payload.raw_email); showModal("raw-email").set("rawEmail", this.reviewable.payload.raw_email);
}, },
},
}); });

View File

@ -11,6 +11,7 @@ export default Component.extend({
@action @action
logClick(topicId) { logClick(topicId) {
// Important: Don't prevent default handling of clicks
if (this.searchLogId && topicId) { if (this.searchLogId && topicId) {
logSearchLinkClick({ logSearchLinkClick({
searchLogId: this.searchLogId, searchLogId: this.searchLogId,

View File

@ -1,4 +1,5 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import { SECOND_FACTOR_METHODS } from "discourse/models/user"; import { SECOND_FACTOR_METHODS } from "discourse/models/user";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
@ -48,8 +49,9 @@ export default Component.extend({
); );
}, },
actions: { @action
toggleSecondFactorMethod() { toggleSecondFactorMethod(event) {
event?.preventDefault();
const secondFactorMethod = this.secondFactorMethod; const secondFactorMethod = this.secondFactorMethod;
this.set("secondFactorToken", ""); this.set("secondFactorToken", "");
if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) { if (secondFactorMethod === SECOND_FACTOR_METHODS.TOTP) {
@ -58,5 +60,4 @@ export default Component.extend({
this.set("secondFactorMethod", SECOND_FACTOR_METHODS.TOTP); this.set("secondFactorMethod", SECOND_FACTOR_METHODS.TOTP);
} }
}, },
},
}); });

View File

@ -1,12 +1,13 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { action } from "@ember/object";
import { SECOND_FACTOR_METHODS } from "discourse/models/user"; import { SECOND_FACTOR_METHODS } from "discourse/models/user";
export default Component.extend({ export default Component.extend({
actions: { @action
useAnotherMethod() { useAnotherMethod(event) {
event?.preventDefault();
this.set("showSecurityKey", false); this.set("showSecurityKey", false);
this.set("showSecondFactor", true); this.set("showSecondFactor", true);
this.set("secondFactorMethod", SECOND_FACTOR_METHODS.TOTP); this.set("secondFactorMethod", SECOND_FACTOR_METHODS.TOTP);
}, },
},
}); });

View File

@ -1,15 +1,19 @@
import Component from "@ember/component"; import Component from "@ember/component";
import discourseLater from "discourse-common/lib/later"; import discourseLater from "discourse-common/lib/later";
import { action } from "@ember/object";
import { on } from "@ember/object/evented"; import { on } from "@ember/object/evented";
export default Component.extend({ export default Component.extend({
action: "showCreateAccount", action: "showCreateAccount",
actions: { @action
neverShow() { neverShow(event) {
event?.preventDefault();
this.keyValueStore.setItem("anon-cta-never", "t"); this.keyValueStore.setItem("anon-cta-never", "t");
this.session.set("showSignupCta", false); this.session.set("showSignupCta", false);
}, },
actions: {
hideForSession() { hideForSession() {
this.session.set("hideSignupCta", true); this.session.set("hideSignupCta", true);
this.keyValueStore.setItem("anon-cta-hidden", Date.now()); this.keyValueStore.setItem("anon-cta-hidden", Date.now());

View File

@ -7,6 +7,7 @@ import discourseComputed from "discourse-common/utils/decorators";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { action } from "@ember/object";
export default Component.extend({ export default Component.extend({
dialog: service(), dialog: service(),
@ -76,12 +77,9 @@ export default Component.extend({
.catch(popupAjaxError); .catch(popupAjaxError);
}, },
actions: { @action
toggleEditControls() { edit(event) {
this.toggleProperty("showEditControls"); event?.preventDefault();
},
edit() {
this.setProperties({ this.setProperties({
editing: true, editing: true,
newTagName: this.tag.id, newTagName: this.tag.id,
@ -89,6 +87,39 @@ export default Component.extend({
}); });
}, },
@action
unlinkSynonym(tag, event) {
event?.preventDefault();
ajax(`/tag/${this.tagInfo.name}/synonyms/${tag.id}`, {
type: "DELETE",
})
.then(() => this.tagInfo.synonyms.removeObject(tag))
.catch(popupAjaxError);
},
@action
deleteSynonym(tag, event) {
event?.preventDefault();
bootbox.confirm(
I18n.t("tagging.delete_synonym_confirm", { tag_name: tag.text }),
(result) => {
if (!result) {
return;
}
tag
.destroyRecord()
.then(() => this.tagInfo.synonyms.removeObject(tag))
.catch(popupAjaxError);
}
);
},
actions: {
toggleEditControls() {
this.toggleProperty("showEditControls");
},
cancelEditing() { cancelEditing() {
this.set("editing", false); this.set("editing", false);
}, },
@ -114,30 +145,6 @@ export default Component.extend({
this.deleteAction(this.tagInfo); this.deleteAction(this.tagInfo);
}, },
unlinkSynonym(tag) {
ajax(`/tag/${this.tagInfo.name}/synonyms/${tag.id}`, {
type: "DELETE",
})
.then(() => this.tagInfo.synonyms.removeObject(tag))
.catch(popupAjaxError);
},
deleteSynonym(tag) {
bootbox.confirm(
I18n.t("tagging.delete_synonym_confirm", { tag_name: tag.text }),
(result) => {
if (!result) {
return;
}
tag
.destroyRecord()
.then(() => this.tagInfo.synonyms.removeObject(tag))
.catch(popupAjaxError);
}
);
},
addSynonyms() { addSynonyms() {
bootbox.confirm( bootbox.confirm(
I18n.t("tagging.add_synonyms_explanation", { I18n.t("tagging.add_synonyms_explanation", {

View File

@ -251,6 +251,7 @@ export default Component.extend({
if (wantsNewWindow(e)) { if (wantsNewWindow(e)) {
return true; return true;
} }
e.preventDefault();
return this.navigateToTopic(topic, e.target.getAttribute("href")); return this.navigateToTopic(topic, e.target.getAttribute("href"));
} }
@ -264,6 +265,7 @@ export default Component.extend({
if (wantsNewWindow(e)) { if (wantsNewWindow(e)) {
return true; return true;
} }
e.preventDefault();
return this.navigateToTopic(topic, topic.lastUnreadUrl); return this.navigateToTopic(topic, topic.lastUnreadUrl);
} }

View File

@ -1,4 +1,4 @@
import EmberObject, { set } from "@ember/object"; import EmberObject, { action, set } from "@ember/object";
import { alias, and, gt, gte, not, or } from "@ember/object/computed"; import { alias, and, gt, gte, not, or } from "@ember/object/computed";
import discourseComputed, { observes } from "discourse-common/utils/decorators"; import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { propertyNotEqual, setting } from "discourse/lib/computed"; import { propertyNotEqual, setting } from "discourse/lib/computed";
@ -220,6 +220,15 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
this._close(); this._close();
}, },
@action
handleShowUser(user, event) {
event?.preventDefault();
// Invokes `showUser` argument. Convert to `this.args.showUser` when
// refactoring this to a glimmer component.
this.showUser(user);
this._close();
},
actions: { actions: {
close() { close() {
this._close(); this._close();
@ -247,9 +256,8 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, {
this._close(); this._close();
}, },
showUser(username) { showUser(user) {
this.showUser(username); this.handleShowUser(user);
this._close();
}, },
checkEmail(user) { checkEmail(user) {

View File

@ -1,6 +1,7 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
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 { action } from "@ember/object";
import { next } from "@ember/runloop"; import { next } from "@ember/runloop";
import { userPath } from "discourse/lib/url"; import { userPath } from "discourse/lib/url";
@ -17,11 +18,13 @@ export default Controller.extend(ModalFunctionality, {
}); });
}, },
actions: { @action
toggleExpanded() { toggleExpanded(event) {
event?.preventDefault();
this.set("expanded", !this.expanded); this.set("expanded", !this.expanded);
}, },
actions: {
highlightSecure() { highlightSecure() {
this.send("closeModal"); this.send("closeModal");

View File

@ -1,4 +1,5 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { action } from "@ember/object";
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 { allowsImages } from "discourse/lib/uploads"; import { allowsImages } from "discourse/lib/uploads";
@ -132,6 +133,15 @@ export default Controller.extend(ModalFunctionality, {
); );
}, },
@action
selectAvatar(url, event) {
event?.preventDefault();
this.user
.selectAvatar(url)
.then(() => window.location.reload())
.catch(popupAjaxError);
},
actions: { actions: {
uploadComplete() { uploadComplete() {
this.set("selected", "custom"); this.set("selected", "custom");
@ -159,13 +169,6 @@ export default Controller.extend(ModalFunctionality, {
.finally(() => this.set("gravatarRefreshDisabled", false)); .finally(() => this.set("gravatarRefreshDisabled", false));
}, },
selectAvatar(url) {
this.user
.selectAvatar(url)
.then(() => window.location.reload())
.catch(popupAjaxError);
},
saveAvatarSelection() { saveAvatarSelection() {
const selectedUploadId = this.selectedUploadId; const selectedUploadId = this.selectedUploadId;
const type = this.selected; const type = this.selected;

View File

@ -508,11 +508,32 @@ export default Controller.extend({
this.set("model.showFullScreenExitPrompt", false); this.set("model.showFullScreenExitPrompt", false);
}, },
actions: { @action
togglePreview() { async cancel(event) {
event?.preventDefault();
await this.cancelComposer();
},
@action
cancelUpload(event) {
event?.preventDefault();
this.set("model.uploadCancelled", true);
},
@action
togglePreview(event) {
event?.preventDefault();
this.toggleProperty("showPreview"); this.toggleProperty("showPreview");
}, },
@action
viewNewReply(event) {
event?.preventDefault();
DiscourseURL.routeTo(this.get("model.createdPost.url"));
this.close();
},
actions: {
closeComposer() { closeComposer() {
this.close(); this.close();
}, },
@ -543,10 +564,6 @@ export default Controller.extend({
}); });
}, },
cancelUpload() {
this.set("model.uploadCancelled", true);
},
onPopupMenuAction(menuAction) { onPopupMenuAction(menuAction) {
this.send(menuAction); this.send(menuAction);
}, },
@ -707,10 +724,6 @@ export default Controller.extend({
this.set("model.loading", false); this.set("model.loading", false);
}, },
async cancel() {
await this.cancelComposer();
},
save(ignore, event) { save(ignore, event) {
this.save(false, { this.save(false, {
jump: jump:
@ -1275,12 +1288,6 @@ export default Controller.extend({
} }
}, },
viewNewReply() {
DiscourseURL.routeTo(this.get("model.createdPost.url"));
this.close();
return false;
},
async destroyDraft(draftSequence = null) { async destroyDraft(draftSequence = null) {
const key = this.get("model.draftKey"); const key = this.get("model.draftKey");
if (!key) { if (!key) {

View File

@ -1,5 +1,6 @@
import DiscoveryController from "discourse/controllers/discovery"; import DiscoveryController from "discourse/controllers/discovery";
import { inject as controller } from "@ember/controller"; import { inject as controller } from "@ember/controller";
import { action } from "@ember/object";
import { dasherize } from "@ember/string"; import { dasherize } from "@ember/string";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { reads } from "@ember/object/computed"; import { reads } from "@ember/object/computed";
@ -50,17 +51,19 @@ export default DiscoveryController.extend({
: style; : style;
return dasherize(componentName); return dasherize(componentName);
}, },
@action
showInserted(event) {
event?.preventDefault();
const tracker = this.topicTrackingState;
// Move inserted into topics
this.model.loadBefore(tracker.get("newIncoming"), true);
tracker.resetTracking();
},
actions: { actions: {
refresh() { refresh() {
this.send("triggerRefresh"); this.send("triggerRefresh");
}, },
showInserted() {
const tracker = this.topicTrackingState;
// Move inserted into topics
this.model.loadBefore(tracker.get("newIncoming"), true);
tracker.resetTracking();
return false;
},
}, },
}); });

View File

@ -63,6 +63,17 @@ const controllerOpts = {
return this._isFilterPage(filter, "new") && topicsLength > 0; return this._isFilterPage(filter, "new") && topicsLength > 0;
}, },
// Show newly inserted topics
@action
showInserted(event) {
event?.preventDefault();
const tracker = this.topicTrackingState;
// Move inserted into topics
this.model.loadBefore(tracker.get("newIncoming"), true);
tracker.resetTracking();
},
actions: { actions: {
changeSort() { changeSort() {
deprecated( deprecated(
@ -72,16 +83,6 @@ const controllerOpts = {
return routeAction("changeSort", this.router._router, ...arguments)(); return routeAction("changeSort", this.router._router, ...arguments)();
}, },
// Show newly inserted topics
showInserted() {
const tracker = this.topicTrackingState;
// Move inserted into topics
this.model.loadBefore(tracker.get("newIncoming"), true);
tracker.resetTracking();
return false;
},
refresh(options = { skipResettingParams: [] }) { refresh(options = { skipResettingParams: [] }) {
const filter = this.get("model.filter"); const filter = this.get("model.filter");
this.send("resetParams", options.skipResettingParams); this.send("resetParams", options.skipResettingParams);

View File

@ -14,6 +14,7 @@ import I18n from "I18n";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { escapeExpression } from "discourse/lib/utilities"; import { escapeExpression } from "discourse/lib/utilities";
import { isEmpty } from "@ember/utils"; import { isEmpty } from "@ember/utils";
import { action } from "@ember/object";
import { gt, or } from "@ember/object/computed"; import { gt, or } from "@ember/object/computed";
import { scrollTop } from "discourse/mixins/scroll-top"; import { scrollTop } from "discourse/mixins/scroll-top";
import { setTransient } from "discourse/lib/page-tracker"; import { setTransient } from "discourse/lib/page-tracker";
@ -391,8 +392,9 @@ export default Controller.extend({
} }
}, },
actions: { @action
createTopic(searchTerm) { createTopic(searchTerm, event) {
event?.preventDefault();
let topicCategory; let topicCategory;
if (searchTerm.includes("category:")) { if (searchTerm.includes("category:")) {
const match = searchTerm.match(/category:(\S*)/); const match = searchTerm.match(/category:(\S*)/);
@ -407,6 +409,7 @@ export default Controller.extend({
}); });
}, },
actions: {
selectAll() { selectAll() {
this.selected.addObjects(this.get("model.posts").mapBy("topic")); this.selected.addObjects(this.get("model.posts").mapBy("topic"));

View File

@ -1,3 +1,4 @@
import { action } from "@ember/object";
import { alias, equal, gt, not, or } from "@ember/object/computed"; import { alias, equal, gt, not, or } from "@ember/object/computed";
import discourseComputed, { import discourseComputed, {
observes, observes,
@ -313,6 +314,24 @@ export default Controller.extend(ModalFunctionality, {
} }
}, },
@action
displayInline(event) {
event?.preventDefault();
this.set("viewMode", "inline");
},
@action
displaySideBySide(event) {
event?.preventDefault();
this.set("viewMode", "side_by_side");
},
@action
displaySideBySideMarkdown(event) {
event?.preventDefault();
this.set("viewMode", "side_by_side_markdown");
},
actions: { actions: {
loadFirstVersion() { loadFirstVersion() {
this.refresh(this.get("model.post_id"), this.get("model.first_revision")); this.refresh(this.get("model.post_id"), this.get("model.first_revision"));
@ -345,15 +364,5 @@ export default Controller.extend(ModalFunctionality, {
revertToVersion() { revertToVersion() {
this.revert(this.post, this.get("model.current_revision")); this.revert(this.post, this.get("model.current_revision"));
}, },
displayInline() {
this.set("viewMode", "inline");
},
displaySideBySide() {
this.set("viewMode", "side_by_side");
},
displaySideBySideMarkdown() {
this.set("viewMode", "side_by_side_markdown");
},
}, },
}); });

View File

@ -3,7 +3,7 @@ import { alias, not, or, readOnly } from "@ember/object/computed";
import { areCookiesEnabled, escapeExpression } from "discourse/lib/utilities"; import { areCookiesEnabled, escapeExpression } from "discourse/lib/utilities";
import cookie, { removeCookie } from "discourse/lib/cookie"; import cookie, { removeCookie } from "discourse/lib/cookie";
import { next, schedule } from "@ember/runloop"; import { next, schedule } from "@ember/runloop";
import EmberObject from "@ember/object"; import EmberObject, { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import ModalFunctionality from "discourse/mixins/modal-functionality"; import ModalFunctionality from "discourse/mixins/modal-functionality";
import { SECOND_FACTOR_METHODS } from "discourse/models/user"; import { SECOND_FACTOR_METHODS } from "discourse/models/user";
@ -133,7 +133,66 @@ export default Controller.extend(ModalFunctionality, {
return canLoginLocalWithEmail; return canLoginLocalWithEmail;
}, },
@action
emailLogin(event) {
event?.preventDefault();
if (this.processingEmailLink) {
return;
}
if (isEmpty(this.loginName)) {
this.flash(I18n.t("login.blank_username"), "info");
return;
}
this.set("processingEmailLink", true);
ajax("/u/email-login", {
data: { login: this.loginName.trim() },
type: "POST",
})
.then((data) => {
const loginName = escapeExpression(this.loginName);
const isEmail = loginName.match(/@/);
let key = `email_login.complete_${isEmail ? "email" : "username"}`;
if (data.user_found === false) {
this.flash(
I18n.t(`${key}_not_found`, {
email: loginName,
username: loginName,
}),
"error"
);
} else {
let postfix = data.hide_taken ? "" : "_found";
this.flash(
I18n.t(`${key}${postfix}`, {
email: loginName,
username: loginName,
})
);
}
})
.catch((e) => this.flash(extractError(e), "error"))
.finally(() => this.set("processingEmailLink", false));
},
@action
handleForgotPassword(event) {
event?.preventDefault();
const forgotPasswordController = this.forgotPassword;
if (forgotPasswordController) {
forgotPasswordController.set("accountEmailOrUsername", this.loginName);
}
this.send("showForgotPassword");
},
actions: { actions: {
forgotPassword() {
this.handleForgotPassword();
},
login() { login() {
if (this.loginDisabled) { if (this.loginDisabled) {
return; return;
@ -297,56 +356,6 @@ export default Controller.extend(ModalFunctionality, {
this.send("showCreateAccount"); this.send("showCreateAccount");
}, },
forgotPassword() {
const forgotPasswordController = this.forgotPassword;
if (forgotPasswordController) {
forgotPasswordController.set("accountEmailOrUsername", this.loginName);
}
this.send("showForgotPassword");
},
emailLogin() {
if (this.processingEmailLink) {
return;
}
if (isEmpty(this.loginName)) {
this.flash(I18n.t("login.blank_username"), "info");
return;
}
this.set("processingEmailLink", true);
ajax("/u/email-login", {
data: { login: this.loginName.trim() },
type: "POST",
})
.then((data) => {
const loginName = escapeExpression(this.loginName);
const isEmail = loginName.match(/@/);
let key = `email_login.complete_${isEmail ? "email" : "username"}`;
if (data.user_found === false) {
this.flash(
I18n.t(`${key}_not_found`, {
email: loginName,
username: loginName,
}),
"error"
);
} else {
let postfix = data.hide_taken ? "" : "_found";
this.flash(
I18n.t(`${key}${postfix}`, {
email: loginName,
username: loginName,
})
);
}
})
.catch((e) => this.flash(extractError(e), "error"))
.finally(() => this.set("processingEmailLink", false));
},
authenticateSecurityKey() { authenticateSecurityKey() {
getWebauthnCredential( getWebauthnCredential(
this.securityKeyChallenge, this.securityKeyChallenge,

View File

@ -1,4 +1,5 @@
import DiscourseURL, { userPath } from "discourse/lib/url"; import DiscourseURL, { userPath } from "discourse/lib/url";
import { action } from "@ember/object";
import { alias, or, readOnly } from "@ember/object/computed"; import { alias, or, readOnly } from "@ember/object/computed";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import I18n from "I18n"; import I18n from "I18n";
@ -46,6 +47,13 @@ export default Controller.extend(PasswordValidation, {
lockImageUrl: getURL("/images/lock.svg"), lockImageUrl: getURL("/images/lock.svg"),
@action
done(event) {
event?.preventDefault();
this.set("redirected", true);
DiscourseURL.redirectTo(this.redirectTo || "/");
},
actions: { actions: {
submit() { submit() {
ajax({ ajax({
@ -126,10 +134,5 @@ export default Controller.extend(PasswordValidation, {
} }
); );
}, },
done() {
this.set("redirected", true);
DiscourseURL.redirectTo(this.redirectTo || "/");
},
}, },
}); });

View File

@ -2,7 +2,7 @@ import { gt, not, or } from "@ember/object/computed";
import { propertyNotEqual, setting } from "discourse/lib/computed"; import { propertyNotEqual, setting } from "discourse/lib/computed";
import CanCheckEmails from "discourse/mixins/can-check-emails"; import CanCheckEmails from "discourse/mixins/can-check-emails";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import EmberObject from "@ember/object"; import EmberObject, { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { findAll } from "discourse/models/login-method"; import { findAll } from "discourse/models/login-method";
@ -132,6 +132,20 @@ export default Controller.extend(CanCheckEmails, {
return findAll().length > 0; return findAll().length > 0;
}, },
@action
resendConfirmationEmail(email, event) {
event?.preventDefault();
email.set("resending", true);
this.model
.addEmail(email.email)
.then(() => {
email.set("resent", true);
})
.finally(() => {
email.set("resending", false);
});
},
actions: { actions: {
save() { save() {
this.set("saved", false); this.set("saved", false);
@ -157,18 +171,6 @@ export default Controller.extend(CanCheckEmails, {
this.model.destroyEmail(email); this.model.destroyEmail(email);
}, },
resendConfirmationEmail(email) {
email.set("resending", true);
this.model
.addEmail(email.email)
.then(() => {
email.set("resent", true);
})
.finally(() => {
email.set("resending", false);
});
},
delete() { delete() {
this.dialog.alert({ this.dialog.alert({
message: I18n.t("user.delete_account_confirm"), message: I18n.t("user.delete_account_confirm"),

View File

@ -3,6 +3,7 @@ import CanCheckEmails from "discourse/mixins/can-check-emails";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import I18n from "I18n"; import I18n from "I18n";
import { SECOND_FACTOR_METHODS } from "discourse/models/user"; import { SECOND_FACTOR_METHODS } from "discourse/models/user";
import { action } from "@ember/object";
import { alias } from "@ember/object/computed"; import { alias } from "@ember/object/computed";
import bootbox from "bootbox"; import bootbox from "bootbox";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
@ -91,17 +92,10 @@ export default Controller.extend(CanCheckEmails, {
this.set("dirty", true); this.set("dirty", true);
}, },
actions: { @action
confirmPassword() { resetPassword(event) {
if (!this.password) { event?.preventDefault();
return;
}
this.markDirty();
this.loadSecondFactors();
this.set("password", null);
},
resetPassword() {
this.setProperties({ this.setProperties({
resetPasswordLoading: true, resetPasswordLoading: true,
resetPasswordProgress: "", resetPasswordProgress: "",
@ -119,6 +113,16 @@ export default Controller.extend(CanCheckEmails, {
.finally(() => this.set("resetPasswordLoading", false)); .finally(() => this.set("resetPasswordLoading", false));
}, },
actions: {
confirmPassword() {
if (!this.password) {
return;
}
this.markDirty();
this.loadSecondFactors();
this.set("password", null);
},
disableAllSecondFactors() { disableAllSecondFactors() {
if (this.loading) { if (this.loading) {
return; return;

View File

@ -1,4 +1,5 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { action } from "@ember/object";
import { gt } from "@ember/object/computed"; import { gt } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
@ -51,21 +52,11 @@ export default Controller.extend(CanCheckEmails, {
DEFAULT_AUTH_TOKENS_COUNT DEFAULT_AUTH_TOKENS_COUNT
), ),
actions: { @action
save() { changePassword(event) {
this.set("saved", false); event?.preventDefault();
return this.model
.then(() => this.set("saved", true))
.catch(popupAjaxError);
},
changePassword() {
if (!this.passwordProgress) { if (!this.passwordProgress) {
this.set( this.set("passwordProgress", I18n.t("user.change_password.in_progress"));
"passwordProgress",
I18n.t("user.change_password.in_progress")
);
return this.model return this.model
.changePassword() .changePassword()
.then(() => { .then(() => {
@ -85,11 +76,15 @@ export default Controller.extend(CanCheckEmails, {
} }
}, },
toggleShowAllAuthTokens() { @action
toggleShowAllAuthTokens(event) {
event?.preventDefault();
this.toggleProperty("showAllAuthTokens"); this.toggleProperty("showAllAuthTokens");
}, },
revokeAuthToken(token) { @action
revokeAuthToken(token, event) {
event?.preventDefault();
ajax( ajax(
userPath( userPath(
`${this.get("model.username_lower")}/preferences/revoke-auth-token` `${this.get("model.username_lower")}/preferences/revoke-auth-token`
@ -107,6 +102,15 @@ export default Controller.extend(CanCheckEmails, {
.catch(popupAjaxError); .catch(popupAjaxError);
}, },
actions: {
save() {
this.set("saved", false);
return this.model
.then(() => this.set("saved", true))
.catch(popupAjaxError);
},
showToken(token) { showToken(token) {
showModal("auth-token", { model: token }); showModal("auth-token", { model: token });
}, },

View File

@ -1,4 +1,5 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { action } from "@ember/object";
import I18n from "I18n"; import I18n from "I18n";
import ModalFunctionality from "discourse/mixins/modal-functionality"; import ModalFunctionality from "discourse/mixins/modal-functionality";
@ -40,9 +41,15 @@ export default Controller.extend(ModalFunctionality, {
.finally(() => this.set("loading", false)); .finally(() => this.set("loading", false));
}, },
@action
enableShowSecondFactorKey(event) {
event?.preventDefault();
this.set("showSecondFactorKey", true);
},
actions: { actions: {
showSecondFactorKey() { showSecondFactorKey() {
this.set("showSecondFactorKey", true); this.enableShowSecondFactorKey();
}, },
enableSecondFactor() { enableSecondFactor() {

View File

@ -212,7 +212,8 @@ export default Controller.extend({
}, },
@action @action
useAnotherMethod(newMethod) { useAnotherMethod(newMethod, event) {
event?.preventDefault();
this.set("userSelectedMethod", newMethod); this.set("userSelectedMethod", newMethod);
}, },

View File

@ -110,7 +110,8 @@ export default DiscoverySortableController.extend(
}, },
@action @action
showInserted() { showInserted(event) {
event?.preventDefault();
const tracker = this.topicTrackingState; const tracker = this.topicTrackingState;
this.list.loadBefore(tracker.newIncoming, true); this.list.loadBefore(tracker.newIncoming, true);
tracker.resetTracking(); tracker.resetTracking();

View File

@ -1,3 +1,4 @@
import { action } from "@ember/object";
import { alias, notEmpty } from "@ember/object/computed"; import { alias, notEmpty } from "@ember/object/computed";
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import I18n from "I18n"; import I18n from "I18n";
@ -41,8 +42,9 @@ export default Controller.extend({
}; };
}, },
actions: { @action
sortByCount() { sortByCount(event) {
event?.preventDefault();
this.setProperties({ this.setProperties({
sortProperties: ["totalCount:desc", "id"], sortProperties: ["totalCount:desc", "id"],
sortedByCount: true, sortedByCount: true,
@ -50,7 +52,9 @@ export default Controller.extend({
}); });
}, },
sortById() { @action
sortById(event) {
event?.preventDefault();
this.setProperties({ this.setProperties({
sortProperties: ["id"], sortProperties: ["id"],
sortedByCount: false, sortedByCount: false,
@ -58,6 +62,7 @@ export default Controller.extend({
}); });
}, },
actions: {
showUploader() { showUploader() {
showModal("tag-upload"); showModal("tag-upload");
}, },

View File

@ -313,6 +313,55 @@ export default Controller.extend(bufferedProperty("model"), {
}); });
}, },
@action
editTopic(event) {
event?.preventDefault();
if (this.get("model.details.can_edit")) {
this.set("editingTopic", true);
}
},
@action
jumpTop(event) {
event?.preventDefault();
DiscourseURL.routeTo(this.get("model.firstPostUrl"), {
skipIfOnScreen: false,
keepFilter: true,
});
},
@action
removeFeaturedLink(event) {
event?.preventDefault();
this.set("buffered.featured_link", null);
},
@action
selectAll(event) {
event?.preventDefault();
const smallActionsPostIds = this._smallActionPostIds();
this.set("selectedPostIds", [
...this.get("model.postStream.stream").filter(
(postId) => !smallActionsPostIds.has(postId)
),
]);
this._forceRefreshPostStream();
},
@action
deselectAll(event) {
event?.preventDefault();
this.set("selectedPostIds", []);
this._forceRefreshPostStream();
},
@action
toggleMultiSelect(event) {
event?.preventDefault();
this.toggleProperty("multiSelect");
this._forceRefreshPostStream();
},
actions: { actions: {
topicCategoryChanged(categoryId) { topicCategoryChanged(categoryId) {
this.set("buffered.category_id", categoryId); this.set("buffered.category_id", categoryId);
@ -822,13 +871,6 @@ export default Controller.extend(bufferedProperty("model"), {
this._jumpToPostNumber(postNumber); this._jumpToPostNumber(postNumber);
}, },
jumpTop() {
DiscourseURL.routeTo(this.get("model.firstPostUrl"), {
skipIfOnScreen: false,
keepFilter: true,
});
},
jumpBottom() { jumpBottom() {
// When a topic only has one lengthy post // When a topic only has one lengthy post
const jumpEnd = this.model.highest_post_number === 1 ? true : false; const jumpEnd = this.model.highest_post_number === 1 ? true : false;
@ -859,26 +901,6 @@ export default Controller.extend(bufferedProperty("model"), {
this._jumpToPostId(postId); this._jumpToPostId(postId);
}, },
toggleMultiSelect() {
this.toggleProperty("multiSelect");
this._forceRefreshPostStream();
},
selectAll() {
const smallActionsPostIds = this._smallActionPostIds();
this.set("selectedPostIds", [
...this.get("model.postStream.stream").filter(
(postId) => !smallActionsPostIds.has(postId)
),
]);
this._forceRefreshPostStream();
},
deselectAll() {
this.set("selectedPostIds", []);
this._forceRefreshPostStream();
},
togglePostSelection(post) { togglePostSelection(post) {
const selected = this.selectedPostIds; const selected = this.selectedPostIds;
selected.includes(post.id) selected.includes(post.id)
@ -973,13 +995,6 @@ export default Controller.extend(bufferedProperty("model"), {
.then(() => this.updateQueryParams); .then(() => this.updateQueryParams);
}, },
editTopic() {
if (this.get("model.details.can_edit")) {
this.set("editingTopic", true);
}
return false;
},
cancelEditingTopic() { cancelEditingTopic() {
this.set("editingTopic", false); this.set("editingTopic", false);
this.rollbackBuffer(); this.rollbackBuffer();
@ -1159,10 +1174,6 @@ export default Controller.extend(bufferedProperty("model"), {
.catch(popupAjaxError); .catch(popupAjaxError);
}, },
removeFeaturedLink() {
this.set("buffered.featured_link", null);
},
resetBumpDate() { resetBumpDate() {
this.model.resetBumpDate(); this.model.resetBumpDate();
}, },

View File

@ -1,12 +1,15 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { action } from "@ember/object";
export default Controller.extend({ export default Controller.extend({
sortProperties: ["count:desc", "id"], sortProperties: ["count:desc", "id"],
tagsForUser: null, tagsForUser: null,
sortedByCount: true, sortedByCount: true,
sortedByName: false, sortedByName: false,
actions: { @action
sortByCount() { sortByCount(event) {
event?.preventDefault();
this.setProperties({ this.setProperties({
sortProperties: ["count:desc", "id"], sortProperties: ["count:desc", "id"],
sortedByCount: true, sortedByCount: true,
@ -14,12 +17,13 @@ export default Controller.extend({
}); });
}, },
sortById() { @action
sortById(event) {
event?.preventDefault();
this.setProperties({ this.setProperties({
sortProperties: ["id"], sortProperties: ["id"],
sortedByCount: false, sortedByCount: false,
sortedByName: true, sortedByName: true,
}); });
}, },
},
}); });

View File

@ -81,10 +81,10 @@ export default Controller.extend(BulkTopicSelection, {
}, },
@action @action
showInserted() { showInserted(event) {
event?.preventDefault();
this.model.loadBefore(this.pmTopicTrackingState.newIncoming); this.model.loadBefore(this.pmTopicTrackingState.newIncoming);
this.pmTopicTrackingState.resetIncomingTracking(); this.pmTopicTrackingState.resetIncomingTracking();
return false;
}, },
@action @action

View File

@ -211,6 +211,15 @@ export default Controller.extend(CanCheckEmails, {
} }
}, },
@action
showSuspensions(event) {
event?.preventDefault();
this.adminTools.showActionLogs(this, {
target_user: this.get("model.username"),
action_name: "suspend_user",
});
},
actions: { actions: {
collapseProfile() { collapseProfile() {
this.set("forceExpand", false); this.set("forceExpand", false);
@ -220,13 +229,6 @@ export default Controller.extend(CanCheckEmails, {
this.set("forceExpand", true); this.set("forceExpand", true);
}, },
showSuspensions() {
this.adminTools.showActionLogs(this, {
target_user: this.get("model.username"),
action_name: "suspend_user",
});
},
adminDelete() { adminDelete() {
const userId = this.get("model.id"); const userId = this.get("model.id");
const location = document.location.pathname; const location = document.location.pathname;

View File

@ -20,7 +20,7 @@
{{#if this.mutedCategories}} {{#if this.mutedCategories}}
<div class="muted-categories"> <div class="muted-categories">
<a href class="muted-categories-link" {{action "toggleShowMuted"}}> <a href class="muted-categories-link" {{on "click" this.toggleShowMuted}}>
<h3 class="muted-categories-heading">{{i18n "categories.muted"}}</h3> <h3 class="muted-categories-heading">{{i18n "categories.muted"}}</h3>
{{#if this.mutedToggleIcon}} {{#if this.mutedToggleIcon}}
{{d-icon this.mutedToggleIcon}} {{d-icon this.mutedToggleIcon}}

View File

@ -1,6 +1,6 @@
<span class="group-name"> <span class="group-name">
<span class="group-name-label">{{this.group_name}}</span> <span class="group-name-label">{{this.group_name}}</span>
<a class="remove-permission" href {{action "removeRow"}}> <a class="remove-permission" href {{on "click" this.removeRow}}>
{{d-icon "far-trash-alt"}} {{d-icon "far-trash-alt"}}
</a> </a>
</span> </span>

View File

@ -11,7 +11,7 @@
{{#each this.messages as |m|}} {{#each this.messages as |m|}}
<div class="controls existing-message"> <div class="controls existing-message">
<label class="radio"> <label class="radio">
<input id="choose-message-{{m.id}}" {{action "chooseMessage" m}} type="radio" name="choose_message_id"> <input id="choose-message-{{m.id}}" {{on "click" (fn this.chooseMessage m)}} type="radio" name="choose_message_id">
<span class="message-title"> <span class="message-title">
{{m.title}} {{m.title}}
</span> </span>

View File

@ -1 +1 @@
<a href {{action "select"}} class={{if this.active "active"}}>{{this.title}}</a> <a href {{on "click" this.select}} class={{if this.active "active"}}>{{this.title}}</a>

View File

@ -1,30 +1,30 @@
{{!-- DO NOT EDIT THIS FILE!!! --}} {{!-- DO NOT EDIT THIS FILE!!! --}}
{{!-- Update it by running `rake javascript:update_constants` --}} {{!-- Update it by running `rake javascript:update_constants` --}}
<button type="button" data-section="smileys_&_emotion" {{action this.onCategorySelection "smileys_&_emotion"}} class="btn btn-default category-button emoji"> <button type="button" data-section="smileys_&_emotion" {{on "click" (fn this.onCategorySelection "smileys_&_emotion")}} class="btn btn-default category-button emoji">
{{replace-emoji ":grinning:"}} {{replace-emoji ":grinning:"}}
</button> </button>
<button type="button" data-section="people_&_body" {{action this.onCategorySelection "people_&_body"}} class="btn btn-default category-button emoji"> <button type="button" data-section="people_&_body" {{on "click" (fn this.onCategorySelection "people_&_body")}} class="btn btn-default category-button emoji">
{{replace-emoji ":wave:"}} {{replace-emoji ":wave:"}}
</button> </button>
<button type="button" data-section="animals_&_nature" {{action this.onCategorySelection "animals_&_nature"}} class="btn btn-default category-button emoji"> <button type="button" data-section="animals_&_nature" {{on "click" (fn this.onCategorySelection "animals_&_nature")}} class="btn btn-default category-button emoji">
{{replace-emoji ":evergreen_tree:"}} {{replace-emoji ":evergreen_tree:"}}
</button> </button>
<button type="button" data-section="food_&_drink" {{action this.onCategorySelection "food_&_drink"}} class="btn btn-default category-button emoji"> <button type="button" data-section="food_&_drink" {{on "click" (fn this.onCategorySelection "food_&_drink")}} class="btn btn-default category-button emoji">
{{replace-emoji ":hamburger:"}} {{replace-emoji ":hamburger:"}}
</button> </button>
<button type="button" data-section="travel_&_places" {{action this.onCategorySelection "travel_&_places"}} class="btn btn-default category-button emoji"> <button type="button" data-section="travel_&_places" {{on "click" (fn this.onCategorySelection "travel_&_places")}} class="btn btn-default category-button emoji">
{{replace-emoji ":airplane:"}} {{replace-emoji ":airplane:"}}
</button> </button>
<button type="button" data-section="activities" {{action this.onCategorySelection "activities"}} class="btn btn-default category-button emoji"> <button type="button" data-section="activities" {{on "click" (fn this.onCategorySelection "activities")}} class="btn btn-default category-button emoji">
{{replace-emoji ":soccer:"}} {{replace-emoji ":soccer:"}}
</button> </button>
<button type="button" data-section="objects" {{action this.onCategorySelection "objects"}} class="btn btn-default category-button emoji"> <button type="button" data-section="objects" {{on "click" (fn this.onCategorySelection "objects")}} class="btn btn-default category-button emoji">
{{replace-emoji ":eyeglasses:"}} {{replace-emoji ":eyeglasses:"}}
</button> </button>
<button type="button" data-section="symbols" {{action this.onCategorySelection "symbols"}} class="btn btn-default category-button emoji"> <button type="button" data-section="symbols" {{on "click" (fn this.onCategorySelection "symbols")}} class="btn btn-default category-button emoji">
{{replace-emoji ":white_check_mark:"}} {{replace-emoji ":white_check_mark:"}}
</button> </button>
<button type="button" data-section="flags" {{action this.onCategorySelection "flags"}} class="btn btn-default category-button emoji"> <button type="button" data-section="flags" {{on "click" (fn this.onCategorySelection "flags")}} class="btn btn-default category-button emoji">
{{replace-emoji ":checkered_flag:"}} {{replace-emoji ":checkered_flag:"}}
</button> </button>

View File

@ -4,15 +4,15 @@
{{!-- template-lint-enable no-invalid-interactive no-down-event-binding --}} {{!-- template-lint-enable no-invalid-interactive no-down-event-binding --}}
<div class="emoji-picker-category-buttons"> <div class="emoji-picker-category-buttons">
{{#if this.recentEmojis.length}} {{#if this.recentEmojis.length}}
<button type="button" data-section="recent" {{action "onCategorySelection" "recent"}} class="btn btn-default category-button emoji"> <button type="button" data-section="recent" {{on "click" (fn this.onCategorySelection "recent")}} class="btn btn-default category-button emoji">
{{replace-emoji ":star:"}} {{replace-emoji ":star:"}}
</button> </button>
{{/if}} {{/if}}
<EmojiGroupButtons @onCategorySelection={{action "onCategorySelection"}} @tagName="" /> <EmojiGroupButtons @onCategorySelection={{this.onCategorySelection}} @tagName="" />
{{#each-in this.customEmojis as |group emojis|}} {{#each-in this.customEmojis as |group emojis|}}
<button type="button" data-section={{concat "custom-" group}} {{action "onCategorySelection" (concat "custom-" group)}} class="btn btn-default category-button emoji"> <button type="button" data-section={{concat "custom-" group}} {{on "click" (fn this.onCategorySelection (concat "custom-" group))}} class="btn btn-default category-button emoji">
{{replace-emoji (concat ":" emojis.firstObject.code ":")}} {{replace-emoji (concat ":" emojis.firstObject.code ":")}}
</button> </button>
{{/each-in}} {{/each-in}}

View File

@ -2,7 +2,7 @@
<h3>{{this.formattedName}}</h3> <h3>{{this.formattedName}}</h3>
<div class="controls"> <div class="controls">
<label class="radio"> <label class="radio">
<input id="radio_{{this.flag.name_key}}" {{action "changePostActionType" this.flag}} type="radio" name="post_action_type_index"> <input id="radio_{{this.flag.name_key}}" {{on "click" (action "changePostActionType" this.flag)}} type="radio" name="post_action_type_index">
<div class="flag-action-type-details"> <div class="flag-action-type-details">
<span class="description">{{html-safe this.flag.description}}</span> <span class="description">{{html-safe this.flag.description}}</span>
@ -19,7 +19,7 @@
{{else}} {{else}}
<div class="controls {{this.flag.name_key}}"> <div class="controls {{this.flag.name_key}}">
<label class="radio"> <label class="radio">
<input id="radio_{{this.flag.name_key}}" {{action "changePostActionType" this.flag}} type="radio" name="post_action_type_index"> <input id="radio_{{this.flag.name_key}}" {{on "click" (action "changePostActionType" this.flag)}} type="radio" name="post_action_type_index">
<div class="flag-action-type-details"> <div class="flag-action-type-details">
<strong>{{this.formattedName}}</strong> <strong>{{this.formattedName}}</strong>
{{#if this.showDescription}} {{#if this.showDescription}}

View File

@ -13,14 +13,14 @@
{{else}} {{else}}
<div class="card-row first-row"> <div class="card-row first-row">
<div class="group-card-avatar"> <div class="group-card-avatar">
<a href={{this.groupPath}} {{action "showGroup" this.group}} class="card-huge-avatar"> <a href={{this.groupPath}} {{on "click" (fn this.handleShowGroup this.group)}} class="card-huge-avatar">
<AvatarFlair @flairName={{this.group.name}} @flairUrl={{this.group.flair_url}} @flairBgColor={{this.group.flair_bg_color}} @flairColor={{this.group.flair_color}} /> <AvatarFlair @flairName={{this.group.name}} @flairUrl={{this.group.flair_url}} @flairBgColor={{this.group.flair_bg_color}} @flairColor={{this.group.flair_color}} />
</a> </a>
</div> </div>
<div class="names"> <div class="names">
<span> <span>
<h1 class={{this.group.name}}> <h1 class={{this.group.name}}>
<a href={{this.groupPath}} {{action "showGroup" this.group}} class="group-page-link">{{this.group.name}}</a> <a href={{this.groupPath}} {{on "click" (fn this.handleShowGroup this.group)}} class="group-page-link">{{this.group.name}}</a>
</h1> </h1>
{{#if this.group.full_name}} {{#if this.group.full_name}}
<h2 class="full-name">{{this.group.full_name}}</h2> <h2 class="full-name">{{this.group.full_name}}</h2>
@ -53,10 +53,10 @@
<div class="card-row third-row"> <div class="card-row third-row">
<div class="members metadata"> <div class="members metadata">
{{#each this.group.members as |user|}} {{#each this.group.members as |user|}}
<a {{action "close"}} href={{user.path}} class="card-tiny-avatar">{{bound-avatar user "tiny"}}</a> <a {{on "click" this.close}} href={{user.path}} class="card-tiny-avatar">{{bound-avatar user "tiny"}}</a>
{{/each}} {{/each}}
{{#if this.showMoreMembers}} {{#if this.showMoreMembers}}
<a href={{this.groupPath}} {{action "showGroup" this.group}} class="more-members-link"> <a href={{this.groupPath}} {{on "click" (fn this.handleShowGroup this.group)}} class="more-members-link">
<span class="more-members-count">+{{this.moreMembersCount}} {{i18n "more"}}</span> <span class="more-members-count">+{{this.moreMembersCount}} {{i18n "more"}}</span>
</a> </a>
{{/if}} {{/if}}

View File

@ -34,7 +34,7 @@
<div class="control-group"> <div class="control-group">
<div class="group-imap-prefill-options"> <div class="group-imap-prefill-options">
{{i18n "groups.manage.email.prefill.title"}} <a id="prefill_imap_gmail" href {{action "prefillSettings" "gmail"}}>{{i18n "groups.manage.email.prefill.gmail"}}</a> {{i18n "groups.manage.email.prefill.title"}} <a id="prefill_imap_gmail" href {{on "click" (fn this.prefillSettings "gmail")}}>{{i18n "groups.manage.email.prefill.gmail"}}</a>
</div> </div>
</div> </div>

View File

@ -3,7 +3,7 @@
<p>{{i18n "groups.manage.email.smtp_instructions"}}</p> <p>{{i18n "groups.manage.email.smtp_instructions"}}</p>
<label for="enable_smtp"> <label for="enable_smtp">
<Input @type="checkbox" @checked={{this.group.smtp_enabled}} id="enable_smtp" tabindex="1" {{on "change" (action "smtpEnabledChange")}} /> <Input @type="checkbox" @checked={{this.group.smtp_enabled}} id="enable_smtp" tabindex="1" {{on "change" this.smtpEnabledChange}} />
{{i18n "groups.manage.email.enable_smtp"}} {{i18n "groups.manage.email.enable_smtp"}}
</label> </label>
@ -23,7 +23,7 @@
<div class="alert alert-warning">{{i18n "groups.manage.email.imap_alpha_warning"}}</div> <div class="alert alert-warning">{{i18n "groups.manage.email.imap_alpha_warning"}}</div>
<label for="enable_imap"> <label for="enable_imap">
<Input @type="checkbox" disabled={{not this.enableImapSettings}} @checked={{this.group.imap_enabled}} id="enable_imap" tabindex="8" {{on "change" (action "imapEnabledChange")}} /> <Input @type="checkbox" disabled={{not this.enableImapSettings}} @checked={{this.group.imap_enabled}} id="enable_imap" tabindex="8" {{on "change" this.imapEnabledChange}} />
{{i18n "groups.manage.email.enable_imap"}} {{i18n "groups.manage.email.enable_imap"}}
</label> </label>

View File

@ -3,7 +3,7 @@
</a> </a>
<span>{{this.member.username}}</span> <span>{{this.member.username}}</span>
{{#unless this.automatic}} {{#unless this.automatic}}
<a href {{action "remove"}} class="remove"> <a href {{on "click" this.remove}} class="remove">
{{d-icon "times"}} {{d-icon "times"}}
</a> </a>
{{/unless}} {{/unless}}

View File

@ -40,7 +40,7 @@
<div class="control-group"> <div class="control-group">
<div class="group-smtp-prefill-options"> <div class="group-smtp-prefill-options">
{{i18n "groups.manage.email.prefill.title"}} <a id="prefill_smtp_gmail" href {{action "prefillSettings" "gmail"}}>{{i18n "groups.manage.email.prefill.gmail"}}</a> {{i18n "groups.manage.email.prefill.title"}} <a id="prefill_smtp_gmail" href {{on "click" (fn this.prefillSettings "gmail")}}>{{i18n "groups.manage.email.prefill.gmail"}}</a>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
{{#each this.buttons as |b|}} {{#each this.buttons as |b|}}
<button type="button" class="btn btn-social {{b.name}}" {{action this.externalLogin b}} aria-label={{b.screenReaderTitle}} tabindex="3"> <button type="button" class="btn btn-social {{b.name}}" {{on "click" (action this.externalLogin b)}} aria-label={{b.screenReaderTitle}} tabindex="3">
{{#if b.isGoogle}} {{#if b.isGoogle}}
<svg class="fa d-icon d-icon-custom-google-oauth2 svg-icon" viewBox="0 0 48 48"><defs><path id="a" d="M44.5 20H24v8.5h11.8C34.7 33.9 30.1 37 24 37c-7.2 0-13-5.8-13-13s5.8-13 13-13c3.1 0 5.9 1.1 8.1 2.9l6.4-6.4C34.6 4.1 29.6 2 24 2 11.8 2 2 11.8 2 24s9.8 22 22 22c11 0 21-8 21-22 0-1.3-.2-2.7-.5-4z"/></defs><clipPath id="b"><use href="#a" overflow="visible"/></clipPath><path clip-path="url(#b)" fill="#FBBC05" d="M0 37V11l17 13z"/><path clip-path="url(#b)" fill="#EA4335" d="M0 11l17 13 7-6.1L48 14V0H0z"/><path clip-path="url(#b)" fill="#34A853" d="M0 37l30-23 7.9 1L48 0v48H0z"/><path clip-path="url(#b)" fill="#4285F4" d="M48 48L17 24l-4-3 35-10z"/></svg> <svg class="fa d-icon d-icon-custom-google-oauth2 svg-icon" viewBox="0 0 48 48"><defs><path id="a" d="M44.5 20H24v8.5h11.8C34.7 33.9 30.1 37 24 37c-7.2 0-13-5.8-13-13s5.8-13 13-13c3.1 0 5.9 1.1 8.1 2.9l6.4-6.4C34.6 4.1 29.6 2 24 2 11.8 2 2 11.8 2 24s9.8 22 22 22c11 0 21-8 21-22 0-1.3-.2-2.7-.5-4z"/></defs><clipPath id="b"><use href="#a" overflow="visible"/></clipPath><path clip-path="url(#b)" fill="#FBBC05" d="M0 37V11l17 13z"/><path clip-path="url(#b)" fill="#EA4335" d="M0 11l17 13 7-6.1L48 14V0H0z"/><path clip-path="url(#b)" fill="#34A853" d="M0 37l30-23 7.9 1L48 0v48H0z"/><path clip-path="url(#b)" fill="#4285F4" d="M48 48L17 24l-4-3 35-10z"/></svg>
{{else if b.icon}} {{else if b.icon}}

View File

@ -10,7 +10,7 @@
<span class="status"> <span class="status">
{{reviewable-status this.reviewable.status}} {{reviewable-status this.reviewable.status}}
</span> </span>
<a href {{action "explainReviewable" this.reviewable}} title={{i18n "review.explain.why"}} class="explain"> <a href {{on "click" (fn this.explainReviewable this.reviewable)}} title={{i18n "review.explain.why"}} class="explain">
{{d-icon "question-circle"}} {{d-icon "question-circle"}}
</a> </a>
</div> </div>

View File

@ -1,5 +1,5 @@
{{#if this.hasEdits}} {{#if this.hasEdits}}
<a href {{action "showEditHistory"}} class="has-edits {{this.historyClass}}" title={{i18n "post.last_edited_on" dateTime=this.editedDate}}> <a href {{on "click" this.showEditHistory}} class="has-edits {{this.historyClass}}" title={{i18n "post.last_edited_on" dateTime=this.editedDate}}>
{{d-icon "pencil-alt"}} {{d-icon "pencil-alt"}}
</a> </a>
{{/if}} {{/if}}

View File

@ -6,7 +6,7 @@
{{category-badge this.reviewable.category}} {{category-badge this.reviewable.category}}
<ReviewableTags @tags={{this.reviewable.payload.tags}} @tagName="" /> <ReviewableTags @tags={{this.reviewable.payload.tags}} @tagName="" />
{{#if this.reviewable.payload.via_email}} {{#if this.reviewable.payload.via_email}}
<a href {{action "showRawEmail"}} class="show-raw-email"> <a href {{on "click" this.showRawEmail}} class="show-raw-email">
{{d-icon "far-envelope" title="post.via_email"}} {{d-icon "far-envelope" title="post.via_email"}}
</a> </a>
{{/if}} {{/if}}

View File

@ -10,7 +10,7 @@
<TrackSelected @selectedList={{this.selected}} @selectedId={{this.post.topic}} @class="bulk-select" /> <TrackSelected @selectedList={{this.selected}} @selectedId={{this.post.topic}} @class="bulk-select" />
{{/if}} {{/if}}
<a href={{this.post.url}} {{action "logClick" this.post.topic_id}} class="search-link{{if this.post.topic.visited " visited"}}" role="heading" aria-level="2"> <a href={{this.post.url}} {{on "click" (fn this.logClick this.post.topic_id)}} class="search-link{{if this.post.topic.visited " visited"}}" role="heading" aria-level="2">
{{raw "topic-status" topic=this.post.topic showPrivateMessageIcon=true}} {{raw "topic-status" topic=this.post.topic showPrivateMessageIcon=true}}
<span class="topic-title"> <span class="topic-title">
{{#if this.post.useTopicTitleHeadline}} {{#if this.post.useTopicTitleHeadline}}

View File

@ -7,7 +7,7 @@
{{yield}} {{yield}}
{{#if this.showToggleMethodLink}} {{#if this.showToggleMethodLink}}
<p> <p>
<a href="" class="toggle-second-factor-method" {{action "toggleSecondFactorMethod"}}>{{ i18n this.linkText }}</a> <a href class="toggle-second-factor-method" {{on "click" this.toggleSecondFactorMethod}}>{{ i18n this.linkText }}</a>
</p> </p>
{{/if}} {{/if}}
</div> </div>

View File

@ -2,7 +2,7 @@
<DButton @action={{this.action}} @icon="key" @id="security-key-authenticate-button" @label="login.security_key_authenticate" @type="button" @class="btn btn-large btn-primary" /> <DButton @action={{this.action}} @icon="key" @id="security-key-authenticate-button" @label="login.security_key_authenticate" @type="button" @class="btn btn-large btn-primary" />
<p> <p>
{{#if this.otherMethodAllowed}} {{#if this.otherMethodAllowed}}
<a href="" class="toggle-second-factor-method" {{action "useAnotherMethod"}}>{{ i18n "login.security_key_alternative" }}</a> <a href class="toggle-second-factor-method" {{on "click" this.useAnotherMethod}}>{{ i18n "login.security_key_alternative" }}</a>
{{/if}} {{/if}}
</p> </p>
</div> </div>

View File

@ -4,7 +4,7 @@
{{#if this.canSelectAll}} {{#if this.canSelectAll}}
<p> <p>
<a class="select-all" href {{action this.selectAll}}> <a class="select-all" href {{on "click" this.selectAll}}>
{{i18n "topic.multi_select.select_all"}} {{i18n "topic.multi_select.select_all"}}
</a> </a>
</p> </p>
@ -12,7 +12,7 @@
{{#if this.canDeselectAll}} {{#if this.canDeselectAll}}
<p> <p>
<a href {{action this.deselectAll}}> <a href {{on "click" this.deselectAll}}>
{{i18n "topic.multi_select.deselect_all"}} {{i18n "topic.multi_select.deselect_all"}}
</a> </a>
</p> </p>
@ -35,7 +35,7 @@
{{/if}} {{/if}}
<p class="cancel"> <p class="cancel">
<a href {{action this.toggleMultiSelect}}> <a href {{on "click" this.toggleMultiSelect}}>
{{i18n "topic.multi_select.cancel"}} {{i18n "topic.multi_select.cancel"}}
</a> </a>
</p> </p>

View File

@ -10,7 +10,7 @@
<div class="buttons"> <div class="buttons">
<DButton @action={{route-action "showCreateAccount"}} @label="signup_cta.sign_up" @icon="user" @class="btn-primary" /> <DButton @action={{route-action "showCreateAccount"}} @label="signup_cta.sign_up" @icon="user" @class="btn-primary" />
<DButton @action={{action "hideForSession"}} @label="signup_cta.hide_session" @class="no-icon" /> <DButton @action={{action "hideForSession"}} @label="signup_cta.hide_session" @class="no-icon" />
<a href {{action "neverShow"}}>{{i18n "signup_cta.hide_forever"}}</a> <a href {{on "click" this.neverShow}}>{{i18n "signup_cta.hide_forever"}}</a>
</div> </div>
{{/if}} {{/if}}
</div> </div>

View File

@ -17,7 +17,7 @@
<div class="tag-name-wrapper"> <div class="tag-name-wrapper">
{{discourse-tag this.tagInfo.name tagName="div"}} {{discourse-tag this.tagInfo.name tagName="div"}}
{{#if this.canAdminTag}} {{#if this.canAdminTag}}
<a href {{action "edit"}} class="edit-tag" title={{i18n "tagging.edit_tag"}}>{{d-icon "pencil-alt"}}</a> <a href {{on "click" this.edit}} class="edit-tag" title={{i18n "tagging.edit_tag"}}>{{d-icon "pencil-alt"}}</a>
{{/if}} {{/if}}
</div> </div>
<div class="tag-description-wrapper"> <div class="tag-description-wrapper">
@ -56,10 +56,10 @@
<div class="tag-box"> <div class="tag-box">
{{discourse-tag tag.id pmOnly=tag.pmOnly tagName="div"}} {{discourse-tag tag.id pmOnly=tag.pmOnly tagName="div"}}
{{#if this.editSynonymsMode}} {{#if this.editSynonymsMode}}
<a href {{action "unlinkSynonym" tag}} class="unlink-synonym"> <a href {{on "click" (fn this.unlinkSynonym tag)}} class="unlink-synonym">
{{d-icon "unlink" title="tagging.remove_synonym"}} {{d-icon "unlink" title="tagging.remove_synonym"}}
</a> </a>
<a href {{action "deleteSynonym" tag}} class="delete-synonym"> <a href {{on "click" (fn this.deleteSynonym tag)}} class="delete-synonym">
{{d-icon "far-trash-alt" title="tagging.delete_tag"}} {{d-icon "far-trash-alt" title="tagging.delete_tag"}}
</a> </a>
{{/if}} {{/if}}

View File

@ -26,7 +26,7 @@
{{#if this.user.profile_hidden}} {{#if this.user.profile_hidden}}
<span class="card-huge-avatar">{{bound-avatar this.user "huge"}}</span> <span class="card-huge-avatar">{{bound-avatar this.user "huge"}}</span>
{{else}} {{else}}
<a href={{this.user.path}} {{action "showUser" this.user}} class="card-huge-avatar">{{bound-avatar this.user "huge"}}</a> <a href={{this.user.path}} {{on "click" (fn this.handleShowUser this.user)}} class="card-huge-avatar">{{bound-avatar this.user "huge"}}</a>
{{/if}} {{/if}}
<UserAvatarFlair @user={{this.user}} /> <UserAvatarFlair @user={{this.user}} />
@ -40,7 +40,7 @@
{{if this.nameFirst this.user.name (format-username this.user.username)}} {{if this.nameFirst this.user.name (format-username this.user.username)}}
</span> </span>
{{else}} {{else}}
<a href={{this.user.path}} {{action "showUser" this.user}} class="user-profile-link"> <a href={{this.user.path}} {{on "click" (fn this.handleShowUser this.user)}} class="user-profile-link">
<span id="discourse-user-card-title" class="name-username-wrapper"> <span id="discourse-user-card-title" class="name-username-wrapper">
{{if this.nameFirst this.user.name (format-username this.user.username)}} {{if this.nameFirst this.user.name (format-username this.user.username)}}
</span> </span>
@ -48,7 +48,7 @@
</a> </a>
{{/if}} {{/if}}
</h1> </h1>
<PluginOutlet @name="user-card-after-username" @connectorTagName="div" @args={{hash user=this.user showUser=(action "showUser" this.user)}} /> <PluginOutlet @name="user-card-after-username" @connectorTagName="div" @args={{hash user=this.user showUser=(fn this.handleShowUser this.user)}} />
{{#if this.nameFirst}} {{#if this.nameFirst}}
<h2 class="username">{{this.user.username}}</h2> <h2 class="username">{{this.user.username}}</h2>
{{else}} {{else}}

View File

@ -101,7 +101,7 @@
<ComposerSaveButton @action={{action "save"}} @icon={{this.saveIcon}} @label={{this.saveLabel}} @forwardEvent={{true}} @disableSubmit={{this.disableSubmit}} /> <ComposerSaveButton @action={{action "save"}} @icon={{this.saveIcon}} @label={{this.saveLabel}} @forwardEvent={{true}} @disableSubmit={{this.disableSubmit}} />
{{#if this.site.mobileView}} {{#if this.site.mobileView}}
<a href {{action "cancel"}} title={{i18n "cancel"}} class="cancel"> <a href {{on "click" this.cancel}} title={{i18n "cancel"}} class="cancel">
{{#if this.canEdit}} {{#if this.canEdit}}
{{d-icon "times"}} {{d-icon "times"}}
{{else}} {{else}}
@ -109,7 +109,7 @@
{{/if}} {{/if}}
</a> </a>
{{else}} {{else}}
<a href {{action "cancel"}} class="cancel" >{{i18n "close"}}</a> <a href {{on "click" this.cancel}} class="cancel" >{{i18n "close"}}</a>
{{/if}} {{/if}}
{{#if this.site.mobileView}} {{#if this.site.mobileView}}
@ -133,7 +133,7 @@
{{/if}} {{/if}}
{{#if this.isCancellable}} {{#if this.isCancellable}}
<a href id="cancel-file-upload" {{action "cancelUpload"}}>{{d-icon "times"}}</a> <a href id="cancel-file-upload" {{on "click" this.cancelUpload}}>{{d-icon "times"}}</a>
{{/if}} {{/if}}
</div> </div>
{{/if}} {{/if}}
@ -165,7 +165,7 @@
</a> </a>
{{/if}} {{/if}}
<a href class="btn btn-default no-text mobile-preview" title={{i18n "composer.show_preview"}} {{action "togglePreview"}} aria-label={{i18n "preview"}}> <a href class="btn btn-default no-text mobile-preview" title={{i18n "composer.show_preview"}} {{on "click" this.togglePreview}} aria-label={{i18n "preview"}}>
{{d-icon "desktop"}} {{d-icon "desktop"}}
</a> </a>
@ -180,7 +180,7 @@
{{else}} {{else}}
<div class="saving-text"> <div class="saving-text">
{{#if this.model.createdPost}} {{#if this.model.createdPost}}
{{i18n "composer.saved"}} <a href={{this.createdPost.url}} {{action "viewNewReply"}} class="permalink">{{i18n "composer.view_new_post"}}</a> {{i18n "composer.saved"}} <a href={{this.createdPost.url}} {{on "click" this.viewNewReply}} class="permalink">{{i18n "composer.view_new_post"}}</a>
{{else}} {{else}}
{{i18n "composer.saving"}} {{loading-spinner size="small"}} {{i18n "composer.saving"}} {{loading-spinner size="small"}}
{{/if}} {{/if}}

View File

@ -1,4 +1,4 @@
<a href {{action this.closeMessage this.message}} class="close" aria-label={{i18n "composer.esc_label"}}> <a href {{on "click" (fn this.closeMessage this.message)}} class="close" aria-label={{i18n "composer.esc_label"}}>
{{i18n "composer.esc"}} {{d-icon "times"}} {{i18n "composer.esc"}} {{d-icon "times"}}
</a> </a>

View File

@ -1,4 +1,4 @@
<a href {{action this.closeMessage this.message}} class="close" aria-label={{i18n "composer.esc_label"}}> <a href {{on "click" (fn this.closeMessage this.message)}} class="close" aria-label={{i18n "composer.esc_label"}}>
{{i18n "composer.esc"}} {{d-icon "times"}} {{i18n "composer.esc"}} {{d-icon "times"}}
</a> </a>

View File

@ -1,4 +1,4 @@
<a href {{action this.closeMessage this.message}} class="close" aria-label={{i18n "composer.esc_label"}}> <a href {{on "click" (fn this.closeMessage this.message)}} class="close" aria-label={{i18n "composer.esc_label"}}>
{{i18n "composer.esc"}} {{d-icon "times"}} {{i18n "composer.esc"}} {{d-icon "times"}}
</a> </a>

View File

@ -1,4 +1,4 @@
<a href {{action this.closeMessage this.message}} class="close" aria-label={{i18n "composer.esc_label"}}> <a href {{on "click" (fn this.closeMessage this.message)}} class="close" aria-label={{i18n "composer.esc_label"}}>
{{i18n "composer.esc"}} {{d-icon "times"}} {{i18n "composer.esc"}} {{d-icon "times"}}
</a> </a>

View File

@ -1,4 +1,4 @@
<a href {{action this.closeMessage this.message}} class="close" aria-label={{i18n "composer.esc_label"}}> <a href {{on "click" (fn this.closeMessage this.message)}} class="close" aria-label={{i18n "composer.esc_label"}}>
{{i18n "composer.esc"}} {{d-icon "times"}} {{i18n "composer.esc"}} {{d-icon "times"}}
</a> </a>

View File

@ -3,7 +3,7 @@
<DiscoveryCategories @refresh={{action "refresh"}}> <DiscoveryCategories @refresh={{action "refresh"}}>
{{#if (and this.topicTrackingState.hasIncoming this.isCategoriesRoute)}} {{#if (and this.topicTrackingState.hasIncoming this.isCategoriesRoute)}}
<div class="show-more {{if this.hasTopics "has-topics"}}"> <div class="show-more {{if this.hasTopics "has-topics"}}">
<div role="button" class="alert alert-info clickable" {{action "showInserted"}}> <div role="button" class="alert alert-info clickable" {{on "click" this.showInserted}}>
<CountI18n @key="topic_count_" @suffix={{this.topicTrackingState.filter}} @count={{this.topicTrackingState.incomingCount}} /> <CountI18n @key="topic_count_" @suffix={{this.topicTrackingState.filter}} @count={{this.topicTrackingState.incomingCount}} />
</div> </div>
</div> </div>

View File

@ -20,7 +20,7 @@
{{else}} {{else}}
{{#if this.topicTrackingState.hasIncoming}} {{#if this.topicTrackingState.hasIncoming}}
<div class="show-more {{if this.hasTopics "has-topics"}}"> <div class="show-more {{if this.hasTopics "has-topics"}}">
<a tabindex="0" href {{action "showInserted"}} class="alert alert-info clickable"> <a tabindex="0" href {{on "click" this.showInserted}} class="alert alert-info clickable">
<CountI18n @key="topic_count_" @suffix={{this.topicTrackingState.filter}} @count={{this.topicTrackingState.incomingCount}} /> <CountI18n @key="topic_count_" @suffix={{this.topicTrackingState.filter}} @count={{this.topicTrackingState.incomingCount}} />
</a> </a>
</div> </div>

View File

@ -101,7 +101,7 @@
<div class="no-results-suggestion"> <div class="no-results-suggestion">
{{i18n "search.cant_find"}} {{i18n "search.cant_find"}}
{{#if this.canCreateTopic}} {{#if this.canCreateTopic}}
<a href {{action "createTopic" this.searchTerm}}>{{i18n "search.start_new_topic"}}</a> <a href {{on "click" (fn this.createTopic this.searchTerm)}}>{{i18n "search.start_new_topic"}}</a>
{{#unless this.siteSettings.login_required}} {{#unless this.siteSettings.login_required}}
{{i18n "search.or_search_google"}} {{i18n "search.or_search_google"}}
{{/unless}} {{/unless}}

View File

@ -9,7 +9,7 @@
{{#if this.mutedCategories}} {{#if this.mutedCategories}}
<div class="muted-categories"> <div class="muted-categories">
<a href class="muted-categories-link" {{action "toggleShowMuted"}}> <a href class="muted-categories-link" {{on "click" this.toggleShowMuted}}>
<h3 class="muted-categories-heading">{{i18n "categories.muted"}}</h3> <h3 class="muted-categories-heading">{{i18n "categories.muted"}}</h3>
{{#if this.mutedToggleIcon}} {{#if this.mutedToggleIcon}}
{{d-icon this.mutedToggleIcon}} {{d-icon this.mutedToggleIcon}}

Some files were not shown because too many files have changed in this diff Show More