[pve-devel] [PATCH v2 widget-toolkit 1/1] refactor info/link extraction from onlinehelp to utils
Dominik Csapak
d.csapak at proxmox.com
Fri Jun 21 12:03:49 CEST 2019
so that we can reuse that code for getting links from the docs
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
new in v2
Utils.js | 23 +++++++++++++++++++++++
button/HelpButton.js | 21 ++-------------------
2 files changed, 25 insertions(+), 19 deletions(-)
diff --git a/Utils.js b/Utils.js
index 645c525..ee0a0ce 100644
--- a/Utils.js
+++ b/Utils.js
@@ -593,6 +593,29 @@ Ext.define('Proxmox.Utils', { utilities: {
return Ext.Date.format(servertime, 'Y-m-d H:i:s');
},
+ get_help_info: function(section) {
+ 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[section];
+ },
+
+ get_help_link: function(section) {
+ var info = Proxmox.Utils.get_help_info(section);
+ if (!info) {
+ return;
+ }
+
+ return window.location.origin + info.link;
+ },
+
openXtermJsViewer: function(vmtype, vmid, nodename, vmname, cmd) {
var url = Ext.Object.toQueryString({
console: vmtype, // kvm, lxc, upgrade or shell
diff --git a/button/HelpButton.js b/button/HelpButton.js
index 1bf3f32..e0fc2a8 100644
--- a/button/HelpButton.js
+++ b/button/HelpButton.js
@@ -41,25 +41,11 @@ 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 = me.getOnlineHelpInfo(blockid);
+ var info = Proxmox.Utils.get_help_info(blockid);
if (info) {
me.onlineHelp = blockid;
var title = info.title;
@@ -81,10 +67,7 @@ Ext.define('Proxmox.button.Help', {
var docsURI;
if (me.onlineHelp) {
- var info = me.getOnlineHelpInfo(me.onlineHelp);
- if (info) {
- docsURI = window.location.origin + info.link;
- }
+ docsURI = Proxmox.Utils.get_help_link(me.onlineHelp);
}
if (docsURI) {
--
2.11.0
More information about the pve-devel
mailing list