snappymail/dev/Common/Plugins.js

55 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-01-26 18:46:30 +08:00
import { settingsAddViewModel } from 'Screen/AbstractSettings';
const USER_VIEW_MODELS_HOOKS = [],
2016-07-02 06:49:59 +08:00
ADMIN_VIEW_MODELS_HOOKS = [];
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {Function} callback
* @param {string} action
* @param {Object=} parameters
* @param {?number=} timeout
*/
rl.pluginRemoteRequest = (callback, action, parameters, timeout) => {
rl.app && rl.app.remote().defaultRequest(callback, 'Plugin' + action, parameters, timeout);
};
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {Function} SettingsViewModelClass
* @param {string} labelName
* @param {string} template
* @param {string} route
*/
rl.addSettingsViewModel = (SettingsViewModelClass, template, labelName, route) => {
2016-06-16 07:36:44 +08:00
USER_VIEW_MODELS_HOOKS.push([SettingsViewModelClass, template, labelName, route]);
};
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {Function} SettingsViewModelClass
* @param {string} labelName
* @param {string} template
* @param {string} route
*/
rl.addSettingsViewModelForAdmin = (SettingsViewModelClass, template, labelName, route) => {
2016-06-16 07:36:44 +08:00
ADMIN_VIEW_MODELS_HOOKS.push([SettingsViewModelClass, template, labelName, route]);
};
2015-11-15 08:23:16 +08:00
2016-06-16 07:36:44 +08:00
/**
* @param {boolean} admin
*/
2019-07-05 03:19:24 +08:00
export function runSettingsViewModelHooks(admin) {
(admin ? ADMIN_VIEW_MODELS_HOOKS : USER_VIEW_MODELS_HOOKS).forEach(view => {
2021-01-26 18:46:30 +08:00
settingsAddViewModel(view[0], view[1], view[2], view[3]);
2016-06-16 07:36:44 +08:00
});
2015-11-15 08:23:16 +08:00
}
2016-06-16 07:36:44 +08:00
/**
* @param {string} pluginSection
* @param {string} name
2016-06-30 08:02:45 +08:00
* @returns {?}
2016-06-16 07:36:44 +08:00
*/
rl.pluginSettingsGet = (pluginSection, name) => {
let plugins = rl.settings.get('Plugins');
plugins = plugins && null != plugins[pluginSection] ? plugins[pluginSection] : null;
return plugins ? (null == plugins[name] ? null : plugins[name]) : null;
};