Components / data
DiagnosticsList builder
A diagnostic list whose data and state remain owned by its caller.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::data::DiagnosticsList;
Reviewed in diagnostics-list.
Construct
new(ident: impl Into<Ident>, diagnostics: Loadable<Vec<Diagnostic>, SharedString>) -> Self
Options
Chain onto the value.
filter(filter: DiagnosticFilter) -> Self
selected(id: impl Into<SharedString>) -> Self
visible_rows(rows: usize) -> Self
on_filter(handler: impl Fn(DiagnosticFilter, &mut Window, &mut App) + 'static) -> Self
on_select(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
on_action(handler: impl Fn(SharedString, SharedString, &mut Window, &mut App) + 'static) -> Self
on_retry(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
Example · diagnostics-list
fn diagnostics_list(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let diagnostics = [
Diagnostic::new(
"fixture-error",
DiagnosticSeverity::Error,
DiagnosticLocation::new("fixture.rs:18"),
"Fixture diagnostic: incompatible value",
)
.action(DiagnosticAction::new("inspect", "Inspect fixture")),
Diagnostic::new(
"fixture-warning",
DiagnosticSeverity::Warning,
DiagnosticLocation::new("fixture.rs:31"),
"Fixture diagnostic: unused declaration",
),
Diagnostic::new(
"fixture-information",
DiagnosticSeverity::Information,
DiagnosticLocation::new("fixture.rs:47"),
"Fixture diagnostic: a simpler form is available",
),
Diagnostic::new(
"fixture-hint",
DiagnosticSeverity::Hint,
DiagnosticLocation::new("fixture.rs:64"),
"Fixture diagnostic: consider a descriptive name",
),
];
stack(&theme)
.w(px(760.0))
.child(caption(
&theme,
"synthetic diagnostics; filters, selection, and actions are caller-owned intents",
))
.child(
DiagnosticsList::new("scene.diagnostics", Loadable::Ready(diagnostics.to_vec()))
.selected("fixture-warning")
.visible_rows(5)
.on_filter(|_, _, _| {})
.on_select(|_, _, _| {})
.on_action(|_, _, _, _| {}),
)
.into_any_element()
}