]> git.proxmox.com Git - pmg-gui.git/commitdiff
utils: add onlineHelpTool
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 18 Mar 2021 09:40:50 +0000 (10:40 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 18 Mar 2021 09:40:50 +0000 (10:40 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
js/Utils.js

index 7c934bc00c08997f31f4a426367d236f0a4d1495..be9ac1d2f5c65a063a5c11a57daf668be3fac7e5 100644 (file)
@@ -8,6 +8,33 @@ Ext.define('PMG.Utils', {
 
     // this singleton contains miscellaneous utilities
 
+    // use in panels with object spread (...) operator, for example:
+    // ...PMG.Utils.onlineHelpTool('sysadmin_certificate_management'),
+    onlineHelpTool: function(blockid) {
+       let info = Proxmox.Utils.get_help_info(blockid);
+       if (info === undefined) {
+           info = Proxmox.Utils.get_help_info('pmg_documentation_index');
+           if (info === undefined) {
+               throw "get_help_info failed"; // should not happen
+           }
+       }
+
+       let docsURI = window.location.origin + info.link;
+       let title = info.title || gettext('Help');
+       if (info.subtitle) {
+           title += ' - ' + info.subtitle;
+       }
+       return {
+           tools: [
+               {
+                   type: 'help',
+                   tooltip: title,
+                   handler: () => window.open(docsURI),
+               },
+           ],
+       };
+    },
+
     senderText: gettext('Sender'),
     receiverText: gettext('Receiver'),
     scoreText: gettext('Score'),