From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager v3 4/5] ui: use AuthView and authSchema from widget-toolkit
Date: Fri, 16 Jul 2021 16:21:25 +0200 [thread overview]
Message-ID: <20210716142126.1216972-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210716142126.1216972-1-d.csapak@proxmox.com>
* 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/Schema.js | 49 +++++++++++++
www/manager6/Utils.js | 40 ----------
www/manager6/Workspace.js | 2 +-
www/manager6/dc/AuthEditBase.js | 2 +-
www/manager6/dc/AuthView.js | 126 ++++++--------------------------
www/manager6/dc/UserView.js | 8 +-
6 files changed, 76 insertions(+), 151 deletions(-)
diff --git a/www/manager6/Schema.js b/www/manager6/Schema.js
index 374b5f17..446f33e4 100644
--- a/www/manager6/Schema.js
+++ b/www/manager6/Schema.js
@@ -191,4 +191,53 @@ Ext.define('PVE.Schema', { // a singleton
faIcon: 'th',
},
},
+
+ constructor: function() {
+ var me = this;
+
+ Proxmox.Schema.overrideAuthDomains({
+ 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/Utils.js b/www/manager6/Utils.js
index 8d210b69..03494d94 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,
- },
- },
-
format_sdnvnet_type: function(value, md, record) {
var schema = PVE.Schema.sdnvnet[value];
if (schema) {
diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js
index 0e2a750b..bb873d67 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.Schema.authDomains[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..996ed6a8 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.Schema.authDomains[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..521e16a2 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.Schema.authDomains[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..ed1ee8f4 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.Schema.authDomains[type]) {
+ return !!Proxmox.Schema.authDomains[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.Schema.authDomains[type]) {
+ return !!Proxmox.Schema.authDomains[type].tfa;
}
}
return false;
--
2.30.2
next prev parent reply other threads:[~2021-07-16 14:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-16 14:21 [pve-devel] [PATCH manager v3 1/5] ui: add Schema.js Dominik Csapak
2021-07-16 14:21 ` [pve-devel] [PATCH manager v3 2/5] ui: move Utils.storageSchema to Schema.storageTypes Dominik Csapak
2021-07-16 14:21 ` [pve-devel] [PATCH manager v3 3/5] ui: move sdn schemas to Schema Dominik Csapak
2021-07-16 14:21 ` Dominik Csapak [this message]
2021-07-16 14:21 ` [pve-devel] [PATCH manager v3 5/5] ui: remove PVE.dc.AuthEditBase window Dominik Csapak
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=20210716142126.1216972-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal