public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 1/2] ui: view configuration: unify create and edit input panel
Date: Thu, 27 Nov 2025 12:22:51 +0100	[thread overview]
Message-ID: <20251127112259.1980130-1-d.csapak@proxmox.com> (raw)

even though the implementation is not big, the two variants did diverge
already (boxlabel on the include all checkbox). To avoid that, unify the
two methods into one so most changes to one node will be reflected in
the other.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/configuration/views.rs | 61 +++++++++++++++++------------------
 1 file changed, 29 insertions(+), 32 deletions(-)

diff --git a/ui/src/configuration/views.rs b/ui/src/configuration/views.rs
index 71cadc68..41969fdd 100644
--- a/ui/src/configuration/views.rs
+++ b/ui/src/configuration/views.rs
@@ -162,7 +162,7 @@ impl ViewGridComp {
         let props = ctx.props();
         let store = self.store.clone();
         EditWindow::new(tr!("Add") + ": " + &tr!("View"))
-            .renderer(move |form_ctx: &FormContext| add_view_input_panel(form_ctx, store.clone()))
+            .renderer(move |form_ctx| input_panel(form_ctx, InputPanelMode::Create(store.clone())))
             .on_submit({
                 let base_url = props.base_url.clone();
                 let store = self.store.clone();
@@ -176,7 +176,7 @@ impl ViewGridComp {
         let props = ctx.props();
         let id = selection.to_string();
         EditWindow::new(tr!("Edit") + ": " + &tr!("View"))
-            .renderer(move |form_ctx| edit_view_input_panel(form_ctx, id.clone()))
+            .renderer(move |form_ctx| input_panel(form_ctx, InputPanelMode::Edit(id.clone())))
             .on_submit({
                 let base_url = props.base_url.clone();
                 move |form| update_view(base_url.clone(), form)
@@ -322,23 +322,39 @@ impl LoadableComponent for ViewGridComp {
     }
 }
 
-fn add_view_input_panel(form_ctx: &FormContext, store: Store<ViewConfig>) -> Html {
+enum InputPanelMode {
+    Create(Store<ViewConfig>),
+    Edit(String), // id
+}
+
+fn input_panel(form_ctx: &FormContext, mode: InputPanelMode) -> Html {
     let include_all = form_ctx.read().get_field_checked("include-all");
-    InputPanel::new()
-        .padding(4)
-        .with_field(tr!("Name"), Field::new().name("id").required(true))
-        .with_right_field(
-            tr!("Copy Layout from"),
-            ViewSelector::new(store)
-                .placeholder(tr!("None"))
-                .name("copy-from"),
-        )
+    let is_create = matches!(mode, InputPanelMode::Create(_));
+    let mut input_panel = InputPanel::new().padding(4);
+
+    match mode {
+        InputPanelMode::Create(store) => {
+            input_panel.add_field(tr!("Name"), Field::new().name("id").required(true));
+            input_panel.add_right_field(
+                tr!("Copy Layout from"),
+                ViewSelector::new(store)
+                    .placeholder(tr!("None"))
+                    .name("copy-from"),
+            );
+        }
+        InputPanelMode::Edit(id) => input_panel.add_field(
+            tr!("Name"),
+            DisplayField::new().name("id").value(id.clone()),
+        ),
+    }
+
+    input_panel
         .with_field(
             tr!("Include All"),
             Checkbox::new()
                 .name("include-all")
                 .box_label(tr!("Include all remotes and their resources."))
-                .default(true),
+                .default(is_create),
         )
         .with_field_and_options(
             pwt::widget::FieldPosition::Large,
@@ -352,22 +368,3 @@ fn add_view_input_panel(form_ctx: &FormContext, store: Store<ViewConfig>) -> Htm
         .with_large_field(tr!("Exclude"), ViewFilterSelector::new().name("exclude"))
         .into()
 }
-
-fn edit_view_input_panel(form_ctx: &FormContext, id: String) -> Html {
-    let include_all = form_ctx.read().get_field_checked("include-all");
-    InputPanel::new()
-        .padding(4)
-        .with_field(tr!("Name"), DisplayField::new().name("id").value(id))
-        .with_field(tr!("Include All"), Checkbox::new().name("include-all"))
-        .with_field_and_options(
-            pwt::widget::FieldPosition::Large,
-            false,
-            include_all,
-            tr!("Include"),
-            ViewFilterSelector::new()
-                .name("include")
-                .disabled(include_all),
-        )
-        .with_large_field(tr!("Exclude"), ViewFilterSelector::new().name("exclude"))
-        .into()
-}
-- 
2.47.3



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


             reply	other threads:[~2025-11-27 11:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 11:22 Dominik Csapak [this message]
2025-11-27 11:22 ` [pdm-devel] [PATCH datacenter-manager 2/2] ui: view configuration: change include all to a large field Dominik Csapak
2025-11-27 20:54 ` [pdm-devel] applied: [PATCH datacenter-manager 1/2] ui: view configuration: unify create and edit input panel 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=20251127112259.1980130-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal