all lists on 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 manager v8 2/3] ui: vm create wizard: allow importing disks
Date: Mon, 14 Jul 2025 14:28:34 +0200	[thread overview]
Message-ID: <20250714122835.3347682-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250714122835.3347682-1-d.csapak@proxmox.com>

by adding a new 'import' button in the disk tab, which adds the same
input panel as the one we have when doing an 'Import Hard Disk' for an
existing VM.

partially fixes #2424

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/panel/MultiDiskEdit.js | 36 +++++++++++++++++++++++++----
 www/manager6/qemu/MultiHDEdit.js    |  5 +++-
 2 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/www/manager6/panel/MultiDiskEdit.js b/www/manager6/panel/MultiDiskEdit.js
index a4954775..32fad5dc 100644
--- a/www/manager6/panel/MultiDiskEdit.js
+++ b/www/manager6/panel/MultiDiskEdit.js
@@ -1,6 +1,8 @@
 Ext.define('PVE.panel.MultiDiskPanel', {
     extend: 'Ext.panel.Panel',
 
+    mixins: ['Proxmox.Mixin.CBind'],
+
     setNodename: function (nodename) {
         this.items.each((panel) => panel.setNodename(nodename));
     },
@@ -8,6 +10,8 @@ Ext.define('PVE.panel.MultiDiskPanel', {
     border: false,
     bodyBorder: false,
 
+    importDisk: false, // allow import panel
+
     layout: 'card',
 
     controller: {
@@ -16,25 +20,35 @@ Ext.define('PVE.panel.MultiDiskPanel', {
         vmconfig: {},
 
         onAdd: function () {
+            this.addDiskChecked(false);
+        },
+
+        onImport: function () {
+            this.addDiskChecked(true);
+        },
+
+        addDiskChecked: function (importDisk) {
             let me = this;
             me.lookup('addButton').setDisabled(true);
-            me.addDisk();
+            me.lookup('addImportButton').setDisabled(true);
+            me.addDisk(importDisk);
             let count = me.lookup('grid').getStore().getCount() + 1; // +1 is from ide2
             me.lookup('addButton').setDisabled(count >= me.maxCount);
+            me.lookup('addImportButton').setDisabled(count >= me.maxCount);
         },
 
         getNextFreeDisk: function (vmconfig) {
             throw 'implement in subclass';
         },
 
-        addPanel: function (itemId, vmconfig, nextFreeDisk) {
+        addPanel: function (itemId, vmconfig, nextFreeDisk, importDisk) {
             throw 'implement in subclass';
         },
 
         // define in subclass
         diskSorter: undefined,
 
-        addDisk: function () {
+        addDisk: function (importDisk) {
             let me = this;
             let grid = me.lookup('grid');
             let store = grid.getStore();
@@ -53,7 +67,7 @@ Ext.define('PVE.panel.MultiDiskPanel', {
                 itemId,
             })[0];
 
-            let panel = me.addPanel(itemId, vmconfig, nextFreeDisk);
+            let panel = me.addPanel(itemId, vmconfig, nextFreeDisk, importDisk);
             panel.updateVMConfig(vmconfig);
 
             // we need to setup a validitychange handler, so that we can show
@@ -175,6 +189,7 @@ Ext.define('PVE.panel.MultiDiskPanel', {
             store.remove(record);
             me.getView().remove(record.get('itemId'));
             me.lookup('addButton').setDisabled(false);
+            me.lookup('addImportButton').setDisabled(false);
             me.updateVMConfig();
             me.checkValidity();
         },
@@ -214,6 +229,7 @@ Ext.define('PVE.panel.MultiDiskPanel', {
             dock: 'left',
             border: false,
             width: 130,
+            cbind: {}, // for nested cbinds
             items: [
                 {
                     xtype: 'grid',
@@ -261,6 +277,18 @@ Ext.define('PVE.panel.MultiDiskPanel', {
                     iconCls: 'fa fa-plus-circle',
                     handler: 'onAdd',
                 },
+                {
+                    xtype: 'button',
+                    reference: 'addImportButton',
+                    text: gettext('Import'),
+                    iconCls: 'fa fa-cloud-download',
+                    handler: 'onImport',
+                    margin: '5 0 0 0',
+                    cbind: {
+                        disabled: '{!importDisk}',
+                        hidden: '{!importDisk}',
+                    },
+                },
                 {
                     // dummy field to control wizard validation
                     xtype: 'textfield',
diff --git a/www/manager6/qemu/MultiHDEdit.js b/www/manager6/qemu/MultiHDEdit.js
index 06b186fd..0b048709 100644
--- a/www/manager6/qemu/MultiHDEdit.js
+++ b/www/manager6/qemu/MultiHDEdit.js
@@ -4,6 +4,8 @@ Ext.define('PVE.qemu.MultiHDPanel', {
 
     onlineHelp: 'qm_hard_disk',
 
+    importDisk: true,
+
     controller: {
         xclass: 'Ext.app.ViewController',
 
@@ -19,7 +21,7 @@ Ext.define('PVE.qemu.MultiHDPanel', {
             return PVE.Utils.nextFreeDisk(clist, vmconfig);
         },
 
-        addPanel: function (itemId, vmconfig, nextFreeDisk) {
+        addPanel: function (itemId, vmconfig, nextFreeDisk, importDisk) {
             let me = this;
             return me.getView().add({
                 vmconfig,
@@ -33,6 +35,7 @@ Ext.define('PVE.qemu.MultiHDPanel', {
                 itemId,
                 isCreate: true,
                 insideWizard: true,
+                importDisk,
             });
         },
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-07-14 12:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14 12:28 [pve-devel] [PATCH manager v8 0/3] allow importing vm disk images on the UI Dominik Csapak
2025-07-14 12:28 ` [pve-devel] [PATCH manager v8 1/3] ui: qemu hd edit: allow importing a disk from the import storage Dominik Csapak
2025-07-14 12:28 ` Dominik Csapak [this message]
2025-07-14 12:28 ` [pve-devel] [PATCH manager v8 3/3] ui: import storage content: allow importing of vm disk images Dominik Csapak
2025-07-15 18:46 ` [pve-devel] applied-series: [PATCH manager v8 0/3] allow importing vm disk images on the 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=20250714122835.3347682-3-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