[pve-devel] [PATCH v2 proxmox-widget-toolkit 45/52] notification ui: add column for 'origin'

Lukas Wagner l.wagner at proxmox.com
Tue Nov 14 13:59:53 CET 2023


This column shows whether a matcher/target was provided as a built-in
default config or if it was created by the user. For built-ins, it
also shows whether the built-in settings have been changed.

To reset a built-in entry to its defaults, one can simply delete it.
For best UX, the 'delete' button should change its text to 'reset
defaults' when a built-in target/matcher is selected. This will be
added in another patch.

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
 src/data/model/NotificationConfig.js |  4 ++--
 src/panel/NotificationConfigView.js  | 32 ++++++++++++++++++++++++++--
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/src/data/model/NotificationConfig.js b/src/data/model/NotificationConfig.js
index 9171515..e8ebf28 100644
--- a/src/data/model/NotificationConfig.js
+++ b/src/data/model/NotificationConfig.js
@@ -1,6 +1,6 @@
 Ext.define('proxmox-notification-endpoints', {
     extend: 'Ext.data.Model',
-    fields: ['name', 'type', 'comment', 'disable'],
+    fields: ['name', 'type', 'comment', 'disable', 'origin'],
     proxy: {
         type: 'proxmox',
     },
@@ -9,7 +9,7 @@ Ext.define('proxmox-notification-endpoints', {
 
 Ext.define('proxmox-notification-matchers', {
     extend: 'Ext.data.Model',
-    fields: ['name', 'comment', 'disable'],
+    fields: ['name', 'comment', 'disable', 'origin'],
     proxy: {
         type: 'proxmox',
     },
diff --git a/src/panel/NotificationConfigView.js b/src/panel/NotificationConfigView.js
index ba69298..4695da5 100644
--- a/src/panel/NotificationConfigView.js
+++ b/src/panel/NotificationConfigView.js
@@ -129,7 +129,7 @@ Ext.define('Proxmox.panel.NotificationEndpointView', {
 	    dataIndex: 'name',
 	    text: gettext('Target Name'),
 	    renderer: Ext.String.htmlEncode,
-	    flex: 1,
+	    flex: 2,
 	},
 	{
 	    dataIndex: 'type',
@@ -141,7 +141,21 @@ Ext.define('Proxmox.panel.NotificationEndpointView', {
 	    dataIndex: 'comment',
 	    text: gettext('Comment'),
 	    renderer: Ext.String.htmlEncode,
-	    flex: 1,
+	    flex: 3,
+	},
+	{
+	    dataIndex: 'origin',
+	    text: gettext('Origin'),
+	    renderer: (origin) => {
+		switch (origin) {
+		    case 'user-created': return gettext('Custom');
+		    case 'modified-builtin': return gettext('Built-In (modified)');
+		    case 'builtin': return gettext('Built-In');
+		}
+
+		// Should not happen...
+		return 'unknown';
+	    },
 	},
     ],
 
@@ -274,6 +288,20 @@ Ext.define('Proxmox.panel.NotificationMatcherView', {
 	    renderer: Ext.String.htmlEncode,
 	    flex: 2,
 	},
+	{
+	    dataIndex: 'origin',
+	    text: gettext('Origin'),
+	    renderer: (origin) => {
+		switch (origin) {
+		    case 'user-created': return gettext('Custom');
+		    case 'modified-builtin': return gettext('Built-In (modified)');
+		    case 'builtin': return gettext('Built-In');
+		}
+
+		// Should not happen...
+		return 'unknown';
+	    },
+	},
     ],
 
     store: {
-- 
2.39.2






More information about the pve-devel mailing list