From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 39B0A1FF17E for ; Thu, 27 Nov 2025 12:22:42 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 55DB8F24; Thu, 27 Nov 2025 12:23:02 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Thu, 27 Nov 2025 12:22:51 +0100 Message-ID: <20251127112259.1980130-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.030 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [views.rs] Subject: [pdm-devel] [PATCH datacenter-manager 1/2] ui: view configuration: unify create and edit input panel X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" 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 --- 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) -> Html { +enum InputPanelMode { + Create(Store), + 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) -> 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