]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
utils: add extendable, translatable notification event descriptions
authorLukas Wagner <l.wagner@proxmox.com>
Wed, 28 Feb 2024 10:00:59 +0000 (11:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 28 Feb 2024 10:40:48 +0000 (11:40 +0100)
Add a similar mechanism like we have for adding and overriding task
description per product UI.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/Utils.js

index 009e222b3fb9b7921abd56a17489f1c29500f980..ff7c1a75ebfab371a38c9a479cef59e9e21af691 100644 (file)
@@ -647,6 +647,37 @@ utilities: {
            Proxmox.Utils.unknownText;
     },
 
+    // Only add product-agnostic fields here!
+    notificationFieldName: {
+       'type': gettext('Notification type'),
+       'hostname': gettext('Hostname'),
+    },
+
+    formatNotificationFieldName: (value) =>
+       Proxmox.Utils.notificationFieldName[value] || value,
+
+    // to add or change existing for product specific ones
+    overrideNotificationFieldName: function(extra) {
+       for (const [key, value] of Object.entries(extra)) {
+           Proxmox.Utils.notificationFieldName[key] = value;
+       }
+    },
+
+    // Only add product-agnostic fields here!
+    notificationFieldValue: {
+       'system-mail': gettext('Forwarded mails to the local root user'),
+    },
+
+    formatNotificationFieldValue: (value) =>
+       Proxmox.Utils.notificationFieldValue[value] || value,
+
+    // to add or change existing for product specific ones
+    overrideNotificationFieldValue: function(extra) {
+       for (const [key, value] of Object.entries(extra)) {
+           Proxmox.Utils.notificationFieldValue[key] = value;
+       }
+    },
+
     // NOTE: only add general, product agnostic, ones here! Else use override helper in product repos
     task_desc_table: {
        aptupdate: ['', gettext('Update package database')],