Migrate a bunch of admin routes to ES6 modules

This commit is contained in:
Robin Ward 2015-08-06 12:14:59 -04:00
parent 0f62a7f781
commit 92b2d8c247
15 changed files with 44 additions and 72 deletions

View file

@ -1,8 +1,8 @@
export default Ember.ArrayController.extend({
needs: ["adminBackups"],
status: Em.computed.alias("controllers.adminBackups"),
isOperationRunning: Em.computed.alias("status.model.isOperationRunning"),
restoreDisabled: Em.computed.alias("status.model.restoreDisabled"),
isOperationRunning: Ember.computed.alias("status.model.isOperationRunning"),
restoreDisabled: Ember.computed.alias("status.model.restoreDisabled"),
uploadLabel: function() { return I18n.t("admin.backups.upload.label"); }.property(),

View file

@ -1,5 +1,5 @@
export default Ember.ObjectController.extend({
noOperationIsRunning: Em.computed.not("model.isOperationRunning"),
rollbackEnabled: Em.computed.and("model.canRollback", "model.restoreEnabled", "noOperationIsRunning"),
rollbackDisabled: Em.computed.not("rollbackEnabled")
noOperationIsRunning: Ember.computed.not("model.isOperationRunning"),
rollbackEnabled: Ember.computed.and("model.canRollback", "model.restoreEnabled", "noOperationIsRunning"),
rollbackDisabled: Ember.computed.not("rollbackEnabled")
});

View file

@ -1,13 +1,5 @@
import showModal from 'discourse/lib/show-modal';
/**
This controller supports interface for creating custom CSS skins in Discourse.
@class AdminCustomizeCssHtmlController
@extends Ember.Controller
@namespace Discourse
@module Discourse
**/
export default Ember.ArrayController.extend({
undoPreviewUrl: function() {

View file

@ -0,0 +1,5 @@
export default Ember.Route.extend({
model() {
return Discourse.ApiKey.find();
}
});

View file

@ -0,0 +1,5 @@
export default Ember.Route.extend({
model() {
return Discourse.Backup.find();
}
});

View file

@ -1,15 +1,15 @@
Discourse.AdminBackupsLogsRoute = Discourse.Route.extend({
export default Ember.Route.extend({
// since the logs are pushed via the message bus
// we only want to preload them (hence the beforeModel hook)
beforeModel: function() {
var logsController = this.controllerFor("adminBackupsLogs");
beforeModel() {
const logsController = this.controllerFor("adminBackupsLogs");
// preload the logs if any
PreloadStore.getAndRemove("logs").then(function (preloadedLogs) {
if (preloadedLogs && preloadedLogs.length) {
// we need to filter out message like: "[SUCCESS]"
// and convert POJOs to Ember Objects
var logs = _.chain(preloadedLogs)
const logs = _.chain(preloadedLogs)
.reject(function (log) { return log.message.length === 0 || log.message[0] === "["; })
.map(function (log) { return Em.Object.create(log); })
.value();
@ -18,6 +18,6 @@ Discourse.AdminBackupsLogsRoute = Discourse.Route.extend({
});
},
setupController: function() { /* prevent default behavior */ }
setupController() { /* prevent default behavior */ }
});

View file

@ -82,7 +82,7 @@ export default Discourse.Route.extend({
Discourse.User.currentProp("hideReadOnlyAlert", true);
backup.restore().then(function() {
self.controllerFor("adminBackupsLogs").clear();
self.modelFor("adminBackups").set("isOperationRunning", true);
self.modelFor("adminBackups").set("model.isOperationRunning", true);
self.transitionTo("admin.backups.logs");
});
}
@ -99,7 +99,7 @@ export default Discourse.Route.extend({
function(confirmed) {
if (confirmed) {
Discourse.Backup.cancel().then(function() {
self.modelFor("adminBackups").set("isOperationRunning", false);
self.controllerFor("adminBackups").set("model.isOperationRunning", false);
});
}
}

View file

@ -0,0 +1,12 @@
export default Ember.Route.extend({
model() {
return Discourse.ColorScheme.findAll();
},
deactivate() {
this._super();
this.controllerFor('adminCustomizeColors').set('selectedItem', null);
},
});

View file

@ -0,0 +1,5 @@
export default Ember.Route.extend({
model() {
return Discourse.SiteCustomization.findAll();
}
});

View file

@ -0,0 +1,5 @@
export default Ember.Route.extend({
beforeModel() {
this.replaceWith('adminCustomize.colors');
}
});

View file

@ -1,15 +0,0 @@
/**
Handles routes related to api
@class AdminApiRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminApiRoute = Discourse.Route.extend({
model: function() {
return Discourse.ApiKey.find();
}
});

View file

@ -1,7 +0,0 @@
Discourse.AdminBackupsIndexRoute = Discourse.Route.extend({
model: function() {
return Discourse.Backup.find();
}
});

View file

@ -1,20 +0,0 @@
/**
Handles routes related to colors customization
@class AdminCustomizeColorsRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminCustomizeColorsRoute = Discourse.Route.extend({
model: function() {
return Discourse.ColorScheme.findAll();
},
deactivate: function() {
this._super();
this.controllerFor('adminCustomizeColors').set('selectedItem', null);
},
});

View file

@ -1,5 +0,0 @@
Discourse.AdminCustomizeCssHtmlRoute = Discourse.Route.extend({
model: function() {
return Discourse.SiteCustomization.findAll();
}
});

View file

@ -1,5 +0,0 @@
Discourse.AdminCustomizeIndexRoute = Discourse.Route.extend({
beforeModel: function() {
this.replaceWith('adminCustomize.colors');
}
});