ES6: A few more controllers on a Holiday Monday
This commit is contained in:
parent
13ff9980ac
commit
919ae73709
|
@ -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);
|
||||
}
|
||||
});
|
|
@ -6,6 +6,6 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.UserActivityController = Discourse.ObjectController.extend({
|
||||
export default Discourse.ObjectController.extend({
|
||||
needs: ['composer']
|
||||
});
|
|
@ -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: {
|
|
@ -6,7 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.UserInvitedController = Ember.ObjectController.extend({
|
||||
export default Ember.ObjectController.extend({
|
||||
user: null,
|
||||
|
||||
init: function() {
|
|
@ -6,7 +6,7 @@
|
|||
@namespace Discourse
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.UserTopicsListController = Discourse.ObjectController.extend({
|
||||
export default Discourse.ObjectController.extend({
|
||||
hideCategory: false,
|
||||
showParticipants: false,
|
||||
|
|
@ -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() {
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
Loading…
Reference in New Issue