From ba8133a29b07d2df06cb908c3bd2069b6f25bc6f Mon Sep 17 00:00:00 2001 From: ShimaginAndrey Date: Mon, 12 Jul 2021 18:41:43 +0300 Subject: [PATCH] [DE PE SSE] Adding parser-plugins --- apps/common/mobile/lib/controller/Plugins.jsx | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/apps/common/mobile/lib/controller/Plugins.jsx b/apps/common/mobile/lib/controller/Plugins.jsx index 146407841..abdcc0fb6 100644 --- a/apps/common/mobile/lib/controller/Plugins.jsx +++ b/apps/common/mobile/lib/controller/Plugins.jsx @@ -182,7 +182,31 @@ const PluginsController = inject('storeAppOptions')(observer(props => { const onPluginsInit = 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 => { @@ -245,7 +269,7 @@ const PluginsController = inject('storeAppOptions')(observer(props => { arr = arr.concat(plugins.plugins); } - registerPlugins(arr); + parsePlugins(arr); } };