DEV: Update admin routes to native class syntax (#20686)
This commit is contained in:
parent
7288bc277b
commit
e700f0af93
|
@ -1,7 +1,7 @@
|
|||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminApiIndexRoute extends Route {
|
||||
beforeModel() {
|
||||
this.transitionTo("adminApiKeys");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminApiKeysIndexRoute extends Route {
|
||||
model() {
|
||||
return this.store.findAll("api-key");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminApiKeysNewRoute extends Route {
|
||||
model() {
|
||||
return this.store.createRecord("api-key");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminApiKeysShowRoute extends Route {
|
||||
model(params) {
|
||||
return this.store.find("api-key", params.api_key_id);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import { action } from "@ember/object";
|
||||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
actions: {
|
||||
show(apiKey) {
|
||||
this.transitionTo("adminApiKeys.show", apiKey.id);
|
||||
},
|
||||
export default class AdminApiKeysRoute extends Route {
|
||||
@action
|
||||
show(apiKey) {
|
||||
this.transitionTo("adminApiKeys.show", apiKey.id);
|
||||
}
|
||||
|
||||
new() {
|
||||
this.transitionTo("adminApiKeys.new");
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
new() {
|
||||
this.transitionTo("adminApiKeys.new");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,20 @@ import Backup from "admin/models/backup";
|
|||
import Route from "@ember/routing/route";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminBackupsIndexRoute extends Route {
|
||||
activate() {
|
||||
this.messageBus.subscribe("/admin/backups", this.onMessage);
|
||||
},
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe("/admin/backups", this.onMessage);
|
||||
},
|
||||
}
|
||||
|
||||
model() {
|
||||
return Backup.find().then((backups) =>
|
||||
backups.map((backup) => Backup.create(backup))
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
@bind
|
||||
onMessage(backups) {
|
||||
|
@ -23,5 +23,5 @@ export default Route.extend({
|
|||
"model",
|
||||
backups.map((backup) => Backup.create(backup))
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import EmberObject from "@ember/object";
|
|||
import PreloadStore from "discourse/lib/preload-store";
|
||||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminBackupsLogsRoute extends Route {
|
||||
// since the logs are pushed via the message bus
|
||||
// we only want to preload them (hence the beforeModel hook)
|
||||
beforeModel() {
|
||||
|
@ -20,9 +20,9 @@ export default Route.extend({
|
|||
logs.pushObjects(newLogs);
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
setupController() {
|
||||
/* prevent default behavior */
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { inject as service } from "@ember/service";
|
||||
import Backup from "admin/models/backup";
|
||||
import BackupStatus from "admin/models/backup-status";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import EmberObject from "@ember/object";
|
||||
import EmberObject, { action } from "@ember/object";
|
||||
import I18n from "I18n";
|
||||
import PreloadStore from "discourse/lib/preload-store";
|
||||
import User from "discourse/models/user";
|
||||
|
@ -9,21 +10,20 @@ import { ajax } from "discourse/lib/ajax";
|
|||
import { extractError } from "discourse/lib/ajax-error";
|
||||
import getURL from "discourse-common/lib/get-url";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
||||
const LOG_CHANNEL = "/admin/backups/logs";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
dialog: service(),
|
||||
export default class AdminBackupsRoute extends DiscourseRoute {
|
||||
@service dialog;
|
||||
|
||||
activate() {
|
||||
this.messageBus.subscribe(LOG_CHANNEL, this.onMessage);
|
||||
},
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe(LOG_CHANNEL, this.onMessage);
|
||||
},
|
||||
}
|
||||
|
||||
model() {
|
||||
return PreloadStore.getAndRemove("operations_status", () =>
|
||||
|
@ -35,7 +35,7 @@ export default DiscourseRoute.extend({
|
|||
allowRestore: status.allow_restore,
|
||||
})
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
@bind
|
||||
onMessage(log) {
|
||||
|
@ -62,104 +62,111 @@ export default DiscourseRoute.extend({
|
|||
.get("logs")
|
||||
.pushObject(EmberObject.create(log));
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
actions: {
|
||||
showStartBackupModal() {
|
||||
showModal("admin-start-backup", { admin: true });
|
||||
},
|
||||
@action
|
||||
showStartBackupModal() {
|
||||
showModal("admin-start-backup", { admin: true });
|
||||
}
|
||||
|
||||
startBackup(withUploads) {
|
||||
this.transitionTo("admin.backups.logs");
|
||||
Backup.start(withUploads).then((result) => {
|
||||
if (!result.success) {
|
||||
this.dialog.alert(result.message);
|
||||
}
|
||||
});
|
||||
},
|
||||
@action
|
||||
startBackup(withUploads) {
|
||||
this.transitionTo("admin.backups.logs");
|
||||
Backup.start(withUploads).then((result) => {
|
||||
if (!result.success) {
|
||||
this.dialog.alert(result.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
destroyBackup(backup) {
|
||||
return this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.backups.operations.destroy.confirm"),
|
||||
didConfirm: () => {
|
||||
backup
|
||||
.destroy()
|
||||
.then(() =>
|
||||
this.controllerFor("adminBackupsIndex")
|
||||
.get("model")
|
||||
.removeObject(backup)
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
startRestore(backup) {
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.backups.operations.restore.confirm"),
|
||||
didConfirm: () => {
|
||||
this.transitionTo("admin.backups.logs");
|
||||
backup.restore();
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
cancelOperation() {
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.backups.operations.cancel.confirm"),
|
||||
didConfirm: () => {
|
||||
Backup.cancel().then(() => {
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
false
|
||||
);
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
rollback() {
|
||||
return this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.backups.operations.rollback.confirm"),
|
||||
didConfirm: () => {
|
||||
Backup.rollback().then((result) => {
|
||||
if (!result.success) {
|
||||
this.dialog.alert(result.message);
|
||||
} else {
|
||||
// redirect to homepage (session might be lost)
|
||||
window.location = getURL("/");
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
uploadSuccess(filename) {
|
||||
this.dialog.alert(I18n.t("admin.backups.upload.success", { filename }));
|
||||
},
|
||||
|
||||
uploadError(filename, message) {
|
||||
this.dialog.alert(
|
||||
I18n.t("admin.backups.upload.error", { filename, message })
|
||||
);
|
||||
},
|
||||
|
||||
remoteUploadSuccess() {
|
||||
Backup.find()
|
||||
.then((backups) => backups.map((backup) => Backup.create(backup)))
|
||||
.then((backups) => {
|
||||
this.controllerFor("adminBackupsIndex").set(
|
||||
"model",
|
||||
backups.map((backup) => Backup.create(backup))
|
||||
@action
|
||||
destroyBackup(backup) {
|
||||
return this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.backups.operations.destroy.confirm"),
|
||||
didConfirm: () => {
|
||||
backup
|
||||
.destroy()
|
||||
.then(() =>
|
||||
this.controllerFor("adminBackupsIndex")
|
||||
.get("model")
|
||||
.removeObject(backup)
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.dialog.alert(
|
||||
I18n.t("admin.backups.backup_storage_error", {
|
||||
error_message: extractError(error),
|
||||
})
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
startRestore(backup) {
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.backups.operations.restore.confirm"),
|
||||
didConfirm: () => {
|
||||
this.transitionTo("admin.backups.logs");
|
||||
backup.restore();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
cancelOperation() {
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.backups.operations.cancel.confirm"),
|
||||
didConfirm: () => {
|
||||
Backup.cancel().then(() => {
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
false
|
||||
);
|
||||
return [];
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
rollback() {
|
||||
return this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.backups.operations.rollback.confirm"),
|
||||
didConfirm: () => {
|
||||
Backup.rollback().then((result) => {
|
||||
if (!result.success) {
|
||||
this.dialog.alert(result.message);
|
||||
} else {
|
||||
// redirect to homepage (session might be lost)
|
||||
window.location = getURL("/");
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@action
|
||||
uploadSuccess(filename) {
|
||||
this.dialog.alert(I18n.t("admin.backups.upload.success", { filename }));
|
||||
}
|
||||
|
||||
@action
|
||||
uploadError(filename, message) {
|
||||
this.dialog.alert(
|
||||
I18n.t("admin.backups.upload.error", { filename, message })
|
||||
);
|
||||
}
|
||||
|
||||
@action
|
||||
remoteUploadSuccess() {
|
||||
Backup.find()
|
||||
.then((backups) => backups.map((backup) => Backup.create(backup)))
|
||||
.then((backups) => {
|
||||
this.controllerFor("adminBackupsIndex").set(
|
||||
"model",
|
||||
backups.map((backup) => Backup.create(backup))
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.dialog.alert(
|
||||
I18n.t("admin.backups.backup_storage_error", {
|
||||
error_message: extractError(error),
|
||||
})
|
||||
);
|
||||
return [];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
import Route from "@ember/routing/route";
|
||||
export default Route.extend({
|
||||
|
||||
export default class AdminCustomizeColorsShowRoute extends Route {
|
||||
model(params) {
|
||||
const all = this.modelFor("adminCustomize.colors");
|
||||
const model = all.findBy("id", parseInt(params.scheme_id, 10));
|
||||
return model ? model : this.replaceWith("adminCustomize.colors.index");
|
||||
},
|
||||
}
|
||||
|
||||
serialize(model) {
|
||||
return { scheme_id: model.get("id") };
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("model", model);
|
||||
controller.set("allColors", this.modelFor("adminCustomize.colors"));
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import ColorScheme from "admin/models/color-scheme";
|
||||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminCustomizeColorsRoute extends Route {
|
||||
model() {
|
||||
return ColorScheme.findAll();
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("model", model);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import { action } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import I18n from "I18n";
|
||||
import Route from "@ember/routing/route";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default Route.extend({
|
||||
dialog: service(),
|
||||
export default class AdminCustomizeEmailStyleEditRoute extends Route {
|
||||
@service dialog;
|
||||
|
||||
model(params) {
|
||||
return {
|
||||
model: this.modelFor("adminCustomizeEmailStyle"),
|
||||
fieldName: params.field_name,
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({
|
||||
|
@ -17,26 +19,25 @@ export default Route.extend({
|
|||
model: model.model,
|
||||
});
|
||||
this._shouldAlertUnsavedChanges = true;
|
||||
},
|
||||
}
|
||||
|
||||
actions: {
|
||||
willTransition(transition) {
|
||||
if (
|
||||
this.get("controller.model.changed") &&
|
||||
this._shouldAlertUnsavedChanges &&
|
||||
transition.intent.name !== this.routeName
|
||||
) {
|
||||
transition.abort();
|
||||
this.dialog.confirm({
|
||||
message: I18n.t("admin.customize.theme.unsaved_changes_alert"),
|
||||
confirmButtonLabel: "admin.customize.theme.discard",
|
||||
cancelButtonLabel: "admin.customize.theme.stay",
|
||||
didConfirm: () => {
|
||||
this._shouldAlertUnsavedChanges = false;
|
||||
transition.retry();
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
willTransition(transition) {
|
||||
if (
|
||||
this.get("controller.model.changed") &&
|
||||
this._shouldAlertUnsavedChanges &&
|
||||
transition.intent.name !== this.routeName
|
||||
) {
|
||||
transition.abort();
|
||||
this.dialog.confirm({
|
||||
message: I18n.t("admin.customize.theme.unsaved_changes_alert"),
|
||||
confirmButtonLabel: "admin.customize.theme.discard",
|
||||
cancelButtonLabel: "admin.customize.theme.stay",
|
||||
didConfirm: () => {
|
||||
this._shouldAlertUnsavedChanges = false;
|
||||
transition.retry();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminCustomizeEmailStyleIndexRoute extends Route {
|
||||
beforeModel() {
|
||||
this.replaceWith("adminCustomizeEmailStyle.edit", "html");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminCustomizeEmailStyleRoute extends Route {
|
||||
model() {
|
||||
return this.store.find("email-style");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import Route from "@ember/routing/route";
|
||||
import { scrollTop } from "discourse/mixins/scroll-top";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminCustomizeEmailTemplatesEditRoute extends Route {
|
||||
model(params) {
|
||||
const all = this.modelFor("adminCustomizeEmailTemplates");
|
||||
return all.findBy("id", params.id);
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, emailTemplate) {
|
||||
controller.setProperties({ emailTemplate, saved: false });
|
||||
scrollTop();
|
||||
},
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.controller.set("emailTemplate", null);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import Route from "@ember/routing/route";
|
||||
import { action } from "@ember/object";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminCustomizeEmailTemplatesRoute extends Route {
|
||||
model() {
|
||||
return this.store.findAll("email-template");
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("emailTemplates", model);
|
||||
},
|
||||
}
|
||||
|
||||
@action
|
||||
didTransition() {
|
||||
|
@ -22,5 +22,5 @@ export default Route.extend({
|
|||
this.controller.get("sortedTemplates.firstObject")
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { action } from "@ember/object";
|
||||
import FormTemplate from "admin/models/form-template";
|
||||
|
||||
export default class AdminCustomizeFormTemplatesIndex extends DiscourseRoute {
|
||||
model() {
|
||||
return FormTemplate.findAll();
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import Route from "@ember/routing/route";
|
||||
export default Route.extend({
|
||||
|
||||
export default class AdminCustomizeIndexRoute extends Route {
|
||||
beforeModel() {
|
||||
if (this.currentUser.admin) {
|
||||
this.transitionTo("adminCustomizeThemes");
|
||||
} else {
|
||||
this.transitionTo("adminWatchedWords");
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import Route from "@ember/routing/route";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminCustomizeRobotsTxtRoute extends Route {
|
||||
model() {
|
||||
return ajax("/admin/customize/robots");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { action } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import I18n from "I18n";
|
||||
import Route from "@ember/routing/route";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default Route.extend({
|
||||
dialog: service(),
|
||||
export default class AdminCustomizeThemesEditRoute extends Route {
|
||||
@service dialog;
|
||||
|
||||
model(params) {
|
||||
const all = this.modelFor("adminCustomizeThemes");
|
||||
|
@ -15,7 +16,7 @@ export default Route.extend({
|
|||
field_name: params.field_name,
|
||||
}
|
||||
: this.replaceWith("adminCustomizeThemes.index");
|
||||
},
|
||||
}
|
||||
|
||||
serialize(wrapper) {
|
||||
return {
|
||||
|
@ -24,7 +25,7 @@ export default Route.extend({
|
|||
field_name: wrapper.field_name || "scss",
|
||||
theme_id: wrapper.model.get("id"),
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, wrapper) {
|
||||
const fields = wrapper.model
|
||||
|
@ -48,27 +49,26 @@ export default Route.extend({
|
|||
controller.set("fieldName", wrapper.field_name || "scss");
|
||||
this.controllerFor("adminCustomizeThemes").set("editingTheme", true);
|
||||
this.set("shouldAlertUnsavedChanges", true);
|
||||
},
|
||||
}
|
||||
|
||||
actions: {
|
||||
willTransition(transition) {
|
||||
if (
|
||||
this.get("controller.model.changed") &&
|
||||
this.shouldAlertUnsavedChanges &&
|
||||
transition.intent.name !== this.routeName
|
||||
) {
|
||||
transition.abort();
|
||||
@action
|
||||
willTransition(transition) {
|
||||
if (
|
||||
this.get("controller.model.changed") &&
|
||||
this.shouldAlertUnsavedChanges &&
|
||||
transition.intent.name !== this.routeName
|
||||
) {
|
||||
transition.abort();
|
||||
|
||||
this.dialog.confirm({
|
||||
message: I18n.t("admin.customize.theme.unsaved_changes_alert"),
|
||||
confirmButtonLabel: "admin.customize.theme.discard",
|
||||
cancelButtonLabel: "admin.customize.theme.stay",
|
||||
didConfirm: () => {
|
||||
this.set("shouldAlertUnsavedChanges", false);
|
||||
transition.retry();
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
this.dialog.confirm({
|
||||
message: I18n.t("admin.customize.theme.unsaved_changes_alert"),
|
||||
confirmButtonLabel: "admin.customize.theme.discard",
|
||||
cancelButtonLabel: "admin.customize.theme.stay",
|
||||
didConfirm: () => {
|
||||
this.set("shouldAlertUnsavedChanges", false);
|
||||
transition.retry();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ const externalResources = [
|
|||
},
|
||||
];
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminCustomizeThemesIndexRoute extends Route {
|
||||
setupController(controller) {
|
||||
this._super(...arguments);
|
||||
super.setupController(...arguments);
|
||||
this.controllerFor("adminCustomizeThemes").set("editingTheme", false);
|
||||
controller.setProperties({
|
||||
externalResources,
|
||||
womanArtistEmojiURL: emojiUrlFor("woman_artist:t5"),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
import { action } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { COMPONENTS, THEMES } from "admin/models/theme";
|
||||
import I18n from "I18n";
|
||||
import Route from "@ember/routing/route";
|
||||
import { scrollTop } from "discourse/mixins/scroll-top";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default Route.extend({
|
||||
dialog: service(),
|
||||
export default class AdminCustomizeThemesShowRoute extends Route {
|
||||
@service dialog;
|
||||
|
||||
serialize(model) {
|
||||
return { theme_id: model.get("id") };
|
||||
},
|
||||
}
|
||||
|
||||
model(params) {
|
||||
const all = this.modelFor("adminCustomizeThemes");
|
||||
const model = all.findBy("id", parseInt(params.theme_id, 10));
|
||||
return model ? model : this.replaceWith("adminCustomizeThemes.index");
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
this._super(...arguments);
|
||||
super.setupController(...arguments);
|
||||
|
||||
const parentController = this.controllerFor("adminCustomizeThemes");
|
||||
|
||||
|
@ -37,11 +38,11 @@ export default Route.extend({
|
|||
});
|
||||
|
||||
this.handleHighlight(model);
|
||||
},
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.handleHighlight();
|
||||
},
|
||||
}
|
||||
|
||||
handleHighlight(theme) {
|
||||
this.get("controller.allThemes")
|
||||
|
@ -50,26 +51,27 @@ export default Route.extend({
|
|||
if (theme) {
|
||||
theme.set("selected", true);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
actions: {
|
||||
didTransition() {
|
||||
scrollTop();
|
||||
},
|
||||
willTransition(transition) {
|
||||
const model = this.controller.model;
|
||||
if (model.warnUnassignedComponent) {
|
||||
transition.abort();
|
||||
@action
|
||||
didTransition() {
|
||||
scrollTop();
|
||||
}
|
||||
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.customize.theme.unsaved_parent_themes"),
|
||||
didConfirm: () => {
|
||||
model.set("recentlyInstalled", false);
|
||||
transition.retry();
|
||||
},
|
||||
didCancel: () => model.set("recentlyInstalled", false),
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
willTransition(transition) {
|
||||
const model = this.controller.model;
|
||||
if (model.warnUnassignedComponent) {
|
||||
transition.abort();
|
||||
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.customize.theme.unsaved_parent_themes"),
|
||||
didConfirm: () => {
|
||||
model.set("recentlyInstalled", false);
|
||||
transition.retry();
|
||||
},
|
||||
didCancel: () => model.set("recentlyInstalled", false),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,24 @@
|
|||
import { action } from "@ember/object";
|
||||
import { inject as service } from "@ember/service";
|
||||
import Route from "@ember/routing/route";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
import I18n from "I18n";
|
||||
import { next } from "@ember/runloop";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
export default Route.extend({
|
||||
dialog: service(),
|
||||
export default class AdminCustomizeThemesRoute extends Route {
|
||||
@service dialog;
|
||||
|
||||
queryParams: {
|
||||
queryParams = {
|
||||
repoUrl: null,
|
||||
repoName: null,
|
||||
},
|
||||
};
|
||||
|
||||
model() {
|
||||
return this.store.findAll("theme");
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
this._super(controller, model);
|
||||
super.setupController(controller, model);
|
||||
controller.set("editingTheme", false);
|
||||
|
||||
if (controller.repoUrl) {
|
||||
|
@ -31,35 +32,33 @@ export default Route.extend({
|
|||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
actions: {
|
||||
installModal() {
|
||||
const currentTheme = this.controllerFor(
|
||||
"adminCustomizeThemes.show"
|
||||
).model;
|
||||
if (currentTheme?.warnUnassignedComponent) {
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.customize.theme.unsaved_parent_themes"),
|
||||
didConfirm: () => {
|
||||
currentTheme.set("recentlyInstalled", false);
|
||||
showModal("admin-install-theme", { admin: true });
|
||||
},
|
||||
});
|
||||
} else {
|
||||
showModal("admin-install-theme", { admin: true });
|
||||
}
|
||||
},
|
||||
|
||||
addTheme(theme) {
|
||||
this.refresh();
|
||||
theme.setProperties({ recentlyInstalled: true });
|
||||
this.transitionTo("adminCustomizeThemes.show", theme.get("id"), {
|
||||
queryParams: {
|
||||
repoName: null,
|
||||
repoUrl: null,
|
||||
@action
|
||||
installModal() {
|
||||
const currentTheme = this.controllerFor("adminCustomizeThemes.show").model;
|
||||
if (currentTheme?.warnUnassignedComponent) {
|
||||
this.dialog.yesNoConfirm({
|
||||
message: I18n.t("admin.customize.theme.unsaved_parent_themes"),
|
||||
didConfirm: () => {
|
||||
currentTheme.set("recentlyInstalled", false);
|
||||
showModal("admin-install-theme", { admin: true });
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
showModal("admin-install-theme", { admin: true });
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
addTheme(theme) {
|
||||
this.refresh();
|
||||
theme.setProperties({ recentlyInstalled: true });
|
||||
this.transitionTo("adminCustomizeThemes.show", theme.get("id"), {
|
||||
queryParams: {
|
||||
repoName: null,
|
||||
repoUrl: null,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminDashboardGeneralRoute extends DiscourseRoute {
|
||||
activate() {
|
||||
this.controllerFor("admin-dashboard-general").fetchDashboard();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminDashboardReportsRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return ajax("/admin/reports");
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({ model: model.reports, filter: null });
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { scrollTop } from "discourse/mixins/scroll-top";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminDashboardRoute extends DiscourseRoute {
|
||||
activate() {
|
||||
this.controllerFor("admin-dashboard").fetchProblems();
|
||||
this.controllerFor("admin-dashboard").fetchDashboard();
|
||||
scrollTop();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { action } from "@ember/object";
|
||||
import AdminEmailLogs from "admin/routes/admin-email-logs";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
|
||||
export default AdminEmailLogs.extend({
|
||||
status: "bounced",
|
||||
export default class AdminEmailBouncedRoute extends AdminEmailLogs {
|
||||
status = "bounced";
|
||||
|
||||
actions: {
|
||||
showIncomingEmail(id) {
|
||||
showModal("admin-incoming-email", { admin: true });
|
||||
this.controllerFor("modals/admin-incoming-email").loadFromBounced(id);
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
showIncomingEmail(id) {
|
||||
showModal("admin-incoming-email", { admin: true });
|
||||
this.controllerFor("modals/admin-incoming-email").loadFromBounced(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import IncomingEmail from "admin/models/incoming-email";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminEmailIncomingsRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return IncomingEmail.findAll({ status: this.status });
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("model", model);
|
||||
controller.set("filter.status", this.status);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import EmailSettings from "admin/models/email-settings";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminEmailIndexRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return EmailSettings.find();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminEmailLogsRoute extends DiscourseRoute {
|
||||
setupController(controller) {
|
||||
controller.setProperties({
|
||||
loading: true,
|
||||
filter: { status: this.status },
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import EmailPreview, { oneWeekAgo } from "admin/models/email-preview";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminEmailPreviewDigestRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return EmailPreview.findDigest(this.currentUser.get("username"));
|
||||
},
|
||||
}
|
||||
|
||||
afterModel(model) {
|
||||
const controller = this.controllerFor("adminEmailPreviewDigest");
|
||||
|
@ -14,5 +14,5 @@ export default DiscourseRoute.extend({
|
|||
lastSeen: oneWeekAgo(),
|
||||
showHtml: true,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
import AdminEmailIncomings from "admin/routes/admin-email-incomings";
|
||||
export default AdminEmailIncomings.extend({ status: "received" });
|
||||
|
||||
export default class AdminEmailReceivedRoute extends AdminEmailIncomings {
|
||||
status = "received";
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { action } from "@ember/object";
|
||||
import AdminEmailIncomings from "admin/routes/admin-email-incomings";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
|
||||
export default AdminEmailIncomings.extend({
|
||||
status: "rejected",
|
||||
export default class AdminEmailRejectedRoute extends AdminEmailIncomings {
|
||||
status = "rejected";
|
||||
|
||||
actions: {
|
||||
showIncomingEmail(id) {
|
||||
showModal("admin-incoming-email", { admin: true });
|
||||
this.controllerFor("modals/admin-incoming-email").load(id);
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
showIncomingEmail(id) {
|
||||
showModal("admin-incoming-email", { admin: true });
|
||||
this.controllerFor("modals/admin-incoming-email").load(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
import AdminEmailLogs from "admin/routes/admin-email-logs";
|
||||
export default AdminEmailLogs.extend({ status: "sent" });
|
||||
|
||||
export default class AdminEmailSentRoute extends AdminEmailLogs {
|
||||
status = "sent";
|
||||
}
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
import AdminEmailLogs from "admin/routes/admin-email-logs";
|
||||
export default AdminEmailLogs.extend({ status: "skipped" });
|
||||
|
||||
export default class AdminEmailSkippedRoute extends AdminEmailLogs {
|
||||
status = "skipped";
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import Route from "@ember/routing/route";
|
||||
export default Route.extend({
|
||||
|
||||
export default class AdminEmbeddingRoute extends Route {
|
||||
model() {
|
||||
return this.store.find("embedding");
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("embedding", model);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@ import DiscourseRoute from "discourse/routes/discourse";
|
|||
import EmberObject from "@ember/object";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminEmojisRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return ajax("/admin/customize/emojis.json").then(function (emojis) {
|
||||
return emojis.map(function (emoji) {
|
||||
return EmberObject.create(emoji);
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminFlagsPostsActiveRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return this.store.findAll("flagged-post", { filter: "active" });
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminFlagsPostsOldRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return this.store.findAll("flagged-post", { filter: "old" });
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminFlagsTopicsIndexRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return this.store.findAll("flagged-topic");
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("flaggedTopics", model);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminLogsIndexRoute extends DiscourseRoute {
|
||||
redirect() {
|
||||
this.transitionTo("adminLogs.staffActionLogs");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminLogsScreenedEmailsRoute extends DiscourseRoute {
|
||||
setupController() {
|
||||
return this.controllerFor("adminLogsScreenedEmails").show();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminLogsScreenedIpAddressesRoute extends DiscourseRoute {
|
||||
setupController() {
|
||||
return this.controllerFor("adminLogsScreenedIpAddresses").show();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminLogsScreenedUrlsRoute extends DiscourseRoute {
|
||||
setupController() {
|
||||
return this.controllerFor("adminLogsScreenedUrls").show();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import EmberObject from "@ember/object";
|
||||
import EmberObject, { action } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
export default class AdminLogsStaffActionLogsRoute extends DiscourseRoute {
|
||||
queryParams = {
|
||||
filters: { refreshModel: true },
|
||||
},
|
||||
};
|
||||
|
||||
beforeModel(transition) {
|
||||
const params = transition.to.queryParams;
|
||||
|
@ -12,15 +12,15 @@ export default DiscourseRoute.extend({
|
|||
if (controller.filters === null || params.force_refresh) {
|
||||
controller.resetFilters();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
deserializeQueryParam(value, urlKey, defaultValueType) {
|
||||
if (urlKey === "filters") {
|
||||
return EmberObject.create(JSON.parse(decodeURIComponent(value)));
|
||||
}
|
||||
|
||||
return this._super(value, urlKey, defaultValueType);
|
||||
},
|
||||
return super.deserializeQueryParam(value, urlKey, defaultValueType);
|
||||
}
|
||||
|
||||
serializeQueryParam(value, urlKey, defaultValueType) {
|
||||
if (urlKey === "filters") {
|
||||
|
@ -31,18 +31,17 @@ export default DiscourseRoute.extend({
|
|||
}
|
||||
}
|
||||
|
||||
return this._super(value, urlKey, defaultValueType);
|
||||
},
|
||||
return super.serializeQueryParam(value, urlKey, defaultValueType);
|
||||
}
|
||||
|
||||
actions: {
|
||||
onFiltersChange(filters) {
|
||||
if (filters && Object.keys(filters) === 0) {
|
||||
this.transitionTo("adminLogs.staffActionLogs");
|
||||
} else {
|
||||
this.transitionTo("adminLogs.staffActionLogs", {
|
||||
queryParams: { filters },
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
onFiltersChange(filters) {
|
||||
if (filters && Object.keys(filters) === 0) {
|
||||
this.transitionTo("adminLogs.staffActionLogs");
|
||||
} else {
|
||||
this.transitionTo("adminLogs.staffActionLogs", {
|
||||
queryParams: { filters },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import Permalink from "admin/models/permalink";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminPermalinksRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return Permalink.findAll();
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("model", model);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,23 @@
|
|||
import { action } from "@ember/object";
|
||||
import Route from "@ember/routing/route";
|
||||
export default Route.extend({
|
||||
|
||||
export default class AdminPluginsRoute extends Route {
|
||||
model() {
|
||||
return this.store.findAll("plugin");
|
||||
},
|
||||
}
|
||||
|
||||
actions: {
|
||||
showSettings(plugin) {
|
||||
const controller = this.controllerFor("adminSiteSettings");
|
||||
this.transitionTo("adminSiteSettingsCategory", "plugins").then(() => {
|
||||
if (plugin) {
|
||||
// filterContent() is normally on a debounce from typing.
|
||||
// Because we don't want the default of "All Results", we tell it
|
||||
// to skip the next debounce.
|
||||
controller.set("filter", `plugin:${plugin.id}`);
|
||||
controller.set("_skipBounce", true);
|
||||
controller.filterContentNow("plugins");
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
showSettings(plugin) {
|
||||
const controller = this.controllerFor("adminSiteSettings");
|
||||
this.transitionTo("adminSiteSettingsCategory", "plugins").then(() => {
|
||||
if (plugin) {
|
||||
// filterContent() is normally on a debounce from typing.
|
||||
// Because we don't want the default of "All Results", we tell it
|
||||
// to skip the next debounce.
|
||||
controller.set("filter", `plugin:${plugin.id}`);
|
||||
controller.set("_skipBounce", true);
|
||||
controller.filterContentNow("plugins");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminReportsIndexRoute extends DiscourseRoute {
|
||||
beforeModel() {
|
||||
this.transitionTo("admin.dashboardReports");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import { action } from "@ember/object";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
export default class AdminReportsShowRoute extends DiscourseRoute {
|
||||
queryParams = {
|
||||
start_date: { refreshModel: true },
|
||||
end_date: { refreshModel: true },
|
||||
filters: { refreshModel: true },
|
||||
chart_grouping: { refreshModel: true },
|
||||
mode: { refreshModel: true },
|
||||
},
|
||||
};
|
||||
|
||||
model(params) {
|
||||
params.customFilters = params.filters;
|
||||
|
@ -30,15 +31,15 @@ export default DiscourseRoute.extend({
|
|||
delete params.chart_grouping;
|
||||
|
||||
return params;
|
||||
},
|
||||
}
|
||||
|
||||
deserializeQueryParam(value, urlKey, defaultValueType) {
|
||||
if (urlKey === "filters") {
|
||||
return JSON.parse(decodeURIComponent(value));
|
||||
}
|
||||
|
||||
return this._super(value, urlKey, defaultValueType);
|
||||
},
|
||||
return super.deserializeQueryParam(value, urlKey, defaultValueType);
|
||||
}
|
||||
|
||||
serializeQueryParam(value, urlKey, defaultValueType) {
|
||||
if (urlKey === "filters") {
|
||||
|
@ -49,25 +50,24 @@ export default DiscourseRoute.extend({
|
|||
}
|
||||
}
|
||||
|
||||
return this._super(value, urlKey, defaultValueType);
|
||||
},
|
||||
return super.serializeQueryParam(value, urlKey, defaultValueType);
|
||||
}
|
||||
|
||||
actions: {
|
||||
onParamsChange(params) {
|
||||
const queryParams = {
|
||||
type: params.type,
|
||||
mode: params.mode,
|
||||
start_date: params.startDate
|
||||
? params.startDate.toISOString(true).split("T")[0]
|
||||
: null,
|
||||
chart_grouping: params.chartGrouping,
|
||||
filters: params.filters,
|
||||
end_date: params.endDate
|
||||
? params.endDate.toISOString(true).split("T")[0]
|
||||
: null,
|
||||
};
|
||||
@action
|
||||
onParamsChange(params) {
|
||||
const queryParams = {
|
||||
type: params.type,
|
||||
mode: params.mode,
|
||||
start_date: params.startDate
|
||||
? params.startDate.toISOString(true).split("T")[0]
|
||||
: null,
|
||||
chart_grouping: params.chartGrouping,
|
||||
filters: params.filters,
|
||||
end_date: params.endDate
|
||||
? params.endDate.toISOString(true).split("T")[0]
|
||||
: null,
|
||||
};
|
||||
|
||||
this.transitionTo("adminReports.show", { queryParams });
|
||||
},
|
||||
},
|
||||
});
|
||||
this.transitionTo("adminReports.show", { queryParams });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ import DiscourseRoute from "discourse/routes/discourse";
|
|||
import EmberObject from "@ember/object";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
export default class AdminSearchLogsIndexRoute extends DiscourseRoute {
|
||||
queryParams = {
|
||||
period: { refreshModel: true },
|
||||
searchType: { refreshModel: true },
|
||||
},
|
||||
};
|
||||
|
||||
model(params) {
|
||||
this._params = params;
|
||||
|
@ -15,7 +15,7 @@ export default DiscourseRoute.extend({
|
|||
}).then((search_logs) => {
|
||||
return search_logs.map((sl) => EmberObject.create(sl));
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
const params = this._params;
|
||||
|
@ -24,5 +24,5 @@ export default DiscourseRoute.extend({
|
|||
period: params.period,
|
||||
searchType: params.searchType,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@ import { ajax } from "discourse/lib/ajax";
|
|||
import { fillMissingDates } from "discourse/lib/utilities";
|
||||
import { translateResults } from "discourse/lib/search";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
export default class AdminSearchLogsTermRoute extends DiscourseRoute {
|
||||
queryParams = {
|
||||
term: { refreshModel: true },
|
||||
period: { refreshModel: true },
|
||||
searchType: { refreshModel: true },
|
||||
},
|
||||
};
|
||||
|
||||
model(params) {
|
||||
this._params = params;
|
||||
|
@ -40,7 +40,7 @@ export default DiscourseRoute.extend({
|
|||
model.setProperties(json.term);
|
||||
return model;
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
const params = this._params;
|
||||
|
@ -50,5 +50,5 @@ export default DiscourseRoute.extend({
|
|||
period: params.period,
|
||||
searchType: params.searchType,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import DiscourseRoute from "discourse/routes/discourse";
|
|||
import EmberObject from "@ember/object";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminSiteSettingsCategoryRoute extends DiscourseRoute {
|
||||
model(params) {
|
||||
// The model depends on user input, so let the controller do the work:
|
||||
this.controllerFor("adminSiteSettingsCategory").set(
|
||||
|
@ -20,5 +20,5 @@ export default DiscourseRoute.extend({
|
|||
"filteredContent"
|
||||
),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
**/
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminSiteSettingsIndexRoute extends DiscourseRoute {
|
||||
beforeModel() {
|
||||
this.replaceWith(
|
||||
"adminSiteSettingsCategory",
|
||||
this.controllerFor("adminSiteSettings").get("visibleSiteSettings")[0]
|
||||
.nameKey
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
import { action } from "@ember/object";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import SiteSetting from "admin/models/site-setting";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
export default class AdminSiteSettingsRoute extends DiscourseRoute {
|
||||
queryParams = {
|
||||
filter: { replace: true },
|
||||
},
|
||||
};
|
||||
|
||||
model() {
|
||||
return SiteSetting.findAll();
|
||||
},
|
||||
}
|
||||
|
||||
afterModel(siteSettings) {
|
||||
const controller = this.controllerFor("adminSiteSettings");
|
||||
|
@ -16,13 +17,12 @@ export default DiscourseRoute.extend({
|
|||
if (!controller.get("visibleSiteSettings")) {
|
||||
controller.set("visibleSiteSettings", siteSettings);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
actions: {
|
||||
refreshAll() {
|
||||
SiteSetting.findAll().then((settings) => {
|
||||
this.controllerFor("adminSiteSettings").set("model", settings);
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
refreshAll() {
|
||||
SiteSetting.findAll().then((settings) => {
|
||||
this.controllerFor("adminSiteSettings").set("model", settings);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import Route from "@ember/routing/route";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
|
||||
export default Route.extend({
|
||||
queryParams: {
|
||||
export default class AdminSiteTextEditRoute extends Route {
|
||||
queryParams = {
|
||||
locale: { replace: true },
|
||||
},
|
||||
};
|
||||
|
||||
model(params) {
|
||||
return ajax(
|
||||
|
@ -12,7 +12,7 @@ export default Route.extend({
|
|||
).then((result) => {
|
||||
return this.store.createRecord("site-text", result.site_text);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, siteText) {
|
||||
const locales = JSON.parse(this.siteSettings.available_locales);
|
||||
|
@ -26,5 +26,5 @@ export default Route.extend({
|
|||
saved: false,
|
||||
localeFullName,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,27 @@
|
|||
import Route from "@ember/routing/route";
|
||||
import { getProperties } from "@ember/object";
|
||||
import { action, getProperties } from "@ember/object";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
|
||||
export default Route.extend({
|
||||
queryParams: {
|
||||
export default class AdminSiteTextIndexRoute extends Route {
|
||||
queryParams = {
|
||||
q: { replace: true },
|
||||
overridden: { replace: true },
|
||||
locale: { replace: true },
|
||||
},
|
||||
};
|
||||
|
||||
model(params) {
|
||||
return this.store.find(
|
||||
"site-text",
|
||||
getProperties(params, "q", "overridden", "locale")
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.set("siteTexts", model);
|
||||
},
|
||||
}
|
||||
|
||||
actions: {
|
||||
showReseedModal() {
|
||||
showModal("admin-reseed", { admin: true });
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
showReseedModal() {
|
||||
showModal("admin-reseed", { admin: true });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ import Badge from "discourse/models/badge";
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import UserBadge from "discourse/models/user-badge";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminUserBadgesRoute extends DiscourseRoute {
|
||||
model() {
|
||||
const username = this.modelFor("adminUser").get("username");
|
||||
return UserBadge.findByUsername(username);
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
// Find all badges.
|
||||
|
@ -23,5 +23,5 @@ export default DiscourseRoute.extend({
|
|||
});
|
||||
// Set the model.
|
||||
controller.set("model", model);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import UserField from "admin/models/user-field";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminUserFieldsRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return this.store.findAll("user-field");
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({ model, fieldTypes: UserField.fieldTypes() });
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import Group from "discourse/models/group";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminUserIndexRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return this.modelFor("adminUser");
|
||||
},
|
||||
}
|
||||
|
||||
afterModel(model) {
|
||||
if (this.currentUser.admin) {
|
||||
|
@ -13,7 +13,7 @@ export default DiscourseRoute.extend({
|
|||
return model;
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({
|
||||
|
@ -24,5 +24,5 @@ export default DiscourseRoute.extend({
|
|||
ssoLastPayload: null,
|
||||
model,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminUserTl3RequirementsRoute extends DiscourseRoute {
|
||||
model() {
|
||||
return this.modelFor("adminUser");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,22 +2,22 @@ import AdminUser from "admin/models/admin-user";
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { get } from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminUserRoute extends DiscourseRoute {
|
||||
serialize(model) {
|
||||
return {
|
||||
user_id: model.get("id"),
|
||||
username: model.get("username").toLowerCase(),
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
model(params) {
|
||||
return AdminUser.find(get(params, "user_id"));
|
||||
},
|
||||
}
|
||||
|
||||
afterModel(adminUser) {
|
||||
return adminUser.loadDetails().then(function () {
|
||||
adminUser.setOriginalTrustLevel();
|
||||
return adminUser;
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminUsersIndexRoute extends DiscourseRoute {
|
||||
redirect() {
|
||||
this.transitionTo("adminUsersList");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminUsersListIndexRoute extends DiscourseRoute {
|
||||
beforeModel() {
|
||||
this.transitionTo("adminUsersList.show", "active");
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
export default class AdminUsersListShowRoute extends DiscourseRoute {
|
||||
queryParams = {
|
||||
order: { refreshModel: true },
|
||||
asc: { refreshModel: true },
|
||||
},
|
||||
};
|
||||
|
||||
// TODO: this has been introduced to fix a bug in admin-users-list-show
|
||||
// loading AdminUser model multiple times without refactoring the controller
|
||||
|
@ -27,5 +27,5 @@ export default DiscourseRoute.extend({
|
|||
controller.resetFilters();
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
import { action } from "@ember/object";
|
||||
import AdminUser from "admin/models/admin-user";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { exportEntity } from "discourse/lib/export-csv";
|
||||
import { outputExportResult } from "discourse/lib/export-result";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
actions: {
|
||||
exportUsers() {
|
||||
exportEntity("user_list", {
|
||||
trust_level: this.controllerFor("admin-users-list-show").get("query"),
|
||||
}).then(outputExportResult);
|
||||
},
|
||||
export default class AdminUsersListRoute extends DiscourseRoute {
|
||||
@action
|
||||
exportUsers() {
|
||||
exportEntity("user_list", {
|
||||
trust_level: this.controllerFor("admin-users-list-show").get("query"),
|
||||
}).then(outputExportResult);
|
||||
}
|
||||
|
||||
sendInvites() {
|
||||
this.transitionTo("userInvited", this.currentUser);
|
||||
},
|
||||
@action
|
||||
sendInvites() {
|
||||
this.transitionTo("userInvited", this.currentUser);
|
||||
}
|
||||
|
||||
deleteUser(user) {
|
||||
AdminUser.create(user).destroy({ deletePosts: true });
|
||||
},
|
||||
},
|
||||
});
|
||||
@action
|
||||
deleteUser(user) {
|
||||
AdminUser.create(user).destroy({ deletePosts: true });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import DiscourseRoute from "discourse/routes/discourse";
|
|||
import EmberObject from "@ember/object";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminWatchedWordsActionRoute extends DiscourseRoute {
|
||||
model(params) {
|
||||
const controller = this.controllerFor("adminWatchedWordsAction");
|
||||
controller.set("actionNameKey", params.action_id);
|
||||
|
@ -11,5 +11,5 @@ export default DiscourseRoute.extend({
|
|||
name: I18n.t("admin.watched_words.actions." + params.action_id),
|
||||
words: controller.filteredContent,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminWatchedWordsIndexRoute extends DiscourseRoute {
|
||||
beforeModel() {
|
||||
this.replaceWith(
|
||||
"adminWatchedWords.action",
|
||||
this.modelFor("adminWatchedWords")[0].nameKey
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import WatchedWord from "admin/models/watched-word";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
queryParams: {
|
||||
export default class AdminWatchedWordsRoute extends DiscourseRoute {
|
||||
queryParams = {
|
||||
filter: { replace: true },
|
||||
},
|
||||
};
|
||||
|
||||
model() {
|
||||
return WatchedWord.findAll();
|
||||
},
|
||||
}
|
||||
|
||||
afterModel(model) {
|
||||
const controller = this.controllerFor("adminWatchedWords");
|
||||
controller.set("allWatchedWords", model);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminWebHooksEditRoute extends DiscourseRoute {
|
||||
serialize(model) {
|
||||
return { web_hook_id: model.id || "new" };
|
||||
},
|
||||
}
|
||||
|
||||
model(params) {
|
||||
if (params.web_hook_id === "new") {
|
||||
|
@ -11,10 +11,10 @@ export default DiscourseRoute.extend({
|
|||
}
|
||||
|
||||
return this.store.find("web-hook", params.web_hook_id);
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
this._super(...arguments);
|
||||
super.setupController(...arguments);
|
||||
|
||||
if (model.get("isNew")) {
|
||||
model.set(
|
||||
|
@ -24,5 +24,5 @@ export default DiscourseRoute.extend({
|
|||
}
|
||||
|
||||
controller.set("saved", false);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminWebHooksShowRoute extends DiscourseRoute {
|
||||
model(params) {
|
||||
return this.store.find("web-hook", params.web_hook_id);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import Route from "@ember/routing/route";
|
||||
|
||||
export default Route.extend({
|
||||
export default class AdminWebHooksRoute extends Route {
|
||||
model() {
|
||||
return this.store.findAll("web-hook");
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({
|
||||
|
@ -13,5 +13,5 @@ export default Route.extend({
|
|||
contentTypes: model.extras.content_types,
|
||||
deliveryStatuses: model.extras.delivery_statuses,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
export default class AdminRoute extends DiscourseRoute {
|
||||
titleToken() {
|
||||
return I18n.t("admin_title");
|
||||
},
|
||||
}
|
||||
|
||||
activate() {
|
||||
this.controllerFor("application").setProperties({
|
||||
showTop: false,
|
||||
showFooter: false,
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
deactivate() {
|
||||
this.controllerFor("application").set("showTop", true);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue