]> git.proxmox.com Git - proxmox-backup.git/commitdiff
ui: datastore content: allow to create new namespace
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 6 May 2022 09:02:59 +0000 (11:02 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 May 2022 07:33:50 +0000 (09:33 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
www/Makefile
www/datastore/Content.js
www/window/NamespaceEdit.js [new file with mode: 0644]

index f217d46d59a708f91402e02d847e718031fddd72..ad8c901de9e6010a286d79ea6306a57fdfddbd66 100644 (file)
@@ -62,6 +62,7 @@ JSSRC=                                                        \
        window/BackupGroupChangeOwner.js                \
        window/CreateDirectory.js                       \
        window/DataStoreEdit.js                         \
+       window/NamespaceEdit.js                         \
        window/MaintenanceOptions.js                    \
        window/NotesEdit.js                             \
        window/RemoteEdit.js                            \
index e6196c014de88d935195e4cf6e4a2373928f30e1..6d942288871752f3727c2748639e476b39c9ad01 100644 (file)
@@ -388,6 +388,21 @@ Ext.define('PBS.DataStoreContent', {
            });
        },
 
+       addNS: function() {
+           let me = this;
+           let view = me.getView();
+           if (!view.datastore) return;
+
+           Ext.create('PBS.window.NamespaceEdit', {
+               autoShow: true,
+               datastore: view.datastore,
+               listeners: {
+                   destroy: () => view.down('pbsNamespaceSelector').store?.load(),
+               },
+           });
+       },
+
+
        onVerify: function(view, rI, cI, item, e, rec) {
            let me = this;
            view = me.getView();
@@ -1036,10 +1051,17 @@ Ext.define('PBS.DataStoreContent', {
        },
        {
            xtype: 'pbsNamespaceSelector',
+           width: 200,
            cbind: {
                datastore: '{datastore}',
            },
        },
+       {
+           xtype: 'proxmoxButton',
+           text: gettext('Add NS'),
+           iconCls: 'fa fa-plus-square',
+           handler: 'addNS',
+       },
        '-',
        {
            xtype: 'tbtext',
diff --git a/www/window/NamespaceEdit.js b/www/window/NamespaceEdit.js
new file mode 100644 (file)
index 0000000..79bf5e5
--- /dev/null
@@ -0,0 +1,52 @@
+Ext.define('PBS.window.NamespaceEdit', {
+    extend: 'Proxmox.window.Edit',
+    xtype: 'pbsNamespaceEdit', // for now rather "NamespaceAdd"
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    //onlineHelp: 'namespaces', // TODO
+
+    isCreate: true,
+    subject: gettext('Namespace'),
+    // avoid that the trigger of the combogrid fields open on window show
+    defaultFocus: 'proxmoxHelpButton',
+
+    cbind: {
+       url: '/api2/extjs/admin/datastore/{datastore}/namespace',
+    },
+    method: 'POST',
+
+    width: 450,
+    fieldDefaults: {
+       labelWidth: 120,
+    },
+
+    items: {
+       xtype: 'inputpanel',
+       onGetValues: function(values) {
+           if (values.parent === '') {
+               delete values.parent;
+           }
+           return values;
+       },
+       items: [
+           {
+               xtype: 'pbsNamespaceSelector',
+               name: 'parent',
+               fieldLabel: gettext('Parent Namespace'),
+               cbind: {
+                   datastore: '{datastore}',
+               },
+           },
+           {
+               xtype: 'proxmoxtextfield',
+               name: 'name',
+               fieldLabel: gettext('Namespace Name'),
+               value: '',
+               allowBlank: false,
+               maxLength: 31,
+               regex: PBS.Utils.SAFE_ID_RE,
+               regexText: gettext("Only alpha numerical, '_' and '-' (if not at start) allowed"),
+           },
+       ],
+    },
+});