ES6: Patch up a few issues with the admin controllers conversion

This commit is contained in:
Robin Ward 2014-07-25 13:02:46 -04:00
parent e242368266
commit 15a51c6316
15 changed files with 37 additions and 51 deletions

View File

@ -0,0 +1,7 @@
export default Ember.ArrayController.extend({
actions: {
goToGithub: function() {
window.open('https://github.com/discourse/discourse');
}
}
});

View File

@ -1,3 +1,3 @@
import AdminEmailSkippedController from "admin/controllers/admin-email-skipped"
import AdminEmailSkippedController from "admin/controllers/admin-email-skipped";
export default AdminEmailSkippedController.extend({});
export default AdminEmailSkippedController.extend();

View File

@ -1,13 +0,0 @@
/**
This controller is for the widget that shows the commits to the discourse repo.
@class AdminGithubCommitsController
@extends Ember.ArrayController
@namespace Discourse
@module Discourse
**/
export default Ember.ArrayController.extend({
goToGithub: function() {
window.open('https://github.com/discourse/discourse');
}
});

View File

@ -21,6 +21,4 @@ export default Ember.ArrayController.extend({
});
}
}
});

View File

@ -9,7 +9,7 @@
export default Ember.ArrayController.extend(Discourse.Presence, {
loading: false,
content: [],
itemController: 'adminLogsScreenedIpAddress',
itemController: 'admin-log-screened-ip-address',
show: function() {
var self = this;

View File

@ -1,6 +1,5 @@
export default Ember.ObjectController.extend({
viewMode: 'table',
viewingTable: Em.computed.equal('viewMode', 'table'),
viewingBarChart: Em.computed.equal('viewMode', 'barChart'),

View File

@ -1 +1 @@
export default Ember.ArrayController.extend({});
export default Ember.ArrayController.extend();

View File

@ -7,4 +7,4 @@
@uses Discourse.ModalFunctionality
@module Discourse
**/
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {});
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality);

View File

@ -7,4 +7,4 @@
@namespace Discourse
@module Discourse
**/
export default Discourse.ObjectController.extend({});
export default Discourse.ObjectController.extend();

View File

@ -1,13 +1,3 @@
/**
The modal for viewing the details of a staff action log record
for when a site customization is created or changed.
@class ChangeSiteCustomizationDetailsController
@extends Discourse.Controller
@namespace Discourse
@uses Discourse.ModalFunctionality
@module Discourse
**/
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
previousSelected: Ember.computed.equal('selectedTab', 'previous'),
newSelected: Ember.computed.equal('selectedTab', 'new'),

View File

@ -8,7 +8,7 @@
@uses Discourse.ModalFunctionality
@module Discourse
**/
import ChangeSiteCustomizationDetailsController from "admin/controllers/change-site-customization-details-controller";
import ChangeSiteCustomizationDetailsController from "admin/controllers/change-site-customization-details";
export default ChangeSiteCustomizationDetailsController.extend({
onShow: function() {

View File

@ -9,7 +9,7 @@
**/
Discourse.AdminUserBadgesRoute = Discourse.Route.extend({
model: function() {
var username = this.controllerFor('adminUser').get('username');
var username = this.modelFor('adminUser').get('username');
return Discourse.UserBadge.findByUsername(username);
},

View File

@ -12,22 +12,22 @@ var classify = Ember.String.classify;
var get = Ember.get;
function parseName(fullName) {
/*jshint validthis:true */
/*jshint validthis:true */
var nameParts = fullName.split(":"),
type = nameParts[0], fullNameWithoutType = nameParts[1],
name = fullNameWithoutType,
namespace = get(this, 'namespace'),
root = namespace;
var nameParts = fullName.split(":"),
type = nameParts[0], fullNameWithoutType = nameParts[1],
name = fullNameWithoutType,
namespace = get(this, 'namespace'),
root = namespace;
return {
fullName: fullName,
type: type,
fullNameWithoutType: fullNameWithoutType,
name: name,
root: root,
resolveMethodName: "resolve" + classify(type)
};
return {
fullName: fullName,
type: type,
fullNameWithoutType: fullNameWithoutType,
name: name,
root: root,
resolveMethodName: "resolve" + classify(type)
};
}
Discourse.Resolver = Ember.DefaultResolver.extend({
@ -40,6 +40,9 @@ Discourse.Resolver = Ember.DefaultResolver.extend({
var discourseBase = 'discourse/' + split[0] + 's/';
var adminBase = 'admin/' + split[0] + 's/';
// Allow render 'admin/templates/xyz' too
split[1] = split[1].replace('.templates', '').replace('/templates', '');
// Try slashes
var dashed = Ember.String.dasherize(split[1].replace(/\./g, '/'));
if (requirejs.entries[discourseBase + dashed] || requirejs.entries[adminBase + dashed]) {

View File

@ -1,3 +1,5 @@
//= require admin/controllers/admin-email-skipped
//= require admin/controllers/change-site-customization-details
//= require_tree ./admin
//= require resumable.js

View File

@ -70,9 +70,9 @@ module Tilt
# For backwards compatibility with plugins, for now export the Global format too.
# We should eventually have an upgrade system for plugins to use ES6 or some other
# resolve based API.
if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /discourse\/(controllers|components|views|routes)\/(.*)/
type = Regexp.last_match[1]
file_name = Regexp.last_match[2].gsub(/[\-\/]/, '_')
if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /(discourse|admin)\/(controllers|components|views|routes)\/(.*)/
type = Regexp.last_match[2]
file_name = Regexp.last_match[3].gsub(/[\-\/]/, '_')
class_name = file_name.classify
# Rails removes pluralization when calling classify