Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
restore original redirect file
Dieser Commit ist enthalten in:
Ursprung
6a9f93bccb
Commit
7861e37224
2 geänderte Dateien mit 49 neuen und 26 gelöschten Zeilen
|
@ -2,44 +2,25 @@ import DiscourseURL from "discourse/lib/url";
|
||||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
import getUrl from "discourse-common/lib/get-url";
|
import getUrl from "discourse-common/lib/get-url";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
import { dasherize } from "@ember/string";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "custom-wizard-edits",
|
name: "custom-wizard-edits",
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const messageBus = container.lookup("service:message-bus");
|
|
||||||
const siteSettings = container.lookup("service:site-settings");
|
const siteSettings = container.lookup("service:site-settings");
|
||||||
|
|
||||||
if (!siteSettings.custom_wizard_enabled) {
|
if (!siteSettings.custom_wizard_enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
messageBus.subscribe("/redirect_to_wizard", function (wizardId) {
|
const existing = DiscourseURL.routeTo;
|
||||||
const wizardUrl = window.location.origin + "/w/" + wizardId;
|
DiscourseURL.routeTo = function (path, opts) {
|
||||||
window.location.href = wizardUrl;
|
if (path && path.indexOf("/w/") > -1) {
|
||||||
});
|
return (window.location = path);
|
||||||
|
}
|
||||||
|
return existing.apply(this, [path, opts]);
|
||||||
|
};
|
||||||
|
|
||||||
withPluginApi("0.8.36", (api) => {
|
withPluginApi("0.8.36", (api) => {
|
||||||
api.onAppEvent("page:changed", (data) => {
|
|
||||||
const currentUser = container.lookup("service:current-user");
|
|
||||||
const settings = container.lookup("service:site-settings");
|
|
||||||
if (currentUser) {
|
|
||||||
const redirectToWizard = currentUser.redirect_to_wizard;
|
|
||||||
const excludedPaths = settings.wizard_redirect_exclude_paths
|
|
||||||
.split("|")
|
|
||||||
.concat(["loading"]);
|
|
||||||
if (
|
|
||||||
redirectToWizard &&
|
|
||||||
data.currentRouteName !== "customWizardStep" &&
|
|
||||||
!excludedPaths.find((p) => {
|
|
||||||
return data.currentRouteName.indexOf(p) > -1;
|
|
||||||
})
|
|
||||||
) {
|
|
||||||
DiscourseURL.routeTo(`/w/${dasherize(redirectToWizard)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
api.modifyClass("component:d-navigation", {
|
api.modifyClass("component:d-navigation", {
|
||||||
pluginId: "custom-wizard",
|
pluginId: "custom-wizard",
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||||
|
import { dasherize } from "@ember/string";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "custom-wizard-redirect",
|
||||||
|
initialize(container) {
|
||||||
|
const messageBus = container.lookup("service:message-bus");
|
||||||
|
const siteSettings = container.lookup("service:site-settings");
|
||||||
|
|
||||||
|
if (!siteSettings.custom_wizard_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
messageBus.subscribe("/redirect_to_wizard", function (wizardId) {
|
||||||
|
const wizardUrl = window.location.origin + "/w/" + wizardId;
|
||||||
|
window.location.href = wizardUrl;
|
||||||
|
});
|
||||||
|
|
||||||
|
withPluginApi("0.8.36", (api) => {
|
||||||
|
api.onAppEvent("page:changed", (data) => {
|
||||||
|
const currentUser = container.lookup("service:current-user");
|
||||||
|
|
||||||
|
if (currentUser) {
|
||||||
|
const redirectToWizard = currentUser.redirect_to_wizard;
|
||||||
|
const excludedPaths = siteSettings.wizard_redirect_exclude_paths
|
||||||
|
.split("|")
|
||||||
|
.concat(["loading"]);
|
||||||
|
if (
|
||||||
|
redirectToWizard &&
|
||||||
|
data.currentRouteName !== "customWizardStep" &&
|
||||||
|
!excludedPaths.find((p) => {
|
||||||
|
return data.currentRouteName.indexOf(p) > -1;
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
DiscourseURL.routeTo(`/w/${dasherize(redirectToWizard)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
Laden …
In neuem Issue referenzieren