mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 13:39:22 +03:00
Code refactoring (4) (es5 -> es2015)
This commit is contained in:
parent
e8df1cdb57
commit
d7ab67a460
30 changed files with 164 additions and 173 deletions
|
|
@ -1,111 +0,0 @@
|
|||
|
||||
/* global RL_COMMUNITY */
|
||||
|
||||
var
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
AppStore = require('Stores/Admin/App'),
|
||||
PluginStore = require('Stores/Admin/Plugin'),
|
||||
|
||||
Remote = require('Remote/Admin/Ajax');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PluginsAdminSettings()
|
||||
{
|
||||
this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins'));
|
||||
|
||||
this.plugins = PluginStore.plugins;
|
||||
this.pluginsError = PluginStore.plugins.error;
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
|
||||
this.visibility = ko.computed(function() {
|
||||
return PluginStore.plugins.loading() ? 'visible' : 'hidden';
|
||||
}, this);
|
||||
|
||||
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
|
||||
this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this);
|
||||
}
|
||||
|
||||
PluginsAdminSettings.prototype.disablePlugin = function(oPlugin)
|
||||
{
|
||||
oPlugin.disabled(!oPlugin.disabled());
|
||||
Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled());
|
||||
};
|
||||
|
||||
PluginsAdminSettings.prototype.configurePlugin = function(oPlugin)
|
||||
{
|
||||
Remote.plugin(this.onPluginLoadRequest, oPlugin.name);
|
||||
};
|
||||
|
||||
PluginsAdminSettings.prototype.onBuild = function(oDom)
|
||||
{
|
||||
var self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.e-item .configure-plugin-action', function() {
|
||||
var oPlugin = ko.dataFor(this);
|
||||
if (oPlugin)
|
||||
{
|
||||
self.configurePlugin(oPlugin);
|
||||
}
|
||||
})
|
||||
.on('click', '.e-item .disabled-plugin', function() {
|
||||
var oPlugin = ko.dataFor(this);
|
||||
if (oPlugin)
|
||||
{
|
||||
self.disablePlugin(oPlugin);
|
||||
}
|
||||
});
|
||||
|
||||
this.enabledPlugins.subscribe(function(bValue) {
|
||||
Remote.saveAdminConfig(Utils.noop, {
|
||||
'EnabledPlugins': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
PluginsAdminSettings.prototype.onShow = function()
|
||||
{
|
||||
PluginStore.plugins.error('');
|
||||
require('App/Admin').default.reloadPluginList();
|
||||
};
|
||||
|
||||
PluginsAdminSettings.prototype.onPluginLoadRequest = function(sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Plugin'), [oData.Result]);
|
||||
}
|
||||
};
|
||||
|
||||
PluginsAdminSettings.prototype.onPluginDisableRequest = function(sResult, oData)
|
||||
{
|
||||
if (Enums.StorageResultType.Success === sResult && oData)
|
||||
{
|
||||
if (!oData.Result && oData.ErrorCode)
|
||||
{
|
||||
if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage)
|
||||
{
|
||||
PluginStore.plugins.error(oData.ErrorMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginStore.plugins.error(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require('App/Admin').default.reloadPluginList();
|
||||
};
|
||||
|
||||
module.exports = PluginsAdminSettings;
|
||||
Loading…
Add table
Add a link
Reference in a new issue