Merge pull request #793 from ONLYOFFICE/fix/plugin-version
Fix/plugin version
This commit is contained in:
commit
0ec5ce92b8
|
@ -205,6 +205,7 @@ define([
|
|||
plugin.set_Name(item.get('name'));
|
||||
plugin.set_Guid(item.get('guid'));
|
||||
plugin.set_BaseUrl(item.get('baseUrl'));
|
||||
plugin.set_MinVersion(item.get('minVersion'));
|
||||
|
||||
var variations = item.get('variations'),
|
||||
variationsArr = [];
|
||||
|
@ -510,7 +511,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 +566,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,
|
||||
|
@ -572,7 +577,8 @@ define([
|
|||
currentVariation: 0,
|
||||
visible: pluginVisible,
|
||||
groupName: (item.group) ? item.group.name : '',
|
||||
groupRank: (item.group) ? item.group.rank : 0
|
||||
groupRank: (item.group) ? item.group.rank : 0,
|
||||
minVersion: item.minVersion
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
@ -609,6 +615,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([]);
|
||||
|
|
|
@ -238,6 +238,7 @@ define([
|
|||
plugin.set_Name(item['name']);
|
||||
plugin.set_Guid(item['guid']);
|
||||
plugin.set_BaseUrl(item['baseUrl']);
|
||||
plugin.set_MinVersion(item['minVersion']);
|
||||
|
||||
var variations = item['variations'],
|
||||
variationsArr = [];
|
||||
|
|
Loading…
Reference in a new issue