DEV: Migrate remaining admin classes to native syntax (#20717)

This commit was generated using the ember-native-class-codemod along with a handful of manual updates
This commit is contained in:
David Taylor 2023-03-17 12:25:05 +00:00 committed by GitHub
parent 1161c980f2
commit 74349e17c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 52 additions and 53 deletions

View File

@ -1,13 +1,13 @@
import RESTAdapter from "discourse/adapters/rest";
import RestAdapter from "discourse/adapters/rest";
export default RESTAdapter.extend({
jsonMode: true,
export default class ApiKey extends RestAdapter {
jsonMode = true;
basePath() {
return "/admin/api/";
},
}
apiNameFor() {
return "key";
},
});
}
}

View File

@ -1,11 +1,11 @@
import RestAdapter from "discourse/adapters/rest";
export default function buildPluginAdapter(pluginName) {
return RestAdapter.extend({
return class extends RestAdapter {
pathFor(store, type, findArgs) {
return (
"/admin/plugins/" + pluginName + this._super(store, type, findArgs)
"/admin/plugins/" + pluginName + super.pathFor(store, type, findArgs)
);
},
});
}
};
}

View File

@ -1,7 +1,7 @@
import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({
export default class CustomizationBase extends RestAdapter {
basePath() {
return "/admin/customize/";
},
});
}
}

View File

@ -1,7 +1,7 @@
import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({
export default class EmailStyle extends RestAdapter {
pathFor() {
return "/admin/customize/email_style";
},
});
}
}

View File

@ -1,7 +1,7 @@
import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({
export default class Embedding extends RestAdapter {
pathFor() {
return "/admin/customize/embedding";
},
});
}
}

View File

@ -1,7 +1,7 @@
import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({
export default class StaffActionLog extends RestAdapter {
basePath() {
return "/admin/logs/";
},
});
}
}

View File

@ -1,5 +1,5 @@
import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({
jsonMode: true,
});
export default class TagGroup extends RestAdapter {
jsonMode = true;
}

View File

@ -1,9 +1,10 @@
import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({
export default class Theme extends RestAdapter {
jsonMode = true;
basePath() {
return "/admin/";
},
}
afterFindAll(results) {
let map = {};
@ -20,7 +21,5 @@ export default RestAdapter.extend({
theme.set("parentThemes", mappedParents);
});
return results;
},
jsonMode: true,
});
}
}

View File

@ -1,7 +1,7 @@
import RESTAdapter from "discourse/adapters/rest";
import RestAdapter from "discourse/adapters/rest";
export default RESTAdapter.extend({
export default class WebHookEvent extends RestAdapter {
basePath() {
return "/admin/api/";
},
});
}
}

View File

@ -1,7 +1,7 @@
import RESTAdapter from "discourse/adapters/rest";
import RestAdapter from "discourse/adapters/rest";
export default RESTAdapter.extend({
export default class WebHook extends RestAdapter {
basePath() {
return "/admin/api/";
},
});
}
}

View File

@ -2,7 +2,7 @@ import Helper from "@ember/component/helper";
import { iconHTML } from "discourse-common/lib/icon-library";
import { htmlSafe } from "@ember/template";
export default Helper.extend({
export default class DispositionIcon extends Helper {
compute([disposition]) {
if (!disposition) {
return null;
@ -24,5 +24,5 @@ export default Helper.extend({
}
}
return htmlSafe(iconHTML(icon, { title }));
},
});
}
}

View File

@ -10,8 +10,8 @@ import { htmlSafe } from "@ember/template";
// A service that can act as a bridge between the front end Discourse application
// and the admin application. Use this if you need front end code to access admin
// modules. Inject it optionally, and if it exists go to town!
export default Service.extend({
dialog: service(),
export default class AdminToolsService extends Service {
@service dialog;
showActionLogs(target, filters) {
const controller = getOwner(target).lookup(
@ -20,15 +20,15 @@ export default Service.extend({
target.transitionToRoute("adminLogs.staffActionLogs").then(() => {
controller.changeFilters(filters);
});
},
}
checkSpammer(userId) {
return AdminUser.find(userId).then((au) => this.spammerDetails(au));
},
}
deleteUser(id, formData) {
return AdminUser.find(id).then((user) => user.destroy(formData));
},
}
spammerDetails(adminUser) {
return {
@ -37,7 +37,7 @@ export default Service.extend({
adminUser.get("can_be_deleted") &&
adminUser.get("can_delete_all_posts"),
};
},
}
_showControlModal(type, user, opts) {
opts = opts || {};
@ -67,15 +67,15 @@ export default Service.extend({
controller.finishedSetup();
});
},
}
showSilenceModal(user, opts) {
this._showControlModal("silence", user, opts);
},
}
showSuspendModal(user, opts) {
this._showControlModal("suspend", user, opts);
},
}
_deleteSpammer(adminUser) {
// Try loading the email if the site supports it
@ -131,5 +131,5 @@ export default Service.extend({
});
});
});
},
});
}
}