public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH widget-toolkit/manager] refactor realm ui
@ 2021-07-09 11:42 Dominik Csapak
  2021-07-09 11:42 ` [pve-devel] [PATCH widget-toolkit 1/4] add window/AuthEditBase from PVE Dominik Csapak
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Dominik Csapak @ 2021-07-09 11:42 UTC (permalink / raw)
  To: pve-devel

refactor the parts of the realm ui that we need for pbs now into
widget-toolkit

manager patches depend on widget toolkit, but can be applied later too
if thats wanted. there is no functional change intended

proxmox-widget-toolkit:

Dominik Csapak (4):
  add window/AuthEditBase from PVE
  Utils: add authSchema from PVE and make it overrideable
  add panel/AuthView from PVE
  add generic OpenIDInputPanel

 src/Makefile                 |   3 +
 src/Utils.js                 |  25 +++++++
 src/panel/AuthView.js        | 125 +++++++++++++++++++++++++++++++++++
 src/window/AuthEditBase.js   |  88 ++++++++++++++++++++++++
 src/window/AuthEditOpenId.js |  96 +++++++++++++++++++++++++++
 5 files changed, 337 insertions(+)
 create mode 100644 src/panel/AuthView.js
 create mode 100644 src/window/AuthEditBase.js
 create mode 100644 src/window/AuthEditOpenId.js

pve-manager:

Dominik Csapak (2):
  ui: use AuthView and authSchema from widget-toolkit
  ui: remove PVE.dc.AuthEditBase window

 www/manager6/Utils.js           |  85 +++++++++++----------
 www/manager6/Workspace.js       |   2 +-
 www/manager6/dc/AuthEditBase.js |  93 +----------------------
 www/manager6/dc/AuthView.js     | 126 ++++++--------------------------
 www/manager6/dc/UserView.js     |   8 +-
 5 files changed, 72 insertions(+), 242 deletions(-)

-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH widget-toolkit 1/4] add window/AuthEditBase from PVE
  2021-07-09 11:42 [pve-devel] [PATCH widget-toolkit/manager] refactor realm ui Dominik Csapak
@ 2021-07-09 11:42 ` 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
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2021-07-09 11:42 UTC (permalink / raw)
  To: pve-devel

basically a straight copy, with the exception that it references
Proxmox.Utils.authSchema instead of PVE.Utils.authSchema

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

diff --git a/src/Makefile b/src/Makefile
index 23f2360..903879e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -71,6 +71,7 @@ JSSRC=					\
 	window/ACMEPluginEdit.js	\
 	window/ACMEDomains.js		\
 	window/FileBrowser.js		\
+	window/AuthEditBase.js		\
 	node/APT.js			\
 	node/APTRepositories.js		\
 	node/NetworkEdit.js		\
