0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-20 07:41:11 +02:00
discourse-custom-wizard/assets/javascripts/discourse/initializers/custom-wizard-edits.js.es6

39 Zeilen
1,2 KiB
Text

2017-11-22 10:34:21 +01:00
import { withPluginApi } from 'discourse/lib/plugin-api';
import DiscourseURL from 'discourse/lib/url';
2017-11-22 10:34:21 +01:00
export default {
name: 'custom-wizard-edits',
initialize(container) {
const siteSettings = container.lookup('site-settings:main');
if (!siteSettings.custom_wizard_enabled) return;
2017-11-22 10:34:21 +01:00
withPluginApi('0.8.12', api => {
api.modifyClass('component:global-notice', {
buildBuffer(buffer) {
this._super(...arguments);
const wizards = this.site.get('complete_custom_wizard');
if (wizards) {
wizards.forEach((w) => {
const text = I18n.t('wizard.complete_custom', {
wizard_url: w.url,
wizard_name: w.name,
site_name: this.siteSettings.title
});
buffer.push(`<div class='row'><div class='alert alert-info alert-wizard'>${text}</div></div>`);
});
}
}
});
});
const existing = DiscourseURL.routeTo;
DiscourseURL.routeTo = function(path, opts) {
2018-08-29 02:01:52 +02:00
if (path && path.indexOf('/w/') > -1) {
return window.location = path;
}
return existing.apply(this, [path, opts]);
};
2017-11-22 10:34:21 +01:00
}
};