mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
This reverts commit b0839ccf27.
This commit is contained in:
@@ -2,7 +2,7 @@ import Controller from "@ember/controller";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { action } from "@ember/object";
|
||||
import { alias } from "@ember/object/computed";
|
||||
import discourseComputed, { bind } from "discourse-common/utils/decorators";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
||||
export default Controller.extend({
|
||||
@@ -23,22 +23,24 @@ export default Controller.extend({
|
||||
subscribe() {
|
||||
this.messageBus.subscribe(
|
||||
`/web_hook_events/${this.get("model.extras.web_hook_id")}`,
|
||||
this._addIncoming
|
||||
(data) => {
|
||||
if (data.event_type === "ping") {
|
||||
this.set("pingDisabled", false);
|
||||
}
|
||||
this._addIncoming(data.web_hook_event_id);
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
unsubscribe() {
|
||||
this.messageBus.unsubscribe("/web_hook_events/*", this._addIncoming);
|
||||
this.messageBus.unsubscribe("/web_hook_events/*");
|
||||
},
|
||||
|
||||
@bind
|
||||
_addIncoming(data) {
|
||||
if (data.event_type === "ping") {
|
||||
this.set("pingDisabled", false);
|
||||
}
|
||||
_addIncoming(eventId) {
|
||||
const incomingEventIds = this.incomingEventIds;
|
||||
|
||||
if (!this.incomingEventIds.includes(data.web_hook_event_id)) {
|
||||
this.incomingEventIds.pushObject(data.web_hook_event_id);
|
||||
if (!incomingEventIds.includes(eventId)) {
|
||||
incomingEventIds.pushObject(eventId);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -2,33 +2,30 @@ import Controller from "@ember/controller";
|
||||
import DiscourseURL from "discourse/lib/url";
|
||||
import I18n from "I18n";
|
||||
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
import messageBus from "message-bus-client";
|
||||
|
||||
export default Controller.extend(ModalFunctionality, {
|
||||
message: I18n.t("admin.user.merging_user"),
|
||||
|
||||
onShow() {
|
||||
this.messageBus.subscribe("/merge_user", this.onMessage);
|
||||
messageBus.subscribe("/merge_user", (data) => {
|
||||
if (data.merged) {
|
||||
if (/^\/admin\/users\/list\//.test(location)) {
|
||||
DiscourseURL.redirectTo(location);
|
||||
} else {
|
||||
DiscourseURL.redirectTo(
|
||||
`/admin/users/${data.user.id}/${data.user.username}`
|
||||
);
|
||||
}
|
||||
} else if (data.message) {
|
||||
this.set("message", data.message);
|
||||
} else if (data.failed) {
|
||||
this.set("message", I18n.t("admin.user.merge_failed"));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onClose() {
|
||||
this.messageBus.unsubscribe("/merge_user", this.onMessage);
|
||||
},
|
||||
|
||||
@bind
|
||||
onMessage(data) {
|
||||
if (data.merged) {
|
||||
if (/^\/admin\/users\/list\//.test(location)) {
|
||||
DiscourseURL.redirectTo(location);
|
||||
} else {
|
||||
DiscourseURL.redirectTo(
|
||||
`/admin/users/${data.user.id}/${data.user.username}`
|
||||
);
|
||||
}
|
||||
} else if (data.message) {
|
||||
this.set("message", data.message);
|
||||
} else if (data.failed) {
|
||||
this.set("message", I18n.t("admin.user.merge_failed"));
|
||||
}
|
||||
this.messageBus.unsubscribe("/merge_user");
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import Backup from "admin/models/backup";
|
||||
import Route from "@ember/routing/route";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
||||
export default Route.extend({
|
||||
activate() {
|
||||
this.messageBus.subscribe("/admin/backups", this.onMessage);
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe("/admin/backups", this.onMessage);
|
||||
this.messageBus.subscribe("/admin/backups", (backups) =>
|
||||
this.controller.set(
|
||||
"model",
|
||||
backups.map((backup) => Backup.create(backup))
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
model() {
|
||||
@@ -17,11 +17,7 @@ export default Route.extend({
|
||||
);
|
||||
},
|
||||
|
||||
@bind
|
||||
onMessage(backups) {
|
||||
this.controller.set(
|
||||
"model",
|
||||
backups.map((backup) => Backup.create(backup))
|
||||
);
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe("/admin/backups");
|
||||
},
|
||||
});
|
||||
|
||||
@@ -10,19 +10,46 @@ 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(),
|
||||
|
||||
activate() {
|
||||
this.messageBus.subscribe(LOG_CHANNEL, this.onMessage);
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe(LOG_CHANNEL, this.onMessage);
|
||||
this.messageBus.subscribe(LOG_CHANNEL, (log) => {
|
||||
if (log.message === "[STARTED]") {
|
||||
User.currentProp("hideReadOnlyAlert", true);
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
true
|
||||
);
|
||||
this.controllerFor("adminBackupsLogs").get("logs").clear();
|
||||
} else if (log.message === "[FAILED]") {
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
false
|
||||
);
|
||||
this.dialog.alert(
|
||||
I18n.t("admin.backups.operations.failed", {
|
||||
operation: log.operation,
|
||||
})
|
||||
);
|
||||
} else if (log.message === "[SUCCESS]") {
|
||||
User.currentProp("hideReadOnlyAlert", false);
|
||||
this.controllerFor("adminBackups").set(
|
||||
"model.isOperationRunning",
|
||||
false
|
||||
);
|
||||
if (log.operation === "restore") {
|
||||
// redirect to homepage when the restore is done (session might be lost)
|
||||
window.location = getURL("/");
|
||||
}
|
||||
} else {
|
||||
this.controllerFor("adminBackupsLogs")
|
||||
.get("logs")
|
||||
.pushObject(EmberObject.create(log));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
model() {
|
||||
@@ -37,31 +64,8 @@ export default DiscourseRoute.extend({
|
||||
);
|
||||
},
|
||||
|
||||
@bind
|
||||
onMessage(log) {
|
||||
if (log.message === "[STARTED]") {
|
||||
User.currentProp("hideReadOnlyAlert", true);
|
||||
this.controllerFor("adminBackups").set("model.isOperationRunning", true);
|
||||
this.controllerFor("adminBackupsLogs").get("logs").clear();
|
||||
} else if (log.message === "[FAILED]") {
|
||||
this.controllerFor("adminBackups").set("model.isOperationRunning", false);
|
||||
this.dialog.alert(
|
||||
I18n.t("admin.backups.operations.failed", {
|
||||
operation: log.operation,
|
||||
})
|
||||
);
|
||||
} else if (log.message === "[SUCCESS]") {
|
||||
User.currentProp("hideReadOnlyAlert", false);
|
||||
this.controllerFor("adminBackups").set("model.isOperationRunning", false);
|
||||
if (log.operation === "restore") {
|
||||
// redirect to homepage when the restore is done (session might be lost)
|
||||
window.location = getURL("/");
|
||||
}
|
||||
} else {
|
||||
this.controllerFor("adminBackupsLogs")
|
||||
.get("logs")
|
||||
.pushObject(EmberObject.create(log));
|
||||
}
|
||||
deactivate() {
|
||||
this.messageBus.unsubscribe(LOG_CHANNEL);
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
Reference in New Issue
Block a user