ES6: A few more controllers on a Holiday Monday

This commit is contained in:
Robin Ward 2014-05-26 14:39:50 -04:00
parent 13ff9980ac
commit 919ae73709
10 changed files with 19 additions and 20 deletions

View File

@ -7,7 +7,7 @@
@uses Discourse.ModalFunctionality
@module Discourse
**/
Discourse.UploadSelectorController = Discourse.Controller.extend(Discourse.ModalFunctionality, {
export default Discourse.Controller.extend(Discourse.ModalFunctionality, {
remote: Em.computed.not("local"),
local: false,
showMore: false,
@ -31,11 +31,3 @@ Discourse.UploadSelectorController = Discourse.Controller.extend(Discourse.Modal
}
});
Discourse.UploadSelectorController.reopenClass({
translate: function(key, options) {
var opts = options || {};
if (Discourse.Utilities.allowsAttachments()) { key += "_with_attachments"; }
return I18n.t("upload_selector." + key, opts);
}
});

View File

@ -6,6 +6,6 @@
@namespace Discourse
@module Discourse
**/
Discourse.UserActivityController = Discourse.ObjectController.extend({
export default Discourse.ObjectController.extend({
needs: ['composer']
});

View File

@ -1,4 +1,4 @@
Discourse.UserDropdownController = Ember.ArrayController.extend(Discourse.HasCurrentUser, {
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
showAdminLinks: Em.computed.alias("currentUser.staff"),
actions: {

View File

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
Discourse.UserInvitedController = Ember.ObjectController.extend({
export default Ember.ObjectController.extend({
user: null,
init: function() {

View File

@ -6,7 +6,7 @@
@namespace Discourse
@module Discourse
**/
Discourse.UserTopicsListController = Discourse.ObjectController.extend({
export default Discourse.ObjectController.extend({
hideCategory: false,
showParticipants: false,

View File

@ -39,7 +39,7 @@ Discourse.ApplicationRoute = Em.Route.extend({
showUploadSelector: function(composerView) {
Discourse.Route.showModal(this, 'uploadSelector');
this.controllerFor('uploadSelector').setProperties({ composerView: composerView });
this.controllerFor('upload-selector').setProperties({ composerView: composerView });
},
showKeyboardShortcutsHelp: function() {

View File

@ -23,7 +23,7 @@ Discourse.TopicRoute = Discourse.Route.extend({
composePrivateMessage: function(user) {
var self = this;
this.transitionTo('userActivity', user).then(function () {
self.controllerFor('userActivity').send('composePrivateMessage');
self.controllerFor('user-activity').send('composePrivateMessage');
});
},

View File

@ -14,7 +14,7 @@ Discourse.UserActivityRoute = Discourse.Route.extend({
setupController: function(controller, user) {
this.controllerFor('userActivity').set('model', user);
this.controllerFor('user-activity').set('model', user);
this.controllerFor('user').set('pmView', null);
// Bring up a draft

View File

@ -6,17 +6,24 @@
@namespace Discourse
@module Discourse
**/
function uploadTranslate(key, options) {
var opts = options || {};
if (Discourse.Utilities.allowsAttachments()) { key += "_with_attachments"; }
return I18n.t("upload_selector." + key, opts);
}
Discourse.UploadSelectorView = Discourse.ModalBodyView.extend({
templateName: 'modal/upload_selector',
classNames: ['upload-selector'],
title: function() { return Discourse.UploadSelectorController.translate("title"); }.property(),
title: function() { return uploadTranslate("title"); }.property(),
uploadIcon: function() { return Discourse.Utilities.allowsAttachments() ? "fa-file-o" : "fa-picture-o"; }.property(),
tip: function() {
var source = this.get("controller.local") ? "local" : "remote";
var opts = { authorized_extensions: Discourse.Utilities.authorizedExtensions() };
return Discourse.UploadSelectorController.translate(source + "_tip", opts);
return uploadTranslate(source + "_tip", opts);
}.property("controller.local"),
hint: function() {

View File

@ -4,7 +4,7 @@ test("logout action logs out the current user", function () {
var logout_mock = sinon.mock(Discourse, "logout");
logout_mock.expects("logout").once();
var controller = Discourse.UserDropdownController.create();
var controller = controllerFor('user-dropdown');
controller.send("logout");
logout_mock.verify();
@ -14,7 +14,7 @@ test("showAdminLinks", function() {
var currentUserStub = Ember.Object.create();
this.stub(Discourse.User, "current").returns(currentUserStub);
var controller = Discourse.UserDropdownController.create();
var controller = controllerFor('user-dropdown');
currentUserStub.set("staff", true);
equal(controller.get("showAdminLinks"), true, "is true when current user is a staff member");