GPUI Box GitHub

Components / display

OutcomePanel builder

A panel that states what finished, including a partial success.

A builder is RenderOnce. Construct and mount it in one expression.

use gpui_kit::display::outcome::OutcomePanel;

Reviewed in outcome-panel.

Construct
new(ident: impl Into<Ident>, kind: OutcomeKind) -> Self
Options

Chain onto the value.

title(title: impl Into<SharedString>) -> Self
detail(detail: impl Into<SharedString>) -> Self
count(count: impl Into<SharedString>) -> Self
action(action: impl IntoElement) -> Self
Example · outcome-panel
fn outcome_panel(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    stack(&theme)
        .w(px(560.0))
        .child(caption(&theme, "Finished"))
        .child(
            OutcomePanel::new("scene.outcome.success", OutcomeKind::Success)
                .title("Import finished")
                .count("50 files imported"),
        )
        .child(caption(&theme, "Finished, with failures the host numbered"))
        .child(
            OutcomePanel::new("scene.outcome.partial", OutcomeKind::Partial)
                .title("Import finished, with failures")
                .count("47 succeeded, 3 failed")
                .detail("The three that failed are still in the queue.")
                .action(
                    Button::new("scene.outcome.review")
                        .label("Review the three")
                        .secondary()
                        .small()
                        .on_click(|_, _| {}),
                ),
        )
        .child(caption(
            &theme,
            "Did not finish. What the reader can do about it is a control, not a \
             sentence about a control",
        ))
        .child(
            OutcomePanel::new("scene.outcome.failed", OutcomeKind::Failed)
                .detail("The host closed the connection before any file landed.")
                .action(
                    Button::new("scene.outcome.retry")
                        .label("Import again")
                        .small()
                        .on_click(|_, _| {}),
                ),
        )
        .into_any_element()
}

Source: crates/gpui-kit/src/display/outcome.rs