Backwards compatibility with deprecation for `Discourse.PostMenuView`

This commit is contained in:
Robin Ward 2015-07-07 15:18:19 -04:00
parent 724781f426
commit 4706b77940
3 changed files with 13 additions and 5 deletions

View File

@ -45,7 +45,7 @@ Button.prototype.render = function(buffer) {
let hiddenButtons;
const PostMenuView = Ember.Component.extend(StringBuffer, {
const PostMenuComponent = Ember.Component.extend(StringBuffer, {
tagName: 'section',
classNames: ['post-menu-area', 'clearfix'],
@ -164,7 +164,7 @@ const PostMenuView = Ember.Component.extend(StringBuffer, {
visibleButtons.splice(visibleButtons.length - 1, 0, this.buttonForShowMoreActions(post));
}
const callbacks = PostMenuView._registerButtonCallbacks;
const callbacks = PostMenuComponent._registerButtonCallbacks;
if (callbacks) {
_.each(callbacks, function(callback) {
callback.apply(self, [visibleButtons]);
@ -412,11 +412,11 @@ const PostMenuView = Ember.Component.extend(StringBuffer, {
});
PostMenuView.reopenClass({
PostMenuComponent.reopenClass({
registerButton(callback){
this._registerButtonCallbacks = this._registerButtonCallbacks || [];
this._registerButtonCallbacks.push(callback);
}
});
export default PostMenuView;
export default PostMenuComponent;

View File

@ -0,0 +1,5 @@
import PostMenuComponent from 'discourse/components/post-menu';
Ember.warn("PostMenuView has been deprecated, use PostMenuComponent instead");
export default PostMenuComponent.extend();

View File

@ -108,10 +108,13 @@ module Tilt
result = "Controller" if result == "ControllerController"
result = "Route" if result == "DiscourseRoute"
result = "View" if result == "ViewView"
result.gsub!(/Mixin$/, '')
result.gsub!(/Model$/, '')
@output << "\n\nDiscourse.#{result} = require('#{require_name}').default;\n"
if result != "PostMenuView"
@output << "\n\nDiscourse.#{result} = require('#{require_name}').default;\n"
end
end
end