From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit 1/4] add window/AuthEditBase from PVE
Date: Fri, 9 Jul 2021 13:42:21 +0200 [thread overview]
Message-ID: <20210709114226.269670-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210709114226.269670-1-d.csapak@proxmox.com>
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
next prev 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 ` Dominik Csapak [this message]
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
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-2-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