public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit 3/4] add panel/AuthView from PVE
Date: Fri,  9 Jul 2021 13:42:23 +0200	[thread overview]
Message-ID: <20210709114226.269670-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210709114226.269670-1-d.csapak@proxmox.com>

added the following (necessary) changes:
* use Proxmox.Utils.authSchema
* omit the sync button/handler, but add a possibilty to add extra buttons
* check for an 'edit' property in the authSchema for enabling editing
* removed the onlineHelp property
* removed 'TFA' column (can be added by the caller)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/Makefile          |   1 +
 src/panel/AuthView.js | 125 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 126 insertions(+)
 create mode 100644 src/panel/AuthView.js

diff --git a/src/Makefile b/src/Makefile
index 903879e..0f094c6 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -45,6 +45,7 @@ JSSRC=					\
 	button/HelpButton.js		\
 	grid/ObjectGrid.js		\
 	grid/PendingObjectGrid.js	\
+	panel/AuthView.js		\
 	panel/DiskList.js		\
 	panel/InputPanel.js		\
 	panel/InfoWidget.js		\
diff --git a/src/panel/AuthView.js b/src/panel/AuthView.js
new file mode 100644
index 0000000..c9b52e0
--- /dev/null
+++ b/src/panel/AuthView.js
@@ -0,0 +1,125 @@
+Ext.define('Proxmox.panel.AuthView', {
+    extend: 'Ext.grid.GridPanel',
+
+    alias: 'widget.pmxAuthView',
+
+    stateful: true,
+    stateId: 'grid-authrealms',
+
+    viewConfig: {
+	trackOver: false,
+    },
+
+    columns: [
+	{
+	    header: gettext('Realm'),
+	    width: 100,
+	    sortable: true,
+	    dataIndex: 'realm',
+	},
+	{
+	    header: gettext('Type'),
+	    width: 100,
+	    sortable: true,
+	    dataIndex: 'type',
+	},
+	{
+	    header: gettext('Comment'),
+	    sortable: false,
+	    dataIndex: 'comment',
+	    renderer: Ext.String.htmlEncode,
+	    flex: 1,
+	},
+    ],
+
+    store: {
+	model: 'pmx-domains',
+	sorters: {
+	    property: 'realm',
+	    order: 'DESC',
+	},
+    },
+
+    openEditWindow: function(authType, realm) {
+	let me = this;
+	Ext.create('Proxmox.window.AuthEditBase', {
+	    authType,
+	    realm,
+	    listeners: {
+		destroy: () => me.reload(),
+	    },
+	}).show();
+    },
+
+    reload: function() {
+	let me = this;
+	me.getStore().load();
+    },
+
+    run_editor: function() {
+	let me = this;
+	let rec = me.getSelection()[0];
+	if (!rec) {
+	    return;
+	}
+
+	if (!Proxmox.Utils.authSchema[rec.data.type].edit) {
+	    return;
+	}
+
+	me.openEditWindow(rec.data.type, rec.data.realm);
+    },
+
+    initComponent: function() {
+	var me = this;
+
+	let menuitems = [];
+	for (const [authType, config] of Object.entries(Proxmox.Utils.authSchema).sort()) {
+	    if (!config.add) { continue; }
+	    menuitems.push({
+		text: config.name,
+		iconCls: 'fa fa-fw ' + (config.iconCls || 'fa-address-book-o'),
+		handler: () => me.openEditWindow(authType),
+	    });
+	}
+
+	let tbar = [
+	    {
+		text: gettext('Add'),
+		menu: {
+		    items: menuitems,
+		},
+	    },
+	    {
+		xtype: 'proxmoxButton',
+		text: gettext('Edit'),
+		disabled: true,
+		enableFn: (rec) => Proxmox.Utils.authSchema[rec.data.type].edit,
+		handler: () => me.run_editor(),
+	    },
+	    {
+		xtype: 'proxmoxStdRemoveButton',
+		baseurl: '/access/domains/',
+		enableFn: (rec) => Proxmox.Utils.authSchema[rec.data.type].add,
+		callback: () => me.reload(),
+	    },
+	];
+
+	if (me.extraButtons) {
+	    tbar.push('-');
+	    for (const button of me.extraButtons) {
+		tbar.push(button);
+	    }
+	}
+
+	Ext.apply(me, {
+	    tbar,
+	    listeners: {
+		activate: () => me.reload(),
+		itemdblclick: () => me.run_editor(),
+	    },
+	});
+
+	me.callParent();
+    },
+});
-- 
2.30.2





  parent reply	other threads:[~2021-07-09 11:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 11:42 [pve-devel] [PATCH widget-toolkit/manager] refactor realm ui Dominik Csapak
2021-07-09 11:42 ` [pve-devel] [PATCH widget-toolkit 1/4] add window/AuthEditBase from PVE Dominik Csapak
2021-07-09 11:42 ` [pve-devel] [PATCH widget-toolkit 2/4] Utils: add authSchema from PVE and make it overrideable Dominik Csapak
2021-07-09 11:42 ` Dominik Csapak [this message]
2021-07-09 11:42 ` [pve-devel] [PATCH widget-toolkit 4/4] add generic OpenIDInputPanel Dominik Csapak
2021-07-09 11:42 ` [pve-devel] [PATCH manager 1/2] ui: use AuthView and authSchema from widget-toolkit Dominik Csapak
2021-07-09 11:42 ` [pve-devel] [PATCH manager 2/2] ui: remove PVE.dc.AuthEditBase window Dominik Csapak
2021-07-13  4:35 ` [pve-devel] partially-applied-series: [PATCH widget-toolkit/manager] refactor realm ui Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210709114226.269670-4-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal