snappymail/dev/Common/Plugins.js

59 lines
1.7 KiB
JavaScript
Raw Normal View History

2021-01-26 18:46:30 +08:00
import { settingsAddViewModel } from 'Screen/AbstractSettings';
2021-03-10 18:44:48 +08:00
import { SettingsGet } from 'Common/Globals';
2021-04-13 17:42:06 +08:00
import { AbstractViewPopup } from 'Knoin/AbstractViews';
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) => {
2022-02-24 06:11:12 +08:00
rl.app.Remote.request('Plugin' + action, callback, 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) => {
2021-03-10 18:44:48 +08:00
let plugins = SettingsGet('Plugins');
plugins = plugins && null != plugins[pluginSection] ? plugins[pluginSection] : null;
return plugins ? (null == plugins[name] ? null : plugins[name]) : null;
};
2021-04-13 17:42:06 +08:00
rl.pluginPopupView = AbstractViewPopup;