custom-wizard-edits.js.es6 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { withPluginApi } from 'discourse/lib/plugin-api';
  2. import DiscourseURL from 'discourse/lib/url';
  3. export default {
  4. name: 'custom-wizard-edits',
  5. initialize() {
  6. withPluginApi('0.8.12', api => {
  7. api.modifyClass('component:global-notice', {
  8. buildBuffer(buffer) {
  9. this._super(...arguments);
  10. const wizards = this.site.get('complete_custom_wizard');
  11. if (wizards) {
  12. wizards.forEach((w) => {
  13. const text = I18n.t('wizard.complete_custom', {
  14. wizard_url: w.url,
  15. wizard_name: w.name,
  16. site_name: this.siteSettings.title
  17. });
  18. buffer.push(`<div class='row'><div class='alert alert-info alert-wizard'>${text}</div></div>`);
  19. });
  20. }
  21. }
  22. });
  23. });
  24. const existing = DiscourseURL.routeTo;
  25. DiscourseURL.routeTo = function(path, opts) {
  26. if (path && path.indexOf('/w/') > -1) {
  27. return window.location = path;
  28. }
  29. return existing.apply(this, [path, opts]);
  30. };
  31. }
  32. };