diff --git a/src/window/AuthEditBase.js b/src/window/AuthEditBase.js
new file mode 100644
index 0000000..c710242
--- /dev/null
+++ b/src/window/AuthEditBase.js
@@ -0,0 +1,88 @@
+Ext.define('Proxmox.window.AuthEditBase', {
+    extend: 'Proxmox.window.Edit',
+
+    isAdd: true,
+
+    fieldDefaults: {
+	labelWidth: 120,
+    },
+
+    initComponent: function() {
+	var me = this;
+
+	me.isCreate = !me.realm;
+
+	if (me.isCreate) {
+	    me.url = '/api2/extjs/access/domains';
+	    me.method = 'POST';
+	} else {
+	    me.url = '/api2/extjs/access/domains/' + me.realm;
+	    me.method = 'PUT';
+	}
+
+	let authConfig = Proxmox.Utils.authSchema[me.authType];
+	if (!authConfig) {
+	    throw 'unknown auth type';
+	} else if (!authConfig.add && me.isCreate) {
+	    throw 'trying to add non addable realm';
+	}
+
+	me.subject = authConfig.name;
+
+	let items;
+	let bodyPadding;
+	if (authConfig.syncipanel) {
+	    bodyPadding = 0;
+	    items = {
+		xtype: 'tabpanel',
+		region: 'center',
+		layout: 'fit',
+		bodyPadding: 10,
+		items: [
+		    {
+			title: gettext('General'),
+			realm: me.realm,
+			xtype: authConfig.ipanel,
+			isCreate: me.isCreate,
+			type: me.authType,
+		    },
+		    {
+			title: gettext('Sync Options'),
+			realm: me.realm,
+			xtype: authConfig.syncipanel,
+			isCreate: me.isCreate,
+			type: me.authType,
+		    },
+		],
+	    };
+	} else {
+	    items = [{
+		realm: me.realm,
+		xtype: authConfig.ipanel,
+		isCreate: me.isCreate,
+		type: me.authType,
+	    }];
+	}
+
+	Ext.apply(me, {
+	    items,
+	    bodyPadding,
+	});
+
+	me.callParent();
+
+	if (!me.isCreate) {
+	    me.load({
+		success: function(response, options) {
+		    var data = response.result.data || {};
+		    // just to be sure (should not happen)
+		    if (data.type !== me.authType) {
+			me.close();
+			throw "got wrong auth type";
+		    }
+		    me.setValues(data);
+		},
+	    });
+	}
+    },
+});
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH widget-toolkit 2/4] Utils: add authSchema from PVE and make it overrideable
  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 ` Dominik Csapak
  2021-07-09 11:42 ` [pve-devel] [PATCH widget-toolkit 3/4] add panel/AuthView from PVE Dominik Csapak
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2021-07-09 11:42 UTC (permalink / raw)
  To: pve-devel

like we do for the task_descriptions.
This way we can have a basic config that is true for all products
and override where necessary

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/Utils.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/Utils.js b/src/Utils.js
index 8e1f9d4..42cc02c 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1150,6 +1150,22 @@ utilities: {
 
 	return icon;
     },
