mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-29 08:09:55 -04:00
Migrate a bunch of admin routes to ES6 modules
This commit is contained in:
parent
0f62a7f781
commit
92b2d8c247
15 changed files with 44 additions and 72 deletions
app/assets/javascripts/admin
controllers
routes
admin-api.js.es6admin-backups-index.js.es6admin-backups-logs.js.es6admin-backups.js.es6admin-customize-colors.js.es6admin-customize-css-html.js.es6admin-customize-index.js.es6admin_api_route.jsadmin_backups_index_route.jsadmin_customize_colors_route.jsadmin_customize_css_html_route.jsadmin_customize_route.js
|
@ -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(),
|
||||
|
||||
|
|
|
@ -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")
|
||||
});
|
||||
|
|
|
@ -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() {
|
||||
|
|
5
app/assets/javascripts/admin/routes/admin-api.js.es6
Normal file
5
app/assets/javascripts/admin/routes/admin-api.js.es6
Normal file
|
@ -0,0 +1,5 @@
|
|||
export default Ember.Route.extend({
|
||||
model() {
|
||||
return Discourse.ApiKey.find();
|
||||
}
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
export default Ember.Route.extend({
|
||||
model() {
|
||||
return Discourse.Backup.find();
|
||||
}
|
||||
});
|
|
@ -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 */ }
|
||||
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
export default Ember.Route.extend({
|
||||
|
||||
model() {
|
||||
return Discourse.ColorScheme.findAll();
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
this._super();
|
||||
this.controllerFor('adminCustomizeColors').set('selectedItem', null);
|
||||
},
|
||||
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
export default Ember.Route.extend({
|
||||
model() {
|
||||
return Discourse.SiteCustomization.findAll();
|
||||
}
|
||||
});
|
|
@ -0,0 +1,5 @@
|
|||
export default Ember.Route.extend({
|
||||
beforeModel() {
|
||||
this.replaceWith('adminCustomize.colors');
|
||||
}
|
||||
});
|
|
@ -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();
|
||||
}
|
||||
|
||||
});
|
|
@ -1,7 +0,0 @@
|
|||
Discourse.AdminBackupsIndexRoute = Discourse.Route.extend({
|
||||
|
||||
model: function() {
|
||||
return Discourse.Backup.find();
|
||||
}
|
||||
|
||||
});
|
|
@ -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);
|
||||
},
|
||||
|
||||
});
|
|
@ -1,5 +0,0 @@
|
|||
Discourse.AdminCustomizeCssHtmlRoute = Discourse.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.SiteCustomization.findAll();
|
||||
}
|
||||
});
|
|
@ -1,5 +0,0 @@
|
|||
Discourse.AdminCustomizeIndexRoute = Discourse.Route.extend({
|
||||
beforeModel: function() {
|
||||
this.replaceWith('adminCustomize.colors');
|
||||
}
|
||||
});
|
Loading…
Add table
Reference in a new issue