[pve-devel] [PATCH widget toolkit] HelpButton: be backward compatible with PVE help mapping

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 11 11:18:14 CET 2017


pve-doc-generator used pveOnlineHelp as variable name while the
widget toolkit expects proxmoxOnlineHelp, allow both for now.

As its not quite clear when the switch to the widget toolkit happens
this is more flexible than changing the generator and adding a
versioned build dependency in pve-manager for it.
We normally do not bump pve-docs during releases either.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
CC: Dominik Csapak <d.csapak at proxmox.com>
---
 button/HelpButton.js | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/button/HelpButton.js b/button/HelpButton.js
index dcb6f6e..1bf3f32 100644
--- a/button/HelpButton.js
+++ b/button/HelpButton.js
@@ -41,11 +41,25 @@ Ext.define('Proxmox.button.Help', {
 	}
     },
 
+    getOnlineHelpInfo: function (ref) {
+	var helpMap;
+	if (typeof proxmoxOnlineHelpInfo !== 'undefined') {
+	    helpMap = proxmoxOnlineHelpInfo;
+	} else if (typeof pveOnlineHelpInfo !== 'undefined') {
+	    // be backward compatible with older pve-doc-generators
+	    helpMap = pveOnlineHelpInfo;
+	} else {
+	    throw "no global OnlineHelpInfo map declared";
+	}
+
+	return helpMap[ref];
+    },
+
     // this sets the link and the tooltip text
     setOnlineHelp:function(blockid) {
 	var me = this;
 
-	var info = proxmoxOnlineHelpInfo[blockid];
+	var info = me.getOnlineHelpInfo(blockid);
 	if (info) {
 	    me.onlineHelp = blockid;
 	    var title = info.title;
@@ -67,7 +81,7 @@ Ext.define('Proxmox.button.Help', {
 	var docsURI;
 
 	if (me.onlineHelp) {
-	    var info = proxmoxOnlineHelpInfo[me.onlineHelp];
+	    var info = me.getOnlineHelpInfo(me.onlineHelp);
 	    if (info) {
 		docsURI = window.location.origin + info.link;
 	    }
-- 
2.11.0





More information about the pve-devel mailing list