Check plugins version

This commit is contained in:
Julia Radzhabova 2021-04-06 19:52:13 +03:00
parent 92c2682419
commit 762b3322b8

View file

@ -510,7 +510,8 @@ define([
var me = this;
var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'),
isEdit = me.appOptions.isEdit,
editor = me.editor;
editor = me.editor,
apiVersion = me.api.GetVersion();
if ( pluginsdata instanceof Array ) {
var arr = [], arrUI = [],
lang = me.appOptions.lang.split(/[\-_]/)[0];
@ -564,6 +565,9 @@ define([
if (typeof item.nameLocale == 'object')
name = item.nameLocale[lang] || item.nameLocale['en'] || name || '';
if (pluginVisible)
pluginVisible = me.checkPluginVersion(apiVersion, item.minVersion);
arr.push(new Common.Models.Plugin({
name : name,
guid: item.guid,
@ -609,6 +613,25 @@ define([
}
},
checkPluginVersion: function(apiVersion, pluginVersion) {
if (apiVersion && apiVersion!=='develop' && pluginVersion && typeof pluginVersion == 'string') {
var res = pluginVersion.match(/^([0-9]+)(?:.([0-9]+))?(?:.([0-9]+))?$/),
apires = apiVersion.match(/^([0-9]+)(?:.([0-9]+))?(?:.([0-9]+))?$/);
if (res && res.length>1 && apires && apires.length>1) {
for (var i=0; i<3; i++) {
var pluginVer = res[i+1] ? parseInt(res[i+1]) : 0,
apiVer = apires[i+1] ? parseInt(apires[i+1]) : 0;
if (pluginVer>apiVer)
return false;
if (pluginVer<apiVer)
return true;
}
}
}
return true;
},
getPlugins: function(pluginsData, fetchFunction) {
if (!pluginsData || pluginsData.length<1)
return Promise.resolve([]);