+
+    authSchema: {
+	pam: {
+	    name: 'Linux PAM',
+	    add: false,
+	    edit: false,
+	    pwchange: true,
+	},
+    },
+
+    // to add or change existing for product specific ones
+    overrideAuthSchema: function(extra) {
+	for (const [key, value] of Object.entries(extra)) {
+	    Proxmox.Utils.authSchema[key] = value;
+	}
+    },
 },
 
     singleton: true,
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH widget-toolkit 3/4] add panel/AuthView from PVE
  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
  2021-07-09 11:42 ` [pve-devel] [PATCH widget-toolkit 4/4] add generic OpenIDInputPanel Dominik Csapak
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2021-07-09 11:42 UTC (permalink / raw)
  To: pve-devel

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





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH widget-toolkit 4/4] add generic OpenIDInputPanel
  2021-07-09 11:42 [pve-devel] [PATCH widget-toolkit/manager] refactor realm ui Dominik Csapak
                   ` (2 preceding siblings ...)
  2021-07-09 11:42 ` [pve-devel] [PATCH widget-toolkit 3/4] add panel/AuthView from PVE Dominik Csapak
@ 2021-07-09 11:42 ` Dominik Csapak
  2021-07-09 11:42 ` [pve-devel] [PATCH manager 1/2] ui: use AuthView and authSchema from widget-toolkit Dominik Csapak
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2021-07-09 11:42 UTC (permalink / raw)
  To: pve-devel

mostly copied from pve, but includes a realm displayeditfield
as well as the comment field

in contrast to the inputpanel in PVE, this is not extended
from a base input panel (where in pve the comment/realm/default/etc.
fields come from)

we do this, since not all products can define a default or tfa

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/Makefile                 |  1 +
 src/Utils.js                 |  9 ++++
 src/window/AuthEditOpenId.js | 96 ++++++++++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+)
 create mode 100644 src/window/AuthEditOpenId.js

diff --git a/src/Makefile b/src/Makefile
index 0f094c6..41b4dc2 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -73,6 +73,7 @@ JSSRC=					\
 	window/ACMEDomains.js		\
 	window/FileBrowser.js		\
 	window/AuthEditBase.js		\
+	window/AuthEditOpenId.js	\
 	node/APT.js			\
 	node/APTRepositories.js		\
 	node/NetworkEdit.js		\
diff --git a/src/Utils.js b/src/Utils.js
index 42cc02c..167679d 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -1158,6 +1158,15 @@ utilities: {
 	    edit: false,
 	    pwchange: true,
 	},
+	openid: {
+	    name: gettext('OpenID Connect Server'),
+	    ipanel: 'pmxAuthOpenIDPanel',
+	    add: true,
+	    edit: true,
+	    tfa: false,
+	    pwchange: false,
+	    iconCls: 'pmx-itype-icon-openid-logo',
+	},
     },
 
     // to add or change existing for product specific ones
diff --git a/src/window/AuthEditOpenId.js b/src/window/AuthEditOpenId.js
new file mode 100644
index 0000000..499e253
--- /dev/null
+++ b/src/window/AuthEditOpenId.js
@@ -0,0 +1,96 @@
+Ext.define('Proxmox.panel.OpenIDInputPanel', {
+    extend: 'Proxmox.panel.InputPanel',
+    xtype: 'pmxAuthOpenIDPanel',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    type: 'openid',
+
+    onGetValues: function(values) {
+	let me = this;
+
+	if (me.isCreate) {
+	    values.type = me.type;
+	}
+
+	return values;
+    },
+
+    columnT: [
+	{
+	    xtype: 'textfield',
+	    name: 'issuer-url',
+	    fieldLabel: gettext('Issuer URL'),
+	    allowBlank: false,
+	},
+    ],
+
+    column1: [
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'realm',
+	    cbind: {
+		value: '{realm}',
+		editable: '{isCreate}',
+	    },
+	    fieldLabel: gettext('Realm'),
+	    allowBlank: false,
+	},
+	{
+	    xtype: 'proxmoxtextfield',
+	    fieldLabel: gettext('Client ID'),
+	    name: 'client-id',
+	    allowBlank: false,
+	},
+	{
+	    xtype: 'proxmoxtextfield',
+	    fieldLabel: gettext('Client Key'),
+	    cbind: {
+		deleteEmpty: '{!isCreate}',
+	    },
+	    name: 'client-key',
+	},
+    ],
+
+    column2: [
+	{
+	    xtype: 'proxmoxcheckbox',
+	    fieldLabel: gettext('Autocreate Users'),
+	    name: 'autocreate',
+	    value: 0,
+	    cbind: {
+		deleteEmpty: '{!isCreate}',
+	    },
+	},
+	{
+	    xtype: 'pmxDisplayEditField',
+	    name: 'username-claim',
+	    editConfig: {
+		xtype: 'proxmoxKVComboBox',
+	    },
+	    cbind: {
+		value: get => get('isCreate') ? '__default__' : Proxmox.Utils.defaultText,
+		deleteEmpty: '{!isCreate}',
+		editable: '{isCreate}',
+	    },
+	    fieldLabel: gettext('Username Claim'),
+	    comboItems: [
+		['__default__', Proxmox.Utils.defaultText],
+		['subject', 'subject'],
+		['username', 'username'],
+		['email', 'email'],
+	    ],
+	},
+    ],
+
+    columnB: [
+	{
+	    xtype: 'textfield',
+	    name: 'comment',
+	    fieldLabel: gettext('Comment'),
+	    cbind: {
+		deleteEmpty: '{!isCreate}',
+	    },
+	},
+    ],
+});
+
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH manager 1/2] ui: use AuthView and authSchema from widget-toolkit
  2021-07-09 11:42 [pve-devel] [PATCH widget-toolkit/manager] refactor realm ui Dominik Csapak
                   ` (3 preceding siblings ...)
  2021-07-09 11:42 ` [pve-devel] [PATCH widget-toolkit 4/4] add generic OpenIDInputPanel Dominik Csapak
@ 2021-07-09 11:42 ` 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
  6 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2021-07-09 11:42 UTC (permalink / raw)
  To: pve-devel

* moves the authSchema to the overrideAuthSchema call so that it can
  be found in Proxmox.Utils.authSchema instead.
* changes the dc/AuthView to be a subclass of Proxmox.panel.AuthView
  with the necesary changes (onlinehelp, columns, etc.)
* changes all calls from PVE.Utils.authSchema to Proxmox.Utils.authSchema

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/Utils.js           |  85 +++++++++++----------
 www/manager6/Workspace.js       |   2 +-
 www/manager6/dc/AuthEditBase.js |   2 +-
 www/manager6/dc/AuthView.js     | 126 ++++++--------------------------
 www/manager6/dc/UserView.js     |   8 +-
 5 files changed, 72 insertions(+), 151 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index a22eaaa7..bf76e135 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -720,46 +720,6 @@ Ext.define('PVE.Utils', {
 	return format === 'pbs-ct' || volid.match(':backup/vzdump-(lxc|openvz)-');
     },
 
-    authSchema: {
-	ad: {
-	    name: gettext('Active Directory Server'),
-	    ipanel: 'pveAuthADPanel',
-	    syncipanel: 'pveAuthLDAPSyncPanel',
-	    add: true,
-	    tfa: true,
-	    pwchange: true,
-	},
-	ldap: {
-	    name: gettext('LDAP Server'),
-	    ipanel: 'pveAuthLDAPPanel',
-	    syncipanel: 'pveAuthLDAPSyncPanel',
-	    add: true,
-	    tfa: true,
-	    pwchange: true,
-	},
-	openid: {
-	    name: gettext('OpenID Connect Server'),
-	    ipanel: 'pveAuthOpenIDPanel',
-	    add: true,
-	    tfa: false,
-	    pwchange: false,
-	    iconCls: 'pmx-itype-icon-openid-logo',
-	},
-	pam: {
-	    name: 'Linux PAM',
-	    ipanel: 'pveAuthBasePanel',
-	    add: false,
-	    tfa: true,
-	    pwchange: true,
-	},
-	pve: {
-	    name: 'Proxmox VE authentication server',
-	    ipanel: 'pveAuthBasePanel',
-	    add: false,
-	    pwchange: true,
-	},
-    },
-
     storageSchema: {
 	dir: {
 	    name: Proxmox.Utils.directoryText,
@@ -1851,6 +1811,51 @@ Ext.define('PVE.Utils', {
 	    vzumount: ['CT', gettext('Unmount')],
 	    zfscreate: [gettext('ZFS Storage'), gettext('Create')],
 	});
+
+	Proxmox.Utils.overrideAuthSchema({
+	    ad: {
+		name: gettext('Active Directory Server'),
+		ipanel: 'pveAuthADPanel',
+		syncipanel: 'pveAuthLDAPSyncPanel',
+		add: true,
+		edit: true,
+		tfa: true,
+		pwchange: true,
+	    },
+	    ldap: {
+		name: gettext('LDAP Server'),
+		ipanel: 'pveAuthLDAPPanel',
+		syncipanel: 'pveAuthLDAPSyncPanel',
+		add: true,
+		edit: true,
+		tfa: true,
+		pwchange: true,
+	    },
+	    openid: {
+		name: gettext('OpenID Connect Server'),
+		ipanel: 'pveAuthOpenIDPanel',
+		add: true,
+		edit: true,
+		tfa: false,
+		pwchange: false,
+		iconCls: 'pmx-itype-icon-openid-logo',
+	    },
+	    pam: {
+		name: 'Linux PAM',
+		ipanel: 'pveAuthBasePanel',
+		add: false,
+		edit: true,
+		tfa: true,
+		pwchange: true,
+	    },
+	    pve: {
+		name: 'Proxmox VE authentication server',
+		ipanel: 'pveAuthBasePanel',
+		add: false,
+		edit: true,
+		pwchange: true,
+	    },
+	});
     },
 
 });
diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js
index 0e2a750b..ad09f2b6 100644
--- a/www/manager6/Workspace.js
+++ b/www/manager6/Workspace.js
@@ -180,7 +180,7 @@ Ext.define('PVE.StdWorkspace', {
 		    let [_username, realm] = Proxmox.Utils.parse_userid(Proxmox.UserName);
 		    response.result.data.forEach((domain) => {
 			if (domain.realm === realm) {
-			    let schema = PVE.Utils.authSchema[domain.type];
+			    let schema = Proxmox.Utils.authSchema[domain.type];
 			    if (schema) {
 				me.query('#tfaitem')[0].setHidden(!schema.tfa);
 				me.query('#passworditem')[0].setHidden(!schema.pwchange);
diff --git a/www/manager6/dc/AuthEditBase.js b/www/manager6/dc/AuthEditBase.js
index e18fbc3b..820b9966 100644
--- a/www/manager6/dc/AuthEditBase.js
+++ b/www/manager6/dc/AuthEditBase.js
@@ -24,7 +24,7 @@ Ext.define('PVE.panel.AuthBase', {
     initComponent: function() {
 	let me = this;
 
-	let options = PVE.Utils.authSchema[me.type];
+	let options = Proxmox.Utils.authSchema[me.type];
 
 	if (!me.column1) { me.column1 = []; }
 	if (!me.column2) { me.column2 = []; }
diff --git a/www/manager6/dc/AuthView.js b/www/manager6/dc/AuthView.js
index 48a51015..aaad487d 100644
--- a/www/manager6/dc/AuthView.js
+++ b/www/manager6/dc/AuthView.js
@@ -1,17 +1,9 @@
 Ext.define('PVE.dc.AuthView', {
-    extend: 'Ext.grid.GridPanel',
-
-    alias: ['widget.pveAuthView'],
+    extend: 'Proxmox.panel.AuthView',
+    alias: 'widget.pveAuthView',
 
     onlineHelp: 'pveum_authentication_realms',
 
-    stateful: true,
-    stateId: 'grid-authrealms',
-
-    viewConfig: {
-	trackOver: false,
-    },
-
     columns: [
 	{
 	    header: gettext('Realm'),
@@ -40,101 +32,25 @@ Ext.define('PVE.dc.AuthView', {
 	},
     ],
 
-    store: {
-	model: 'pmx-domains',
-	sorters: {
-	    property: 'realm',
-	    order: 'DESC',
-	},
-    },
-
-    openEditWindow: function(authType, realm) {
-	let me = this;
-	Ext.create('PVE.dc.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;
-	}
-	me.openEditWindow(rec.data.type, rec.data.realm);
-    },
-
-    open_sync_window: function() {
-	let me = this;
-	let rec = me.getSelection()[0];
-	if (!rec) {
-	    return;
-	}
-	Ext.create('PVE.dc.SyncWindow', {
-	    realm: rec.data.realm,
-	    listeners: {
-		destroy: () => me.reload(),
-	    },
-	}).show();
-    },
-
-    initComponent: function() {
-	var me = this;
-
-	let items = [];
-	for (const [authType, config] of Object.entries(PVE.Utils.authSchema)) {
-	    if (!config.add) { continue; }
-	    items.push({
-		text: config.name,
-		iconCls: 'fa fa-fw ' + (config.iconCls || 'fa-address-book-o'),
-		handler: () => me.openEditWindow(authType),
-	    });
-	}
-
-	Ext.apply(me, {
-	    tbar: [
-		{
-		    text: gettext('Add'),
-		    menu: {
-			items: items,
+    extraButtons: [
+	{
+	    xtype: 'proxmoxButton',
+	    text: gettext('Sync'),
+	    disabled: true,
+	    enableFn: (rec) => Boolean(Proxmox.Utils.authSchema[rec.data.type].syncipanel),
+	    handler: function() {
+		let panel = this.up('pveAuthView');
+		let rec = panel.getSelection()[0];
+		if (!rec) {
+		    return;
+		}
+		Ext.create('PVE.dc.SyncWindow', {
+		    realm: rec.data.realm,
+		    listeners: {
+			destroy: () => panel.reload(),
 		    },
-		},
-		{
-		    xtype: 'proxmoxButton',
-		    text: gettext('Edit'),
-		    disabled: true,
-		    handler: () => me.run_editor(),
-		},
-		{
-		    xtype: 'proxmoxStdRemoveButton',
-		    baseurl: '/access/domains/',
-		    enableFn: (rec) => PVE.Utils.authSchema[rec.data.type].add,
-		    callback: () => me.reload(),
-		},
-		'-',
-		{
-		    xtype: 'proxmoxButton',
-		    text: gettext('Sync'),
-		    disabled: true,
-		    enableFn: (rec) => Boolean(PVE.Utils.authSchema[rec.data.type].syncipanel),
-		    handler: () => me.open_sync_window(),
-		},
-	    ],
-	    listeners: {
-		activate: () => me.reload(),
-		itemdblclick: () => me.run_editor(),
+		}).show();
 	    },
-	});
-
-	me.callParent();
-    },
+	},
+    ],
 });
diff --git a/www/manager6/dc/UserView.js b/www/manager6/dc/UserView.js
index ef394bdb..5fa01683 100644
--- a/www/manager6/dc/UserView.js
+++ b/www/manager6/dc/UserView.js
@@ -61,8 +61,8 @@ Ext.define('PVE.dc.UserView', {
 	    enableFn: function(record) {
 		let type = record.data['realm-type'];
 		if (type) {
-		    if (PVE.Utils.authSchema[type]) {
-			return !!PVE.Utils.authSchema[type].pwchange;
+		    if (Proxmox.Utils.authSchema[type]) {
+			return !!Proxmox.Utils.authSchema[type].pwchange;
 		    }
 		}
 		return false;
@@ -84,8 +84,8 @@ Ext.define('PVE.dc.UserView', {
 	    enableFn: function(record) {
 		let type = record.data['realm-type'];
 		if (type) {
-		    if (PVE.Utils.authSchema[type]) {
-			return !!PVE.Utils.authSchema[type].tfa;
+		    if (Proxmox.Utils.authSchema[type]) {
+			return !!Proxmox.Utils.authSchema[type].tfa;
 		    }
 		}
 		return false;
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] [PATCH manager 2/2] ui: remove PVE.dc.AuthEditBase window
  2021-07-09 11:42 [pve-devel] [PATCH widget-toolkit/manager] refactor realm ui Dominik Csapak
                   ` (4 preceding siblings ...)
  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 ` Dominik Csapak
  2021-07-13  4:35 ` [pve-devel] partially-applied-series: [PATCH widget-toolkit/manager] refactor realm ui Thomas Lamprecht
  6 siblings, 0 replies; 8+ messages in thread
From: Dominik Csapak @ 2021-07-09 11:42 UTC (permalink / raw)
  To: pve-devel

this is not needed anymore since we now use Proxmox.window.AuthEditBase

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/dc/AuthEditBase.js | 91 ---------------------------------
 1 file changed, 91 deletions(-)

diff --git a/www/manager6/dc/AuthEditBase.js b/www/manager6/dc/AuthEditBase.js
index 820b9966..3227ca7b 100644
--- a/www/manager6/dc/AuthEditBase.js
+++ b/www/manager6/dc/AuthEditBase.js
@@ -64,94 +64,3 @@ Ext.define('PVE.panel.AuthBase', {
 	me.callParent();
     },
 });
-
-Ext.define('PVE.dc.AuthEditBase', {
-    extend: 'Proxmox.window.Edit',
-
-    onlineHelp: 'pveum_authentication_realms',
-
-    isAdd: true,
-
-    fieldDefaults: {
-	labelWidth: 120,
-    },
-
-    initComponent: function() {
-	var me = this;
-
-	me.isCreate = !me.realm;
-
-	if (me.isCreate) {
-	    me.url = '/api2/extjs/access/domains';
-	    me.method = 'POST';
-	} else {
-	    me.url = '/api2/extjs/access/domains/' + me.realm;
-	    me.method = 'PUT';
-	}
-
-	let authConfig = PVE.Utils.authSchema[me.authType];
-	if (!authConfig) {
-	    throw 'unknown auth type';
-	} else if (!authConfig.add && me.isCreate) {
-	    throw 'trying to add non addable realm';
-	}
-
-	me.subject = authConfig.name;
-
-	let items;
-	let bodyPadding;
-	if (authConfig.syncipanel) {
-	    bodyPadding = 0;
-	    items = {
-		xtype: 'tabpanel',
-		region: 'center',
-		layout: 'fit',
-		bodyPadding: 10,
-		items: [
-		    {
-			title: gettext('General'),
-			realm: me.realm,
-			xtype: authConfig.ipanel,
-			isCreate: me.isCreate,
-			type: me.authType,
-		    },
-		    {
-			title: gettext('Sync Options'),
-			realm: me.realm,
-			xtype: authConfig.syncipanel,
-			isCreate: me.isCreate,
-			type: me.authType,
-		    },
-		],
-	    };
-	} else {
-	    items = [{
-		realm: me.realm,
-		xtype: authConfig.ipanel,
-		isCreate: me.isCreate,
-		type: me.authType,
-	    }];
-	}
-
-	Ext.apply(me, {
-	    items,
-	    bodyPadding,
-	});
-
-	me.callParent();
-
-	if (!me.isCreate) {
-	    me.load({
-		success: function(response, options) {
-		    var data = response.result.data || {};
-		    // just to be sure (should not happen)
-		    if (data.type !== me.authType) {
-			me.close();
-			throw "got wrong auth type";
-		    }
-		    me.setValues(data);
-		},
-	    });
-	}
-    },
-});
-- 
2.30.2





^ permalink raw reply	[flat|nested] 8+ messages in thread

* [pve-devel] partially-applied-series: [PATCH widget-toolkit/manager] refactor realm ui
  2021-07-09 11:42 [pve-devel] [PATCH widget-toolkit/manager] refactor realm ui Dominik Csapak
                   ` (5 preceding siblings ...)
  2021-07-09 11:42 ` [pve-devel] [PATCH manager 2/2] ui: remove PVE.dc.AuthEditBase window Dominik Csapak
@ 2021-07-13  4:35 ` Thomas Lamprecht
  6 siblings, 0 replies; 8+ messages in thread
From: Thomas Lamprecht @ 2021-07-13  4:35 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominik Csapak

On 09.07.21 13:42, Dominik Csapak wrote:
> refactor the parts of the realm ui that we need for pbs now into
> widget-toolkit
> 
> manager patches depend on widget toolkit, but can be applied later too
> if thats wanted. there is no functional change intended
> 
> proxmox-widget-toolkit:
> 
> Dominik Csapak (4):
>   add window/AuthEditBase from PVE
>   Utils: add authSchema from PVE and make it overrideable
>   add panel/AuthView from PVE
>   add generic OpenIDInputPanel
> 
>  src/Makefile                 |   3 +
>  src/Utils.js                 |  25 +++++++
>  src/panel/AuthView.js        | 125 +++++++++++++++++++++++++++++++++++
>  src/window/AuthEditBase.js   |  88 ++++++++++++++++++++++++
>  src/window/AuthEditOpenId.js |  96 +++++++++++++++++++++++++++
>  5 files changed, 337 insertions(+)
>  create mode 100644 src/panel/AuthView.js
>  create mode 100644 src/window/AuthEditBase.js
>  create mode 100644 src/window/AuthEditOpenId.js
> 

for the widget toolkit part: applied series, thanks!

> pve-manager:
> 
> Dominik Csapak (2):
>   ui: use AuthView and authSchema from widget-toolkit
>   ui: remove PVE.dc.AuthEditBase window
> 
>  www/manager6/Utils.js           |  85 +++++++++++----------
>  www/manager6/Workspace.js       |   2 +-
>  www/manager6/dc/AuthEditBase.js |  93 +----------------------
>  www/manager6/dc/AuthView.js     | 126 ++++++--------------------------
>  www/manager6/dc/UserView.js     |   8 +-
>  5 files changed, 72 insertions(+), 242 deletions(-)
> 





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-07-13  4:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pve-devel] [PATCH widget-toolkit 3/4] add panel/AuthView from PVE Dominik Csapak
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

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