mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 11:12:40 +08:00
Upgrade Ember to 2.13
This commit is contained in:
@ -101,7 +101,7 @@ GEM
|
|||||||
ember-source (>= 1.1.0)
|
ember-source (>= 1.1.0)
|
||||||
jquery-rails (>= 1.0.17)
|
jquery-rails (>= 1.0.17)
|
||||||
railties (>= 3.1)
|
railties (>= 3.1)
|
||||||
ember-source (2.10.2)
|
ember-source (2.13.3)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
excon (0.56.0)
|
excon (0.56.0)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
|
@ -15,7 +15,11 @@ export function getRegister(obj) {
|
|||||||
const register = {
|
const register = {
|
||||||
lookup: (...args) => owner.lookup(...args),
|
lookup: (...args) => owner.lookup(...args),
|
||||||
lookupFactory: (...args) => {
|
lookupFactory: (...args) => {
|
||||||
return owner.lookupFactory ? owner.lookupFactory(...args) : owner._lookupFactory(...args);
|
if (owner.factoryFor) {
|
||||||
|
return owner.factoryFor(...args);
|
||||||
|
} else if (owner._lookupFactory) {
|
||||||
|
return owner._lookupFactory(...args);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deprecateContainer(target) {
|
deprecateContainer(target) {
|
||||||
|
@ -22,7 +22,7 @@ import { attachAdditionalPanel } from 'discourse/widgets/header';
|
|||||||
|
|
||||||
|
|
||||||
// If you add any methods to the API ensure you bump up this number
|
// If you add any methods to the API ensure you bump up this number
|
||||||
const PLUGIN_API_VERSION = '0.8.6';
|
const PLUGIN_API_VERSION = '0.8.7';
|
||||||
|
|
||||||
class PluginApi {
|
class PluginApi {
|
||||||
constructor(version, container) {
|
constructor(version, container) {
|
||||||
@ -39,6 +39,25 @@ class PluginApi {
|
|||||||
return this.container.lookup('current-user:main');
|
return this.container.lookup('current-user:main');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows you to overwrite or extend methods in a class.
|
||||||
|
*
|
||||||
|
* For example:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* api.modifyClass('controller:composer', {
|
||||||
|
* actions: {
|
||||||
|
* newActionHere() { }
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
**/
|
||||||
|
modifyClass(resolverName, changes) {
|
||||||
|
const klass = this.container.factoryFor(resolverName);
|
||||||
|
klass.class.reopen(changes);
|
||||||
|
return klass;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for decorating the `cooked` content of a post after it is rendered using
|
* Used for decorating the `cooked` content of a post after it is rendered using
|
||||||
* jQuery.
|
* jQuery.
|
||||||
@ -61,7 +80,7 @@ class PluginApi {
|
|||||||
|
|
||||||
if (!opts.onlyStream) {
|
if (!opts.onlyStream) {
|
||||||
decorate(ComposerEditor, 'previewRefreshed', callback);
|
decorate(ComposerEditor, 'previewRefreshed', callback);
|
||||||
decorate(this.container.lookupFactory('component:user-stream'), 'didInsertElement', callback);
|
decorate(this.container.factoryFor('component:user-stream').class, 'didInsertElement', callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +189,7 @@ class PluginApi {
|
|||||||
* ```
|
* ```
|
||||||
**/
|
**/
|
||||||
attachWidgetAction(widget, actionName, fn) {
|
attachWidgetAction(widget, actionName, fn) {
|
||||||
const widgetClass = this.container.lookupFactory(`widget:${widget}`);
|
const widgetClass = this.container.factoryFor(`widget:${widget}`).class;
|
||||||
widgetClass.prototype[actionName] = fn;
|
widgetClass.prototype[actionName] = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ const DiscourseURL = Ember.Object.extend({
|
|||||||
discoveryTopics.resetParams();
|
discoveryTopics.resetParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
router.router.updateURL(path);
|
router._routerMicrolib.updateURL(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
const split = path.split('#');
|
const split = path.split('#');
|
||||||
|
@ -31,7 +31,7 @@ const Scrolling = Ember.Mixin.create({
|
|||||||
opts = opts || { debounce: 100 };
|
opts = opts || { debounce: 100 };
|
||||||
|
|
||||||
// So we can not call the scrolled event while transitioning
|
// So we can not call the scrolled event while transitioning
|
||||||
const router = Discourse.__container__.lookup('router:main').router;
|
const router = Discourse.__container__.lookup('router:main')._routerMicrolib;
|
||||||
|
|
||||||
let onScrollMethod = () => {
|
let onScrollMethod = () => {
|
||||||
if (router.activeTransition) { return; }
|
if (router.activeTransition) { return; }
|
||||||
|
@ -297,7 +297,16 @@ export default Ember.Object.extend({
|
|||||||
|
|
||||||
if (existing) {
|
if (existing) {
|
||||||
delete obj.id;
|
delete obj.id;
|
||||||
const klass = this.register.lookupFactory('model:' + type) || RestModel;
|
let klass = this.register.lookupFactory('model:' + type);
|
||||||
|
|
||||||
|
if (klass && klass.class) {
|
||||||
|
klass = klass.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!klass) {
|
||||||
|
klass = RestModel;
|
||||||
|
}
|
||||||
|
|
||||||
existing.setProperties(klass.munge(obj));
|
existing.setProperties(klass.munge(obj));
|
||||||
obj.id = id;
|
obj.id = id;
|
||||||
return existing;
|
return existing;
|
||||||
|
@ -248,6 +248,9 @@ export default class Widget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WidgetClass = this.register.lookupFactory(`widget:${widgetName}`);
|
WidgetClass = this.register.lookupFactory(`widget:${widgetName}`);
|
||||||
|
if (WidgetClass && WidgetClass.class) {
|
||||||
|
WidgetClass = WidgetClass.class;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WidgetClass) {
|
if (WidgetClass) {
|
||||||
|
@ -11,8 +11,7 @@ function initializeDetails(api) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const ComposerController = api.container.lookupFactory("controller:composer");
|
api.modifyClass('controller:composer', {
|
||||||
ComposerController.reopen({
|
|
||||||
actions: {
|
actions: {
|
||||||
insertDetails() {
|
insertDetails() {
|
||||||
this.get("toolbarEvent").applySurround(
|
this.get("toolbarEvent").applySurround(
|
||||||
@ -31,6 +30,6 @@ export default {
|
|||||||
name: "apply-details",
|
name: "apply-details",
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
withPluginApi('0.5', initializeDetails);
|
withPluginApi('0.8.7', initializeDetails);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,9 +4,8 @@ function initialize(api) {
|
|||||||
const messageBus = api.container.lookup('message-bus:main');
|
const messageBus = api.container.lookup('message-bus:main');
|
||||||
const currentUser = api.getCurrentUser();
|
const currentUser = api.getCurrentUser();
|
||||||
const appEvents = api.container.lookup('app-events:main');
|
const appEvents = api.container.lookup('app-events:main');
|
||||||
const SiteHeaderComponent = api.container.lookupFactory('component:site-header');
|
|
||||||
|
|
||||||
SiteHeaderComponent.reopen({
|
api.modifyClass('component:site-header', {
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super();
|
this._super();
|
||||||
this.dispatch('header:search-context-trigger', 'header');
|
this.dispatch('header:search-context-trigger', 'header');
|
||||||
@ -34,6 +33,6 @@ export default {
|
|||||||
|
|
||||||
initialize(container) {
|
initialize(container) {
|
||||||
const siteSettings = container.lookup('site-settings:main');
|
const siteSettings = container.lookup('site-settings:main');
|
||||||
if (siteSettings.discourse_narrative_bot_enabled) withPluginApi('0.5', initialize);
|
if (siteSettings.discourse_narrative_bot_enabled) withPluginApi('0.8.7', initialize);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,8 +6,7 @@ function initializePollUIBuilder(api) {
|
|||||||
|
|
||||||
if (!siteSettings.poll_enabled && (api.getCurrentUser() && !api.getCurrentUser().staff)) return;
|
if (!siteSettings.poll_enabled && (api.getCurrentUser() && !api.getCurrentUser().staff)) return;
|
||||||
|
|
||||||
const ComposerController = api.container.lookupFactory("controller:composer");
|
api.modifyClass('controller:composer', {
|
||||||
ComposerController.reopen({
|
|
||||||
actions: {
|
actions: {
|
||||||
showPollBuilder() {
|
showPollBuilder() {
|
||||||
showModal("poll-ui-builder").set("toolbarEvent", this.get("toolbarEvent"));
|
showModal("poll-ui-builder").set("toolbarEvent", this.get("toolbarEvent"));
|
||||||
@ -28,6 +27,6 @@ export default {
|
|||||||
name: "add-poll-ui-builder",
|
name: "add-poll-ui-builder",
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
withPluginApi('0.5', initializePollUIBuilder);
|
withPluginApi('0.8.7', initializePollUIBuilder);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -6,8 +6,7 @@ import WidgetGlue from 'discourse/widgets/glue';
|
|||||||
function initializePolls(api) {
|
function initializePolls(api) {
|
||||||
const register = getRegister(api);
|
const register = getRegister(api);
|
||||||
|
|
||||||
const TopicController = api.container.lookupFactory('controller:topic');
|
api.modifyClass('controller:topic', {
|
||||||
TopicController.reopen({
|
|
||||||
subscribe(){
|
subscribe(){
|
||||||
this._super();
|
this._super();
|
||||||
this.messageBus.subscribe("/polls/" + this.get("model.id"), msg => {
|
this.messageBus.subscribe("/polls/" + this.get("model.id"), msg => {
|
||||||
@ -23,8 +22,7 @@ function initializePolls(api) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Post = api.container.lookupFactory('model:post');
|
api.modifyClass('model:post', {
|
||||||
Post.reopen({
|
|
||||||
_polls: null,
|
_polls: null,
|
||||||
pollsObject: null,
|
pollsObject: null,
|
||||||
|
|
||||||
@ -95,6 +93,6 @@ export default {
|
|||||||
name: "extend-for-poll",
|
name: "extend-for-poll",
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
withPluginApi('0.1', initializePolls);
|
withPluginApi('0.8.7', initializePolls);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user