use fission::prelude::*;
use std::sync::Arc;
fission_component! {
pub BuildRunsTable<()> {
props {
rows: Vec<TableRow>,
selected: Vec<String>,
toggle_run: Arc<dyn Fn(String) -> ActionEnvelope + Send + Sync>,
select_all: ActionEnvelope,
}
}
view(table, _state, cx) =>
DataTable(
id: WidgetId::explicit("build-runs"),
columns: vec![
TableColumn {
id: "status".into(),
title: cx.tr("build.status"),
..Default::default()
},
TableColumn {
id: "branch".into(),
title: cx.tr("build.branch"),
..Default::default()
},
],
rows: table.rows.clone(),
selected_ids: table.selected.clone(),
on_selection_change: table.toggle_run.clone(),
on_select_all: table.select_all.clone(),
label: Some(cx.tr("build.runs")),
)
}
Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id | WidgetId | Stable identity for the table instance. | Used by retained interaction; Compose supplies component-relative identity. |
columns | Vec<TableColumn> | Column definitions in display order. | Required. Width comes from the column records. |
rows | Vec<TableRow> | Row data in display order. | Required. Each row's cells are matched to columns by index. |
selection_mode | DataTableSelectionMode | Read-only or multiple controlled selection. | Use None to omit selection controls; default is Multiple. |
selected_ids | Vec<String> | Currently selected row ids. | Controlled by app state. |
on_selection_change | Option<Arc<dyn Fn(String) -> ActionEnvelope + Send + Sync>> | Closure that builds the action for row or checkbox selection. | Called with the row id. |
on_select_all | Option<ActionEnvelope> | Action dispatched by the header checkbox. | The checkbox is disabled when no action is supplied. |
label | Option<String> | Accessible name for the table. | Recommended when surrounding context does not already name the table. |