Merge pull request #983 from ONLYOFFICE/feature/parse-plugins

Feature/parse plugins
This commit is contained in:
Julia Radzhabova 2021-07-14 21:19:28 +03:00 committed by GitHub
commit c86e2c4402
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -182,7 +182,31 @@ const PluginsController = inject('storeAppOptions')(observer(props => {
const onPluginsInit = pluginsdata => { const onPluginsInit = pluginsdata => {
!(pluginsdata instanceof Array) && (pluginsdata = pluginsdata["pluginsData"]); !(pluginsdata instanceof Array) && (pluginsdata = pluginsdata["pluginsData"]);
registerPlugins(pluginsdata) parsePlugins(pluginsdata)
};
const parsePlugins = pluginsdata => {
let isEdit = storeAppOptions.isEdit;
if ( pluginsdata instanceof Array ) {
let lang = storeAppOptions.lang.split(/[\-_]/)[0];
pluginsdata.forEach((item) => {
item.variations.forEach( (itemVar) => {
let description = itemVar.description;
if (typeof itemVar.descriptionLocale == 'object')
description = itemVar.descriptionLocale[lang] || itemVar.descriptionLocale['en'] || description || '';
if(itemVar.buttons !== undefined) {
itemVar.buttons.forEach( (button) => {
if (typeof button.textLocale == 'object')
button.text = button.textLocale[lang] || button.textLocale['en'] || button.text || '';
button.visible = (isEdit || button.isViewer !== false);
})
}
})
});
}
registerPlugins(pluginsdata);
}; };
const registerPlugins = plugins => { const registerPlugins = plugins => {
@ -194,6 +218,7 @@ const PluginsController = inject('storeAppOptions')(observer(props => {
plugin.set_Name(item['name']); plugin.set_Name(item['name']);
plugin.set_Guid(item['guid']); plugin.set_Guid(item['guid']);
plugin.set_BaseUrl(item['baseUrl']); plugin.set_BaseUrl(item['baseUrl']);
plugin.set_MinVersion && plugin.set_MinVersion(item.get('minVersion'));
let variations = item['variations'], let variations = item['variations'],
variationsArr = []; variationsArr = [];
@ -245,7 +270,7 @@ const PluginsController = inject('storeAppOptions')(observer(props => {
arr = arr.concat(plugins.plugins); arr = arr.concat(plugins.plugins);
} }
registerPlugins(arr); parsePlugins(arr);
} }
}; };