From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 205D41FF179 for ; Wed, 12 Nov 2025 17:19:22 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C5384980F; Wed, 12 Nov 2025 17:20:05 +0100 (CET) From: Dominik Csapak To: pdm-devel@lists.proxmox.com Date: Wed, 12 Nov 2025 17:11:42 +0100 Message-ID: <20251112161900.75032-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251112161900.75032-1-d.csapak@proxmox.com> References: <20251112161900.75032-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 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 Subject: [pdm-devel] [PATCH datacenter-manager 07/18] ui: dashboard: status row: add optional 'editing state' 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" If that is given, enable some editing buttons (start, finish, cancel) so that a listener on that editing state can react to those actions. Signed-off-by: Dominik Csapak --- ui/src/dashboard/status_row.rs | 60 +++++++++++++++++++++++++++++++++- ui/src/dashboard/view.rs | 7 ++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/ui/src/dashboard/status_row.rs b/ui/src/dashboard/status_row.rs index 0855b123..e1af6697 100644 --- a/ui/src/dashboard/status_row.rs +++ b/ui/src/dashboard/status_row.rs @@ -1,17 +1,23 @@ use gloo_timers::callback::Interval; +use yew::html::IntoPropValue; use yew::{Component, Properties}; +use pwt::css; use pwt::prelude::*; +use pwt::state::SharedState; use pwt::{ css::AlignItems, widget::{ActionIcon, Container, Row, Tooltip}, }; -use pwt_macros::widget; +use pwt_macros::{builder, widget}; use proxmox_yew_comp::utils::render_epoch; +use crate::dashboard::view::EditingMessage; + #[widget(comp=PdmDashboardStatusRow)] #[derive(Properties, PartialEq, Clone)] +#[builder] pub struct DashboardStatusRow { last_refresh: Option, reload_interval_s: u32, @@ -19,6 +25,11 @@ pub struct DashboardStatusRow { on_reload: Callback, on_settings_click: Callback<()>, + + #[builder(IntoPropValue, into_prop_value)] + #[prop_or_default] + /// If added, shows a edit/finish/cancel button + editing_state: Option>>, } impl DashboardStatusRow { @@ -40,12 +51,14 @@ impl DashboardStatusRow { pub enum Msg { /// The bool denotes if the reload comes from the click or the timer. Reload(bool), + Edit(EditingMessage), } #[doc(hidden)] pub struct PdmDashboardStatusRow { _interval: Interval, loading: bool, + edit: bool, } impl PdmDashboardStatusRow { @@ -70,6 +83,7 @@ impl Component for PdmDashboardStatusRow { Self { _interval: Self::create_interval(ctx), loading: false, + edit: false, } } @@ -81,6 +95,13 @@ impl Component for PdmDashboardStatusRow { self.loading = true; true } + Msg::Edit(editing) => { + self.edit = matches!(editing, EditingMessage::Start); + if let Some(state) = props.editing_state.as_ref() { + state.write().push(editing); + } + true + } } } @@ -121,6 +142,43 @@ impl Component for PdmDashboardStatusRow { None => tr!("Now refreshing"), })) .with_flex_spacer() + .with_optional_child(props.editing_state.clone().and_then(|_| { + (!self.edit).then_some({ + Tooltip::new(ActionIcon::new("fa fa-pencil").tabindex(0).on_activate({ + ctx.link() + .callback(move |_| Msg::Edit(EditingMessage::Start)) + })) + .tip(tr!("Edit")) + }) + })) + .with_optional_child(props.editing_state.clone().and_then(|_| { + self.edit.then_some({ + Tooltip::new( + ActionIcon::new("fa fa-check") + .class(css::ColorScheme::Success) + .tabindex(0) + .on_activate({ + ctx.link() + .callback(move |_| Msg::Edit(EditingMessage::Finish)) + }), + ) + .tip(tr!("Finish Editing")) + }) + })) + .with_optional_child(props.editing_state.clone().and_then(|_| { + self.edit.then_some({ + Tooltip::new( + ActionIcon::new("fa fa-times") + .class(css::ColorScheme::Error) + .tabindex(0) + .on_activate({ + ctx.link() + .callback(move |_| Msg::Edit(EditingMessage::Cancel)) + }), + ) + .tip(tr!("Cancel Editing")) + }) + })) .with_child( Tooltip::new( ActionIcon::new("fa fa-cogs") diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index c973d321..c5149d69 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -39,6 +39,13 @@ use pdm_client::types::TopEntities; mod row_view; pub use row_view::RowView; +#[derive(Debug, Clone, PartialEq, Copy)] +pub enum EditingMessage { + Start, + Cancel, + Finish, +} + #[derive(Properties, PartialEq)] pub struct View { view: AttrValue, -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel