Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Update modifyClass calls to native class syntax #227

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions assets/javascripts/discourse/initializers/init-code-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import DiscourseURL, { userPath } from "discourse/lib/url";
import { findAll } from "discourse/models/login-method";
import I18n from "I18n";

const PLUGIN_ID = "discourse-code-review";

async function actOnCommit(topic, action) {
try {
let result = await ajax(`/code-review/${action}.json`, {
Expand Down Expand Up @@ -37,22 +35,27 @@ function initialize(api) {
//
// note there are slightly cleaner ways of doing this but we would need
// to amend core for the plugin which is not feeling right
api.modifyClass("controller:preferences/account", {
pluginId: PLUGIN_ID,

canUpdateAssociatedAccounts: computed("authProviders", function () {
return findAll().length > 0;
}),
});

api.modifyClass("controller:preferences/notifications", {
pluginId: PLUGIN_ID,

init() {
this._super(...arguments);
this.saveAttrNames.push("custom_fields");
},
});
api.modifyClass(
"controller:preferences/account",
(Superclass) =>
class extends Superclass {
@computed("authProviders")
get canUpdateAssociatedAccounts() {
return findAll().length > 0;
}
}
);

api.modifyClass(
"controller:preferences/notifications",
(Superclass) =>
class extends Superclass {
init() {
super.init(...arguments);
this.saveAttrNames.push("custom_fields");
}
}
);

function allowSkip(currentUser, topic, siteSettings) {
return allowApprove(currentUser, topic, siteSettings);
Expand Down