Convert admin section controllers to ES6 modules
This commit is contained in:
parent
2358d13d49
commit
e242368266
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminApiController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
/**
|
/**
|
|
@ -1,4 +1,4 @@
|
||||||
Discourse.AdminBackupsIndexController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
needs: ["adminBackups"],
|
needs: ["adminBackups"],
|
||||||
status: Em.computed.alias("controllers.adminBackups"),
|
status: Em.computed.alias("controllers.adminBackups"),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Discourse.AdminBackupsLogsController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
needs: ["adminBackups"],
|
needs: ["adminBackups"],
|
||||||
status: Em.computed.alias("controllers.adminBackups")
|
status: Em.computed.alias("controllers.adminBackups")
|
||||||
});
|
});
|
|
@ -1,4 +1,4 @@
|
||||||
Discourse.AdminBackupsController = Ember.ObjectController.extend({
|
export default Ember.ObjectController.extend({
|
||||||
noOperationIsRunning: Em.computed.not("isOperationRunning"),
|
noOperationIsRunning: Em.computed.not("isOperationRunning"),
|
||||||
rollbackEnabled: Em.computed.and("canRollback", "restoreEnabled", "noOperationIsRunning"),
|
rollbackEnabled: Em.computed.and("canRollback", "restoreEnabled", "noOperationIsRunning"),
|
||||||
rollbackDisabled: Em.computed.not("rollbackEnabled")
|
rollbackDisabled: Em.computed.not("rollbackEnabled")
|
|
@ -8,7 +8,7 @@
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
|
|
||||||
Discourse.AdminBadgeController = Discourse.ObjectController.extend({
|
export default Discourse.ObjectController.extend({
|
||||||
/**
|
/**
|
||||||
Whether this badge has been selected.
|
Whether this badge has been selected.
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminBadgesController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
itemController: 'adminBadge',
|
itemController: 'admin-badge',
|
||||||
queryParams: ['badgeId'],
|
queryParams: ['badgeId'],
|
||||||
badgeId: Em.computed.alias('selectedId'),
|
badgeId: Em.computed.alias('selectedId'),
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminCustomizeColorsController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
|
|
||||||
onlyOverridden: false,
|
onlyOverridden: false,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminCustomizeCssHtmlController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminDashboardController = Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
loading: true,
|
loading: true,
|
||||||
versionCheck: null,
|
versionCheck: null,
|
||||||
problemsCheckMinutes: 1,
|
problemsCheckMinutes: 1,
|
|
@ -0,0 +1,3 @@
|
||||||
|
import AdminEmailSkippedController from "admin/controllers/admin-email-skipped"
|
||||||
|
|
||||||
|
export default AdminEmailSkippedController.extend({});
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminEmailIndexController = Discourse.Controller.extend({
|
export default Discourse.Controller.extend({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Is the "send test email" button disabled?
|
Is the "send test email" button disabled?
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminEmailPreviewDigestController = Discourse.ObjectController.extend({
|
export default Discourse.ObjectController.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
refresh: function() {
|
refresh: function() {
|
|
@ -0,0 +1,17 @@
|
||||||
|
/**
|
||||||
|
This controller supports email logs functionality.
|
||||||
|
|
||||||
|
@class AdminEmailSentController
|
||||||
|
@extends Discourse.Controller
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
export default Discourse.Controller.extend({
|
||||||
|
|
||||||
|
filterEmailLogs: Discourse.debounce(function() {
|
||||||
|
var self = this;
|
||||||
|
Discourse.EmailLog.findAll(this.get("filter")).then(function(logs) {
|
||||||
|
self.set("model", logs);
|
||||||
|
});
|
||||||
|
}, 250).observes("filter.user", "filter.address", "filter.type", "filter.reply_key")
|
||||||
|
});
|
|
@ -0,0 +1,17 @@
|
||||||
|
/**
|
||||||
|
This controller supports email logs functionality.
|
||||||
|
|
||||||
|
@class AdminEmailSkippedController
|
||||||
|
@extends Discourse.Controller
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
export default Discourse.Controller.extend({
|
||||||
|
|
||||||
|
filterEmailLogs: Discourse.debounce(function() {
|
||||||
|
var self = this;
|
||||||
|
Discourse.EmailLog.findAll(this.get("filter")).then(function(logs) {
|
||||||
|
self.set("model", logs);
|
||||||
|
});
|
||||||
|
}, 250).observes("filter.user", "filter.address", "filter.type", "filter.skipped_reason")
|
||||||
|
});
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminFlagsController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
/**
|
/**
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminGithubCommitsController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
goToGithub: function() {
|
goToGithub: function() {
|
||||||
window.open('https://github.com/discourse/discourse');
|
window.open('https://github.com/discourse/discourse');
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
Discourse.AdminGroupController = Em.ObjectController.extend({
|
export default Em.ObjectController.extend({
|
||||||
needs: ['adminGroups'],
|
needs: ['adminGroups'],
|
||||||
members: null,
|
members: null,
|
||||||
disableSave: false,
|
disableSave: false,
|
|
@ -1,4 +1,4 @@
|
||||||
Discourse.AdminGroupsController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
sortProperties: ['name'],
|
sortProperties: ['name'],
|
||||||
|
|
||||||
refreshingAutoGroups: false,
|
refreshingAutoGroups: false,
|
|
@ -1,33 +1,4 @@
|
||||||
/**
|
export default Ember.ObjectController.extend({
|
||||||
This controller supports the interface for listing screened IP addresses in the admin section.
|
|
||||||
|
|
||||||
@class AdminLogsScreenedIpAddressesController
|
|
||||||
@extends Ember.ArrayController
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.AdminLogsScreenedIpAddressesController = Ember.ArrayController.extend(Discourse.Presence, {
|
|
||||||
loading: false,
|
|
||||||
content: [],
|
|
||||||
itemController: 'adminLogsScreenedIpAddress',
|
|
||||||
|
|
||||||
show: function() {
|
|
||||||
var self = this;
|
|
||||||
this.set('loading', true);
|
|
||||||
Discourse.ScreenedIpAddress.findAll().then(function(result) {
|
|
||||||
self.set('content', result);
|
|
||||||
self.set('loading', false);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
actions: {
|
|
||||||
recordAdded: function(arg) {
|
|
||||||
this.get("content").unshiftObject(arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Discourse.AdminLogsScreenedIpAddressController = Ember.ObjectController.extend({
|
|
||||||
editing: false,
|
editing: false,
|
||||||
savedIpAddress: null,
|
savedIpAddress: null,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminLogsScreenedEmailsController = Ember.ArrayController.extend(Discourse.Presence, {
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
||||||
loading: false,
|
loading: false,
|
||||||
content: [],
|
content: [],
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
This controller supports the interface for listing screened IP addresses in the admin section.
|
||||||
|
|
||||||
|
@class AdminLogsScreenedIpAddressesController
|
||||||
|
@extends Ember.ArrayController
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
||||||
|
loading: false,
|
||||||
|
content: [],
|
||||||
|
itemController: 'adminLogsScreenedIpAddress',
|
||||||
|
|
||||||
|
show: function() {
|
||||||
|
var self = this;
|
||||||
|
this.set('loading', true);
|
||||||
|
Discourse.ScreenedIpAddress.findAll().then(function(result) {
|
||||||
|
self.set('content', result);
|
||||||
|
self.set('loading', false);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
recordAdded: function(arg) {
|
||||||
|
this.get("content").unshiftObject(arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminLogsScreenedUrlsController = Ember.ArrayController.extend(Discourse.Presence, {
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
||||||
loading: false,
|
loading: false,
|
||||||
content: [],
|
content: [],
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminLogsStaffActionLogsController = Ember.ArrayController.extend(Discourse.Presence, {
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
||||||
loading: false,
|
loading: false,
|
||||||
filters: {},
|
filters: {},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Discourse.AdminReportsController = Ember.ObjectController.extend({
|
export default Ember.ObjectController.extend({
|
||||||
viewMode: 'table',
|
viewMode: 'table',
|
||||||
|
|
||||||
viewingTable: Em.computed.equal('viewMode', 'table'),
|
viewingTable: Em.computed.equal('viewMode', 'table'),
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminSiteContentEditController = Discourse.Controller.extend({
|
export default Discourse.Controller.extend({
|
||||||
|
|
||||||
saveDisabled: function() {
|
saveDisabled: function() {
|
||||||
if (this.get('saving')) { return true; }
|
if (this.get('saving')) { return true; }
|
||||||
|
@ -24,5 +24,3 @@ Discourse.AdminSiteContentEditController = Discourse.Controller.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Discourse.AdminSiteContentsController = Ember.ArrayController.extend({});
|
|
|
@ -0,0 +1 @@
|
||||||
|
export default Ember.ArrayController.extend({});
|
|
@ -1,4 +1,4 @@
|
||||||
Discourse.AdminSiteSettingsCategoryController = Ember.ObjectController.extend({
|
export default Ember.ObjectController.extend({
|
||||||
categoryNameKey: null,
|
categoryNameKey: null,
|
||||||
needs: ['adminSiteSettings'],
|
needs: ['adminSiteSettings'],
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminSiteSettingsController = Ember.ArrayController.extend(Discourse.Presence, {
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
||||||
filter: null,
|
filter: null,
|
||||||
onlyOverridden: false,
|
onlyOverridden: false,
|
||||||
filtered: Ember.computed.notEmpty('filter'),
|
filtered: Ember.computed.notEmpty('filter'),
|
|
@ -7,4 +7,4 @@
|
||||||
@uses Discourse.ModalFunctionality
|
@uses Discourse.ModalFunctionality
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminStaffActionLogDetailsController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {});
|
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {});
|
|
@ -7,7 +7,7 @@
|
||||||
@uses Discourse.ModalFunctionality
|
@uses Discourse.ModalFunctionality
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminSuspendUserController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||||
|
|
||||||
submitDisabled: function() {
|
submitDisabled: function() {
|
||||||
return (!this.get('reason') || this.get('reason').length < 1);
|
return (!this.get('reason') || this.get('reason').length < 1);
|
|
@ -7,7 +7,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminUserBadgesController = Ember.ArrayController.extend({
|
export default Ember.ArrayController.extend({
|
||||||
needs: ["adminUser"],
|
needs: ["adminUser"],
|
||||||
user: Em.computed.alias('controllers.adminUser'),
|
user: Em.computed.alias('controllers.adminUser'),
|
||||||
sortProperties: ['granted_at'],
|
sortProperties: ['granted_at'],
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminUserIndexController = Discourse.ObjectController.extend({
|
export default Discourse.ObjectController.extend({
|
||||||
editingTitle: false,
|
editingTitle: false,
|
||||||
originalPrimaryGroupId: null,
|
originalPrimaryGroupId: null,
|
||||||
availableGroups: null,
|
availableGroups: null,
|
||||||
|
@ -88,4 +88,3 @@ Discourse.AdminUserIndexController = Discourse.ObjectController.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
/**
|
||||||
|
The top-level controller for user pages in admin.
|
||||||
|
Ember assertion says that this class needs to be defined even if it's empty.
|
||||||
|
|
||||||
|
@class AdminUserController
|
||||||
|
@extends Discourse.ObjectController
|
||||||
|
@namespace Discourse
|
||||||
|
@module Discourse
|
||||||
|
**/
|
||||||
|
export default Discourse.ObjectController.extend({});
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminUsersListController = Ember.ArrayController.extend(Discourse.Presence, {
|
export default Ember.ArrayController.extend(Discourse.Presence, {
|
||||||
username: null,
|
username: null,
|
||||||
query: null,
|
query: null,
|
||||||
selectAll: false,
|
selectAll: false,
|
|
@ -6,7 +6,7 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminController = Discourse.Controller.extend({
|
export default Discourse.Controller.extend({
|
||||||
showBadges: function() {
|
showBadges: function() {
|
||||||
return this.get('currentUser.admin') && Discourse.SiteSettings.enable_badges;
|
return this.get('currentUser.admin') && Discourse.SiteSettings.enable_badges;
|
||||||
}.property()
|
}.property()
|
|
@ -1,38 +0,0 @@
|
||||||
/**
|
|
||||||
This controller supports email logs functionality.
|
|
||||||
|
|
||||||
@class AdminEmailSentController
|
|
||||||
@extends Discourse.Controller
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.AdminEmailSentController = Discourse.Controller.extend({
|
|
||||||
|
|
||||||
filterEmailLogs: Discourse.debounce(function() {
|
|
||||||
var self = this;
|
|
||||||
Discourse.EmailLog.findAll(this.get("filter")).then(function(logs) {
|
|
||||||
self.set("model", logs);
|
|
||||||
});
|
|
||||||
}, 250).observes("filter.user", "filter.address", "filter.type", "filter.reply_key")
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
This controller supports email logs functionality.
|
|
||||||
|
|
||||||
@class AdminEmailSkippedController
|
|
||||||
@extends Discourse.Controller
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
Discourse.AdminEmailSkippedController = Discourse.Controller.extend({
|
|
||||||
|
|
||||||
filterEmailLogs: Discourse.debounce(function() {
|
|
||||||
var self = this;
|
|
||||||
Discourse.EmailLog.findAll(this.get("filter")).then(function(logs) {
|
|
||||||
self.set("model", logs);
|
|
||||||
});
|
|
||||||
}, 250).observes("filter.user", "filter.address", "filter.type", "filter.skipped_reason")
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Discourse.AdminEmailAllController = Discourse.AdminEmailSkippedController.extend({});
|
|
|
@ -8,7 +8,7 @@
|
||||||
@uses Discourse.ModalFunctionality
|
@uses Discourse.ModalFunctionality
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.ChangeSiteCustomizationDetailsController = Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
export default Discourse.ObjectController.extend(Discourse.ModalFunctionality, {
|
||||||
previousSelected: Ember.computed.equal('selectedTab', 'previous'),
|
previousSelected: Ember.computed.equal('selectedTab', 'previous'),
|
||||||
newSelected: Ember.computed.equal('selectedTab', 'new'),
|
newSelected: Ember.computed.equal('selectedTab', 'new'),
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
@uses Discourse.ModalFunctionality
|
@uses Discourse.ModalFunctionality
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.DeleteSiteCustomizationDetailsController = Discourse.ChangeSiteCustomizationDetailsController.extend({
|
import ChangeSiteCustomizationDetailsController from "admin/controllers/change-site-customization-details-controller";
|
||||||
|
|
||||||
|
export default ChangeSiteCustomizationDetailsController.extend({
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
this.selectPrevious();
|
this.selectPrevious();
|
||||||
}
|
}
|
|
@ -6,7 +6,8 @@
|
||||||
@namespace Discourse
|
@namespace Discourse
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.AdminDashboardRoute = Discourse.Route.extend({
|
|
||||||
|
export default Discourse.Route.extend({
|
||||||
|
|
||||||
setupController: function(c) {
|
setupController: function(c) {
|
||||||
this.fetchDashboardData(c);
|
this.fetchDashboardData(c);
|
|
@ -37,16 +37,20 @@ Discourse.Resolver = Ember.DefaultResolver.extend({
|
||||||
normalize: function(fullName) {
|
normalize: function(fullName) {
|
||||||
var split = fullName.split(':');
|
var split = fullName.split(':');
|
||||||
if (split.length > 1) {
|
if (split.length > 1) {
|
||||||
|
var discourseBase = 'discourse/' + split[0] + 's/';
|
||||||
|
var adminBase = 'admin/' + split[0] + 's/';
|
||||||
|
|
||||||
// Try slashes
|
// Try slashes
|
||||||
var dashed = Ember.String.dasherize(split[1].replace(/\./g, '/')),
|
var dashed = Ember.String.dasherize(split[1].replace(/\./g, '/'));
|
||||||
moduleName = 'discourse/' + split[0] + 's/' + dashed;
|
if (requirejs.entries[discourseBase + dashed] || requirejs.entries[adminBase + dashed]) {
|
||||||
if (requirejs.entries[moduleName]) { return split[0] + ":" + dashed; }
|
return split[0] + ":" + dashed;
|
||||||
|
}
|
||||||
|
|
||||||
// Try with dashes instead of slashes
|
// Try with dashes instead of slashes
|
||||||
dashed = Ember.String.dasherize(split[1].replace(/\./g, '-'));
|
dashed = Ember.String.dasherize(split[1].replace(/\./g, '-'));
|
||||||
moduleName = 'discourse/' + split[0] + 's/' + dashed;
|
if (requirejs.entries[discourseBase + dashed] || requirejs.entries[adminBase + dashed]) {
|
||||||
if (requirejs.entries[moduleName]) { return split[0] + ":" + dashed; }
|
return split[0] + ":" + dashed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this._super(fullName);
|
return this._super(fullName);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
module("Discourse.AdminBadgesController");
|
module("controller:admin-badges");
|
||||||
|
|
||||||
test("canEditDescription", function() {
|
test("canEditDescription", function() {
|
||||||
var badge, controller;
|
var badge, controller;
|
||||||
|
|
||||||
badge = Discourse.Badge.create({id: 101, name: "Test Badge"});
|
badge = Discourse.Badge.create({id: 101, name: "Test Badge"});
|
||||||
controller = testController(Discourse.AdminBadgesController, [badge]);
|
controller = testController("admin-badges", [badge]);
|
||||||
controller.send('selectBadge', badge);
|
controller.send('selectBadge', badge);
|
||||||
ok(controller.get('canEditDescription'), "allows editing description when a translation exists for the badge name");
|
ok(controller.get('canEditDescription'), "allows editing description when a translation exists for the badge name");
|
||||||
|
|
||||||
this.stub(I18n, "t").returns("translated string");
|
this.stub(I18n, "t").returns("translated string");
|
||||||
badge = Discourse.Badge.create({id: 102, name: "Test Badge"});
|
badge = Discourse.Badge.create({id: 102, name: "Test Badge"});
|
||||||
controller = testController(Discourse.AdminBadgesController, [badge]);
|
controller = testController("admin-badges", [badge]);
|
||||||
controller.send('selectBadge', badge);
|
controller.send('selectBadge', badge);
|
||||||
ok(!controller.get('canEditDescription'), "shows the displayName when it is different from the name");
|
ok(!controller.get('canEditDescription'), "shows the displayName when it is different from the name");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("createNewBadge", function() {
|
test("createNewBadge", function() {
|
||||||
var controller = testController(Discourse.AdminBadgesController, []);
|
var controller = testController("admin-badges", []);
|
||||||
controller.send('createNewBadge');
|
controller.send('createNewBadge');
|
||||||
equal(controller.get('model.length'), 1, "adds a new badge to the list of badges");
|
equal(controller.get('model.length'), 1, "adds a new badge to the list of badges");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("selectBadge", function() {
|
test("selectBadge", function() {
|
||||||
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
||||||
controller = testController(Discourse.AdminBadgesController, [badge]);
|
controller = testController("admin-badges", [badge]);
|
||||||
|
|
||||||
controller.send('selectBadge', badge);
|
controller.send('selectBadge', badge);
|
||||||
equal(controller.get('selectedItem'), badge, "the badge is selected");
|
equal(controller.get('selectedItem'), badge, "the badge is selected");
|
||||||
|
@ -32,7 +32,7 @@ test("selectBadge", function() {
|
||||||
test("save", function() {
|
test("save", function() {
|
||||||
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
||||||
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
|
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
|
||||||
controller = testController(Discourse.AdminBadgesController, [badge, otherBadge]);
|
controller = testController("admin-badges", [badge, otherBadge]);
|
||||||
|
|
||||||
controller.send('selectBadge', badge);
|
controller.send('selectBadge', badge);
|
||||||
this.stub(badge, "save").returns(Ember.RSVP.resolve({}));
|
this.stub(badge, "save").returns(Ember.RSVP.resolve({}));
|
||||||
|
@ -43,7 +43,7 @@ test("save", function() {
|
||||||
test("destroy", function() {
|
test("destroy", function() {
|
||||||
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
var badge = Discourse.Badge.create({id: 101, name: "Test Badge"}),
|
||||||
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
|
otherBadge = Discourse.Badge.create({id: 102, name: "Other Badge"}),
|
||||||
controller = testController(Discourse.AdminBadgesController, [badge, otherBadge]);
|
controller = testController("admin-badges", [badge, otherBadge]);
|
||||||
|
|
||||||
this.stub(badge, 'destroy').returns(Ember.RSVP.resolve({}));
|
this.stub(badge, 'destroy').returns(Ember.RSVP.resolve({}));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module("Discourse.AdminEmailIndexController");
|
module("controller:admin-email-index");
|
||||||
|
|
||||||
test("mixes in Discourse.Presence", function() {
|
test("mixes in Discourse.Presence", function() {
|
||||||
ok(Discourse.Presence.detect(Discourse.AdminEmailIndexController.create()));
|
ok(Discourse.Presence.detect(controllerFor("admin-email-index")));
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module("Discourse.AdminEmailPreviewDigestController");
|
module("controller:admin-email-preview-digest");
|
||||||
|
|
||||||
test("mixes in Discourse.Presence", function() {
|
test("mixes in Discourse.Presence", function() {
|
||||||
ok(Discourse.Presence.detect(Discourse.AdminEmailPreviewDigestController.create()));
|
ok(Discourse.Presence.detect(controllerFor("admin-email-preview-digest")));
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module("Discourse.AdminSiteSettingsController", {
|
module("controller:admin-site-settings", {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
sinon.stub(Ember.run, "debounce").callsArg(1);
|
sinon.stub(Ember.run, "debounce").callsArg(1);
|
||||||
},
|
},
|
||||||
|
@ -16,7 +16,7 @@ test("filter", function() {
|
||||||
nameKey: 'posting', name: 'posting',
|
nameKey: 'posting', name: 'posting',
|
||||||
siteSettings: [Discourse.SiteSetting.create({"setting":"display_name_on_posts","description":"x","default":false,"type":"bool","value":"true","category":"posting"})]
|
siteSettings: [Discourse.SiteSetting.create({"setting":"display_name_on_posts","description":"x","default":false,"type":"bool","value":"true","category":"posting"})]
|
||||||
})]);
|
})]);
|
||||||
var adminSiteSettingsController = testController(Discourse.AdminSiteSettingsController, allSettings);
|
var adminSiteSettingsController = testController("admin-site-settings", allSettings);
|
||||||
adminSiteSettingsController.set('allSiteSettings', allSettings);
|
adminSiteSettingsController.set('allSiteSettings', allSettings);
|
||||||
|
|
||||||
equal(adminSiteSettingsController.get('content')[0].nameKey, 'users', "Can get first site setting category's name key.");
|
equal(adminSiteSettingsController.get('content')[0].nameKey, 'users', "Can get first site setting category's name key.");
|
||||||
|
|
|
@ -27,8 +27,18 @@ function integration(name, lifecycle) {
|
||||||
function testController(klass, model) {
|
function testController(klass, model) {
|
||||||
// HAX until we get ES6 everywhere:
|
// HAX until we get ES6 everywhere:
|
||||||
if (typeof klass === "string") {
|
if (typeof klass === "string") {
|
||||||
var moduleName = 'discourse/controllers/' + klass,
|
var base = "discourse",
|
||||||
module = requirejs.entries[moduleName];
|
moduleName,
|
||||||
|
module;
|
||||||
|
|
||||||
|
// maybe a bit too hacky? (all of the "admin-*" controllers are in the "admin" directory)
|
||||||
|
if (klass.indexOf("admin") == 0) {
|
||||||
|
base = "admin";
|
||||||
|
}
|
||||||
|
|
||||||
|
moduleName = base + '/controllers/' + klass;
|
||||||
|
module = requirejs.entries[moduleName];
|
||||||
|
|
||||||
if (module) {
|
if (module) {
|
||||||
klass = require(moduleName, null, null, true).default;
|
klass = require(moduleName, null, null, true).default;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue