[pve-devel] applied: [PATCH v2 widget-toolkit 1/1] refactor info/link extraction from onlinehelp to utils

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Jun 21 15:18:09 CEST 2019


Am 6/21/19 um 12:03 PM schrieb Dominik Csapak:
> 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

applied, small comment - independent of your change - inline.

>  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;

above can now be probably dropped safely.

> +	} 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) {
> 





More information about the pve-devel mailing list